documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076
  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. * Represens a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. /**
  2412. * Defines the first coordinates (on X axis)
  2413. */
  2414. x: number;
  2415. /**
  2416. * Defines the second coordinates (on Y axis)
  2417. */
  2418. y: number;
  2419. /**
  2420. * Defines the third coordinates (on Z axis)
  2421. */
  2422. z: number;
  2423. private static _UpReadOnly;
  2424. private static _ZeroReadOnly;
  2425. /**
  2426. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2427. * @param x defines the first coordinates (on X axis)
  2428. * @param y defines the second coordinates (on Y axis)
  2429. * @param z defines the third coordinates (on Z axis)
  2430. */
  2431. constructor(
  2432. /**
  2433. * Defines the first coordinates (on X axis)
  2434. */
  2435. x?: number,
  2436. /**
  2437. * Defines the second coordinates (on Y axis)
  2438. */
  2439. y?: number,
  2440. /**
  2441. * Defines the third coordinates (on Z axis)
  2442. */
  2443. z?: number);
  2444. /**
  2445. * Creates a string representation of the Vector3
  2446. * @returns a string with the Vector3 coordinates.
  2447. */
  2448. toString(): string;
  2449. /**
  2450. * Gets the class name
  2451. * @returns the string "Vector3"
  2452. */
  2453. getClassName(): string;
  2454. /**
  2455. * Creates the Vector3 hash code
  2456. * @returns a number which tends to be unique between Vector3 instances
  2457. */
  2458. getHashCode(): number;
  2459. /**
  2460. * Creates an array containing three elements : the coordinates of the Vector3
  2461. * @returns a new array of numbers
  2462. */
  2463. asArray(): number[];
  2464. /**
  2465. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2466. * @param array defines the destination array
  2467. * @param index defines the offset in the destination array
  2468. * @returns the current Vector3
  2469. */
  2470. toArray(array: FloatArray, index?: number): Vector3;
  2471. /**
  2472. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2473. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2474. */
  2475. toQuaternion(): Quaternion;
  2476. /**
  2477. * Adds the given vector to the current Vector3
  2478. * @param otherVector defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Adds the given coordinates to the current Vector3
  2484. * @param x defines the x coordinate of the operand
  2485. * @param y defines the y coordinate of the operand
  2486. * @param z defines the z coordinate of the operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2490. /**
  2491. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the resulting Vector3
  2494. */
  2495. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Subtract the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2511. * @param otherVector defines the second operand
  2512. * @returns the resulting Vector3
  2513. */
  2514. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the resulting Vector3
  2528. */
  2529. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2532. * @param x defines the x coordinate of the operand
  2533. * @param y defines the y coordinate of the operand
  2534. * @param z defines the z coordinate of the operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2539. /**
  2540. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2541. * @returns a new Vector3
  2542. */
  2543. negate(): Vector3;
  2544. /**
  2545. * Negate this vector in place
  2546. * @returns this
  2547. */
  2548. negateInPlace(): Vector3;
  2549. /**
  2550. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2551. * @param result defines the Vector3 object where to store the result
  2552. * @returns the current Vector3
  2553. */
  2554. negateToRef(result: Vector3): Vector3;
  2555. /**
  2556. * Multiplies the Vector3 coordinates by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns the current updated Vector3
  2559. */
  2560. scaleInPlace(scale: number): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2563. * @param scale defines the multiplier factor
  2564. * @returns a new Vector3
  2565. */
  2566. scale(scale: number): Vector3;
  2567. /**
  2568. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2569. * @param scale defines the multiplier factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the current Vector3
  2572. */
  2573. scaleToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2576. * @param scale defines the scale factor
  2577. * @param result defines the Vector3 object where to store the result
  2578. * @returns the unmodified current Vector3
  2579. */
  2580. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @returns the projected vector3
  2586. */
  2587. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2588. /**
  2589. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2590. * @param origin defines the origin of the projection ray
  2591. * @param plane defines the plane to project to
  2592. * @param result defines the Vector3 where to store the result
  2593. */
  2594. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2597. * @param otherVector defines the second operand
  2598. * @returns true if both vectors are equals
  2599. */
  2600. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2603. * @param otherVector defines the second operand
  2604. * @param epsilon defines the minimal distance to define values as equals
  2605. * @returns true if both vectors are distant less than epsilon
  2606. */
  2607. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2608. /**
  2609. * Returns true if the current Vector3 coordinates equals the given floats
  2610. * @param x defines the x coordinate of the operand
  2611. * @param y defines the y coordinate of the operand
  2612. * @param z defines the z coordinate of the operand
  2613. * @returns true if both vectors are equals
  2614. */
  2615. equalsToFloats(x: number, y: number, z: number): boolean;
  2616. /**
  2617. * Multiplies the current Vector3 coordinates by the given ones
  2618. * @param otherVector defines the second operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2624. * @param otherVector defines the second operand
  2625. * @returns the new Vector3
  2626. */
  2627. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2630. * @param otherVector defines the second operand
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the new Vector3
  2641. */
  2642. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2645. * @param otherVector defines the second operand
  2646. * @returns the new Vector3
  2647. */
  2648. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2651. * @param otherVector defines the second operand
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the current Vector3
  2654. */
  2655. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2656. /**
  2657. * Divides the current Vector3 coordinates by the given ones.
  2658. * @param otherVector defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. divideInPlace(otherVector: Vector3): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2670. * @param other defines the second operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2692. * Check if is non uniform within a certain amount of decimal places to account for this
  2693. * @param epsilon the amount the values can differ
  2694. * @returns if the the vector is non uniform to a certain number of decimal places
  2695. */
  2696. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2697. /**
  2698. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2699. */
  2700. get isNonUniform(): boolean;
  2701. /**
  2702. * Gets a new Vector3 from current Vector3 floored values
  2703. * @returns a new Vector3
  2704. */
  2705. floor(): Vector3;
  2706. /**
  2707. * Gets a new Vector3 from current Vector3 floored values
  2708. * @returns a new Vector3
  2709. */
  2710. fract(): Vector3;
  2711. /**
  2712. * Gets the length of the Vector3
  2713. * @returns the length of the Vector3
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Gets the squared length of the Vector3
  2718. * @returns squared length of the Vector3
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalize the current Vector3.
  2723. * Please note that this is an in place operation.
  2724. * @returns the current updated Vector3
  2725. */
  2726. normalize(): Vector3;
  2727. /**
  2728. * Reorders the x y z properties of the vector in place
  2729. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2730. * @returns the current updated vector
  2731. */
  2732. reorderInPlace(order: string): this;
  2733. /**
  2734. * Rotates the vector around 0,0,0 by a quaternion
  2735. * @param quaternion the rotation quaternion
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2740. /**
  2741. * Rotates a vector around a given point
  2742. * @param quaternion the rotation quaternion
  2743. * @param point the point to rotate around
  2744. * @param result vector to store the result
  2745. * @returns the resulting vector
  2746. */
  2747. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2748. /**
  2749. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2750. * The cross product is then orthogonal to both current and "other"
  2751. * @param other defines the right operand
  2752. * @returns the cross product
  2753. */
  2754. cross(other: Vector3): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 with the given input length.
  2757. * Please note that this is an in place operation.
  2758. * @param len the length of the vector
  2759. * @returns the current updated Vector3
  2760. */
  2761. normalizeFromLength(len: number): Vector3;
  2762. /**
  2763. * Normalize the current Vector3 to a new vector
  2764. * @returns the new Vector3
  2765. */
  2766. normalizeToNew(): Vector3;
  2767. /**
  2768. * Normalize the current Vector3 to the reference
  2769. * @param reference define the Vector3 to update
  2770. * @returns the updated Vector3
  2771. */
  2772. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2773. /**
  2774. * Creates a new Vector3 copied from the current Vector3
  2775. * @returns the new Vector3
  2776. */
  2777. clone(): Vector3;
  2778. /**
  2779. * Copies the given vector coordinates to the current Vector3 ones
  2780. * @param source defines the source Vector3
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. copyFromFloats(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given floats to the current Vector3 coordinates
  2794. * @param x defines the x coordinate of the operand
  2795. * @param y defines the y coordinate of the operand
  2796. * @param z defines the z coordinate of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. set(x: number, y: number, z: number): Vector3;
  2800. /**
  2801. * Copies the given float to the current Vector3 coordinates
  2802. * @param v defines the x, y and z coordinates of the operand
  2803. * @returns the current updated Vector3
  2804. */
  2805. setAll(v: number): Vector3;
  2806. /**
  2807. * Get the clip factor between two vectors
  2808. * @param vector0 defines the first operand
  2809. * @param vector1 defines the second operand
  2810. * @param axis defines the axis to use
  2811. * @param size defines the size along the axis
  2812. * @returns the clip factor
  2813. */
  2814. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2815. /**
  2816. * Get angle between two vectors
  2817. * @param vector0 angle between vector0 and vector1
  2818. * @param vector1 angle between vector0 and vector1
  2819. * @param normal direction of the normal
  2820. * @return the angle between vector0 and vector1
  2821. */
  2822. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. */
  2829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2830. /**
  2831. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @returns the new Vector3
  2835. * @deprecated Please use FromArray instead.
  2836. */
  2837. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2847. * @param array defines the source array
  2848. * @param offset defines the offset in the source array
  2849. * @param result defines the Vector3 where to store the result
  2850. * @deprecated Please use FromArrayToRef instead.
  2851. */
  2852. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2853. /**
  2854. * Sets the given vector "result" with the given floats.
  2855. * @param x defines the x coordinate of the source
  2856. * @param y defines the y coordinate of the source
  2857. * @param z defines the z coordinate of the source
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2863. * @returns a new empty Vector3
  2864. */
  2865. static Zero(): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2868. * @returns a new unit Vector3
  2869. */
  2870. static One(): Vector3;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2873. * @returns a new up Vector3
  2874. */
  2875. static Up(): Vector3;
  2876. /**
  2877. * Gets a up Vector3 that must not be updated
  2878. */
  2879. static get UpReadOnly(): DeepImmutable<Vector3>;
  2880. /**
  2881. * Gets a zero Vector3 that must not be updated
  2882. */
  2883. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2884. /**
  2885. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2886. * @returns a new down Vector3
  2887. */
  2888. static Down(): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Forward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2897. * @param rightHandedSystem is the scene right-handed (negative-z)
  2898. * @returns a new forward Vector3
  2899. */
  2900. static Backward(rightHandedSystem?: boolean): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2903. * @returns a new right Vector3
  2904. */
  2905. static Right(): Vector3;
  2906. /**
  2907. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2908. * @returns a new left Vector3
  2909. */
  2910. static Left(): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @returns the transformed Vector3
  2917. */
  2918. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2921. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2922. * @param vector defines the Vector3 to transform
  2923. * @param transformation defines the transformation matrix
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2929. * This method computes tranformed coordinates only, not transformed direction vectors
  2930. * @param x define the x coordinate of the source vector
  2931. * @param y define the y coordinate of the source vector
  2932. * @param z define the z coordinate of the source vector
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @returns the new Vector3
  2943. */
  2944. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param vector defines the Vector3 to transform
  2949. * @param transformation defines the transformation matrix
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2955. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2956. * @param x define the x coordinate of the source vector
  2957. * @param y define the y coordinate of the source vector
  2958. * @param z define the z coordinate of the source vector
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2965. * @param value1 defines the first control point
  2966. * @param value2 defines the second control point
  2967. * @param value3 defines the third control point
  2968. * @param value4 defines the fourth control point
  2969. * @param amount defines the amount on the spline to use
  2970. * @returns the new Vector3
  2971. */
  2972. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2973. /**
  2974. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2975. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2976. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2977. * @param value defines the current value
  2978. * @param min defines the lower range value
  2979. * @param max defines the upper range value
  2980. * @returns the new Vector3
  2981. */
  2982. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2993. /**
  2994. * Checks if a given vector is inside a specific range
  2995. * @param v defines the vector to test
  2996. * @param min defines the minimum range
  2997. * @param max defines the maximum range
  2998. */
  2999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3000. /**
  3001. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3002. * @param value1 defines the first control point
  3003. * @param tangent1 defines the first tangent vector
  3004. * @param value2 defines the second control point
  3005. * @param tangent2 defines the second tangent vector
  3006. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @returns the new Vector3
  3016. */
  3017. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3018. /**
  3019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3020. * @param start defines the start value
  3021. * @param end defines the end value
  3022. * @param amount max defines amount between both (between 0 and 1)
  3023. * @param result defines the Vector3 where to store the result
  3024. */
  3025. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3026. /**
  3027. * Returns the dot product (float) between the vectors "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the dot product
  3031. */
  3032. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3033. /**
  3034. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @returns the cross product
  3039. */
  3040. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Sets the given vector "result" with the cross product of "left" and "right"
  3043. * The cross product is then orthogonal to both "left" and "right"
  3044. * @param left defines the left operand
  3045. * @param right defines the right operand
  3046. * @param result defines the Vector3 where to store the result
  3047. */
  3048. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3049. /**
  3050. * Returns a new Vector3 as the normalization of the given vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @returns the new Vector3
  3053. */
  3054. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Sets the given vector "result" with the normalization of the given first vector
  3057. * @param vector defines the Vector3 to normalize
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Project a Vector3 onto screen space
  3063. * @param vector defines the Vector3 to project
  3064. * @param world defines the world matrix to use
  3065. * @param transform defines the transform (view x projection) matrix to use
  3066. * @param viewport defines the screen viewport to use
  3067. * @returns the new Vector3
  3068. */
  3069. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3070. /** @hidden */
  3071. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3072. /**
  3073. * Unproject from screen space to object space
  3074. * @param source defines the screen space Vector3 to use
  3075. * @param viewportWidth defines the current width of the viewport
  3076. * @param viewportHeight defines the current height of the viewport
  3077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3078. * @param transform defines the transform (view x projection) matrix to use
  3079. * @returns the new Vector3
  3080. */
  3081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param view defines the view matrix to use
  3089. * @param projection defines the projection matrix to use
  3090. * @returns the new Vector3
  3091. */
  3092. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3093. /**
  3094. * Unproject from screen space to object space
  3095. * @param source defines the screen space Vector3 to use
  3096. * @param viewportWidth defines the current width of the viewport
  3097. * @param viewportHeight defines the current height of the viewport
  3098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3099. * @param view defines the view matrix to use
  3100. * @param projection defines the projection matrix to use
  3101. * @param result defines the Vector3 where to store the result
  3102. */
  3103. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3104. /**
  3105. * Unproject from screen space to object space
  3106. * @param sourceX defines the screen space x coordinate to use
  3107. * @param sourceY defines the screen space y coordinate to use
  3108. * @param sourceZ defines the screen space z coordinate to use
  3109. * @param viewportWidth defines the current width of the viewport
  3110. * @param viewportHeight defines the current height of the viewport
  3111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3112. * @param view defines the view matrix to use
  3113. * @param projection defines the projection matrix to use
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3117. /**
  3118. * Gets the minimal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Gets the maximal coordinate values between two Vector3
  3126. * @param left defines the first operand
  3127. * @param right defines the second operand
  3128. * @returns the new Vector3
  3129. */
  3130. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3131. /**
  3132. * Returns the distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the distance
  3136. */
  3137. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns the squared distance between the vectors "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the squared distance
  3143. */
  3144. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3145. /**
  3146. * Returns a new Vector3 located at the center between "value1" and "value2"
  3147. * @param value1 defines the first operand
  3148. * @param value2 defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3155. * to something in order to rotate it from its local system to the given target system
  3156. * Note: axis1, axis2 and axis3 are normalized during this operation
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @returns a new Vector3
  3161. */
  3162. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3165. * @param axis1 defines the first axis
  3166. * @param axis2 defines the second axis
  3167. * @param axis3 defines the third axis
  3168. * @param ref defines the Vector3 where to store the result
  3169. */
  3170. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3171. }
  3172. /**
  3173. * Vector4 class created for EulerAngle class conversion to Quaternion
  3174. */
  3175. export class Vector4 {
  3176. /** x value of the vector */
  3177. x: number;
  3178. /** y value of the vector */
  3179. y: number;
  3180. /** z value of the vector */
  3181. z: number;
  3182. /** w value of the vector */
  3183. w: number;
  3184. /**
  3185. * Creates a Vector4 object from the given floats.
  3186. * @param x x value of the vector
  3187. * @param y y value of the vector
  3188. * @param z z value of the vector
  3189. * @param w w value of the vector
  3190. */
  3191. constructor(
  3192. /** x value of the vector */
  3193. x: number,
  3194. /** y value of the vector */
  3195. y: number,
  3196. /** z value of the vector */
  3197. z: number,
  3198. /** w value of the vector */
  3199. w: number);
  3200. /**
  3201. * Returns the string with the Vector4 coordinates.
  3202. * @returns a string containing all the vector values
  3203. */
  3204. toString(): string;
  3205. /**
  3206. * Returns the string "Vector4".
  3207. * @returns "Vector4"
  3208. */
  3209. getClassName(): string;
  3210. /**
  3211. * Returns the Vector4 hash code.
  3212. * @returns a unique hash code
  3213. */
  3214. getHashCode(): number;
  3215. /**
  3216. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3217. * @returns the resulting array
  3218. */
  3219. asArray(): number[];
  3220. /**
  3221. * Populates the given array from the given index with the Vector4 coordinates.
  3222. * @param array array to populate
  3223. * @param index index of the array to start at (default: 0)
  3224. * @returns the Vector4.
  3225. */
  3226. toArray(array: FloatArray, index?: number): Vector4;
  3227. /**
  3228. * Adds the given vector to the current Vector4.
  3229. * @param otherVector the vector to add
  3230. * @returns the updated Vector4.
  3231. */
  3232. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @returns the resulting vector
  3237. */
  3238. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3239. /**
  3240. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3241. * @param otherVector the vector to add
  3242. * @param result the vector to store the result
  3243. * @returns the current Vector4.
  3244. */
  3245. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3246. /**
  3247. * Subtract in place the given vector from the current Vector4.
  3248. * @param otherVector the vector to subtract
  3249. * @returns the updated Vector4.
  3250. */
  3251. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the new vector with the result
  3256. */
  3257. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3260. * @param otherVector the vector to subtract
  3261. * @param result the vector to store the result
  3262. * @returns the current Vector4.
  3263. */
  3264. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3265. /**
  3266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3267. */
  3268. /**
  3269. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3270. * @param x value to subtract
  3271. * @param y value to subtract
  3272. * @param z value to subtract
  3273. * @param w value to subtract
  3274. * @returns new vector containing the result
  3275. */
  3276. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3277. /**
  3278. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3279. * @param x value to subtract
  3280. * @param y value to subtract
  3281. * @param z value to subtract
  3282. * @param w value to subtract
  3283. * @param result the vector to store the result in
  3284. * @returns the current Vector4.
  3285. */
  3286. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3287. /**
  3288. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3289. * @returns a new vector with the negated values
  3290. */
  3291. negate(): Vector4;
  3292. /**
  3293. * Negate this vector in place
  3294. * @returns this
  3295. */
  3296. negateInPlace(): Vector4;
  3297. /**
  3298. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3299. * @param result defines the Vector3 object where to store the result
  3300. * @returns the current Vector4
  3301. */
  3302. negateToRef(result: Vector4): Vector4;
  3303. /**
  3304. * Multiplies the current Vector4 coordinates by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns the updated Vector4.
  3307. */
  3308. scaleInPlace(scale: number): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @returns a new vector with the result
  3313. */
  3314. scale(scale: number): Vector4;
  3315. /**
  3316. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3317. * @param scale the number to scale with
  3318. * @param result a vector to store the result in
  3319. * @returns the current Vector4.
  3320. */
  3321. scaleToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3324. * @param scale defines the scale factor
  3325. * @param result defines the Vector4 object where to store the result
  3326. * @returns the unmodified current Vector4
  3327. */
  3328. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3331. * @param otherVector the vector to compare against
  3332. * @returns true if they are equal
  3333. */
  3334. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3335. /**
  3336. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3337. * @param otherVector vector to compare against
  3338. * @param epsilon (Default: very small number)
  3339. * @returns true if they are equal
  3340. */
  3341. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3342. /**
  3343. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3344. * @param x x value to compare against
  3345. * @param y y value to compare against
  3346. * @param z z value to compare against
  3347. * @param w w value to compare against
  3348. * @returns true if equal
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3351. /**
  3352. * Multiplies in place the current Vector4 by the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns the updated Vector4.
  3355. */
  3356. multiplyInPlace(otherVector: Vector4): Vector4;
  3357. /**
  3358. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @returns resulting new vector
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3365. * @param otherVector vector to multiple with
  3366. * @param result vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3372. * @param x x value multiply with
  3373. * @param y y value multiply with
  3374. * @param z z value multiply with
  3375. * @param w w value multiply with
  3376. * @returns resulting new vector
  3377. */
  3378. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3379. /**
  3380. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @returns resulting new vector
  3383. */
  3384. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3387. * @param otherVector vector to devide with
  3388. * @param result vector to store the result
  3389. * @returns the current Vector4.
  3390. */
  3391. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3392. /**
  3393. * Divides the current Vector3 coordinates by the given ones.
  3394. * @param otherVector vector to devide with
  3395. * @returns the updated Vector3.
  3396. */
  3397. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3406. * @param other defines the second operand
  3407. * @returns the current updated Vector4
  3408. */
  3409. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Gets a new Vector4 from current Vector4 floored values
  3412. * @returns a new Vector4
  3413. */
  3414. floor(): Vector4;
  3415. /**
  3416. * Gets a new Vector4 from current Vector3 floored values
  3417. * @returns a new Vector4
  3418. */
  3419. fract(): Vector4;
  3420. /**
  3421. * Returns the Vector4 length (float).
  3422. * @returns the length
  3423. */
  3424. length(): number;
  3425. /**
  3426. * Returns the Vector4 squared length (float).
  3427. * @returns the length squared
  3428. */
  3429. lengthSquared(): number;
  3430. /**
  3431. * Normalizes in place the Vector4.
  3432. * @returns the updated Vector4.
  3433. */
  3434. normalize(): Vector4;
  3435. /**
  3436. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3437. * @returns this converted to a new vector3
  3438. */
  3439. toVector3(): Vector3;
  3440. /**
  3441. * Returns a new Vector4 copied from the current one.
  3442. * @returns the new cloned vector
  3443. */
  3444. clone(): Vector4;
  3445. /**
  3446. * Updates the current Vector4 with the given one coordinates.
  3447. * @param source the source vector to copy from
  3448. * @returns the updated Vector4.
  3449. */
  3450. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3451. /**
  3452. * Updates the current Vector4 coordinates with the given floats.
  3453. * @param x float to copy from
  3454. * @param y float to copy from
  3455. * @param z float to copy from
  3456. * @param w float to copy from
  3457. * @returns the updated Vector4.
  3458. */
  3459. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3460. /**
  3461. * Updates the current Vector4 coordinates with the given floats.
  3462. * @param x float to set from
  3463. * @param y float to set from
  3464. * @param z float to set from
  3465. * @param w float to set from
  3466. * @returns the updated Vector4.
  3467. */
  3468. set(x: number, y: number, z: number, w: number): Vector4;
  3469. /**
  3470. * Copies the given float to the current Vector3 coordinates
  3471. * @param v defines the x, y, z and w coordinates of the operand
  3472. * @returns the current updated Vector3
  3473. */
  3474. setAll(v: number): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @returns the new vector
  3480. */
  3481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" from the starting index of the given Float32Array.
  3491. * @param array the array to pull values from
  3492. * @param offset the offset into the array to start at
  3493. * @param result the vector to store the result in
  3494. */
  3495. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3496. /**
  3497. * Updates the given vector "result" coordinates from the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @param result the vector to the floats in
  3503. */
  3504. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3505. /**
  3506. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3507. * @returns the new vector
  3508. */
  3509. static Zero(): Vector4;
  3510. /**
  3511. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3512. * @returns the new vector
  3513. */
  3514. static One(): Vector4;
  3515. /**
  3516. * Returns a new normalized Vector4 from the given one.
  3517. * @param vector the vector to normalize
  3518. * @returns the vector
  3519. */
  3520. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the given vector "result" from the normalization of the given one.
  3523. * @param vector the vector to normalize
  3524. * @param result the vector to store the result in
  3525. */
  3526. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3527. /**
  3528. * Returns a vector with the minimum values from the left and right vectors
  3529. * @param left left vector to minimize
  3530. * @param right right vector to minimize
  3531. * @returns a new vector with the minimum of the left and right vector values
  3532. */
  3533. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns a vector with the maximum values from the left and right vectors
  3536. * @param left left vector to maximize
  3537. * @param right right vector to maximize
  3538. * @returns a new vector with the maximum of the left and right vector values
  3539. */
  3540. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3541. /**
  3542. * Returns the distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors
  3546. */
  3547. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the distance between
  3551. * @param value2 value to calulate the distance between
  3552. * @return the distance between the two vectors squared
  3553. */
  3554. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3555. /**
  3556. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3557. * @param value1 value to calulate the center between
  3558. * @param value2 value to calulate the center between
  3559. * @return the center between the two vectors
  3560. */
  3561. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @returns the new vector
  3568. */
  3569. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param vector the vector to transform
  3574. * @param transformation the transformation matrix to apply
  3575. * @param result the vector to store the result in
  3576. */
  3577. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3578. /**
  3579. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3580. * This methods computes transformed normalized direction vectors only.
  3581. * @param x value to transform
  3582. * @param y value to transform
  3583. * @param z value to transform
  3584. * @param w value to transform
  3585. * @param transformation the transformation matrix to apply
  3586. * @param result the vector to store the results in
  3587. */
  3588. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3589. /**
  3590. * Creates a new Vector4 from a Vector3
  3591. * @param source defines the source data
  3592. * @param w defines the 4th component (default is 0)
  3593. * @returns a new Vector4
  3594. */
  3595. static FromVector3(source: Vector3, w?: number): Vector4;
  3596. }
  3597. /**
  3598. * Class used to store quaternion data
  3599. * @see https://en.wikipedia.org/wiki/Quaternion
  3600. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3601. */
  3602. export class Quaternion {
  3603. /** defines the first component (0 by default) */
  3604. x: number;
  3605. /** defines the second component (0 by default) */
  3606. y: number;
  3607. /** defines the third component (0 by default) */
  3608. z: number;
  3609. /** defines the fourth component (1.0 by default) */
  3610. w: number;
  3611. /**
  3612. * Creates a new Quaternion from the given floats
  3613. * @param x defines the first component (0 by default)
  3614. * @param y defines the second component (0 by default)
  3615. * @param z defines the third component (0 by default)
  3616. * @param w defines the fourth component (1.0 by default)
  3617. */
  3618. constructor(
  3619. /** defines the first component (0 by default) */
  3620. x?: number,
  3621. /** defines the second component (0 by default) */
  3622. y?: number,
  3623. /** defines the third component (0 by default) */
  3624. z?: number,
  3625. /** defines the fourth component (1.0 by default) */
  3626. w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5064. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /**
  7757. * Creates a cube texture from an array of image urls
  7758. * @param files defines an array of image urls
  7759. * @param scene defines the hosting scene
  7760. * @param noMipmap specifies if mip maps are not used
  7761. * @returns a cube texture
  7762. */
  7763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7764. /**
  7765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7766. * @param url defines the url of the prefiltered texture
  7767. * @param scene defines the scene the texture is attached to
  7768. * @param forcedExtension defines the extension of the file if different from the url
  7769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7770. * @return the prefiltered texture
  7771. */
  7772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7773. /**
  7774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7775. * as prefiltered data.
  7776. * @param rootUrl defines the url of the texture or the root name of the six images
  7777. * @param null defines the scene or engine the texture is attached to
  7778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7779. * @param noMipmap defines if mipmaps should be created or not
  7780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7782. * @param onError defines a callback triggered in case of error during load
  7783. * @param format defines the internal format to use for the texture once loaded
  7784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @return the cube texture
  7790. */
  7791. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7803. */
  7804. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7805. /**
  7806. * Delays loading of the cube texture
  7807. * @param forcedExtension defines the extension to use
  7808. */
  7809. delayLoad(forcedExtension?: string): void;
  7810. /**
  7811. * Returns the reflection texture matrix
  7812. * @returns the reflection texture matrix
  7813. */
  7814. getReflectionTextureMatrix(): Matrix;
  7815. /**
  7816. * Sets the reflection texture matrix
  7817. * @param value Reflection texture matrix
  7818. */
  7819. setReflectionTextureMatrix(value: Matrix): void;
  7820. /**
  7821. * Parses text to create a cube texture
  7822. * @param parsedTexture define the serialized text to read from
  7823. * @param scene defines the hosting scene
  7824. * @param rootUrl defines the root url of the cube texture
  7825. * @returns a cube texture
  7826. */
  7827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7828. /**
  7829. * Makes a clone, or deep copy, of the cube texture
  7830. * @returns a new cube texture
  7831. */
  7832. clone(): CubeTexture;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets the global Density value.
  7973. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets the highlights Density value.
  8019. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets the midtones Density value.
  8065. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets the shadows Density value.
  8111. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /**
  8519. * Defines the kind of connection point for node based material
  8520. */
  8521. export enum NodeMaterialBlockConnectionPointTypes {
  8522. /** Float */
  8523. Float = 1,
  8524. /** Int */
  8525. Int = 2,
  8526. /** Vector2 */
  8527. Vector2 = 4,
  8528. /** Vector3 */
  8529. Vector3 = 8,
  8530. /** Vector4 */
  8531. Vector4 = 16,
  8532. /** Color3 */
  8533. Color3 = 32,
  8534. /** Color4 */
  8535. Color4 = 64,
  8536. /** Matrix */
  8537. Matrix = 128,
  8538. /** Custom object */
  8539. Object = 256,
  8540. /** Detect type based on connection */
  8541. AutoDetect = 1024,
  8542. /** Output type that will be defined by input type */
  8543. BasedOnInput = 2048
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * Enum used to define the target of a block
  8549. */
  8550. export enum NodeMaterialBlockTargets {
  8551. /** Vertex shader */
  8552. Vertex = 1,
  8553. /** Fragment shader */
  8554. Fragment = 2,
  8555. /** Neutral */
  8556. Neutral = 4,
  8557. /** Vertex and Fragment */
  8558. VertexAndFragment = 3
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8564. */
  8565. export enum NodeMaterialBlockConnectionPointMode {
  8566. /** Value is an uniform */
  8567. Uniform = 0,
  8568. /** Value is a mesh attribute */
  8569. Attribute = 1,
  8570. /** Value is a varying between vertex and fragment shaders */
  8571. Varying = 2,
  8572. /** Mode is undefined */
  8573. Undefined = 3
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Enum used to define system values e.g. values automatically provided by the system
  8579. */
  8580. export enum NodeMaterialSystemValues {
  8581. /** World */
  8582. World = 1,
  8583. /** View */
  8584. View = 2,
  8585. /** Projection */
  8586. Projection = 3,
  8587. /** ViewProjection */
  8588. ViewProjection = 4,
  8589. /** WorldView */
  8590. WorldView = 5,
  8591. /** WorldViewProjection */
  8592. WorldViewProjection = 6,
  8593. /** CameraPosition */
  8594. CameraPosition = 7,
  8595. /** Fog Color */
  8596. FogColor = 8,
  8597. /** Delta time */
  8598. DeltaTime = 9
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Represents a camera frustum
  8624. */
  8625. export class Frustum {
  8626. /**
  8627. * Gets the planes representing the frustum
  8628. * @param transform matrix to be applied to the returned planes
  8629. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8630. */
  8631. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8632. /**
  8633. * Gets the near frustum plane transformed by the transform matrix
  8634. * @param transform transformation matrix to be applied to the resulting frustum plane
  8635. * @param frustumPlane the resuling frustum plane
  8636. */
  8637. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8638. /**
  8639. * Gets the far frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the left frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the right frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the top frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the bottom frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8670. * @param transform transformation matrix to be applied to the resulting frustum planes
  8671. * @param frustumPlanes the resuling frustum planes
  8672. */
  8673. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Interface for the size containing width and height
  8679. */
  8680. export interface ISize {
  8681. /**
  8682. * Width
  8683. */
  8684. width: number;
  8685. /**
  8686. * Heighht
  8687. */
  8688. height: number;
  8689. }
  8690. /**
  8691. * Size containing widht and height
  8692. */
  8693. export class Size implements ISize {
  8694. /**
  8695. * Width
  8696. */
  8697. width: number;
  8698. /**
  8699. * Height
  8700. */
  8701. height: number;
  8702. /**
  8703. * Creates a Size object from the given width and height (floats).
  8704. * @param width width of the new size
  8705. * @param height height of the new size
  8706. */
  8707. constructor(width: number, height: number);
  8708. /**
  8709. * Returns a string with the Size width and height
  8710. * @returns a string with the Size width and height
  8711. */
  8712. toString(): string;
  8713. /**
  8714. * "Size"
  8715. * @returns the string "Size"
  8716. */
  8717. getClassName(): string;
  8718. /**
  8719. * Returns the Size hash code.
  8720. * @returns a hash code for a unique width and height
  8721. */
  8722. getHashCode(): number;
  8723. /**
  8724. * Updates the current size from the given one.
  8725. * @param src the given size
  8726. */
  8727. copyFrom(src: Size): void;
  8728. /**
  8729. * Updates in place the current Size from the given floats.
  8730. * @param width width of the new size
  8731. * @param height height of the new size
  8732. * @returns the updated Size.
  8733. */
  8734. copyFromFloats(width: number, height: number): Size;
  8735. /**
  8736. * Updates in place the current Size from the given floats.
  8737. * @param width width to set
  8738. * @param height height to set
  8739. * @returns the updated Size.
  8740. */
  8741. set(width: number, height: number): Size;
  8742. /**
  8743. * Multiplies the width and height by numbers
  8744. * @param w factor to multiple the width by
  8745. * @param h factor to multiple the height by
  8746. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8747. */
  8748. multiplyByFloats(w: number, h: number): Size;
  8749. /**
  8750. * Clones the size
  8751. * @returns a new Size copied from the given one.
  8752. */
  8753. clone(): Size;
  8754. /**
  8755. * True if the current Size and the given one width and height are strictly equal.
  8756. * @param other the other size to compare against
  8757. * @returns True if the current Size and the given one width and height are strictly equal.
  8758. */
  8759. equals(other: Size): boolean;
  8760. /**
  8761. * The surface of the Size : width * height (float).
  8762. */
  8763. get surface(): number;
  8764. /**
  8765. * Create a new size of zero
  8766. * @returns a new Size set to (0.0, 0.0)
  8767. */
  8768. static Zero(): Size;
  8769. /**
  8770. * Sums the width and height of two sizes
  8771. * @param otherSize size to add to this size
  8772. * @returns a new Size set as the addition result of the current Size and the given one.
  8773. */
  8774. add(otherSize: Size): Size;
  8775. /**
  8776. * Subtracts the width and height of two
  8777. * @param otherSize size to subtract to this size
  8778. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8779. */
  8780. subtract(otherSize: Size): Size;
  8781. /**
  8782. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8783. * @param start starting size to lerp between
  8784. * @param end end size to lerp between
  8785. * @param amount amount to lerp between the start and end values
  8786. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8787. */
  8788. static Lerp(start: Size, end: Size, amount: number): Size;
  8789. }
  8790. }
  8791. declare module BABYLON {
  8792. /**
  8793. * Contains position and normal vectors for a vertex
  8794. */
  8795. export class PositionNormalVertex {
  8796. /** the position of the vertex (defaut: 0,0,0) */
  8797. position: Vector3;
  8798. /** the normal of the vertex (defaut: 0,1,0) */
  8799. normal: Vector3;
  8800. /**
  8801. * Creates a PositionNormalVertex
  8802. * @param position the position of the vertex (defaut: 0,0,0)
  8803. * @param normal the normal of the vertex (defaut: 0,1,0)
  8804. */
  8805. constructor(
  8806. /** the position of the vertex (defaut: 0,0,0) */
  8807. position?: Vector3,
  8808. /** the normal of the vertex (defaut: 0,1,0) */
  8809. normal?: Vector3);
  8810. /**
  8811. * Clones the PositionNormalVertex
  8812. * @returns the cloned PositionNormalVertex
  8813. */
  8814. clone(): PositionNormalVertex;
  8815. }
  8816. /**
  8817. * Contains position, normal and uv vectors for a vertex
  8818. */
  8819. export class PositionNormalTextureVertex {
  8820. /** the position of the vertex (defaut: 0,0,0) */
  8821. position: Vector3;
  8822. /** the normal of the vertex (defaut: 0,1,0) */
  8823. normal: Vector3;
  8824. /** the uv of the vertex (default: 0,0) */
  8825. uv: Vector2;
  8826. /**
  8827. * Creates a PositionNormalTextureVertex
  8828. * @param position the position of the vertex (defaut: 0,0,0)
  8829. * @param normal the normal of the vertex (defaut: 0,1,0)
  8830. * @param uv the uv of the vertex (default: 0,0)
  8831. */
  8832. constructor(
  8833. /** the position of the vertex (defaut: 0,0,0) */
  8834. position?: Vector3,
  8835. /** the normal of the vertex (defaut: 0,1,0) */
  8836. normal?: Vector3,
  8837. /** the uv of the vertex (default: 0,0) */
  8838. uv?: Vector2);
  8839. /**
  8840. * Clones the PositionNormalTextureVertex
  8841. * @returns the cloned PositionNormalTextureVertex
  8842. */
  8843. clone(): PositionNormalTextureVertex;
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Enum defining the type of animations supported by InputBlock
  8849. */
  8850. export enum AnimatedInputBlockTypes {
  8851. /** No animation */
  8852. None = 0,
  8853. /** Time based animation. Will only work for floats */
  8854. Time = 1
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * Interface describing all the common properties and methods a shadow light needs to implement.
  8860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8861. * as well as binding the different shadow properties to the effects.
  8862. */
  8863. export interface IShadowLight extends Light {
  8864. /**
  8865. * The light id in the scene (used in scene.findLighById for instance)
  8866. */
  8867. id: string;
  8868. /**
  8869. * The position the shdow will be casted from.
  8870. */
  8871. position: Vector3;
  8872. /**
  8873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8874. */
  8875. direction: Vector3;
  8876. /**
  8877. * The transformed position. Position of the light in world space taking parenting in account.
  8878. */
  8879. transformedPosition: Vector3;
  8880. /**
  8881. * The transformed direction. Direction of the light in world space taking parenting in account.
  8882. */
  8883. transformedDirection: Vector3;
  8884. /**
  8885. * The friendly name of the light in the scene.
  8886. */
  8887. name: string;
  8888. /**
  8889. * Defines the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. /**
  8893. * Defines the shadow projection clipping maximum z value.
  8894. */
  8895. shadowMaxZ: number;
  8896. /**
  8897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8899. */
  8900. computeTransformedInformation(): boolean;
  8901. /**
  8902. * Gets the scene the light belongs to.
  8903. * @returns The scene
  8904. */
  8905. getScene(): Scene;
  8906. /**
  8907. * Callback defining a custom Projection Matrix Builder.
  8908. * This can be used to override the default projection matrix computation.
  8909. */
  8910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. /**
  8920. * Gets the current depth scale used in ESM.
  8921. * @returns The scale
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /**
  8939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8942. */
  8943. getShadowDirection(faceIndex?: number): Vector3;
  8944. /**
  8945. * Gets the minZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the min for
  8947. * @returns the depth min z
  8948. */
  8949. getDepthMinZ(activeCamera: Camera): number;
  8950. /**
  8951. * Gets the maxZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the max for
  8953. * @returns the depth max z
  8954. */
  8955. getDepthMaxZ(activeCamera: Camera): number;
  8956. }
  8957. /**
  8958. * Base implementation IShadowLight
  8959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8960. */
  8961. export abstract class ShadowLight extends Light implements IShadowLight {
  8962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8963. protected _position: Vector3;
  8964. protected _setPosition(value: Vector3): void;
  8965. /**
  8966. * Sets the position the shadow will be casted from. Also use as the light position for both
  8967. * point and spot lights.
  8968. */
  8969. get position(): Vector3;
  8970. /**
  8971. * Sets the position the shadow will be casted from. Also use as the light position for both
  8972. * point and spot lights.
  8973. */
  8974. set position(value: Vector3);
  8975. protected _direction: Vector3;
  8976. protected _setDirection(value: Vector3): void;
  8977. /**
  8978. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8979. * Also use as the light direction on spot and directional lights.
  8980. */
  8981. get direction(): Vector3;
  8982. /**
  8983. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8984. * Also use as the light direction on spot and directional lights.
  8985. */
  8986. set direction(value: Vector3);
  8987. protected _shadowMinZ: number;
  8988. /**
  8989. * Gets the shadow projection clipping minimum z value.
  8990. */
  8991. get shadowMinZ(): number;
  8992. /**
  8993. * Sets the shadow projection clipping minimum z value.
  8994. */
  8995. set shadowMinZ(value: number);
  8996. protected _shadowMaxZ: number;
  8997. /**
  8998. * Sets the shadow projection clipping maximum z value.
  8999. */
  9000. get shadowMaxZ(): number;
  9001. /**
  9002. * Gets the shadow projection clipping maximum z value.
  9003. */
  9004. set shadowMaxZ(value: number);
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * The transformed position. Position of the light in world space taking parenting in account.
  9012. */
  9013. transformedPosition: Vector3;
  9014. /**
  9015. * The transformed direction. Direction of the light in world space taking parenting in account.
  9016. */
  9017. transformedDirection: Vector3;
  9018. private _needProjectionMatrixCompute;
  9019. /**
  9020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9022. */
  9023. computeTransformedInformation(): boolean;
  9024. /**
  9025. * Return the depth scale used for the shadow map.
  9026. * @returns the depth scale.
  9027. */
  9028. getDepthScale(): number;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Returns the ShadowLight absolute position in the World.
  9037. * @returns the position vector in world space
  9038. */
  9039. getAbsolutePosition(): Vector3;
  9040. /**
  9041. * Sets the ShadowLight direction toward the passed target.
  9042. * @param target The point to target in local space
  9043. * @returns the updated ShadowLight direction
  9044. */
  9045. setDirectionToTarget(target: Vector3): Vector3;
  9046. /**
  9047. * Returns the light rotation in euler definition.
  9048. * @returns the x y z rotation in local space.
  9049. */
  9050. getRotation(): Vector3;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /** @hidden */
  9066. _initCache(): void;
  9067. /** @hidden */
  9068. _isSynchronized(): boolean;
  9069. /**
  9070. * Computes the world matrix of the node
  9071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9072. * @returns the world matrix
  9073. */
  9074. computeWorldMatrix(force?: boolean): Matrix;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. /**
  9088. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9089. * @param matrix The materix to updated with the projection information
  9090. * @param viewMatrix The transform matrix of the light
  9091. * @param renderList The list of mesh to render in the map
  9092. * @returns The current light
  9093. */
  9094. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var packingFunctions: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var bayerDitherFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var shadowMapFragmentDeclaration: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var clipPlaneFragmentDeclaration: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var clipPlaneFragment: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapFragment: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var shadowMapVertexDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var clipPlaneVertexDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexNormalBias: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapVertexMetric: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var clipPlaneVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var shadowMapVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var depthBoxBlurPixelShader: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapFragmentSoftTransparentShadow: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /**
  9260. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9261. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9262. */
  9263. export class EffectFallbacks implements IEffectFallbacks {
  9264. private _defines;
  9265. private _currentRank;
  9266. private _maxRank;
  9267. private _mesh;
  9268. /**
  9269. * Removes the fallback from the bound mesh.
  9270. */
  9271. unBindMesh(): void;
  9272. /**
  9273. * Adds a fallback on the specified property.
  9274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9275. * @param define The name of the define in the shader
  9276. */
  9277. addFallback(rank: number, define: string): void;
  9278. /**
  9279. * Sets the mesh to use CPU skinning when needing to fallback.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param mesh The mesh to use the fallbacks.
  9282. */
  9283. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9284. /**
  9285. * Checks to see if more fallbacks are still availible.
  9286. */
  9287. get hasMoreFallbacks(): boolean;
  9288. /**
  9289. * Removes the defines that should be removed when falling back.
  9290. * @param currentDefines defines the current define statements for the shader.
  9291. * @param effect defines the current effect we try to compile
  9292. * @returns The resulting defines with defines of the current rank removed.
  9293. */
  9294. reduce(currentDefines: string, effect: Effect): string;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /**
  9299. * Interface used to define Action
  9300. */
  9301. export interface IAction {
  9302. /**
  9303. * Trigger for the action
  9304. */
  9305. trigger: number;
  9306. /** Options of the trigger */
  9307. triggerOptions: any;
  9308. /**
  9309. * Gets the trigger parameters
  9310. * @returns the trigger parameters
  9311. */
  9312. getTriggerParameter(): any;
  9313. /**
  9314. * Internal only - executes current action event
  9315. * @hidden
  9316. */
  9317. _executeCurrent(evt?: ActionEvent): void;
  9318. /**
  9319. * Serialize placeholder for child classes
  9320. * @param parent of child
  9321. * @returns the serialized object
  9322. */
  9323. serialize(parent: any): any;
  9324. /**
  9325. * Internal only
  9326. * @hidden
  9327. */
  9328. _prepare(): void;
  9329. /**
  9330. * Internal only - manager for action
  9331. * @hidden
  9332. */
  9333. _actionManager: AbstractActionManager;
  9334. /**
  9335. * Adds action to chain of actions, may be a DoNothingAction
  9336. * @param action defines the next action to execute
  9337. * @returns The action passed in
  9338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9339. */
  9340. then(action: IAction): IAction;
  9341. }
  9342. /**
  9343. * The action to be carried out following a trigger
  9344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9345. */
  9346. export class Action implements IAction {
  9347. /** the trigger, with or without parameters, for the action */
  9348. triggerOptions: any;
  9349. /**
  9350. * Trigger for the action
  9351. */
  9352. trigger: number;
  9353. /**
  9354. * Internal only - manager for action
  9355. * @hidden
  9356. */
  9357. _actionManager: ActionManager;
  9358. private _nextActiveAction;
  9359. private _child;
  9360. private _condition?;
  9361. private _triggerParameter;
  9362. /**
  9363. * An event triggered prior to action being executed.
  9364. */
  9365. onBeforeExecuteObservable: Observable<Action>;
  9366. /**
  9367. * Creates a new Action
  9368. * @param triggerOptions the trigger, with or without parameters, for the action
  9369. * @param condition an optional determinant of action
  9370. */
  9371. constructor(
  9372. /** the trigger, with or without parameters, for the action */
  9373. triggerOptions: any, condition?: Condition);
  9374. /**
  9375. * Internal only
  9376. * @hidden
  9377. */
  9378. _prepare(): void;
  9379. /**
  9380. * Gets the trigger parameters
  9381. * @returns the trigger parameters
  9382. */
  9383. getTriggerParameter(): any;
  9384. /**
  9385. * Internal only - executes current action event
  9386. * @hidden
  9387. */
  9388. _executeCurrent(evt?: ActionEvent): void;
  9389. /**
  9390. * Execute placeholder for child classes
  9391. * @param evt optional action event
  9392. */
  9393. execute(evt?: ActionEvent): void;
  9394. /**
  9395. * Skips to next active action
  9396. */
  9397. skipToNextActiveAction(): void;
  9398. /**
  9399. * Adds action to chain of actions, may be a DoNothingAction
  9400. * @param action defines the next action to execute
  9401. * @returns The action passed in
  9402. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9403. */
  9404. then(action: Action): Action;
  9405. /**
  9406. * Internal only
  9407. * @hidden
  9408. */
  9409. _getProperty(propertyPath: string): string;
  9410. /**
  9411. * Internal only
  9412. * @hidden
  9413. */
  9414. _getEffectiveTarget(target: any, propertyPath: string): any;
  9415. /**
  9416. * Serialize placeholder for child classes
  9417. * @param parent of child
  9418. * @returns the serialized object
  9419. */
  9420. serialize(parent: any): any;
  9421. /**
  9422. * Internal only called by serialize
  9423. * @hidden
  9424. */
  9425. protected _serialize(serializedAction: any, parent?: any): any;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. static _SerializeValueAsString: (value: any) => string;
  9431. /**
  9432. * Internal only
  9433. * @hidden
  9434. */
  9435. static _GetTargetProperty: (target: Node | Scene) => {
  9436. name: string;
  9437. targetType: string;
  9438. value: string;
  9439. };
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * A Condition applied to an Action
  9445. */
  9446. export class Condition {
  9447. /**
  9448. * Internal only - manager for action
  9449. * @hidden
  9450. */
  9451. _actionManager: ActionManager;
  9452. /**
  9453. * Internal only
  9454. * @hidden
  9455. */
  9456. _evaluationId: number;
  9457. /**
  9458. * Internal only
  9459. * @hidden
  9460. */
  9461. _currentResult: boolean;
  9462. /**
  9463. * Creates a new Condition
  9464. * @param actionManager the manager of the action the condition is applied to
  9465. */
  9466. constructor(actionManager: ActionManager);
  9467. /**
  9468. * Check if the current condition is valid
  9469. * @returns a boolean
  9470. */
  9471. isValid(): boolean;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _getProperty(propertyPath: string): string;
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _getEffectiveTarget(target: any, propertyPath: string): any;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @returns the serialized object
  9485. */
  9486. serialize(): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. protected _serialize(serializedCondition: any): any;
  9492. }
  9493. /**
  9494. * Defines specific conditional operators as extensions of Condition
  9495. */
  9496. export class ValueCondition extends Condition {
  9497. /** path to specify the property of the target the conditional operator uses */
  9498. propertyPath: string;
  9499. /** the value compared by the conditional operator against the current value of the property */
  9500. value: any;
  9501. /** the conditional operator, default ValueCondition.IsEqual */
  9502. operator: number;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. private static _IsEqual;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. private static _IsDifferent;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. private static _IsGreater;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. private static _IsLesser;
  9523. /**
  9524. * returns the number for IsEqual
  9525. */
  9526. static get IsEqual(): number;
  9527. /**
  9528. * Returns the number for IsDifferent
  9529. */
  9530. static get IsDifferent(): number;
  9531. /**
  9532. * Returns the number for IsGreater
  9533. */
  9534. static get IsGreater(): number;
  9535. /**
  9536. * Returns the number for IsLesser
  9537. */
  9538. static get IsLesser(): number;
  9539. /**
  9540. * Internal only The action manager for the condition
  9541. * @hidden
  9542. */
  9543. _actionManager: ActionManager;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. private _target;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. private _effectiveTarget;
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. private _property;
  9559. /**
  9560. * Creates a new ValueCondition
  9561. * @param actionManager manager for the action the condition applies to
  9562. * @param target for the action
  9563. * @param propertyPath path to specify the property of the target the conditional operator uses
  9564. * @param value the value compared by the conditional operator against the current value of the property
  9565. * @param operator the conditional operator, default ValueCondition.IsEqual
  9566. */
  9567. constructor(actionManager: ActionManager, target: any,
  9568. /** path to specify the property of the target the conditional operator uses */
  9569. propertyPath: string,
  9570. /** the value compared by the conditional operator against the current value of the property */
  9571. value: any,
  9572. /** the conditional operator, default ValueCondition.IsEqual */
  9573. operator?: number);
  9574. /**
  9575. * Compares the given value with the property value for the specified conditional operator
  9576. * @returns the result of the comparison
  9577. */
  9578. isValid(): boolean;
  9579. /**
  9580. * Serialize the ValueCondition into a JSON compatible object
  9581. * @returns serialization object
  9582. */
  9583. serialize(): any;
  9584. /**
  9585. * Gets the name of the conditional operator for the ValueCondition
  9586. * @param operator the conditional operator
  9587. * @returns the name
  9588. */
  9589. static GetOperatorName(operator: number): string;
  9590. }
  9591. /**
  9592. * Defines a predicate condition as an extension of Condition
  9593. */
  9594. export class PredicateCondition extends Condition {
  9595. /** defines the predicate function used to validate the condition */
  9596. predicate: () => boolean;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. /**
  9603. * Creates a new PredicateCondition
  9604. * @param actionManager manager for the action the condition applies to
  9605. * @param predicate defines the predicate function used to validate the condition
  9606. */
  9607. constructor(actionManager: ActionManager,
  9608. /** defines the predicate function used to validate the condition */
  9609. predicate: () => boolean);
  9610. /**
  9611. * @returns the validity of the predicate condition
  9612. */
  9613. isValid(): boolean;
  9614. }
  9615. /**
  9616. * Defines a state condition as an extension of Condition
  9617. */
  9618. export class StateCondition extends Condition {
  9619. /** Value to compare with target state */
  9620. value: string;
  9621. /**
  9622. * Internal only - manager for action
  9623. * @hidden
  9624. */
  9625. _actionManager: ActionManager;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. private _target;
  9631. /**
  9632. * Creates a new StateCondition
  9633. * @param actionManager manager for the action the condition applies to
  9634. * @param target of the condition
  9635. * @param value to compare with target state
  9636. */
  9637. constructor(actionManager: ActionManager, target: any,
  9638. /** Value to compare with target state */
  9639. value: string);
  9640. /**
  9641. * Gets a boolean indicating if the current condition is met
  9642. * @returns the validity of the state
  9643. */
  9644. isValid(): boolean;
  9645. /**
  9646. * Serialize the StateCondition into a JSON compatible object
  9647. * @returns serialization object
  9648. */
  9649. serialize(): any;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. /**
  9654. * This defines an action responsible to toggle a boolean once triggered.
  9655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9656. */
  9657. export class SwitchBooleanAction extends Action {
  9658. /**
  9659. * The path to the boolean property in the target object
  9660. */
  9661. propertyPath: string;
  9662. private _target;
  9663. private _effectiveTarget;
  9664. private _property;
  9665. /**
  9666. * Instantiate the action
  9667. * @param triggerOptions defines the trigger options
  9668. * @param target defines the object containing the boolean
  9669. * @param propertyPath defines the path to the boolean property in the target object
  9670. * @param condition defines the trigger related conditions
  9671. */
  9672. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9673. /** @hidden */
  9674. _prepare(): void;
  9675. /**
  9676. * Execute the action toggle the boolean value.
  9677. */
  9678. execute(): void;
  9679. /**
  9680. * Serializes the actions and its related information.
  9681. * @param parent defines the object to serialize in
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. }
  9686. /**
  9687. * This defines an action responsible to set a the state field of the target
  9688. * to a desired value once triggered.
  9689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9690. */
  9691. export class SetStateAction extends Action {
  9692. /**
  9693. * The value to store in the state field.
  9694. */
  9695. value: string;
  9696. private _target;
  9697. /**
  9698. * Instantiate the action
  9699. * @param triggerOptions defines the trigger options
  9700. * @param target defines the object containing the state property
  9701. * @param value defines the value to store in the state field
  9702. * @param condition defines the trigger related conditions
  9703. */
  9704. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9705. /**
  9706. * Execute the action and store the value on the target state property.
  9707. */
  9708. execute(): void;
  9709. /**
  9710. * Serializes the actions and its related information.
  9711. * @param parent defines the object to serialize in
  9712. * @returns the serialized object
  9713. */
  9714. serialize(parent: any): any;
  9715. }
  9716. /**
  9717. * This defines an action responsible to set a property of the target
  9718. * to a desired value once triggered.
  9719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9720. */
  9721. export class SetValueAction extends Action {
  9722. /**
  9723. * The path of the property to set in the target.
  9724. */
  9725. propertyPath: string;
  9726. /**
  9727. * The value to set in the property
  9728. */
  9729. value: any;
  9730. private _target;
  9731. private _effectiveTarget;
  9732. private _property;
  9733. /**
  9734. * Instantiate the action
  9735. * @param triggerOptions defines the trigger options
  9736. * @param target defines the object containing the property
  9737. * @param propertyPath defines the path of the property to set in the target
  9738. * @param value defines the value to set in the property
  9739. * @param condition defines the trigger related conditions
  9740. */
  9741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9742. /** @hidden */
  9743. _prepare(): void;
  9744. /**
  9745. * Execute the action and set the targetted property to the desired value.
  9746. */
  9747. execute(): void;
  9748. /**
  9749. * Serializes the actions and its related information.
  9750. * @param parent defines the object to serialize in
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. }
  9755. /**
  9756. * This defines an action responsible to increment the target value
  9757. * to a desired value once triggered.
  9758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class IncrementValueAction extends Action {
  9761. /**
  9762. * The path of the property to increment in the target.
  9763. */
  9764. propertyPath: string;
  9765. /**
  9766. * The value we should increment the property by.
  9767. */
  9768. value: any;
  9769. private _target;
  9770. private _effectiveTarget;
  9771. private _property;
  9772. /**
  9773. * Instantiate the action
  9774. * @param triggerOptions defines the trigger options
  9775. * @param target defines the object containing the property
  9776. * @param propertyPath defines the path of the property to increment in the target
  9777. * @param value defines the value value we should increment the property by
  9778. * @param condition defines the trigger related conditions
  9779. */
  9780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9781. /** @hidden */
  9782. _prepare(): void;
  9783. /**
  9784. * Execute the action and increment the target of the value amount.
  9785. */
  9786. execute(): void;
  9787. /**
  9788. * Serializes the actions and its related information.
  9789. * @param parent defines the object to serialize in
  9790. * @returns the serialized object
  9791. */
  9792. serialize(parent: any): any;
  9793. }
  9794. /**
  9795. * This defines an action responsible to start an animation once triggered.
  9796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9797. */
  9798. export class PlayAnimationAction extends Action {
  9799. /**
  9800. * Where the animation should start (animation frame)
  9801. */
  9802. from: number;
  9803. /**
  9804. * Where the animation should stop (animation frame)
  9805. */
  9806. to: number;
  9807. /**
  9808. * Define if the animation should loop or stop after the first play.
  9809. */
  9810. loop?: boolean;
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param from defines from where the animation should start (animation frame)
  9817. * @param end defines where the animation should stop (animation frame)
  9818. * @param loop defines if the animation should loop or stop after the first play
  9819. * @param condition defines the trigger related conditions
  9820. */
  9821. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9822. /** @hidden */
  9823. _prepare(): void;
  9824. /**
  9825. * Execute the action and play the animation.
  9826. */
  9827. execute(): void;
  9828. /**
  9829. * Serializes the actions and its related information.
  9830. * @param parent defines the object to serialize in
  9831. * @returns the serialized object
  9832. */
  9833. serialize(parent: any): any;
  9834. }
  9835. /**
  9836. * This defines an action responsible to stop an animation once triggered.
  9837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class StopAnimationAction extends Action {
  9840. private _target;
  9841. /**
  9842. * Instantiate the action
  9843. * @param triggerOptions defines the trigger options
  9844. * @param target defines the target animation or animation name
  9845. * @param condition defines the trigger related conditions
  9846. */
  9847. constructor(triggerOptions: any, target: any, condition?: Condition);
  9848. /** @hidden */
  9849. _prepare(): void;
  9850. /**
  9851. * Execute the action and stop the animation.
  9852. */
  9853. execute(): void;
  9854. /**
  9855. * Serializes the actions and its related information.
  9856. * @param parent defines the object to serialize in
  9857. * @returns the serialized object
  9858. */
  9859. serialize(parent: any): any;
  9860. }
  9861. /**
  9862. * This defines an action responsible that does nothing once triggered.
  9863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9864. */
  9865. export class DoNothingAction extends Action {
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions?: any, condition?: Condition);
  9872. /**
  9873. * Execute the action and do nothing.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to trigger several actions once triggered.
  9885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class CombineAction extends Action {
  9888. /**
  9889. * The list of aggregated animations to run.
  9890. */
  9891. children: Action[];
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param children defines the list of aggregated animations to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9899. /** @hidden */
  9900. _prepare(): void;
  9901. /**
  9902. * Execute the action and executes all the aggregated actions.
  9903. */
  9904. execute(evt: ActionEvent): void;
  9905. /**
  9906. * Serializes the actions and its related information.
  9907. * @param parent defines the object to serialize in
  9908. * @returns the serialized object
  9909. */
  9910. serialize(parent: any): any;
  9911. }
  9912. /**
  9913. * This defines an action responsible to run code (external event) once triggered.
  9914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9915. */
  9916. export class ExecuteCodeAction extends Action {
  9917. /**
  9918. * The callback function to run.
  9919. */
  9920. func: (evt: ActionEvent) => void;
  9921. /**
  9922. * Instantiate the action
  9923. * @param triggerOptions defines the trigger options
  9924. * @param func defines the callback function to run
  9925. * @param condition defines the trigger related conditions
  9926. */
  9927. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9928. /**
  9929. * Execute the action and run the attached code.
  9930. */
  9931. execute(evt: ActionEvent): void;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set the parent property of the target once triggered.
  9935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class SetParentAction extends Action {
  9938. private _parent;
  9939. private _target;
  9940. /**
  9941. * Instantiate the action
  9942. * @param triggerOptions defines the trigger options
  9943. * @param target defines the target containing the parent property
  9944. * @param parent defines from where the animation should start (animation frame)
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and set the parent property.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9965. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class ActionManager extends AbstractActionManager {
  9969. /**
  9970. * Nothing
  9971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9972. */
  9973. static readonly NothingTrigger: number;
  9974. /**
  9975. * On pick
  9976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9977. */
  9978. static readonly OnPickTrigger: number;
  9979. /**
  9980. * On left pick
  9981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9982. */
  9983. static readonly OnLeftPickTrigger: number;
  9984. /**
  9985. * On right pick
  9986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9987. */
  9988. static readonly OnRightPickTrigger: number;
  9989. /**
  9990. * On center pick
  9991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9992. */
  9993. static readonly OnCenterPickTrigger: number;
  9994. /**
  9995. * On pick down
  9996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9997. */
  9998. static readonly OnPickDownTrigger: number;
  9999. /**
  10000. * On double pick
  10001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10002. */
  10003. static readonly OnDoublePickTrigger: number;
  10004. /**
  10005. * On pick up
  10006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly OnPickUpTrigger: number;
  10009. /**
  10010. * On pick out.
  10011. * This trigger will only be raised if you also declared a OnPickDown
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickOutTrigger: number;
  10015. /**
  10016. * On long press
  10017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnLongPressTrigger: number;
  10020. /**
  10021. * On pointer over
  10022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPointerOverTrigger: number;
  10025. /**
  10026. * On pointer out
  10027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10028. */
  10029. static readonly OnPointerOutTrigger: number;
  10030. /**
  10031. * On every frame
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10033. */
  10034. static readonly OnEveryFrameTrigger: number;
  10035. /**
  10036. * On intersection enter
  10037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10038. */
  10039. static readonly OnIntersectionEnterTrigger: number;
  10040. /**
  10041. * On intersection exit
  10042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10043. */
  10044. static readonly OnIntersectionExitTrigger: number;
  10045. /**
  10046. * On key down
  10047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnKeyDownTrigger: number;
  10050. /**
  10051. * On key up
  10052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnKeyUpTrigger: number;
  10055. private _scene;
  10056. /**
  10057. * Creates a new action manager
  10058. * @param scene defines the hosting scene
  10059. */
  10060. constructor(scene: Scene);
  10061. /**
  10062. * Releases all associated resources
  10063. */
  10064. dispose(): void;
  10065. /**
  10066. * Gets hosting scene
  10067. * @returns the hosting scene
  10068. */
  10069. getScene(): Scene;
  10070. /**
  10071. * Does this action manager handles actions of any of the given triggers
  10072. * @param triggers defines the triggers to be tested
  10073. * @return a boolean indicating whether one (or more) of the triggers is handled
  10074. */
  10075. hasSpecificTriggers(triggers: number[]): boolean;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10078. * speed.
  10079. * @param triggerA defines the trigger to be tested
  10080. * @param triggerB defines the trigger to be tested
  10081. * @return a boolean indicating whether one (or more) of the triggers is handled
  10082. */
  10083. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10084. /**
  10085. * Does this action manager handles actions of a given trigger
  10086. * @param trigger defines the trigger to be tested
  10087. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10088. * @return whether the trigger is handled
  10089. */
  10090. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10091. /**
  10092. * Does this action manager has pointer triggers
  10093. */
  10094. get hasPointerTriggers(): boolean;
  10095. /**
  10096. * Does this action manager has pick triggers
  10097. */
  10098. get hasPickTriggers(): boolean;
  10099. /**
  10100. * Registers an action to this action manager
  10101. * @param action defines the action to be registered
  10102. * @return the action amended (prepared) after registration
  10103. */
  10104. registerAction(action: IAction): Nullable<IAction>;
  10105. /**
  10106. * Unregisters an action to this action manager
  10107. * @param action defines the action to be unregistered
  10108. * @return a boolean indicating whether the action has been unregistered
  10109. */
  10110. unregisterAction(action: IAction): Boolean;
  10111. /**
  10112. * Process a specific trigger
  10113. * @param trigger defines the trigger to process
  10114. * @param evt defines the event details to be processed
  10115. */
  10116. processTrigger(trigger: number, evt?: IActionEvent): void;
  10117. /** @hidden */
  10118. _getEffectiveTarget(target: any, propertyPath: string): any;
  10119. /** @hidden */
  10120. _getProperty(propertyPath: string): string;
  10121. /**
  10122. * Serialize this manager to a JSON object
  10123. * @param name defines the property name to store this manager
  10124. * @returns a JSON representation of this manager
  10125. */
  10126. serialize(name: string): any;
  10127. /**
  10128. * Creates a new ActionManager from a JSON data
  10129. * @param parsedActions defines the JSON data to read from
  10130. * @param object defines the hosting mesh
  10131. * @param scene defines the hosting scene
  10132. */
  10133. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10134. /**
  10135. * Get a trigger name by index
  10136. * @param trigger defines the trigger index
  10137. * @returns a trigger name
  10138. */
  10139. static GetTriggerName(trigger: number): string;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Class used to represent a sprite
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class Sprite implements IAnimatable {
  10148. /** defines the name */
  10149. name: string;
  10150. /** Gets or sets the current world position */
  10151. position: Vector3;
  10152. /** Gets or sets the main color */
  10153. color: Color4;
  10154. /** Gets or sets the width */
  10155. width: number;
  10156. /** Gets or sets the height */
  10157. height: number;
  10158. /** Gets or sets rotation angle */
  10159. angle: number;
  10160. /** Gets or sets the cell index in the sprite sheet */
  10161. cellIndex: number;
  10162. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10163. cellRef: string;
  10164. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10165. invertU: boolean;
  10166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10167. invertV: boolean;
  10168. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10169. disposeWhenFinishedAnimating: boolean;
  10170. /** Gets the list of attached animations */
  10171. animations: Nullable<Array<Animation>>;
  10172. /** Gets or sets a boolean indicating if the sprite can be picked */
  10173. isPickable: boolean;
  10174. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10175. useAlphaForPicking: boolean;
  10176. /** @hidden */
  10177. _xOffset: number;
  10178. /** @hidden */
  10179. _yOffset: number;
  10180. /** @hidden */
  10181. _xSize: number;
  10182. /** @hidden */
  10183. _ySize: number;
  10184. /**
  10185. * Gets or sets the associated action manager
  10186. */
  10187. actionManager: Nullable<ActionManager>;
  10188. /**
  10189. * An event triggered when the control has been disposed
  10190. */
  10191. onDisposeObservable: Observable<Sprite>;
  10192. private _animationStarted;
  10193. private _loopAnimation;
  10194. private _fromIndex;
  10195. private _toIndex;
  10196. private _delay;
  10197. private _direction;
  10198. private _manager;
  10199. private _time;
  10200. private _onAnimationEnd;
  10201. /**
  10202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10203. */
  10204. isVisible: boolean;
  10205. /**
  10206. * Gets or sets the sprite size
  10207. */
  10208. get size(): number;
  10209. set size(value: number);
  10210. /**
  10211. * Returns a boolean indicating if the animation is started
  10212. */
  10213. get animationStarted(): boolean;
  10214. /**
  10215. * Gets or sets the unique id of the sprite
  10216. */
  10217. uniqueId: number;
  10218. /**
  10219. * Gets the manager of this sprite
  10220. */
  10221. get manager(): ISpriteManager;
  10222. /**
  10223. * Creates a new Sprite
  10224. * @param name defines the name
  10225. * @param manager defines the manager
  10226. */
  10227. constructor(
  10228. /** defines the name */
  10229. name: string, manager: ISpriteManager);
  10230. /**
  10231. * Returns the string "Sprite"
  10232. * @returns "Sprite"
  10233. */
  10234. getClassName(): string;
  10235. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10236. get fromIndex(): number;
  10237. set fromIndex(value: number);
  10238. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10239. get toIndex(): number;
  10240. set toIndex(value: number);
  10241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10242. get loopAnimation(): boolean;
  10243. set loopAnimation(value: boolean);
  10244. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10245. get delay(): number;
  10246. set delay(value: number);
  10247. /**
  10248. * Starts an animation
  10249. * @param from defines the initial key
  10250. * @param to defines the end key
  10251. * @param loop defines if the animation must loop
  10252. * @param delay defines the start delay (in ms)
  10253. * @param onAnimationEnd defines a callback to call when animation ends
  10254. */
  10255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10256. /** Stops current animation (if any) */
  10257. stopAnimation(): void;
  10258. /** @hidden */
  10259. _animate(deltaTime: number): void;
  10260. /** Release associated resources */
  10261. dispose(): void;
  10262. /**
  10263. * Serializes the sprite to a JSON object
  10264. * @returns the JSON object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Parses a JSON object to create a new sprite
  10269. * @param parsedSprite The JSON object to parse
  10270. * @param manager defines the hosting manager
  10271. * @returns the new sprite
  10272. */
  10273. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Information about the result of picking within a scene
  10279. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10280. */
  10281. export class PickingInfo {
  10282. /** @hidden */
  10283. _pickingUnavailable: boolean;
  10284. /**
  10285. * If the pick collided with an object
  10286. */
  10287. hit: boolean;
  10288. /**
  10289. * Distance away where the pick collided
  10290. */
  10291. distance: number;
  10292. /**
  10293. * The location of pick collision
  10294. */
  10295. pickedPoint: Nullable<Vector3>;
  10296. /**
  10297. * The mesh corresponding the the pick collision
  10298. */
  10299. pickedMesh: Nullable<AbstractMesh>;
  10300. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10301. bu: number;
  10302. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10303. bv: number;
  10304. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10305. faceId: number;
  10306. /** Id of the the submesh that was picked */
  10307. subMeshId: number;
  10308. /** If a sprite was picked, this will be the sprite the pick collided with */
  10309. pickedSprite: Nullable<Sprite>;
  10310. /**
  10311. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10312. */
  10313. originMesh: Nullable<AbstractMesh>;
  10314. /**
  10315. * The ray that was used to perform the picking.
  10316. */
  10317. ray: Nullable<Ray>;
  10318. /**
  10319. * Gets the normal correspodning to the face the pick collided with
  10320. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10321. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10322. * @returns The normal correspodning to the face the pick collided with
  10323. */
  10324. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10325. /**
  10326. * Gets the texture coordinates of where the pick occured
  10327. * @returns the vector containing the coordnates of the texture
  10328. */
  10329. getTextureCoordinates(): Nullable<Vector2>;
  10330. }
  10331. }
  10332. declare module BABYLON {
  10333. /**
  10334. * Class representing a ray with position and direction
  10335. */
  10336. export class Ray {
  10337. /** origin point */
  10338. origin: Vector3;
  10339. /** direction */
  10340. direction: Vector3;
  10341. /** length of the ray */
  10342. length: number;
  10343. private static readonly TmpVector3;
  10344. private _tmpRay;
  10345. /**
  10346. * Creates a new ray
  10347. * @param origin origin point
  10348. * @param direction direction
  10349. * @param length length of the ray
  10350. */
  10351. constructor(
  10352. /** origin point */
  10353. origin: Vector3,
  10354. /** direction */
  10355. direction: Vector3,
  10356. /** length of the ray */
  10357. length?: number);
  10358. /**
  10359. * Checks if the ray intersects a box
  10360. * This does not account for the ray lenght by design to improve perfs.
  10361. * @param minimum bound of the box
  10362. * @param maximum bound of the box
  10363. * @param intersectionTreshold extra extend to be added to the box in all direction
  10364. * @returns if the box was hit
  10365. */
  10366. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10367. /**
  10368. * Checks if the ray intersects a box
  10369. * This does not account for the ray lenght by design to improve perfs.
  10370. * @param box the bounding box to check
  10371. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10372. * @returns if the box was hit
  10373. */
  10374. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10375. /**
  10376. * If the ray hits a sphere
  10377. * @param sphere the bounding sphere to check
  10378. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10379. * @returns true if it hits the sphere
  10380. */
  10381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10382. /**
  10383. * If the ray hits a triange
  10384. * @param vertex0 triangle vertex
  10385. * @param vertex1 triangle vertex
  10386. * @param vertex2 triangle vertex
  10387. * @returns intersection information if hit
  10388. */
  10389. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10390. /**
  10391. * Checks if ray intersects a plane
  10392. * @param plane the plane to check
  10393. * @returns the distance away it was hit
  10394. */
  10395. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10396. /**
  10397. * Calculate the intercept of a ray on a given axis
  10398. * @param axis to check 'x' | 'y' | 'z'
  10399. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10400. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10401. */
  10402. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10403. /**
  10404. * Checks if ray intersects a mesh
  10405. * @param mesh the mesh to check
  10406. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10407. * @returns picking info of the intersecton
  10408. */
  10409. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10410. /**
  10411. * Checks if ray intersects a mesh
  10412. * @param meshes the meshes to check
  10413. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10414. * @param results array to store result in
  10415. * @returns Array of picking infos
  10416. */
  10417. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10418. private _comparePickingInfo;
  10419. private static smallnum;
  10420. private static rayl;
  10421. /**
  10422. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10423. * @param sega the first point of the segment to test the intersection against
  10424. * @param segb the second point of the segment to test the intersection against
  10425. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10426. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10427. */
  10428. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10429. /**
  10430. * Update the ray from viewport position
  10431. * @param x position
  10432. * @param y y position
  10433. * @param viewportWidth viewport width
  10434. * @param viewportHeight viewport height
  10435. * @param world world matrix
  10436. * @param view view matrix
  10437. * @param projection projection matrix
  10438. * @returns this ray updated
  10439. */
  10440. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10441. /**
  10442. * Creates a ray with origin and direction of 0,0,0
  10443. * @returns the new ray
  10444. */
  10445. static Zero(): Ray;
  10446. /**
  10447. * Creates a new ray from screen space and viewport
  10448. * @param x position
  10449. * @param y y position
  10450. * @param viewportWidth viewport width
  10451. * @param viewportHeight viewport height
  10452. * @param world world matrix
  10453. * @param view view matrix
  10454. * @param projection projection matrix
  10455. * @returns new ray
  10456. */
  10457. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10458. /**
  10459. * 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
  10460. * transformed to the given world matrix.
  10461. * @param origin The origin point
  10462. * @param end The end point
  10463. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10464. * @returns the new ray
  10465. */
  10466. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10467. /**
  10468. * Transforms a ray by a matrix
  10469. * @param ray ray to transform
  10470. * @param matrix matrix to apply
  10471. * @returns the resulting new ray
  10472. */
  10473. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10474. /**
  10475. * Transforms a ray by a matrix
  10476. * @param ray ray to transform
  10477. * @param matrix matrix to apply
  10478. * @param result ray to store result in
  10479. */
  10480. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10481. /**
  10482. * Unproject a ray from screen space to object space
  10483. * @param sourceX defines the screen space x coordinate to use
  10484. * @param sourceY defines the screen space y coordinate to use
  10485. * @param viewportWidth defines the current width of the viewport
  10486. * @param viewportHeight defines the current height of the viewport
  10487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10488. * @param view defines the view matrix to use
  10489. * @param projection defines the projection matrix to use
  10490. */
  10491. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10492. }
  10493. /**
  10494. * Type used to define predicate used to select faces when a mesh intersection is detected
  10495. */
  10496. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10497. interface Scene {
  10498. /** @hidden */
  10499. _tempPickingRay: Nullable<Ray>;
  10500. /** @hidden */
  10501. _cachedRayForTransform: Ray;
  10502. /** @hidden */
  10503. _pickWithRayInverseMatrix: Matrix;
  10504. /** @hidden */
  10505. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10506. /** @hidden */
  10507. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10508. }
  10509. }
  10510. declare module BABYLON {
  10511. /**
  10512. * Groups all the scene component constants in one place to ease maintenance.
  10513. * @hidden
  10514. */
  10515. export class SceneComponentConstants {
  10516. static readonly NAME_EFFECTLAYER: string;
  10517. static readonly NAME_LAYER: string;
  10518. static readonly NAME_LENSFLARESYSTEM: string;
  10519. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10520. static readonly NAME_PARTICLESYSTEM: string;
  10521. static readonly NAME_GAMEPAD: string;
  10522. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10523. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10524. static readonly NAME_DEPTHRENDERER: string;
  10525. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10526. static readonly NAME_SPRITE: string;
  10527. static readonly NAME_OUTLINERENDERER: string;
  10528. static readonly NAME_PROCEDURALTEXTURE: string;
  10529. static readonly NAME_SHADOWGENERATOR: string;
  10530. static readonly NAME_OCTREE: string;
  10531. static readonly NAME_PHYSICSENGINE: string;
  10532. static readonly NAME_AUDIO: string;
  10533. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10534. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10535. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10538. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10540. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10542. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10545. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10547. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10548. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10549. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10553. static readonly STEP_AFTERRENDER_AUDIO: number;
  10554. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10558. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10559. static readonly STEP_POINTERMOVE_SPRITE: number;
  10560. static readonly STEP_POINTERDOWN_SPRITE: number;
  10561. static readonly STEP_POINTERUP_SPRITE: number;
  10562. }
  10563. /**
  10564. * This represents a scene component.
  10565. *
  10566. * This is used to decouple the dependency the scene is having on the different workloads like
  10567. * layers, post processes...
  10568. */
  10569. export interface ISceneComponent {
  10570. /**
  10571. * The name of the component. Each component must have a unique name.
  10572. */
  10573. name: string;
  10574. /**
  10575. * The scene the component belongs to.
  10576. */
  10577. scene: Scene;
  10578. /**
  10579. * Register the component to one instance of a scene.
  10580. */
  10581. register(): void;
  10582. /**
  10583. * Rebuilds the elements related to this component in case of
  10584. * context lost for instance.
  10585. */
  10586. rebuild(): void;
  10587. /**
  10588. * Disposes the component and the associated ressources.
  10589. */
  10590. dispose(): void;
  10591. }
  10592. /**
  10593. * This represents a SERIALIZABLE scene component.
  10594. *
  10595. * This extends Scene Component to add Serialization methods on top.
  10596. */
  10597. export interface ISceneSerializableComponent extends ISceneComponent {
  10598. /**
  10599. * Adds all the elements from the container to the scene
  10600. * @param container the container holding the elements
  10601. */
  10602. addFromContainer(container: AbstractScene): void;
  10603. /**
  10604. * Removes all the elements in the container from the scene
  10605. * @param container contains the elements to remove
  10606. * @param dispose if the removed element should be disposed (default: false)
  10607. */
  10608. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10609. /**
  10610. * Serializes the component data to the specified json object
  10611. * @param serializationObject The object to serialize to
  10612. */
  10613. serialize(serializationObject: any): void;
  10614. }
  10615. /**
  10616. * Strong typing of a Mesh related stage step action
  10617. */
  10618. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10619. /**
  10620. * Strong typing of a Evaluate Sub Mesh related stage step action
  10621. */
  10622. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10623. /**
  10624. * Strong typing of a Active Mesh related stage step action
  10625. */
  10626. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10627. /**
  10628. * Strong typing of a Camera related stage step action
  10629. */
  10630. export type CameraStageAction = (camera: Camera) => void;
  10631. /**
  10632. * Strong typing of a Camera Frame buffer related stage step action
  10633. */
  10634. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10635. /**
  10636. * Strong typing of a Render Target related stage step action
  10637. */
  10638. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10639. /**
  10640. * Strong typing of a RenderingGroup related stage step action
  10641. */
  10642. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10643. /**
  10644. * Strong typing of a Mesh Render related stage step action
  10645. */
  10646. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10647. /**
  10648. * Strong typing of a simple stage step action
  10649. */
  10650. export type SimpleStageAction = () => void;
  10651. /**
  10652. * Strong typing of a render target action.
  10653. */
  10654. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10655. /**
  10656. * Strong typing of a pointer move action.
  10657. */
  10658. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10659. /**
  10660. * Strong typing of a pointer up/down action.
  10661. */
  10662. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10663. /**
  10664. * Representation of a stage in the scene (Basically a list of ordered steps)
  10665. * @hidden
  10666. */
  10667. export class Stage<T extends Function> extends Array<{
  10668. index: number;
  10669. component: ISceneComponent;
  10670. action: T;
  10671. }> {
  10672. /**
  10673. * Hide ctor from the rest of the world.
  10674. * @param items The items to add.
  10675. */
  10676. private constructor();
  10677. /**
  10678. * Creates a new Stage.
  10679. * @returns A new instance of a Stage
  10680. */
  10681. static Create<T extends Function>(): Stage<T>;
  10682. /**
  10683. * Registers a step in an ordered way in the targeted stage.
  10684. * @param index Defines the position to register the step in
  10685. * @param component Defines the component attached to the step
  10686. * @param action Defines the action to launch during the step
  10687. */
  10688. registerStep(index: number, component: ISceneComponent, action: T): void;
  10689. /**
  10690. * Clears all the steps from the stage.
  10691. */
  10692. clear(): void;
  10693. }
  10694. }
  10695. declare module BABYLON {
  10696. interface Scene {
  10697. /** @hidden */
  10698. _pointerOverSprite: Nullable<Sprite>;
  10699. /** @hidden */
  10700. _pickedDownSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _tempSpritePickingRay: Nullable<Ray>;
  10703. /**
  10704. * All of the sprite managers added to this scene
  10705. * @see http://doc.babylonjs.com/babylon101/sprites
  10706. */
  10707. spriteManagers: Array<ISpriteManager>;
  10708. /**
  10709. * An event triggered when sprites rendering is about to start
  10710. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10711. */
  10712. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10713. /**
  10714. * An event triggered when sprites rendering is done
  10715. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10716. */
  10717. onAfterSpritesRenderingObservable: Observable<Scene>;
  10718. /** @hidden */
  10719. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10720. /** Launch a ray to try to pick a sprite in the scene
  10721. * @param x position on screen
  10722. * @param y position on screen
  10723. * @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
  10724. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10725. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10726. * @returns a PickingInfo
  10727. */
  10728. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10729. /** Use the given ray to pick a sprite in the scene
  10730. * @param ray The ray (in world space) to use to pick meshes
  10731. * @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
  10732. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10733. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10734. * @returns a PickingInfo
  10735. */
  10736. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10737. /** @hidden */
  10738. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10739. /** Launch a ray to try to pick sprites in the scene
  10740. * @param x position on screen
  10741. * @param y position on screen
  10742. * @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
  10743. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10744. * @returns a PickingInfo array
  10745. */
  10746. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10747. /** Use the given ray to pick sprites in the scene
  10748. * @param ray The ray (in world space) to use to pick meshes
  10749. * @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
  10750. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10751. * @returns a PickingInfo array
  10752. */
  10753. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10754. /**
  10755. * Force the sprite under the pointer
  10756. * @param sprite defines the sprite to use
  10757. */
  10758. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10759. /**
  10760. * Gets the sprite under the pointer
  10761. * @returns a Sprite or null if no sprite is under the pointer
  10762. */
  10763. getPointerOverSprite(): Nullable<Sprite>;
  10764. }
  10765. /**
  10766. * Defines the sprite scene component responsible to manage sprites
  10767. * in a given scene.
  10768. */
  10769. export class SpriteSceneComponent implements ISceneComponent {
  10770. /**
  10771. * The component name helpfull to identify the component in the list of scene components.
  10772. */
  10773. readonly name: string;
  10774. /**
  10775. * The scene the component belongs to.
  10776. */
  10777. scene: Scene;
  10778. /** @hidden */
  10779. private _spritePredicate;
  10780. /**
  10781. * Creates a new instance of the component for the given scene
  10782. * @param scene Defines the scene to register the component in
  10783. */
  10784. constructor(scene: Scene);
  10785. /**
  10786. * Registers the component in a given scene
  10787. */
  10788. register(): void;
  10789. /**
  10790. * Rebuilds the elements related to this component in case of
  10791. * context lost for instance.
  10792. */
  10793. rebuild(): void;
  10794. /**
  10795. * Disposes the component and the associated ressources.
  10796. */
  10797. dispose(): void;
  10798. private _pickSpriteButKeepRay;
  10799. private _pointerMove;
  10800. private _pointerDown;
  10801. private _pointerUp;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /** @hidden */
  10806. export var fogFragmentDeclaration: {
  10807. name: string;
  10808. shader: string;
  10809. };
  10810. }
  10811. declare module BABYLON {
  10812. /** @hidden */
  10813. export var fogFragment: {
  10814. name: string;
  10815. shader: string;
  10816. };
  10817. }
  10818. declare module BABYLON {
  10819. /** @hidden */
  10820. export var spritesPixelShader: {
  10821. name: string;
  10822. shader: string;
  10823. };
  10824. }
  10825. declare module BABYLON {
  10826. /** @hidden */
  10827. export var fogVertexDeclaration: {
  10828. name: string;
  10829. shader: string;
  10830. };
  10831. }
  10832. declare module BABYLON {
  10833. /** @hidden */
  10834. export var spritesVertexShader: {
  10835. name: string;
  10836. shader: string;
  10837. };
  10838. }
  10839. declare module BABYLON {
  10840. /**
  10841. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10842. */
  10843. export interface ISpriteManager extends IDisposable {
  10844. /**
  10845. * Gets manager's name
  10846. */
  10847. name: string;
  10848. /**
  10849. * Restricts the camera to viewing objects with the same layerMask.
  10850. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10851. */
  10852. layerMask: number;
  10853. /**
  10854. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10855. */
  10856. isPickable: boolean;
  10857. /**
  10858. * Gets the hosting scene
  10859. */
  10860. scene: Scene;
  10861. /**
  10862. * Specifies the rendering group id for this mesh (0 by default)
  10863. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10864. */
  10865. renderingGroupId: number;
  10866. /**
  10867. * Defines the list of sprites managed by the manager.
  10868. */
  10869. sprites: Array<Sprite>;
  10870. /**
  10871. * Gets or sets the spritesheet texture
  10872. */
  10873. texture: Texture;
  10874. /** Defines the default width of a cell in the spritesheet */
  10875. cellWidth: number;
  10876. /** Defines the default height of a cell in the spritesheet */
  10877. cellHeight: number;
  10878. /**
  10879. * Tests the intersection of a sprite with a specific ray.
  10880. * @param ray The ray we are sending to test the collision
  10881. * @param camera The camera space we are sending rays in
  10882. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10883. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10884. * @returns picking info or null.
  10885. */
  10886. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10887. /**
  10888. * Intersects the sprites with a ray
  10889. * @param ray defines the ray to intersect with
  10890. * @param camera defines the current active camera
  10891. * @param predicate defines a predicate used to select candidate sprites
  10892. * @returns null if no hit or a PickingInfo array
  10893. */
  10894. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10895. /**
  10896. * Renders the list of sprites on screen.
  10897. */
  10898. render(): void;
  10899. }
  10900. /**
  10901. * Class used to manage multiple sprites on the same spritesheet
  10902. * @see http://doc.babylonjs.com/babylon101/sprites
  10903. */
  10904. export class SpriteManager implements ISpriteManager {
  10905. /** defines the manager's name */
  10906. name: string;
  10907. /** Define the Url to load snippets */
  10908. static SnippetUrl: string;
  10909. /** Snippet ID if the manager was created from the snippet server */
  10910. snippetId: string;
  10911. /** Gets the list of sprites */
  10912. sprites: Sprite[];
  10913. /** Gets or sets the rendering group id (0 by default) */
  10914. renderingGroupId: number;
  10915. /** Gets or sets camera layer mask */
  10916. layerMask: number;
  10917. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10918. fogEnabled: boolean;
  10919. /** Gets or sets a boolean indicating if the sprites are pickable */
  10920. isPickable: boolean;
  10921. /** Defines the default width of a cell in the spritesheet */
  10922. cellWidth: number;
  10923. /** Defines the default height of a cell in the spritesheet */
  10924. cellHeight: number;
  10925. /** Associative array from JSON sprite data file */
  10926. private _cellData;
  10927. /** Array of sprite names from JSON sprite data file */
  10928. private _spriteMap;
  10929. /** True when packed cell data from JSON file is ready*/
  10930. private _packedAndReady;
  10931. private _textureContent;
  10932. /**
  10933. * An event triggered when the manager is disposed.
  10934. */
  10935. onDisposeObservable: Observable<SpriteManager>;
  10936. private _onDisposeObserver;
  10937. /**
  10938. * Callback called when the manager is disposed
  10939. */
  10940. set onDispose(callback: () => void);
  10941. private _capacity;
  10942. private _fromPacked;
  10943. private _spriteTexture;
  10944. private _epsilon;
  10945. private _scene;
  10946. private _vertexData;
  10947. private _buffer;
  10948. private _vertexBuffers;
  10949. private _indexBuffer;
  10950. private _effectBase;
  10951. private _effectFog;
  10952. /**
  10953. * Gets or sets the unique id of the sprite
  10954. */
  10955. uniqueId: number;
  10956. /**
  10957. * Gets the array of sprites
  10958. */
  10959. get children(): Sprite[];
  10960. /**
  10961. * Gets the hosting scene
  10962. */
  10963. get scene(): Scene;
  10964. /**
  10965. * Gets the capacity of the manager
  10966. */
  10967. get capacity(): number;
  10968. /**
  10969. * Gets or sets the spritesheet texture
  10970. */
  10971. get texture(): Texture;
  10972. set texture(value: Texture);
  10973. private _blendMode;
  10974. /**
  10975. * Blend mode use to render the particle, it can be any of
  10976. * the static Constants.ALPHA_x properties provided in this class.
  10977. * Default value is Constants.ALPHA_COMBINE
  10978. */
  10979. get blendMode(): number;
  10980. set blendMode(blendMode: number);
  10981. /** Disables writing to the depth buffer when rendering the sprites.
  10982. * It can be handy to disable depth writing when using textures without alpha channel
  10983. * and setting some specific blend modes.
  10984. */
  10985. disableDepthWrite: boolean;
  10986. /**
  10987. * Creates a new sprite manager
  10988. * @param name defines the manager's name
  10989. * @param imgUrl defines the sprite sheet url
  10990. * @param capacity defines the maximum allowed number of sprites
  10991. * @param cellSize defines the size of a sprite cell
  10992. * @param scene defines the hosting scene
  10993. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10994. * @param samplingMode defines the smapling mode to use with spritesheet
  10995. * @param fromPacked set to false; do not alter
  10996. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10997. */
  10998. constructor(
  10999. /** defines the manager's name */
  11000. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11001. /**
  11002. * Returns the string "SpriteManager"
  11003. * @returns "SpriteManager"
  11004. */
  11005. getClassName(): string;
  11006. private _makePacked;
  11007. private _appendSpriteVertex;
  11008. private _checkTextureAlpha;
  11009. /**
  11010. * Intersects the sprites with a ray
  11011. * @param ray defines the ray to intersect with
  11012. * @param camera defines the current active camera
  11013. * @param predicate defines a predicate used to select candidate sprites
  11014. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11015. * @returns null if no hit or a PickingInfo
  11016. */
  11017. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11018. /**
  11019. * Intersects the sprites with a ray
  11020. * @param ray defines the ray to intersect with
  11021. * @param camera defines the current active camera
  11022. * @param predicate defines a predicate used to select candidate sprites
  11023. * @returns null if no hit or a PickingInfo array
  11024. */
  11025. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11026. /**
  11027. * Render all child sprites
  11028. */
  11029. render(): void;
  11030. /**
  11031. * Release associated resources
  11032. */
  11033. dispose(): void;
  11034. /**
  11035. * Serializes the sprite manager to a JSON object
  11036. * @param serializeTexture defines if the texture must be serialized as well
  11037. * @returns the JSON object
  11038. */
  11039. serialize(serializeTexture?: boolean): any;
  11040. /**
  11041. * Parses a JSON object to create a new sprite manager.
  11042. * @param parsedManager The JSON object to parse
  11043. * @param scene The scene to create the sprite managerin
  11044. * @param rootUrl The root url to use to load external dependencies like texture
  11045. * @returns the new sprite manager
  11046. */
  11047. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11048. /**
  11049. * Creates a sprite manager from a snippet saved in a remote file
  11050. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11051. * @param url defines the url to load from
  11052. * @param scene defines the hosting scene
  11053. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11054. * @returns a promise that will resolve to the new sprite manager
  11055. */
  11056. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11057. /**
  11058. * Creates a sprite manager from a snippet saved by the sprite editor
  11059. * @param snippetId defines the snippet to load
  11060. * @param scene defines the hosting scene
  11061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11062. * @returns a promise that will resolve to the new sprite manager
  11063. */
  11064. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11065. }
  11066. }
  11067. declare module BABYLON {
  11068. /** Interface used by value gradients (color, factor, ...) */
  11069. export interface IValueGradient {
  11070. /**
  11071. * Gets or sets the gradient value (between 0 and 1)
  11072. */
  11073. gradient: number;
  11074. }
  11075. /** Class used to store color4 gradient */
  11076. export class ColorGradient implements IValueGradient {
  11077. /**
  11078. * Gets or sets the gradient value (between 0 and 1)
  11079. */
  11080. gradient: number;
  11081. /**
  11082. * Gets or sets first associated color
  11083. */
  11084. color1: Color4;
  11085. /**
  11086. * Gets or sets second associated color
  11087. */
  11088. color2?: Color4 | undefined;
  11089. /**
  11090. * Creates a new color4 gradient
  11091. * @param gradient gets or sets the gradient value (between 0 and 1)
  11092. * @param color1 gets or sets first associated color
  11093. * @param color2 gets or sets first second color
  11094. */
  11095. constructor(
  11096. /**
  11097. * Gets or sets the gradient value (between 0 and 1)
  11098. */
  11099. gradient: number,
  11100. /**
  11101. * Gets or sets first associated color
  11102. */
  11103. color1: Color4,
  11104. /**
  11105. * Gets or sets second associated color
  11106. */
  11107. color2?: Color4 | undefined);
  11108. /**
  11109. * Will get a color picked randomly between color1 and color2.
  11110. * If color2 is undefined then color1 will be used
  11111. * @param result defines the target Color4 to store the result in
  11112. */
  11113. getColorToRef(result: Color4): void;
  11114. }
  11115. /** Class used to store color 3 gradient */
  11116. export class Color3Gradient implements IValueGradient {
  11117. /**
  11118. * Gets or sets the gradient value (between 0 and 1)
  11119. */
  11120. gradient: number;
  11121. /**
  11122. * Gets or sets the associated color
  11123. */
  11124. color: Color3;
  11125. /**
  11126. * Creates a new color3 gradient
  11127. * @param gradient gets or sets the gradient value (between 0 and 1)
  11128. * @param color gets or sets associated color
  11129. */
  11130. constructor(
  11131. /**
  11132. * Gets or sets the gradient value (between 0 and 1)
  11133. */
  11134. gradient: number,
  11135. /**
  11136. * Gets or sets the associated color
  11137. */
  11138. color: Color3);
  11139. }
  11140. /** Class used to store factor gradient */
  11141. export class FactorGradient implements IValueGradient {
  11142. /**
  11143. * Gets or sets the gradient value (between 0 and 1)
  11144. */
  11145. gradient: number;
  11146. /**
  11147. * Gets or sets first associated factor
  11148. */
  11149. factor1: number;
  11150. /**
  11151. * Gets or sets second associated factor
  11152. */
  11153. factor2?: number | undefined;
  11154. /**
  11155. * Creates a new factor gradient
  11156. * @param gradient gets or sets the gradient value (between 0 and 1)
  11157. * @param factor1 gets or sets first associated factor
  11158. * @param factor2 gets or sets second associated factor
  11159. */
  11160. constructor(
  11161. /**
  11162. * Gets or sets the gradient value (between 0 and 1)
  11163. */
  11164. gradient: number,
  11165. /**
  11166. * Gets or sets first associated factor
  11167. */
  11168. factor1: number,
  11169. /**
  11170. * Gets or sets second associated factor
  11171. */
  11172. factor2?: number | undefined);
  11173. /**
  11174. * Will get a number picked randomly between factor1 and factor2.
  11175. * If factor2 is undefined then factor1 will be used
  11176. * @returns the picked number
  11177. */
  11178. getFactor(): number;
  11179. }
  11180. /**
  11181. * Helper used to simplify some generic gradient tasks
  11182. */
  11183. export class GradientHelper {
  11184. /**
  11185. * Gets the current gradient from an array of IValueGradient
  11186. * @param ratio defines the current ratio to get
  11187. * @param gradients defines the array of IValueGradient
  11188. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11189. */
  11190. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11191. }
  11192. }
  11193. declare module BABYLON {
  11194. interface ThinEngine {
  11195. /**
  11196. * Creates a dynamic texture
  11197. * @param width defines the width of the texture
  11198. * @param height defines the height of the texture
  11199. * @param generateMipMaps defines if the engine should generate the mip levels
  11200. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11201. * @returns the dynamic texture inside an InternalTexture
  11202. */
  11203. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11204. /**
  11205. * Update the content of a dynamic texture
  11206. * @param texture defines the texture to update
  11207. * @param canvas defines the canvas containing the source
  11208. * @param invertY defines if data must be stored with Y axis inverted
  11209. * @param premulAlpha defines if alpha is stored as premultiplied
  11210. * @param format defines the format of the data
  11211. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11212. */
  11213. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11214. }
  11215. }
  11216. declare module BABYLON {
  11217. /**
  11218. * Helper class used to generate a canvas to manipulate images
  11219. */
  11220. export class CanvasGenerator {
  11221. /**
  11222. * Create a new canvas (or offscreen canvas depending on the context)
  11223. * @param width defines the expected width
  11224. * @param height defines the expected height
  11225. * @return a new canvas or offscreen canvas
  11226. */
  11227. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11228. }
  11229. }
  11230. declare module BABYLON {
  11231. /**
  11232. * A class extending Texture allowing drawing on a texture
  11233. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11234. */
  11235. export class DynamicTexture extends Texture {
  11236. private _generateMipMaps;
  11237. private _canvas;
  11238. private _context;
  11239. /**
  11240. * Creates a DynamicTexture
  11241. * @param name defines the name of the texture
  11242. * @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
  11243. * @param scene defines the scene where you want the texture
  11244. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11245. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11246. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11247. */
  11248. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11249. /**
  11250. * Get the current class name of the texture useful for serialization or dynamic coding.
  11251. * @returns "DynamicTexture"
  11252. */
  11253. getClassName(): string;
  11254. /**
  11255. * Gets the current state of canRescale
  11256. */
  11257. get canRescale(): boolean;
  11258. private _recreate;
  11259. /**
  11260. * Scales the texture
  11261. * @param ratio the scale factor to apply to both width and height
  11262. */
  11263. scale(ratio: number): void;
  11264. /**
  11265. * Resizes the texture
  11266. * @param width the new width
  11267. * @param height the new height
  11268. */
  11269. scaleTo(width: number, height: number): void;
  11270. /**
  11271. * Gets the context of the canvas used by the texture
  11272. * @returns the canvas context of the dynamic texture
  11273. */
  11274. getContext(): CanvasRenderingContext2D;
  11275. /**
  11276. * Clears the texture
  11277. */
  11278. clear(): void;
  11279. /**
  11280. * Updates the texture
  11281. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11282. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11283. */
  11284. update(invertY?: boolean, premulAlpha?: boolean): void;
  11285. /**
  11286. * Draws text onto the texture
  11287. * @param text defines the text to be drawn
  11288. * @param x defines the placement of the text from the left
  11289. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11290. * @param font defines the font to be used with font-style, font-size, font-name
  11291. * @param color defines the color used for the text
  11292. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11293. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11294. * @param update defines whether texture is immediately update (default is true)
  11295. */
  11296. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11297. /**
  11298. * Clones the texture
  11299. * @returns the clone of the texture.
  11300. */
  11301. clone(): DynamicTexture;
  11302. /**
  11303. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11304. * @returns a serialized dynamic texture object
  11305. */
  11306. serialize(): any;
  11307. /** @hidden */
  11308. _rebuild(): void;
  11309. }
  11310. }
  11311. declare module BABYLON {
  11312. interface ThinEngine {
  11313. /**
  11314. * Creates a raw texture
  11315. * @param data defines the data to store in the texture
  11316. * @param width defines the width of the texture
  11317. * @param height defines the height of the texture
  11318. * @param format defines the format of the data
  11319. * @param generateMipMaps defines if the engine should generate the mip levels
  11320. * @param invertY defines if data must be stored with Y axis inverted
  11321. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11322. * @param compression defines the compression used (null by default)
  11323. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11324. * @returns the raw texture inside an InternalTexture
  11325. */
  11326. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11327. /**
  11328. * Update a raw texture
  11329. * @param texture defines the texture to update
  11330. * @param data defines the data to store in the texture
  11331. * @param format defines the format of the data
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. */
  11334. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11335. /**
  11336. * Update a raw texture
  11337. * @param texture defines the texture to update
  11338. * @param data defines the data to store in the texture
  11339. * @param format defines the format of the data
  11340. * @param invertY defines if data must be stored with Y axis inverted
  11341. * @param compression defines the compression used (null by default)
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. */
  11344. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11345. /**
  11346. * Creates a new raw cube texture
  11347. * @param data defines the array of data to use to create each face
  11348. * @param size defines the size of the textures
  11349. * @param format defines the format of the data
  11350. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11351. * @param generateMipMaps defines if the engine should generate the mip levels
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11354. * @param compression defines the compression used (null by default)
  11355. * @returns the cube texture as an InternalTexture
  11356. */
  11357. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11358. /**
  11359. * Update a raw cube texture
  11360. * @param texture defines the texture to udpdate
  11361. * @param data defines the data to store
  11362. * @param format defines the data format
  11363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11364. * @param invertY defines if data must be stored with Y axis inverted
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11367. /**
  11368. * Update a raw cube texture
  11369. * @param texture defines the texture to udpdate
  11370. * @param data defines the data to store
  11371. * @param format defines the data format
  11372. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11373. * @param invertY defines if data must be stored with Y axis inverted
  11374. * @param compression defines the compression used (null by default)
  11375. */
  11376. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11377. /**
  11378. * Update a raw cube texture
  11379. * @param texture defines the texture to udpdate
  11380. * @param data defines the data to store
  11381. * @param format defines the data format
  11382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11383. * @param invertY defines if data must be stored with Y axis inverted
  11384. * @param compression defines the compression used (null by default)
  11385. * @param level defines which level of the texture to update
  11386. */
  11387. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11388. /**
  11389. * Creates a new raw cube texture from a specified url
  11390. * @param url defines the url where the data is located
  11391. * @param scene defines the current scene
  11392. * @param size defines the size of the textures
  11393. * @param format defines the format of the data
  11394. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11395. * @param noMipmap defines if the engine should avoid generating the mip levels
  11396. * @param callback defines a callback used to extract texture data from loaded data
  11397. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11398. * @param onLoad defines a callback called when texture is loaded
  11399. * @param onError defines a callback called if there is an error
  11400. * @returns the cube texture as an InternalTexture
  11401. */
  11402. 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;
  11403. /**
  11404. * Creates a new raw cube texture from a specified url
  11405. * @param url defines the url where the data is located
  11406. * @param scene defines the current scene
  11407. * @param size defines the size of the textures
  11408. * @param format defines the format of the data
  11409. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11410. * @param noMipmap defines if the engine should avoid generating the mip levels
  11411. * @param callback defines a callback used to extract texture data from loaded data
  11412. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11413. * @param onLoad defines a callback called when texture is loaded
  11414. * @param onError defines a callback called if there is an error
  11415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @returns the cube texture as an InternalTexture
  11418. */
  11419. 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;
  11420. /**
  11421. * Creates a new raw 3D texture
  11422. * @param data defines the data used to create the texture
  11423. * @param width defines the width of the texture
  11424. * @param height defines the height of the texture
  11425. * @param depth defines the depth of the texture
  11426. * @param format defines the format of the texture
  11427. * @param generateMipMaps defines if the engine must generate mip levels
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11430. * @param compression defines the compressed used (can be null)
  11431. * @param textureType defines the compressed used (can be null)
  11432. * @returns a new raw 3D texture (stored in an InternalTexture)
  11433. */
  11434. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11435. /**
  11436. * Update a raw 3D texture
  11437. * @param texture defines the texture to update
  11438. * @param data defines the data to store
  11439. * @param format defines the data format
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. */
  11442. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11443. /**
  11444. * Update a raw 3D texture
  11445. * @param texture defines the texture to update
  11446. * @param data defines the data to store
  11447. * @param format defines the data format
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param compression defines the used compression (can be null)
  11450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11451. */
  11452. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11453. /**
  11454. * Creates a new raw 2D array texture
  11455. * @param data defines the data used to create the texture
  11456. * @param width defines the width of the texture
  11457. * @param height defines the height of the texture
  11458. * @param depth defines the number of layers of the texture
  11459. * @param format defines the format of the texture
  11460. * @param generateMipMaps defines if the engine must generate mip levels
  11461. * @param invertY defines if data must be stored with Y axis inverted
  11462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11463. * @param compression defines the compressed used (can be null)
  11464. * @param textureType defines the compressed used (can be null)
  11465. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11466. */
  11467. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11468. /**
  11469. * Update a raw 2D array texture
  11470. * @param texture defines the texture to update
  11471. * @param data defines the data to store
  11472. * @param format defines the data format
  11473. * @param invertY defines if data must be stored with Y axis inverted
  11474. */
  11475. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11476. /**
  11477. * Update a raw 2D array texture
  11478. * @param texture defines the texture to update
  11479. * @param data defines the data to store
  11480. * @param format defines the data format
  11481. * @param invertY defines if data must be stored with Y axis inverted
  11482. * @param compression defines the used compression (can be null)
  11483. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11484. */
  11485. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11486. }
  11487. }
  11488. declare module BABYLON {
  11489. /**
  11490. * Raw texture can help creating a texture directly from an array of data.
  11491. * This can be super useful if you either get the data from an uncompressed source or
  11492. * if you wish to create your texture pixel by pixel.
  11493. */
  11494. export class RawTexture extends Texture {
  11495. /**
  11496. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11497. */
  11498. format: number;
  11499. /**
  11500. * Instantiates a new RawTexture.
  11501. * Raw texture can help creating a texture directly from an array of data.
  11502. * This can be super useful if you either get the data from an uncompressed source or
  11503. * if you wish to create your texture pixel by pixel.
  11504. * @param data define the array of data to use to create the texture
  11505. * @param width define the width of the texture
  11506. * @param height define the height of the texture
  11507. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11508. * @param scene define the scene the texture belongs to
  11509. * @param generateMipMaps define whether mip maps should be generated or not
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11513. */
  11514. constructor(data: ArrayBufferView, width: number, height: number,
  11515. /**
  11516. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11517. */
  11518. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11519. /**
  11520. * Updates the texture underlying data.
  11521. * @param data Define the new data of the texture
  11522. */
  11523. update(data: ArrayBufferView): void;
  11524. /**
  11525. * Creates a luminance texture from some data.
  11526. * @param data Define the texture data
  11527. * @param width Define the width of the texture
  11528. * @param height Define the height of the texture
  11529. * @param scene Define the scene the texture belongs to
  11530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11533. * @returns the luminance texture
  11534. */
  11535. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11536. /**
  11537. * Creates a luminance alpha texture from some data.
  11538. * @param data Define the texture data
  11539. * @param width Define the width of the texture
  11540. * @param height Define the height of the texture
  11541. * @param scene Define the scene the texture belongs to
  11542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11545. * @returns the luminance alpha texture
  11546. */
  11547. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11548. /**
  11549. * Creates an alpha texture from some data.
  11550. * @param data Define the texture data
  11551. * @param width Define the width of the texture
  11552. * @param height Define the height of the texture
  11553. * @param scene Define the scene the texture belongs to
  11554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11557. * @returns the alpha texture
  11558. */
  11559. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11560. /**
  11561. * Creates a RGB texture from some data.
  11562. * @param data Define the texture data
  11563. * @param width Define the width of the texture
  11564. * @param height Define the height of the texture
  11565. * @param scene Define the scene the texture belongs to
  11566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11570. * @returns the RGB alpha texture
  11571. */
  11572. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11573. /**
  11574. * Creates a RGBA texture from some data.
  11575. * @param data Define the texture data
  11576. * @param width Define the width of the texture
  11577. * @param height Define the height of the texture
  11578. * @param scene Define the scene the texture belongs to
  11579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11583. * @returns the RGBA texture
  11584. */
  11585. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11586. /**
  11587. * Creates a R texture from some data.
  11588. * @param data Define the texture data
  11589. * @param width Define the width of the texture
  11590. * @param height Define the height of the texture
  11591. * @param scene Define the scene the texture belongs to
  11592. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11593. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11594. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11595. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11596. * @returns the R texture
  11597. */
  11598. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11599. }
  11600. }
  11601. declare module BABYLON {
  11602. interface AbstractScene {
  11603. /**
  11604. * The list of procedural textures added to the scene
  11605. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11606. */
  11607. proceduralTextures: Array<ProceduralTexture>;
  11608. }
  11609. /**
  11610. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11611. * in a given scene.
  11612. */
  11613. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11614. /**
  11615. * The component name helpfull to identify the component in the list of scene components.
  11616. */
  11617. readonly name: string;
  11618. /**
  11619. * The scene the component belongs to.
  11620. */
  11621. scene: Scene;
  11622. /**
  11623. * Creates a new instance of the component for the given scene
  11624. * @param scene Defines the scene to register the component in
  11625. */
  11626. constructor(scene: Scene);
  11627. /**
  11628. * Registers the component in a given scene
  11629. */
  11630. register(): void;
  11631. /**
  11632. * Rebuilds the elements related to this component in case of
  11633. * context lost for instance.
  11634. */
  11635. rebuild(): void;
  11636. /**
  11637. * Disposes the component and the associated ressources.
  11638. */
  11639. dispose(): void;
  11640. private _beforeClear;
  11641. }
  11642. }
  11643. declare module BABYLON {
  11644. interface ThinEngine {
  11645. /**
  11646. * Creates a new render target cube texture
  11647. * @param size defines the size of the texture
  11648. * @param options defines the options used to create the texture
  11649. * @returns a new render target cube texture stored in an InternalTexture
  11650. */
  11651. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11652. }
  11653. }
  11654. declare module BABYLON {
  11655. /** @hidden */
  11656. export var proceduralVertexShader: {
  11657. name: string;
  11658. shader: string;
  11659. };
  11660. }
  11661. declare module BABYLON {
  11662. /**
  11663. * 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.
  11664. * This is the base class of any Procedural texture and contains most of the shareable code.
  11665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11666. */
  11667. export class ProceduralTexture extends Texture {
  11668. isCube: boolean;
  11669. /**
  11670. * Define if the texture is enabled or not (disabled texture will not render)
  11671. */
  11672. isEnabled: boolean;
  11673. /**
  11674. * Define if the texture must be cleared before rendering (default is true)
  11675. */
  11676. autoClear: boolean;
  11677. /**
  11678. * Callback called when the texture is generated
  11679. */
  11680. onGenerated: () => void;
  11681. /**
  11682. * Event raised when the texture is generated
  11683. */
  11684. onGeneratedObservable: Observable<ProceduralTexture>;
  11685. /** @hidden */
  11686. _generateMipMaps: boolean;
  11687. /** @hidden **/
  11688. _effect: Effect;
  11689. /** @hidden */
  11690. _textures: {
  11691. [key: string]: Texture;
  11692. };
  11693. /** @hidden */
  11694. protected _fallbackTexture: Nullable<Texture>;
  11695. private _size;
  11696. private _currentRefreshId;
  11697. private _frameId;
  11698. private _refreshRate;
  11699. private _vertexBuffers;
  11700. private _indexBuffer;
  11701. private _uniforms;
  11702. private _samplers;
  11703. private _fragment;
  11704. private _floats;
  11705. private _ints;
  11706. private _floatsArrays;
  11707. private _colors3;
  11708. private _colors4;
  11709. private _vectors2;
  11710. private _vectors3;
  11711. private _matrices;
  11712. private _fallbackTextureUsed;
  11713. private _fullEngine;
  11714. private _cachedDefines;
  11715. private _contentUpdateId;
  11716. private _contentData;
  11717. /**
  11718. * Instantiates a new procedural texture.
  11719. * 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.
  11720. * This is the base class of any Procedural texture and contains most of the shareable code.
  11721. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11722. * @param name Define the name of the texture
  11723. * @param size Define the size of the texture to create
  11724. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11725. * @param scene Define the scene the texture belongs to
  11726. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11727. * @param generateMipMaps Define if the texture should creates mip maps or not
  11728. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11729. */
  11730. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11731. /**
  11732. * The effect that is created when initializing the post process.
  11733. * @returns The created effect corresponding the the postprocess.
  11734. */
  11735. getEffect(): Effect;
  11736. /**
  11737. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11738. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11739. */
  11740. getContent(): Nullable<ArrayBufferView>;
  11741. private _createIndexBuffer;
  11742. /** @hidden */
  11743. _rebuild(): void;
  11744. /**
  11745. * Resets the texture in order to recreate its associated resources.
  11746. * This can be called in case of context loss
  11747. */
  11748. reset(): void;
  11749. protected _getDefines(): string;
  11750. /**
  11751. * Is the texture ready to be used ? (rendered at least once)
  11752. * @returns true if ready, otherwise, false.
  11753. */
  11754. isReady(): boolean;
  11755. /**
  11756. * Resets the refresh counter of the texture and start bak from scratch.
  11757. * Could be useful to regenerate the texture if it is setup to render only once.
  11758. */
  11759. resetRefreshCounter(): void;
  11760. /**
  11761. * Set the fragment shader to use in order to render the texture.
  11762. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11763. */
  11764. setFragment(fragment: any): void;
  11765. /**
  11766. * Define the refresh rate of the texture or the rendering frequency.
  11767. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11768. */
  11769. get refreshRate(): number;
  11770. set refreshRate(value: number);
  11771. /** @hidden */
  11772. _shouldRender(): boolean;
  11773. /**
  11774. * Get the size the texture is rendering at.
  11775. * @returns the size (texture is always squared)
  11776. */
  11777. getRenderSize(): number;
  11778. /**
  11779. * Resize the texture to new value.
  11780. * @param size Define the new size the texture should have
  11781. * @param generateMipMaps Define whether the new texture should create mip maps
  11782. */
  11783. resize(size: number, generateMipMaps: boolean): void;
  11784. private _checkUniform;
  11785. /**
  11786. * Set a texture in the shader program used to render.
  11787. * @param name Define the name of the uniform samplers as defined in the shader
  11788. * @param texture Define the texture to bind to this sampler
  11789. * @return the texture itself allowing "fluent" like uniform updates
  11790. */
  11791. setTexture(name: string, texture: Texture): ProceduralTexture;
  11792. /**
  11793. * Set a float in the shader.
  11794. * @param name Define the name of the uniform as defined in the shader
  11795. * @param value Define the value to give to the uniform
  11796. * @return the texture itself allowing "fluent" like uniform updates
  11797. */
  11798. setFloat(name: string, value: number): ProceduralTexture;
  11799. /**
  11800. * Set a int in the shader.
  11801. * @param name Define the name of the uniform as defined in the shader
  11802. * @param value Define the value to give to the uniform
  11803. * @return the texture itself allowing "fluent" like uniform updates
  11804. */
  11805. setInt(name: string, value: number): ProceduralTexture;
  11806. /**
  11807. * Set an array of floats in the shader.
  11808. * @param name Define the name of the uniform as defined in the shader
  11809. * @param value Define the value to give to the uniform
  11810. * @return the texture itself allowing "fluent" like uniform updates
  11811. */
  11812. setFloats(name: string, value: number[]): ProceduralTexture;
  11813. /**
  11814. * Set a vec3 in the shader from a Color3.
  11815. * @param name Define the name of the uniform as defined in the shader
  11816. * @param value Define the value to give to the uniform
  11817. * @return the texture itself allowing "fluent" like uniform updates
  11818. */
  11819. setColor3(name: string, value: Color3): ProceduralTexture;
  11820. /**
  11821. * Set a vec4 in the shader from a Color4.
  11822. * @param name Define the name of the uniform as defined in the shader
  11823. * @param value Define the value to give to the uniform
  11824. * @return the texture itself allowing "fluent" like uniform updates
  11825. */
  11826. setColor4(name: string, value: Color4): ProceduralTexture;
  11827. /**
  11828. * Set a vec2 in the shader from a Vector2.
  11829. * @param name Define the name of the uniform as defined in the shader
  11830. * @param value Define the value to give to the uniform
  11831. * @return the texture itself allowing "fluent" like uniform updates
  11832. */
  11833. setVector2(name: string, value: Vector2): ProceduralTexture;
  11834. /**
  11835. * Set a vec3 in the shader from a Vector3.
  11836. * @param name Define the name of the uniform as defined in the shader
  11837. * @param value Define the value to give to the uniform
  11838. * @return the texture itself allowing "fluent" like uniform updates
  11839. */
  11840. setVector3(name: string, value: Vector3): ProceduralTexture;
  11841. /**
  11842. * Set a mat4 in the shader from a MAtrix.
  11843. * @param name Define the name of the uniform as defined in the shader
  11844. * @param value Define the value to give to the uniform
  11845. * @return the texture itself allowing "fluent" like uniform updates
  11846. */
  11847. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11848. /**
  11849. * Render the texture to its associated render target.
  11850. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11851. */
  11852. render(useCameraPostProcess?: boolean): void;
  11853. /**
  11854. * Clone the texture.
  11855. * @returns the cloned texture
  11856. */
  11857. clone(): ProceduralTexture;
  11858. /**
  11859. * Dispose the texture and release its asoociated resources.
  11860. */
  11861. dispose(): void;
  11862. }
  11863. }
  11864. declare module BABYLON {
  11865. /**
  11866. * This represents the base class for particle system in Babylon.
  11867. * 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.
  11868. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11869. * @example https://doc.babylonjs.com/babylon101/particles
  11870. */
  11871. export class BaseParticleSystem {
  11872. /**
  11873. * Source color is added to the destination color without alpha affecting the result
  11874. */
  11875. static BLENDMODE_ONEONE: number;
  11876. /**
  11877. * Blend current color and particle color using particle’s alpha
  11878. */
  11879. static BLENDMODE_STANDARD: number;
  11880. /**
  11881. * Add current color and particle color multiplied by particle’s alpha
  11882. */
  11883. static BLENDMODE_ADD: number;
  11884. /**
  11885. * Multiply current color with particle color
  11886. */
  11887. static BLENDMODE_MULTIPLY: number;
  11888. /**
  11889. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11890. */
  11891. static BLENDMODE_MULTIPLYADD: number;
  11892. /**
  11893. * List of animations used by the particle system.
  11894. */
  11895. animations: Animation[];
  11896. /**
  11897. * Gets or sets the unique id of the particle system
  11898. */
  11899. uniqueId: number;
  11900. /**
  11901. * The id of the Particle system.
  11902. */
  11903. id: string;
  11904. /**
  11905. * The friendly name of the Particle system.
  11906. */
  11907. name: string;
  11908. /**
  11909. * Snippet ID if the particle system was created from the snippet server
  11910. */
  11911. snippetId: string;
  11912. /**
  11913. * The rendering group used by the Particle system to chose when to render.
  11914. */
  11915. renderingGroupId: number;
  11916. /**
  11917. * The emitter represents the Mesh or position we are attaching the particle system to.
  11918. */
  11919. emitter: Nullable<AbstractMesh | Vector3>;
  11920. /**
  11921. * The maximum number of particles to emit per frame
  11922. */
  11923. emitRate: number;
  11924. /**
  11925. * If you want to launch only a few particles at once, that can be done, as well.
  11926. */
  11927. manualEmitCount: number;
  11928. /**
  11929. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11930. */
  11931. updateSpeed: number;
  11932. /**
  11933. * The amount of time the particle system is running (depends of the overall update speed).
  11934. */
  11935. targetStopDuration: number;
  11936. /**
  11937. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11938. */
  11939. disposeOnStop: boolean;
  11940. /**
  11941. * Minimum power of emitting particles.
  11942. */
  11943. minEmitPower: number;
  11944. /**
  11945. * Maximum power of emitting particles.
  11946. */
  11947. maxEmitPower: number;
  11948. /**
  11949. * Minimum life time of emitting particles.
  11950. */
  11951. minLifeTime: number;
  11952. /**
  11953. * Maximum life time of emitting particles.
  11954. */
  11955. maxLifeTime: number;
  11956. /**
  11957. * Minimum Size of emitting particles.
  11958. */
  11959. minSize: number;
  11960. /**
  11961. * Maximum Size of emitting particles.
  11962. */
  11963. maxSize: number;
  11964. /**
  11965. * Minimum scale of emitting particles on X axis.
  11966. */
  11967. minScaleX: number;
  11968. /**
  11969. * Maximum scale of emitting particles on X axis.
  11970. */
  11971. maxScaleX: number;
  11972. /**
  11973. * Minimum scale of emitting particles on Y axis.
  11974. */
  11975. minScaleY: number;
  11976. /**
  11977. * Maximum scale of emitting particles on Y axis.
  11978. */
  11979. maxScaleY: number;
  11980. /**
  11981. * Gets or sets the minimal initial rotation in radians.
  11982. */
  11983. minInitialRotation: number;
  11984. /**
  11985. * Gets or sets the maximal initial rotation in radians.
  11986. */
  11987. maxInitialRotation: number;
  11988. /**
  11989. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11990. */
  11991. minAngularSpeed: number;
  11992. /**
  11993. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11994. */
  11995. maxAngularSpeed: number;
  11996. /**
  11997. * The texture used to render each particle. (this can be a spritesheet)
  11998. */
  11999. particleTexture: Nullable<Texture>;
  12000. /**
  12001. * The layer mask we are rendering the particles through.
  12002. */
  12003. layerMask: number;
  12004. /**
  12005. * This can help using your own shader to render the particle system.
  12006. * The according effect will be created
  12007. */
  12008. customShader: any;
  12009. /**
  12010. * By default particle system starts as soon as they are created. This prevents the
  12011. * automatic start to happen and let you decide when to start emitting particles.
  12012. */
  12013. preventAutoStart: boolean;
  12014. private _noiseTexture;
  12015. /**
  12016. * Gets or sets a texture used to add random noise to particle positions
  12017. */
  12018. get noiseTexture(): Nullable<ProceduralTexture>;
  12019. set noiseTexture(value: Nullable<ProceduralTexture>);
  12020. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12021. noiseStrength: Vector3;
  12022. /**
  12023. * Callback triggered when the particle animation is ending.
  12024. */
  12025. onAnimationEnd: Nullable<() => void>;
  12026. /**
  12027. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12028. */
  12029. blendMode: number;
  12030. /**
  12031. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12032. * to override the particles.
  12033. */
  12034. forceDepthWrite: boolean;
  12035. /** 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 */
  12036. preWarmCycles: number;
  12037. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12038. preWarmStepOffset: number;
  12039. /**
  12040. * 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)
  12041. */
  12042. spriteCellChangeSpeed: number;
  12043. /**
  12044. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12045. */
  12046. startSpriteCellID: number;
  12047. /**
  12048. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12049. */
  12050. endSpriteCellID: number;
  12051. /**
  12052. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12053. */
  12054. spriteCellWidth: number;
  12055. /**
  12056. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12057. */
  12058. spriteCellHeight: number;
  12059. /**
  12060. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12061. */
  12062. spriteRandomStartCell: boolean;
  12063. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12064. translationPivot: Vector2;
  12065. /** @hidden */
  12066. protected _isAnimationSheetEnabled: boolean;
  12067. /**
  12068. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12069. */
  12070. beginAnimationOnStart: boolean;
  12071. /**
  12072. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12073. */
  12074. beginAnimationFrom: number;
  12075. /**
  12076. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12077. */
  12078. beginAnimationTo: number;
  12079. /**
  12080. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12081. */
  12082. beginAnimationLoop: boolean;
  12083. /**
  12084. * Gets or sets a world offset applied to all particles
  12085. */
  12086. worldOffset: Vector3;
  12087. /**
  12088. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12089. */
  12090. get isAnimationSheetEnabled(): boolean;
  12091. set isAnimationSheetEnabled(value: boolean);
  12092. /**
  12093. * Get hosting scene
  12094. * @returns the scene
  12095. */
  12096. getScene(): Scene;
  12097. /**
  12098. * You can use gravity if you want to give an orientation to your particles.
  12099. */
  12100. gravity: Vector3;
  12101. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12102. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12103. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12104. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12105. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12106. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12107. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12108. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12109. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12110. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12111. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12112. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12113. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12114. /**
  12115. * Defines the delay in milliseconds before starting the system (0 by default)
  12116. */
  12117. startDelay: number;
  12118. /**
  12119. * Gets the current list of drag gradients.
  12120. * You must use addDragGradient and removeDragGradient to udpate this list
  12121. * @returns the list of drag gradients
  12122. */
  12123. getDragGradients(): Nullable<Array<FactorGradient>>;
  12124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12125. limitVelocityDamping: number;
  12126. /**
  12127. * Gets the current list of limit velocity gradients.
  12128. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12129. * @returns the list of limit velocity gradients
  12130. */
  12131. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12132. /**
  12133. * Gets the current list of color gradients.
  12134. * You must use addColorGradient and removeColorGradient to udpate this list
  12135. * @returns the list of color gradients
  12136. */
  12137. getColorGradients(): Nullable<Array<ColorGradient>>;
  12138. /**
  12139. * Gets the current list of size gradients.
  12140. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12141. * @returns the list of size gradients
  12142. */
  12143. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12144. /**
  12145. * Gets the current list of color remap gradients.
  12146. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12147. * @returns the list of color remap gradients
  12148. */
  12149. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12150. /**
  12151. * Gets the current list of alpha remap gradients.
  12152. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12153. * @returns the list of alpha remap gradients
  12154. */
  12155. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12156. /**
  12157. * Gets the current list of life time gradients.
  12158. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12159. * @returns the list of life time gradients
  12160. */
  12161. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12162. /**
  12163. * Gets the current list of angular speed gradients.
  12164. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12165. * @returns the list of angular speed gradients
  12166. */
  12167. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12168. /**
  12169. * Gets the current list of velocity gradients.
  12170. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12171. * @returns the list of velocity gradients
  12172. */
  12173. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12174. /**
  12175. * Gets the current list of start size gradients.
  12176. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12177. * @returns the list of start size gradients
  12178. */
  12179. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12180. /**
  12181. * Gets the current list of emit rate gradients.
  12182. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12183. * @returns the list of emit rate gradients
  12184. */
  12185. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12186. /**
  12187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12188. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12189. */
  12190. get direction1(): Vector3;
  12191. set direction1(value: Vector3);
  12192. /**
  12193. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12194. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12195. */
  12196. get direction2(): Vector3;
  12197. set direction2(value: Vector3);
  12198. /**
  12199. * 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.
  12200. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12201. */
  12202. get minEmitBox(): Vector3;
  12203. set minEmitBox(value: Vector3);
  12204. /**
  12205. * 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.
  12206. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12207. */
  12208. get maxEmitBox(): Vector3;
  12209. set maxEmitBox(value: Vector3);
  12210. /**
  12211. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12212. */
  12213. color1: Color4;
  12214. /**
  12215. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12216. */
  12217. color2: Color4;
  12218. /**
  12219. * Color the particle will have at the end of its lifetime
  12220. */
  12221. colorDead: Color4;
  12222. /**
  12223. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12224. */
  12225. textureMask: Color4;
  12226. /**
  12227. * The particle emitter type defines the emitter used by the particle system.
  12228. * It can be for example box, sphere, or cone...
  12229. */
  12230. particleEmitterType: IParticleEmitterType;
  12231. /** @hidden */
  12232. _isSubEmitter: boolean;
  12233. /**
  12234. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12235. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12236. */
  12237. billboardMode: number;
  12238. protected _isBillboardBased: boolean;
  12239. /**
  12240. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12241. */
  12242. get isBillboardBased(): boolean;
  12243. set isBillboardBased(value: boolean);
  12244. /**
  12245. * The scene the particle system belongs to.
  12246. */
  12247. protected _scene: Scene;
  12248. /**
  12249. * Local cache of defines for image processing.
  12250. */
  12251. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12252. /**
  12253. * Default configuration related to image processing available in the standard Material.
  12254. */
  12255. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12256. /**
  12257. * Gets the image processing configuration used either in this material.
  12258. */
  12259. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12260. /**
  12261. * Sets the Default image processing configuration used either in the this material.
  12262. *
  12263. * If sets to null, the scene one is in use.
  12264. */
  12265. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12266. /**
  12267. * Attaches a new image processing configuration to the Standard Material.
  12268. * @param configuration
  12269. */
  12270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12271. /** @hidden */
  12272. protected _reset(): void;
  12273. /** @hidden */
  12274. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12275. /**
  12276. * Instantiates a particle system.
  12277. * 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.
  12278. * @param name The name of the particle system
  12279. */
  12280. constructor(name: string);
  12281. /**
  12282. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12283. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12284. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @returns the emitter
  12286. */
  12287. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12288. /**
  12289. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12290. * @param radius The radius of the hemisphere to emit from
  12291. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12292. * @returns the emitter
  12293. */
  12294. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12295. /**
  12296. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12297. * @param radius The radius of the sphere to emit from
  12298. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12299. * @returns the emitter
  12300. */
  12301. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12302. /**
  12303. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12304. * @param radius The radius of the sphere to emit from
  12305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @returns the emitter
  12308. */
  12309. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12310. /**
  12311. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12312. * @param radius The radius of the emission cylinder
  12313. * @param height The height of the emission cylinder
  12314. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12315. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12316. * @returns the emitter
  12317. */
  12318. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12319. /**
  12320. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12321. * @param radius The radius of the cylinder to emit from
  12322. * @param height The height of the emission cylinder
  12323. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @returns the emitter
  12327. */
  12328. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12329. /**
  12330. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12331. * @param radius The radius of the cone to emit from
  12332. * @param angle The base angle of the cone
  12333. * @returns the emitter
  12334. */
  12335. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12336. /**
  12337. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12341. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @returns the emitter
  12343. */
  12344. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Type of sub emitter
  12350. */
  12351. export enum SubEmitterType {
  12352. /**
  12353. * Attached to the particle over it's lifetime
  12354. */
  12355. ATTACHED = 0,
  12356. /**
  12357. * Created when the particle dies
  12358. */
  12359. END = 1
  12360. }
  12361. /**
  12362. * Sub emitter class used to emit particles from an existing particle
  12363. */
  12364. export class SubEmitter {
  12365. /**
  12366. * the particle system to be used by the sub emitter
  12367. */
  12368. particleSystem: ParticleSystem;
  12369. /**
  12370. * Type of the submitter (Default: END)
  12371. */
  12372. type: SubEmitterType;
  12373. /**
  12374. * 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)
  12375. * Note: This only is supported when using an emitter of type Mesh
  12376. */
  12377. inheritDirection: boolean;
  12378. /**
  12379. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12380. */
  12381. inheritedVelocityAmount: number;
  12382. /**
  12383. * Creates a sub emitter
  12384. * @param particleSystem the particle system to be used by the sub emitter
  12385. */
  12386. constructor(
  12387. /**
  12388. * the particle system to be used by the sub emitter
  12389. */
  12390. particleSystem: ParticleSystem);
  12391. /**
  12392. * Clones the sub emitter
  12393. * @returns the cloned sub emitter
  12394. */
  12395. clone(): SubEmitter;
  12396. /**
  12397. * Serialize current object to a JSON object
  12398. * @returns the serialized object
  12399. */
  12400. serialize(): any;
  12401. /** @hidden */
  12402. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12403. /**
  12404. * Creates a new SubEmitter from a serialized JSON version
  12405. * @param serializationObject defines the JSON object to read from
  12406. * @param scene defines the hosting scene
  12407. * @param rootUrl defines the rootUrl for data loading
  12408. * @returns a new SubEmitter
  12409. */
  12410. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12411. /** Release associated resources */
  12412. dispose(): void;
  12413. }
  12414. }
  12415. declare module BABYLON {
  12416. /** @hidden */
  12417. export var imageProcessingDeclaration: {
  12418. name: string;
  12419. shader: string;
  12420. };
  12421. }
  12422. declare module BABYLON {
  12423. /** @hidden */
  12424. export var imageProcessingFunctions: {
  12425. name: string;
  12426. shader: string;
  12427. };
  12428. }
  12429. declare module BABYLON {
  12430. /** @hidden */
  12431. export var particlesPixelShader: {
  12432. name: string;
  12433. shader: string;
  12434. };
  12435. }
  12436. declare module BABYLON {
  12437. /** @hidden */
  12438. export var particlesVertexShader: {
  12439. name: string;
  12440. shader: string;
  12441. };
  12442. }
  12443. declare module BABYLON {
  12444. /**
  12445. * This represents a particle system in Babylon.
  12446. * 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.
  12447. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12448. * @example https://doc.babylonjs.com/babylon101/particles
  12449. */
  12450. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12451. /**
  12452. * Billboard mode will only apply to Y axis
  12453. */
  12454. static readonly BILLBOARDMODE_Y: number;
  12455. /**
  12456. * Billboard mode will apply to all axes
  12457. */
  12458. static readonly BILLBOARDMODE_ALL: number;
  12459. /**
  12460. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12461. */
  12462. static readonly BILLBOARDMODE_STRETCHED: number;
  12463. /**
  12464. * This function can be defined to provide custom update for active particles.
  12465. * This function will be called instead of regular update (age, position, color, etc.).
  12466. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12467. */
  12468. updateFunction: (particles: Particle[]) => void;
  12469. private _emitterWorldMatrix;
  12470. /**
  12471. * This function can be defined to specify initial direction for every new particle.
  12472. * It by default use the emitterType defined function
  12473. */
  12474. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12475. /**
  12476. * This function can be defined to specify initial position for every new particle.
  12477. * It by default use the emitterType defined function
  12478. */
  12479. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12480. /**
  12481. * @hidden
  12482. */
  12483. _inheritedVelocityOffset: Vector3;
  12484. /**
  12485. * An event triggered when the system is disposed
  12486. */
  12487. onDisposeObservable: Observable<IParticleSystem>;
  12488. private _onDisposeObserver;
  12489. /**
  12490. * Sets a callback that will be triggered when the system is disposed
  12491. */
  12492. set onDispose(callback: () => void);
  12493. private _particles;
  12494. private _epsilon;
  12495. private _capacity;
  12496. private _stockParticles;
  12497. private _newPartsExcess;
  12498. private _vertexData;
  12499. private _vertexBuffer;
  12500. private _vertexBuffers;
  12501. private _spriteBuffer;
  12502. private _indexBuffer;
  12503. private _effect;
  12504. private _customEffect;
  12505. private _cachedDefines;
  12506. private _scaledColorStep;
  12507. private _colorDiff;
  12508. private _scaledDirection;
  12509. private _scaledGravity;
  12510. private _currentRenderId;
  12511. private _alive;
  12512. private _useInstancing;
  12513. private _started;
  12514. private _stopped;
  12515. private _actualFrame;
  12516. private _scaledUpdateSpeed;
  12517. private _vertexBufferSize;
  12518. /** @hidden */
  12519. _currentEmitRateGradient: Nullable<FactorGradient>;
  12520. /** @hidden */
  12521. _currentEmitRate1: number;
  12522. /** @hidden */
  12523. _currentEmitRate2: number;
  12524. /** @hidden */
  12525. _currentStartSizeGradient: Nullable<FactorGradient>;
  12526. /** @hidden */
  12527. _currentStartSize1: number;
  12528. /** @hidden */
  12529. _currentStartSize2: number;
  12530. private readonly _rawTextureWidth;
  12531. private _rampGradientsTexture;
  12532. private _useRampGradients;
  12533. /** Gets or sets a boolean indicating that ramp gradients must be used
  12534. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12535. */
  12536. get useRampGradients(): boolean;
  12537. set useRampGradients(value: boolean);
  12538. /**
  12539. * 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.
  12540. * 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: [])
  12541. */
  12542. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12543. private _subEmitters;
  12544. /**
  12545. * @hidden
  12546. * If the particle systems emitter should be disposed when the particle system is disposed
  12547. */
  12548. _disposeEmitterOnDispose: boolean;
  12549. /**
  12550. * The current active Sub-systems, this property is used by the root particle system only.
  12551. */
  12552. activeSubSystems: Array<ParticleSystem>;
  12553. /**
  12554. * Specifies if the particles are updated in emitter local space or world space
  12555. */
  12556. isLocal: boolean;
  12557. private _rootParticleSystem;
  12558. /**
  12559. * Gets the current list of active particles
  12560. */
  12561. get particles(): Particle[];
  12562. /**
  12563. * Gets the number of particles active at the same time.
  12564. * @returns The number of active particles.
  12565. */
  12566. getActiveCount(): number;
  12567. /**
  12568. * Returns the string "ParticleSystem"
  12569. * @returns a string containing the class name
  12570. */
  12571. getClassName(): string;
  12572. /**
  12573. * Gets a boolean indicating that the system is stopping
  12574. * @returns true if the system is currently stopping
  12575. */
  12576. isStopping(): boolean;
  12577. /**
  12578. * Gets the custom effect used to render the particles
  12579. * @param blendMode Blend mode for which the effect should be retrieved
  12580. * @returns The effect
  12581. */
  12582. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12583. /**
  12584. * Sets the custom effect used to render the particles
  12585. * @param effect The effect to set
  12586. * @param blendMode Blend mode for which the effect should be set
  12587. */
  12588. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12589. /** @hidden */
  12590. private _onBeforeDrawParticlesObservable;
  12591. /**
  12592. * Observable that will be called just before the particles are drawn
  12593. */
  12594. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12595. /**
  12596. * Gets the name of the particle vertex shader
  12597. */
  12598. get vertexShaderName(): string;
  12599. /**
  12600. * Instantiates a particle system.
  12601. * 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.
  12602. * @param name The name of the particle system
  12603. * @param capacity The max number of particles alive at the same time
  12604. * @param scene The scene the particle system belongs to
  12605. * @param customEffect a custom effect used to change the way particles are rendered by default
  12606. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12607. * @param epsilon Offset used to render the particles
  12608. */
  12609. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12610. private _addFactorGradient;
  12611. private _removeFactorGradient;
  12612. /**
  12613. * Adds a new life time gradient
  12614. * @param gradient defines the gradient to use (between 0 and 1)
  12615. * @param factor defines the life time factor to affect to the specified gradient
  12616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12617. * @returns the current particle system
  12618. */
  12619. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12620. /**
  12621. * Remove a specific life time gradient
  12622. * @param gradient defines the gradient to remove
  12623. * @returns the current particle system
  12624. */
  12625. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12626. /**
  12627. * Adds a new size gradient
  12628. * @param gradient defines the gradient to use (between 0 and 1)
  12629. * @param factor defines the size factor to affect to the specified gradient
  12630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12631. * @returns the current particle system
  12632. */
  12633. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12634. /**
  12635. * Remove a specific size gradient
  12636. * @param gradient defines the gradient to remove
  12637. * @returns the current particle system
  12638. */
  12639. removeSizeGradient(gradient: number): IParticleSystem;
  12640. /**
  12641. * Adds a new color remap gradient
  12642. * @param gradient defines the gradient to use (between 0 and 1)
  12643. * @param min defines the color remap minimal range
  12644. * @param max defines the color remap maximal range
  12645. * @returns the current particle system
  12646. */
  12647. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12648. /**
  12649. * Remove a specific color remap gradient
  12650. * @param gradient defines the gradient to remove
  12651. * @returns the current particle system
  12652. */
  12653. removeColorRemapGradient(gradient: number): IParticleSystem;
  12654. /**
  12655. * Adds a new alpha remap gradient
  12656. * @param gradient defines the gradient to use (between 0 and 1)
  12657. * @param min defines the alpha remap minimal range
  12658. * @param max defines the alpha remap maximal range
  12659. * @returns the current particle system
  12660. */
  12661. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12662. /**
  12663. * Remove a specific alpha remap gradient
  12664. * @param gradient defines the gradient to remove
  12665. * @returns the current particle system
  12666. */
  12667. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12668. /**
  12669. * Adds a new angular speed gradient
  12670. * @param gradient defines the gradient to use (between 0 and 1)
  12671. * @param factor defines the angular speed to affect to the specified gradient
  12672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12673. * @returns the current particle system
  12674. */
  12675. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12676. /**
  12677. * Remove a specific angular speed gradient
  12678. * @param gradient defines the gradient to remove
  12679. * @returns the current particle system
  12680. */
  12681. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12682. /**
  12683. * Adds a new velocity gradient
  12684. * @param gradient defines the gradient to use (between 0 and 1)
  12685. * @param factor defines the velocity to affect to the specified gradient
  12686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12687. * @returns the current particle system
  12688. */
  12689. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12690. /**
  12691. * Remove a specific velocity gradient
  12692. * @param gradient defines the gradient to remove
  12693. * @returns the current particle system
  12694. */
  12695. removeVelocityGradient(gradient: number): IParticleSystem;
  12696. /**
  12697. * Adds a new limit velocity gradient
  12698. * @param gradient defines the gradient to use (between 0 and 1)
  12699. * @param factor defines the limit velocity value to affect to the specified gradient
  12700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12701. * @returns the current particle system
  12702. */
  12703. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12704. /**
  12705. * Remove a specific limit velocity gradient
  12706. * @param gradient defines the gradient to remove
  12707. * @returns the current particle system
  12708. */
  12709. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12710. /**
  12711. * Adds a new drag gradient
  12712. * @param gradient defines the gradient to use (between 0 and 1)
  12713. * @param factor defines the drag value to affect to the specified gradient
  12714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12715. * @returns the current particle system
  12716. */
  12717. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12718. /**
  12719. * Remove a specific drag gradient
  12720. * @param gradient defines the gradient to remove
  12721. * @returns the current particle system
  12722. */
  12723. removeDragGradient(gradient: number): IParticleSystem;
  12724. /**
  12725. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12726. * @param gradient defines the gradient to use (between 0 and 1)
  12727. * @param factor defines the emit rate value to affect to the specified gradient
  12728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12729. * @returns the current particle system
  12730. */
  12731. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12732. /**
  12733. * Remove a specific emit rate gradient
  12734. * @param gradient defines the gradient to remove
  12735. * @returns the current particle system
  12736. */
  12737. removeEmitRateGradient(gradient: number): IParticleSystem;
  12738. /**
  12739. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12740. * @param gradient defines the gradient to use (between 0 and 1)
  12741. * @param factor defines the start size value to affect to the specified gradient
  12742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12743. * @returns the current particle system
  12744. */
  12745. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12746. /**
  12747. * Remove a specific start size gradient
  12748. * @param gradient defines the gradient to remove
  12749. * @returns the current particle system
  12750. */
  12751. removeStartSizeGradient(gradient: number): IParticleSystem;
  12752. private _createRampGradientTexture;
  12753. /**
  12754. * Gets the current list of ramp gradients.
  12755. * You must use addRampGradient and removeRampGradient to udpate this list
  12756. * @returns the list of ramp gradients
  12757. */
  12758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12759. /** Force the system to rebuild all gradients that need to be resync */
  12760. forceRefreshGradients(): void;
  12761. private _syncRampGradientTexture;
  12762. /**
  12763. * Adds a new ramp gradient used to remap particle colors
  12764. * @param gradient defines the gradient to use (between 0 and 1)
  12765. * @param color defines the color to affect to the specified gradient
  12766. * @returns the current particle system
  12767. */
  12768. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12769. /**
  12770. * Remove a specific ramp gradient
  12771. * @param gradient defines the gradient to remove
  12772. * @returns the current particle system
  12773. */
  12774. removeRampGradient(gradient: number): ParticleSystem;
  12775. /**
  12776. * Adds a new color gradient
  12777. * @param gradient defines the gradient to use (between 0 and 1)
  12778. * @param color1 defines the color to affect to the specified gradient
  12779. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12780. * @returns this particle system
  12781. */
  12782. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12783. /**
  12784. * Remove a specific color gradient
  12785. * @param gradient defines the gradient to remove
  12786. * @returns this particle system
  12787. */
  12788. removeColorGradient(gradient: number): IParticleSystem;
  12789. private _fetchR;
  12790. protected _reset(): void;
  12791. private _resetEffect;
  12792. private _createVertexBuffers;
  12793. private _createIndexBuffer;
  12794. /**
  12795. * Gets the maximum number of particles active at the same time.
  12796. * @returns The max number of active particles.
  12797. */
  12798. getCapacity(): number;
  12799. /**
  12800. * Gets whether there are still active particles in the system.
  12801. * @returns True if it is alive, otherwise false.
  12802. */
  12803. isAlive(): boolean;
  12804. /**
  12805. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12806. * @returns True if it has been started, otherwise false.
  12807. */
  12808. isStarted(): boolean;
  12809. private _prepareSubEmitterInternalArray;
  12810. /**
  12811. * Starts the particle system and begins to emit
  12812. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12813. */
  12814. start(delay?: number): void;
  12815. /**
  12816. * Stops the particle system.
  12817. * @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.
  12818. */
  12819. stop(stopSubEmitters?: boolean): void;
  12820. /**
  12821. * Remove all active particles
  12822. */
  12823. reset(): void;
  12824. /**
  12825. * @hidden (for internal use only)
  12826. */
  12827. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12828. /**
  12829. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12830. * Its lifetime will start back at 0.
  12831. */
  12832. recycleParticle: (particle: Particle) => void;
  12833. private _stopSubEmitters;
  12834. private _createParticle;
  12835. private _removeFromRoot;
  12836. private _emitFromParticle;
  12837. private _update;
  12838. /** @hidden */
  12839. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12840. /** @hidden */
  12841. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12842. /**
  12843. * Fill the defines array according to the current settings of the particle system
  12844. * @param defines Array to be updated
  12845. * @param blendMode blend mode to take into account when updating the array
  12846. */
  12847. fillDefines(defines: Array<string>, blendMode: number): void;
  12848. /**
  12849. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12850. * @param uniforms Uniforms array to fill
  12851. * @param attributes Attributes array to fill
  12852. * @param samplers Samplers array to fill
  12853. */
  12854. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12855. /** @hidden */
  12856. private _getEffect;
  12857. /**
  12858. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12859. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12860. */
  12861. animate(preWarmOnly?: boolean): void;
  12862. private _appendParticleVertices;
  12863. /**
  12864. * Rebuilds the particle system.
  12865. */
  12866. rebuild(): void;
  12867. /**
  12868. * Is this system ready to be used/rendered
  12869. * @return true if the system is ready
  12870. */
  12871. isReady(): boolean;
  12872. private _render;
  12873. /**
  12874. * Renders the particle system in its current state.
  12875. * @returns the current number of particles
  12876. */
  12877. render(): number;
  12878. /**
  12879. * Disposes the particle system and free the associated resources
  12880. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12881. */
  12882. dispose(disposeTexture?: boolean): void;
  12883. /**
  12884. * Clones the particle system.
  12885. * @param name The name of the cloned object
  12886. * @param newEmitter The new emitter to use
  12887. * @returns the cloned particle system
  12888. */
  12889. clone(name: string, newEmitter: any): ParticleSystem;
  12890. /**
  12891. * Serializes the particle system to a JSON object
  12892. * @param serializeTexture defines if the texture must be serialized as well
  12893. * @returns the JSON object
  12894. */
  12895. serialize(serializeTexture?: boolean): any;
  12896. /** @hidden */
  12897. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12898. /** @hidden */
  12899. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12900. /**
  12901. * Parses a JSON object to create a particle system.
  12902. * @param parsedParticleSystem The JSON object to parse
  12903. * @param scene The scene to create the particle system in
  12904. * @param rootUrl The root url to use to load external dependencies like texture
  12905. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12906. * @returns the Parsed particle system
  12907. */
  12908. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12909. }
  12910. }
  12911. declare module BABYLON {
  12912. /**
  12913. * A particle represents one of the element emitted by a particle system.
  12914. * This is mainly define by its coordinates, direction, velocity and age.
  12915. */
  12916. export class Particle {
  12917. /**
  12918. * The particle system the particle belongs to.
  12919. */
  12920. particleSystem: ParticleSystem;
  12921. private static _Count;
  12922. /**
  12923. * Unique ID of the particle
  12924. */
  12925. id: number;
  12926. /**
  12927. * The world position of the particle in the scene.
  12928. */
  12929. position: Vector3;
  12930. /**
  12931. * The world direction of the particle in the scene.
  12932. */
  12933. direction: Vector3;
  12934. /**
  12935. * The color of the particle.
  12936. */
  12937. color: Color4;
  12938. /**
  12939. * The color change of the particle per step.
  12940. */
  12941. colorStep: Color4;
  12942. /**
  12943. * Defines how long will the life of the particle be.
  12944. */
  12945. lifeTime: number;
  12946. /**
  12947. * The current age of the particle.
  12948. */
  12949. age: number;
  12950. /**
  12951. * The current size of the particle.
  12952. */
  12953. size: number;
  12954. /**
  12955. * The current scale of the particle.
  12956. */
  12957. scale: Vector2;
  12958. /**
  12959. * The current angle of the particle.
  12960. */
  12961. angle: number;
  12962. /**
  12963. * Defines how fast is the angle changing.
  12964. */
  12965. angularSpeed: number;
  12966. /**
  12967. * Defines the cell index used by the particle to be rendered from a sprite.
  12968. */
  12969. cellIndex: number;
  12970. /**
  12971. * The information required to support color remapping
  12972. */
  12973. remapData: Vector4;
  12974. /** @hidden */
  12975. _randomCellOffset?: number;
  12976. /** @hidden */
  12977. _initialDirection: Nullable<Vector3>;
  12978. /** @hidden */
  12979. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12980. /** @hidden */
  12981. _initialStartSpriteCellID: number;
  12982. /** @hidden */
  12983. _initialEndSpriteCellID: number;
  12984. /** @hidden */
  12985. _currentColorGradient: Nullable<ColorGradient>;
  12986. /** @hidden */
  12987. _currentColor1: Color4;
  12988. /** @hidden */
  12989. _currentColor2: Color4;
  12990. /** @hidden */
  12991. _currentSizeGradient: Nullable<FactorGradient>;
  12992. /** @hidden */
  12993. _currentSize1: number;
  12994. /** @hidden */
  12995. _currentSize2: number;
  12996. /** @hidden */
  12997. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12998. /** @hidden */
  12999. _currentAngularSpeed1: number;
  13000. /** @hidden */
  13001. _currentAngularSpeed2: number;
  13002. /** @hidden */
  13003. _currentVelocityGradient: Nullable<FactorGradient>;
  13004. /** @hidden */
  13005. _currentVelocity1: number;
  13006. /** @hidden */
  13007. _currentVelocity2: number;
  13008. /** @hidden */
  13009. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13010. /** @hidden */
  13011. _currentLimitVelocity1: number;
  13012. /** @hidden */
  13013. _currentLimitVelocity2: number;
  13014. /** @hidden */
  13015. _currentDragGradient: Nullable<FactorGradient>;
  13016. /** @hidden */
  13017. _currentDrag1: number;
  13018. /** @hidden */
  13019. _currentDrag2: number;
  13020. /** @hidden */
  13021. _randomNoiseCoordinates1: Vector3;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates2: Vector3;
  13024. /** @hidden */
  13025. _localPosition?: Vector3;
  13026. /**
  13027. * Creates a new instance Particle
  13028. * @param particleSystem the particle system the particle belongs to
  13029. */
  13030. constructor(
  13031. /**
  13032. * The particle system the particle belongs to.
  13033. */
  13034. particleSystem: ParticleSystem);
  13035. private updateCellInfoFromSystem;
  13036. /**
  13037. * Defines how the sprite cell index is updated for the particle
  13038. */
  13039. updateCellIndex(): void;
  13040. /** @hidden */
  13041. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitters(): void;
  13044. /** @hidden */
  13045. _reset(): void;
  13046. /**
  13047. * Copy the properties of particle to another one.
  13048. * @param other the particle to copy the information to.
  13049. */
  13050. copyTo(other: Particle): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * Particle emitter represents a volume emitting particles.
  13056. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13057. */
  13058. export interface IParticleEmitterType {
  13059. /**
  13060. * Called by the particle System when the direction is computed for the created particle.
  13061. * @param worldMatrix is the world matrix of the particle system
  13062. * @param directionToUpdate is the direction vector to update with the result
  13063. * @param particle is the particle we are computed the direction for
  13064. * @param isLocal defines if the direction should be set in local space
  13065. */
  13066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13067. /**
  13068. * Called by the particle System when the position is computed for the created particle.
  13069. * @param worldMatrix is the world matrix of the particle system
  13070. * @param positionToUpdate is the position vector to update with the result
  13071. * @param particle is the particle we are computed the position for
  13072. * @param isLocal defines if the position should be set in local space
  13073. */
  13074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13075. /**
  13076. * Clones the current emitter and returns a copy of it
  13077. * @returns the new emitter
  13078. */
  13079. clone(): IParticleEmitterType;
  13080. /**
  13081. * Called by the GPUParticleSystem to setup the update shader
  13082. * @param effect defines the update shader
  13083. */
  13084. applyToShader(effect: Effect): void;
  13085. /**
  13086. * Returns a string to use to update the GPU particles update shader
  13087. * @returns the effect defines string
  13088. */
  13089. getEffectDefines(): string;
  13090. /**
  13091. * Returns a string representing the class name
  13092. * @returns a string containing the class name
  13093. */
  13094. getClassName(): string;
  13095. /**
  13096. * Serializes the particle system to a JSON object.
  13097. * @returns the JSON object
  13098. */
  13099. serialize(): any;
  13100. /**
  13101. * Parse properties from a JSON object
  13102. * @param serializationObject defines the JSON object
  13103. * @param scene defines the hosting scene
  13104. */
  13105. parse(serializationObject: any, scene: Scene): void;
  13106. }
  13107. }
  13108. declare module BABYLON {
  13109. /**
  13110. * Particle emitter emitting particles from the inside of a box.
  13111. * It emits the particles randomly between 2 given directions.
  13112. */
  13113. export class BoxParticleEmitter implements IParticleEmitterType {
  13114. /**
  13115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13116. */
  13117. direction1: Vector3;
  13118. /**
  13119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13120. */
  13121. direction2: Vector3;
  13122. /**
  13123. * 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.
  13124. */
  13125. minEmitBox: Vector3;
  13126. /**
  13127. * 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.
  13128. */
  13129. maxEmitBox: Vector3;
  13130. /**
  13131. * Creates a new instance BoxParticleEmitter
  13132. */
  13133. constructor();
  13134. /**
  13135. * Called by the particle System when the direction is computed for the created particle.
  13136. * @param worldMatrix is the world matrix of the particle system
  13137. * @param directionToUpdate is the direction vector to update with the result
  13138. * @param particle is the particle we are computed the direction for
  13139. * @param isLocal defines if the direction should be set in local space
  13140. */
  13141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13142. /**
  13143. * Called by the particle System when the position is computed for the created particle.
  13144. * @param worldMatrix is the world matrix of the particle system
  13145. * @param positionToUpdate is the position vector to update with the result
  13146. * @param particle is the particle we are computed the position for
  13147. * @param isLocal defines if the position should be set in local space
  13148. */
  13149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13150. /**
  13151. * Clones the current emitter and returns a copy of it
  13152. * @returns the new emitter
  13153. */
  13154. clone(): BoxParticleEmitter;
  13155. /**
  13156. * Called by the GPUParticleSystem to setup the update shader
  13157. * @param effect defines the update shader
  13158. */
  13159. applyToShader(effect: Effect): void;
  13160. /**
  13161. * Returns a string to use to update the GPU particles update shader
  13162. * @returns a string containng the defines string
  13163. */
  13164. getEffectDefines(): string;
  13165. /**
  13166. * Returns the string "BoxParticleEmitter"
  13167. * @returns a string containing the class name
  13168. */
  13169. getClassName(): string;
  13170. /**
  13171. * Serializes the particle system to a JSON object.
  13172. * @returns the JSON object
  13173. */
  13174. serialize(): any;
  13175. /**
  13176. * Parse properties from a JSON object
  13177. * @param serializationObject defines the JSON object
  13178. */
  13179. parse(serializationObject: any): void;
  13180. }
  13181. }
  13182. declare module BABYLON {
  13183. /**
  13184. * Particle emitter emitting particles from the inside of a cone.
  13185. * It emits the particles alongside the cone volume from the base to the particle.
  13186. * The emission direction might be randomized.
  13187. */
  13188. export class ConeParticleEmitter implements IParticleEmitterType {
  13189. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13190. directionRandomizer: number;
  13191. private _radius;
  13192. private _angle;
  13193. private _height;
  13194. /**
  13195. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13196. */
  13197. radiusRange: number;
  13198. /**
  13199. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13200. */
  13201. heightRange: number;
  13202. /**
  13203. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13204. */
  13205. emitFromSpawnPointOnly: boolean;
  13206. /**
  13207. * Gets or sets the radius of the emission cone
  13208. */
  13209. get radius(): number;
  13210. set radius(value: number);
  13211. /**
  13212. * Gets or sets the angle of the emission cone
  13213. */
  13214. get angle(): number;
  13215. set angle(value: number);
  13216. private _buildHeight;
  13217. /**
  13218. * Creates a new instance ConeParticleEmitter
  13219. * @param radius the radius of the emission cone (1 by default)
  13220. * @param angle the cone base angle (PI by default)
  13221. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13222. */
  13223. constructor(radius?: number, angle?: number,
  13224. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13225. directionRandomizer?: number);
  13226. /**
  13227. * Called by the particle System when the direction is computed for the created particle.
  13228. * @param worldMatrix is the world matrix of the particle system
  13229. * @param directionToUpdate is the direction vector to update with the result
  13230. * @param particle is the particle we are computed the direction for
  13231. * @param isLocal defines if the direction should be set in local space
  13232. */
  13233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13234. /**
  13235. * Called by the particle System when the position is computed for the created particle.
  13236. * @param worldMatrix is the world matrix of the particle system
  13237. * @param positionToUpdate is the position vector to update with the result
  13238. * @param particle is the particle we are computed the position for
  13239. * @param isLocal defines if the position should be set in local space
  13240. */
  13241. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13242. /**
  13243. * Clones the current emitter and returns a copy of it
  13244. * @returns the new emitter
  13245. */
  13246. clone(): ConeParticleEmitter;
  13247. /**
  13248. * Called by the GPUParticleSystem to setup the update shader
  13249. * @param effect defines the update shader
  13250. */
  13251. applyToShader(effect: Effect): void;
  13252. /**
  13253. * Returns a string to use to update the GPU particles update shader
  13254. * @returns a string containng the defines string
  13255. */
  13256. getEffectDefines(): string;
  13257. /**
  13258. * Returns the string "ConeParticleEmitter"
  13259. * @returns a string containing the class name
  13260. */
  13261. getClassName(): string;
  13262. /**
  13263. * Serializes the particle system to a JSON object.
  13264. * @returns the JSON object
  13265. */
  13266. serialize(): any;
  13267. /**
  13268. * Parse properties from a JSON object
  13269. * @param serializationObject defines the JSON object
  13270. */
  13271. parse(serializationObject: any): void;
  13272. }
  13273. }
  13274. declare module BABYLON {
  13275. /**
  13276. * Particle emitter emitting particles from the inside of a cylinder.
  13277. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13278. */
  13279. export class CylinderParticleEmitter implements IParticleEmitterType {
  13280. /**
  13281. * The radius of the emission cylinder.
  13282. */
  13283. radius: number;
  13284. /**
  13285. * The height of the emission cylinder.
  13286. */
  13287. height: number;
  13288. /**
  13289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13290. */
  13291. radiusRange: number;
  13292. /**
  13293. * How much to randomize the particle direction [0-1].
  13294. */
  13295. directionRandomizer: number;
  13296. /**
  13297. * Creates a new instance CylinderParticleEmitter
  13298. * @param radius the radius of the emission cylinder (1 by default)
  13299. * @param height the height of the emission cylinder (1 by default)
  13300. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13301. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13302. */
  13303. constructor(
  13304. /**
  13305. * The radius of the emission cylinder.
  13306. */
  13307. radius?: number,
  13308. /**
  13309. * The height of the emission cylinder.
  13310. */
  13311. height?: number,
  13312. /**
  13313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13314. */
  13315. radiusRange?: number,
  13316. /**
  13317. * How much to randomize the particle direction [0-1].
  13318. */
  13319. directionRandomizer?: number);
  13320. /**
  13321. * Called by the particle System when the direction is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param directionToUpdate is the direction vector to update with the result
  13324. * @param particle is the particle we are computed the direction for
  13325. * @param isLocal defines if the direction should be set in local space
  13326. */
  13327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13328. /**
  13329. * Called by the particle System when the position is computed for the created particle.
  13330. * @param worldMatrix is the world matrix of the particle system
  13331. * @param positionToUpdate is the position vector to update with the result
  13332. * @param particle is the particle we are computed the position for
  13333. * @param isLocal defines if the position should be set in local space
  13334. */
  13335. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13336. /**
  13337. * Clones the current emitter and returns a copy of it
  13338. * @returns the new emitter
  13339. */
  13340. clone(): CylinderParticleEmitter;
  13341. /**
  13342. * Called by the GPUParticleSystem to setup the update shader
  13343. * @param effect defines the update shader
  13344. */
  13345. applyToShader(effect: Effect): void;
  13346. /**
  13347. * Returns a string to use to update the GPU particles update shader
  13348. * @returns a string containng the defines string
  13349. */
  13350. getEffectDefines(): string;
  13351. /**
  13352. * Returns the string "CylinderParticleEmitter"
  13353. * @returns a string containing the class name
  13354. */
  13355. getClassName(): string;
  13356. /**
  13357. * Serializes the particle system to a JSON object.
  13358. * @returns the JSON object
  13359. */
  13360. serialize(): any;
  13361. /**
  13362. * Parse properties from a JSON object
  13363. * @param serializationObject defines the JSON object
  13364. */
  13365. parse(serializationObject: any): void;
  13366. }
  13367. /**
  13368. * Particle emitter emitting particles from the inside of a cylinder.
  13369. * It emits the particles randomly between two vectors.
  13370. */
  13371. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13372. /**
  13373. * The min limit of the emission direction.
  13374. */
  13375. direction1: Vector3;
  13376. /**
  13377. * The max limit of the emission direction.
  13378. */
  13379. direction2: Vector3;
  13380. /**
  13381. * Creates a new instance CylinderDirectedParticleEmitter
  13382. * @param radius the radius of the emission cylinder (1 by default)
  13383. * @param height the height of the emission cylinder (1 by default)
  13384. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13385. * @param direction1 the min limit of the emission direction (up vector by default)
  13386. * @param direction2 the max limit of the emission direction (up vector by default)
  13387. */
  13388. constructor(radius?: number, height?: number, radiusRange?: number,
  13389. /**
  13390. * The min limit of the emission direction.
  13391. */
  13392. direction1?: Vector3,
  13393. /**
  13394. * The max limit of the emission direction.
  13395. */
  13396. direction2?: Vector3);
  13397. /**
  13398. * Called by the particle System when the direction is computed for the created particle.
  13399. * @param worldMatrix is the world matrix of the particle system
  13400. * @param directionToUpdate is the direction vector to update with the result
  13401. * @param particle is the particle we are computed the direction for
  13402. */
  13403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13404. /**
  13405. * Clones the current emitter and returns a copy of it
  13406. * @returns the new emitter
  13407. */
  13408. clone(): CylinderDirectedParticleEmitter;
  13409. /**
  13410. * Called by the GPUParticleSystem to setup the update shader
  13411. * @param effect defines the update shader
  13412. */
  13413. applyToShader(effect: Effect): void;
  13414. /**
  13415. * Returns a string to use to update the GPU particles update shader
  13416. * @returns a string containng the defines string
  13417. */
  13418. getEffectDefines(): string;
  13419. /**
  13420. * Returns the string "CylinderDirectedParticleEmitter"
  13421. * @returns a string containing the class name
  13422. */
  13423. getClassName(): string;
  13424. /**
  13425. * Serializes the particle system to a JSON object.
  13426. * @returns the JSON object
  13427. */
  13428. serialize(): any;
  13429. /**
  13430. * Parse properties from a JSON object
  13431. * @param serializationObject defines the JSON object
  13432. */
  13433. parse(serializationObject: any): void;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * Particle emitter emitting particles from the inside of a hemisphere.
  13439. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13440. */
  13441. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13442. /**
  13443. * The radius of the emission hemisphere.
  13444. */
  13445. radius: number;
  13446. /**
  13447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13448. */
  13449. radiusRange: number;
  13450. /**
  13451. * How much to randomize the particle direction [0-1].
  13452. */
  13453. directionRandomizer: number;
  13454. /**
  13455. * Creates a new instance HemisphericParticleEmitter
  13456. * @param radius the radius of the emission hemisphere (1 by default)
  13457. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13459. */
  13460. constructor(
  13461. /**
  13462. * The radius of the emission hemisphere.
  13463. */
  13464. radius?: number,
  13465. /**
  13466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13467. */
  13468. radiusRange?: number,
  13469. /**
  13470. * How much to randomize the particle direction [0-1].
  13471. */
  13472. directionRandomizer?: number);
  13473. /**
  13474. * Called by the particle System when the direction is computed for the created particle.
  13475. * @param worldMatrix is the world matrix of the particle system
  13476. * @param directionToUpdate is the direction vector to update with the result
  13477. * @param particle is the particle we are computed the direction for
  13478. * @param isLocal defines if the direction should be set in local space
  13479. */
  13480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13481. /**
  13482. * Called by the particle System when the position is computed for the created particle.
  13483. * @param worldMatrix is the world matrix of the particle system
  13484. * @param positionToUpdate is the position vector to update with the result
  13485. * @param particle is the particle we are computed the position for
  13486. * @param isLocal defines if the position should be set in local space
  13487. */
  13488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13489. /**
  13490. * Clones the current emitter and returns a copy of it
  13491. * @returns the new emitter
  13492. */
  13493. clone(): HemisphericParticleEmitter;
  13494. /**
  13495. * Called by the GPUParticleSystem to setup the update shader
  13496. * @param effect defines the update shader
  13497. */
  13498. applyToShader(effect: Effect): void;
  13499. /**
  13500. * Returns a string to use to update the GPU particles update shader
  13501. * @returns a string containng the defines string
  13502. */
  13503. getEffectDefines(): string;
  13504. /**
  13505. * Returns the string "HemisphericParticleEmitter"
  13506. * @returns a string containing the class name
  13507. */
  13508. getClassName(): string;
  13509. /**
  13510. * Serializes the particle system to a JSON object.
  13511. * @returns the JSON object
  13512. */
  13513. serialize(): any;
  13514. /**
  13515. * Parse properties from a JSON object
  13516. * @param serializationObject defines the JSON object
  13517. */
  13518. parse(serializationObject: any): void;
  13519. }
  13520. }
  13521. declare module BABYLON {
  13522. /**
  13523. * Particle emitter emitting particles from a point.
  13524. * It emits the particles randomly between 2 given directions.
  13525. */
  13526. export class PointParticleEmitter implements IParticleEmitterType {
  13527. /**
  13528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13529. */
  13530. direction1: Vector3;
  13531. /**
  13532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13533. */
  13534. direction2: Vector3;
  13535. /**
  13536. * Creates a new instance PointParticleEmitter
  13537. */
  13538. constructor();
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): PointParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "PointParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a sphere.
  13590. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13591. */
  13592. export class SphereParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * The radius of the emission sphere.
  13595. */
  13596. radius: number;
  13597. /**
  13598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13599. */
  13600. radiusRange: number;
  13601. /**
  13602. * How much to randomize the particle direction [0-1].
  13603. */
  13604. directionRandomizer: number;
  13605. /**
  13606. * Creates a new instance SphereParticleEmitter
  13607. * @param radius the radius of the emission sphere (1 by default)
  13608. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13610. */
  13611. constructor(
  13612. /**
  13613. * The radius of the emission sphere.
  13614. */
  13615. radius?: number,
  13616. /**
  13617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13618. */
  13619. radiusRange?: number,
  13620. /**
  13621. * How much to randomize the particle direction [0-1].
  13622. */
  13623. directionRandomizer?: number);
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): SphereParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "SphereParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. /**
  13672. * Particle emitter emitting particles from the inside of a sphere.
  13673. * It emits the particles randomly between two vectors.
  13674. */
  13675. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13676. /**
  13677. * The min limit of the emission direction.
  13678. */
  13679. direction1: Vector3;
  13680. /**
  13681. * The max limit of the emission direction.
  13682. */
  13683. direction2: Vector3;
  13684. /**
  13685. * Creates a new instance SphereDirectedParticleEmitter
  13686. * @param radius the radius of the emission sphere (1 by default)
  13687. * @param direction1 the min limit of the emission direction (up vector by default)
  13688. * @param direction2 the max limit of the emission direction (up vector by default)
  13689. */
  13690. constructor(radius?: number,
  13691. /**
  13692. * The min limit of the emission direction.
  13693. */
  13694. direction1?: Vector3,
  13695. /**
  13696. * The max limit of the emission direction.
  13697. */
  13698. direction2?: Vector3);
  13699. /**
  13700. * Called by the particle System when the direction is computed for the created particle.
  13701. * @param worldMatrix is the world matrix of the particle system
  13702. * @param directionToUpdate is the direction vector to update with the result
  13703. * @param particle is the particle we are computed the direction for
  13704. */
  13705. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): SphereDirectedParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "SphereDirectedParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module BABYLON {
  13739. /**
  13740. * Particle emitter emitting particles from a custom list of positions.
  13741. */
  13742. export class CustomParticleEmitter implements IParticleEmitterType {
  13743. /**
  13744. * Gets or sets the position generator that will create the inital position of each particle.
  13745. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13746. */
  13747. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13748. /**
  13749. * Gets or sets the destination generator that will create the final destination of each particle.
  13750. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13751. */
  13752. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13753. /**
  13754. * Creates a new instance CustomParticleEmitter
  13755. */
  13756. constructor();
  13757. /**
  13758. * Called by the particle System when the direction is computed for the created particle.
  13759. * @param worldMatrix is the world matrix of the particle system
  13760. * @param directionToUpdate is the direction vector to update with the result
  13761. * @param particle is the particle we are computed the direction for
  13762. * @param isLocal defines if the direction should be set in local space
  13763. */
  13764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13765. /**
  13766. * Called by the particle System when the position is computed for the created particle.
  13767. * @param worldMatrix is the world matrix of the particle system
  13768. * @param positionToUpdate is the position vector to update with the result
  13769. * @param particle is the particle we are computed the position for
  13770. * @param isLocal defines if the position should be set in local space
  13771. */
  13772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13773. /**
  13774. * Clones the current emitter and returns a copy of it
  13775. * @returns the new emitter
  13776. */
  13777. clone(): CustomParticleEmitter;
  13778. /**
  13779. * Called by the GPUParticleSystem to setup the update shader
  13780. * @param effect defines the update shader
  13781. */
  13782. applyToShader(effect: Effect): void;
  13783. /**
  13784. * Returns a string to use to update the GPU particles update shader
  13785. * @returns a string containng the defines string
  13786. */
  13787. getEffectDefines(): string;
  13788. /**
  13789. * Returns the string "PointParticleEmitter"
  13790. * @returns a string containing the class name
  13791. */
  13792. getClassName(): string;
  13793. /**
  13794. * Serializes the particle system to a JSON object.
  13795. * @returns the JSON object
  13796. */
  13797. serialize(): any;
  13798. /**
  13799. * Parse properties from a JSON object
  13800. * @param serializationObject defines the JSON object
  13801. */
  13802. parse(serializationObject: any): void;
  13803. }
  13804. }
  13805. declare module BABYLON {
  13806. /**
  13807. * Particle emitter emitting particles from the inside of a box.
  13808. * It emits the particles randomly between 2 given directions.
  13809. */
  13810. export class MeshParticleEmitter implements IParticleEmitterType {
  13811. private _indices;
  13812. private _positions;
  13813. private _normals;
  13814. private _storedNormal;
  13815. private _mesh;
  13816. /**
  13817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13818. */
  13819. direction1: Vector3;
  13820. /**
  13821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13822. */
  13823. direction2: Vector3;
  13824. /**
  13825. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13826. */
  13827. useMeshNormalsForDirection: boolean;
  13828. /** Defines the mesh to use as source */
  13829. get mesh(): Nullable<AbstractMesh>;
  13830. set mesh(value: Nullable<AbstractMesh>);
  13831. /**
  13832. * Creates a new instance MeshParticleEmitter
  13833. * @param mesh defines the mesh to use as source
  13834. */
  13835. constructor(mesh?: Nullable<AbstractMesh>);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): MeshParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "BoxParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. * @param scene defines the hosting scene
  13881. */
  13882. parse(serializationObject: any, scene: Scene): void;
  13883. }
  13884. }
  13885. declare module BABYLON {
  13886. /**
  13887. * Interface representing a particle system in Babylon.js.
  13888. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13889. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13890. */
  13891. export interface IParticleSystem {
  13892. /**
  13893. * List of animations used by the particle system.
  13894. */
  13895. animations: Animation[];
  13896. /**
  13897. * The id of the Particle system.
  13898. */
  13899. id: string;
  13900. /**
  13901. * The name of the Particle system.
  13902. */
  13903. name: string;
  13904. /**
  13905. * The emitter represents the Mesh or position we are attaching the particle system to.
  13906. */
  13907. emitter: Nullable<AbstractMesh | Vector3>;
  13908. /**
  13909. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13910. */
  13911. isBillboardBased: boolean;
  13912. /**
  13913. * The rendering group used by the Particle system to chose when to render.
  13914. */
  13915. renderingGroupId: number;
  13916. /**
  13917. * The layer mask we are rendering the particles through.
  13918. */
  13919. layerMask: number;
  13920. /**
  13921. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13922. */
  13923. updateSpeed: number;
  13924. /**
  13925. * The amount of time the particle system is running (depends of the overall update speed).
  13926. */
  13927. targetStopDuration: number;
  13928. /**
  13929. * The texture used to render each particle. (this can be a spritesheet)
  13930. */
  13931. particleTexture: Nullable<Texture>;
  13932. /**
  13933. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13934. */
  13935. blendMode: number;
  13936. /**
  13937. * Minimum life time of emitting particles.
  13938. */
  13939. minLifeTime: number;
  13940. /**
  13941. * Maximum life time of emitting particles.
  13942. */
  13943. maxLifeTime: number;
  13944. /**
  13945. * Minimum Size of emitting particles.
  13946. */
  13947. minSize: number;
  13948. /**
  13949. * Maximum Size of emitting particles.
  13950. */
  13951. maxSize: number;
  13952. /**
  13953. * Minimum scale of emitting particles on X axis.
  13954. */
  13955. minScaleX: number;
  13956. /**
  13957. * Maximum scale of emitting particles on X axis.
  13958. */
  13959. maxScaleX: number;
  13960. /**
  13961. * Minimum scale of emitting particles on Y axis.
  13962. */
  13963. minScaleY: number;
  13964. /**
  13965. * Maximum scale of emitting particles on Y axis.
  13966. */
  13967. maxScaleY: number;
  13968. /**
  13969. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13970. */
  13971. color1: Color4;
  13972. /**
  13973. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13974. */
  13975. color2: Color4;
  13976. /**
  13977. * Color the particle will have at the end of its lifetime.
  13978. */
  13979. colorDead: Color4;
  13980. /**
  13981. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13982. */
  13983. emitRate: number;
  13984. /**
  13985. * You can use gravity if you want to give an orientation to your particles.
  13986. */
  13987. gravity: Vector3;
  13988. /**
  13989. * Minimum power of emitting particles.
  13990. */
  13991. minEmitPower: number;
  13992. /**
  13993. * Maximum power of emitting particles.
  13994. */
  13995. maxEmitPower: number;
  13996. /**
  13997. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13998. */
  13999. minAngularSpeed: number;
  14000. /**
  14001. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14002. */
  14003. maxAngularSpeed: number;
  14004. /**
  14005. * Gets or sets the minimal initial rotation in radians.
  14006. */
  14007. minInitialRotation: number;
  14008. /**
  14009. * Gets or sets the maximal initial rotation in radians.
  14010. */
  14011. maxInitialRotation: number;
  14012. /**
  14013. * The particle emitter type defines the emitter used by the particle system.
  14014. * It can be for example box, sphere, or cone...
  14015. */
  14016. particleEmitterType: Nullable<IParticleEmitterType>;
  14017. /**
  14018. * Defines the delay in milliseconds before starting the system (0 by default)
  14019. */
  14020. startDelay: number;
  14021. /**
  14022. * 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
  14023. */
  14024. preWarmCycles: number;
  14025. /**
  14026. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14027. */
  14028. preWarmStepOffset: number;
  14029. /**
  14030. * 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)
  14031. */
  14032. spriteCellChangeSpeed: number;
  14033. /**
  14034. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14035. */
  14036. startSpriteCellID: number;
  14037. /**
  14038. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14039. */
  14040. endSpriteCellID: number;
  14041. /**
  14042. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14043. */
  14044. spriteCellWidth: number;
  14045. /**
  14046. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14047. */
  14048. spriteCellHeight: number;
  14049. /**
  14050. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14051. */
  14052. spriteRandomStartCell: boolean;
  14053. /**
  14054. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14055. */
  14056. isAnimationSheetEnabled: boolean;
  14057. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14058. translationPivot: Vector2;
  14059. /**
  14060. * Gets or sets a texture used to add random noise to particle positions
  14061. */
  14062. noiseTexture: Nullable<BaseTexture>;
  14063. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14064. noiseStrength: Vector3;
  14065. /**
  14066. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14067. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14068. */
  14069. billboardMode: number;
  14070. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14071. limitVelocityDamping: number;
  14072. /**
  14073. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14074. */
  14075. beginAnimationOnStart: boolean;
  14076. /**
  14077. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14078. */
  14079. beginAnimationFrom: number;
  14080. /**
  14081. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14082. */
  14083. beginAnimationTo: number;
  14084. /**
  14085. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14086. */
  14087. beginAnimationLoop: boolean;
  14088. /**
  14089. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14090. */
  14091. disposeOnStop: boolean;
  14092. /**
  14093. * Specifies if the particles are updated in emitter local space or world space
  14094. */
  14095. isLocal: boolean;
  14096. /** Snippet ID if the particle system was created from the snippet server */
  14097. snippetId: string;
  14098. /**
  14099. * Gets the maximum number of particles active at the same time.
  14100. * @returns The max number of active particles.
  14101. */
  14102. getCapacity(): number;
  14103. /**
  14104. * Gets the number of particles active at the same time.
  14105. * @returns The number of active particles.
  14106. */
  14107. getActiveCount(): number;
  14108. /**
  14109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14110. * @returns True if it has been started, otherwise false.
  14111. */
  14112. isStarted(): boolean;
  14113. /**
  14114. * Animates the particle system for this frame.
  14115. */
  14116. animate(): void;
  14117. /**
  14118. * Renders the particle system in its current state.
  14119. * @returns the current number of particles
  14120. */
  14121. render(): number;
  14122. /**
  14123. * Dispose the particle system and frees its associated resources.
  14124. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14125. */
  14126. dispose(disposeTexture?: boolean): void;
  14127. /**
  14128. * An event triggered when the system is disposed
  14129. */
  14130. onDisposeObservable: Observable<IParticleSystem>;
  14131. /**
  14132. * Clones the particle system.
  14133. * @param name The name of the cloned object
  14134. * @param newEmitter The new emitter to use
  14135. * @returns the cloned particle system
  14136. */
  14137. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14138. /**
  14139. * Serializes the particle system to a JSON object
  14140. * @param serializeTexture defines if the texture must be serialized as well
  14141. * @returns the JSON object
  14142. */
  14143. serialize(serializeTexture: boolean): any;
  14144. /**
  14145. * Rebuild the particle system
  14146. */
  14147. rebuild(): void;
  14148. /** Force the system to rebuild all gradients that need to be resync */
  14149. forceRefreshGradients(): void;
  14150. /**
  14151. * Starts the particle system and begins to emit
  14152. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14153. */
  14154. start(delay?: number): void;
  14155. /**
  14156. * Stops the particle system.
  14157. */
  14158. stop(): void;
  14159. /**
  14160. * Remove all active particles
  14161. */
  14162. reset(): void;
  14163. /**
  14164. * Gets a boolean indicating that the system is stopping
  14165. * @returns true if the system is currently stopping
  14166. */
  14167. isStopping(): boolean;
  14168. /**
  14169. * Is this system ready to be used/rendered
  14170. * @return true if the system is ready
  14171. */
  14172. isReady(): boolean;
  14173. /**
  14174. * Returns the string "ParticleSystem"
  14175. * @returns a string containing the class name
  14176. */
  14177. getClassName(): string;
  14178. /**
  14179. * Gets the custom effect used to render the particles
  14180. * @param blendMode Blend mode for which the effect should be retrieved
  14181. * @returns The effect
  14182. */
  14183. getCustomEffect(blendMode: number): Nullable<Effect>;
  14184. /**
  14185. * Sets the custom effect used to render the particles
  14186. * @param effect The effect to set
  14187. * @param blendMode Blend mode for which the effect should be set
  14188. */
  14189. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14190. /**
  14191. * Fill the defines array according to the current settings of the particle system
  14192. * @param defines Array to be updated
  14193. * @param blendMode blend mode to take into account when updating the array
  14194. */
  14195. fillDefines(defines: Array<string>, blendMode: number): void;
  14196. /**
  14197. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14198. * @param uniforms Uniforms array to fill
  14199. * @param attributes Attributes array to fill
  14200. * @param samplers Samplers array to fill
  14201. */
  14202. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14203. /**
  14204. * Observable that will be called just before the particles are drawn
  14205. */
  14206. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14207. /**
  14208. * Gets the name of the particle vertex shader
  14209. */
  14210. vertexShaderName: string;
  14211. /**
  14212. * Adds a new color gradient
  14213. * @param gradient defines the gradient to use (between 0 and 1)
  14214. * @param color1 defines the color to affect to the specified gradient
  14215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14216. * @returns the current particle system
  14217. */
  14218. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14219. /**
  14220. * Remove a specific color gradient
  14221. * @param gradient defines the gradient to remove
  14222. * @returns the current particle system
  14223. */
  14224. removeColorGradient(gradient: number): IParticleSystem;
  14225. /**
  14226. * Adds a new size gradient
  14227. * @param gradient defines the gradient to use (between 0 and 1)
  14228. * @param factor defines the size factor to affect to the specified gradient
  14229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14230. * @returns the current particle system
  14231. */
  14232. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14233. /**
  14234. * Remove a specific size gradient
  14235. * @param gradient defines the gradient to remove
  14236. * @returns the current particle system
  14237. */
  14238. removeSizeGradient(gradient: number): IParticleSystem;
  14239. /**
  14240. * Gets the current list of color gradients.
  14241. * You must use addColorGradient and removeColorGradient to udpate this list
  14242. * @returns the list of color gradients
  14243. */
  14244. getColorGradients(): Nullable<Array<ColorGradient>>;
  14245. /**
  14246. * Gets the current list of size gradients.
  14247. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14248. * @returns the list of size gradients
  14249. */
  14250. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14251. /**
  14252. * Gets the current list of angular speed gradients.
  14253. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14254. * @returns the list of angular speed gradients
  14255. */
  14256. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14257. /**
  14258. * Adds a new angular speed gradient
  14259. * @param gradient defines the gradient to use (between 0 and 1)
  14260. * @param factor defines the angular speed to affect to the specified gradient
  14261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14262. * @returns the current particle system
  14263. */
  14264. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14265. /**
  14266. * Remove a specific angular speed gradient
  14267. * @param gradient defines the gradient to remove
  14268. * @returns the current particle system
  14269. */
  14270. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14271. /**
  14272. * Gets the current list of velocity gradients.
  14273. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14274. * @returns the list of velocity gradients
  14275. */
  14276. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14277. /**
  14278. * Adds a new velocity gradient
  14279. * @param gradient defines the gradient to use (between 0 and 1)
  14280. * @param factor defines the velocity to affect to the specified gradient
  14281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14282. * @returns the current particle system
  14283. */
  14284. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14285. /**
  14286. * Remove a specific velocity gradient
  14287. * @param gradient defines the gradient to remove
  14288. * @returns the current particle system
  14289. */
  14290. removeVelocityGradient(gradient: number): IParticleSystem;
  14291. /**
  14292. * Gets the current list of limit velocity gradients.
  14293. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14294. * @returns the list of limit velocity gradients
  14295. */
  14296. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14297. /**
  14298. * Adds a new limit velocity gradient
  14299. * @param gradient defines the gradient to use (between 0 and 1)
  14300. * @param factor defines the limit velocity to affect to the specified gradient
  14301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14302. * @returns the current particle system
  14303. */
  14304. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14305. /**
  14306. * Remove a specific limit velocity gradient
  14307. * @param gradient defines the gradient to remove
  14308. * @returns the current particle system
  14309. */
  14310. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14311. /**
  14312. * Adds a new drag gradient
  14313. * @param gradient defines the gradient to use (between 0 and 1)
  14314. * @param factor defines the drag to affect to the specified gradient
  14315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14316. * @returns the current particle system
  14317. */
  14318. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14319. /**
  14320. * Remove a specific drag gradient
  14321. * @param gradient defines the gradient to remove
  14322. * @returns the current particle system
  14323. */
  14324. removeDragGradient(gradient: number): IParticleSystem;
  14325. /**
  14326. * Gets the current list of drag gradients.
  14327. * You must use addDragGradient and removeDragGradient to udpate this list
  14328. * @returns the list of drag gradients
  14329. */
  14330. getDragGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14333. * @param gradient defines the gradient to use (between 0 and 1)
  14334. * @param factor defines the emit rate to affect to the specified gradient
  14335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14336. * @returns the current particle system
  14337. */
  14338. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14339. /**
  14340. * Remove a specific emit rate gradient
  14341. * @param gradient defines the gradient to remove
  14342. * @returns the current particle system
  14343. */
  14344. removeEmitRateGradient(gradient: number): IParticleSystem;
  14345. /**
  14346. * Gets the current list of emit rate gradients.
  14347. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14348. * @returns the list of emit rate gradients
  14349. */
  14350. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14351. /**
  14352. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14353. * @param gradient defines the gradient to use (between 0 and 1)
  14354. * @param factor defines the start size to affect to the specified gradient
  14355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14356. * @returns the current particle system
  14357. */
  14358. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14359. /**
  14360. * Remove a specific start size gradient
  14361. * @param gradient defines the gradient to remove
  14362. * @returns the current particle system
  14363. */
  14364. removeStartSizeGradient(gradient: number): IParticleSystem;
  14365. /**
  14366. * Gets the current list of start size gradients.
  14367. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14368. * @returns the list of start size gradients
  14369. */
  14370. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14371. /**
  14372. * Adds a new life time gradient
  14373. * @param gradient defines the gradient to use (between 0 and 1)
  14374. * @param factor defines the life time factor to affect to the specified gradient
  14375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14376. * @returns the current particle system
  14377. */
  14378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14379. /**
  14380. * Remove a specific life time gradient
  14381. * @param gradient defines the gradient to remove
  14382. * @returns the current particle system
  14383. */
  14384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of color gradients.
  14393. * You must use addColorGradient and removeColorGradient to udpate this list
  14394. * @returns the list of color gradients
  14395. */
  14396. getColorGradients(): Nullable<Array<ColorGradient>>;
  14397. /**
  14398. * Adds a new ramp gradient used to remap particle colors
  14399. * @param gradient defines the gradient to use (between 0 and 1)
  14400. * @param color defines the color to affect to the specified gradient
  14401. * @returns the current particle system
  14402. */
  14403. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14404. /**
  14405. * Gets the current list of ramp gradients.
  14406. * You must use addRampGradient and removeRampGradient to udpate this list
  14407. * @returns the list of ramp gradients
  14408. */
  14409. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14410. /** Gets or sets a boolean indicating that ramp gradients must be used
  14411. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14412. */
  14413. useRampGradients: boolean;
  14414. /**
  14415. * Adds a new color remap gradient
  14416. * @param gradient defines the gradient to use (between 0 and 1)
  14417. * @param min defines the color remap minimal range
  14418. * @param max defines the color remap maximal range
  14419. * @returns the current particle system
  14420. */
  14421. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14422. /**
  14423. * Gets the current list of color remap gradients.
  14424. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14425. * @returns the list of color remap gradients
  14426. */
  14427. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14428. /**
  14429. * Adds a new alpha remap gradient
  14430. * @param gradient defines the gradient to use (between 0 and 1)
  14431. * @param min defines the alpha remap minimal range
  14432. * @param max defines the alpha remap maximal range
  14433. * @returns the current particle system
  14434. */
  14435. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14436. /**
  14437. * Gets the current list of alpha remap gradients.
  14438. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14439. * @returns the list of alpha remap gradients
  14440. */
  14441. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14446. * @returns the emitter
  14447. */
  14448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14449. /**
  14450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14451. * @param radius The radius of the hemisphere to emit from
  14452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14453. * @returns the emitter
  14454. */
  14455. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14456. /**
  14457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14458. * @param radius The radius of the sphere to emit from
  14459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14460. * @returns the emitter
  14461. */
  14462. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14463. /**
  14464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14465. * @param radius The radius of the sphere to emit from
  14466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14468. * @returns the emitter
  14469. */
  14470. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14471. /**
  14472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14473. * @param radius The radius of the emission cylinder
  14474. * @param height The height of the emission cylinder
  14475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14477. * @returns the emitter
  14478. */
  14479. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14480. /**
  14481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14482. * @param radius The radius of the cylinder to emit from
  14483. * @param height The height of the emission cylinder
  14484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14487. * @returns the emitter
  14488. */
  14489. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14490. /**
  14491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14492. * @param radius The radius of the cone to emit from
  14493. * @param angle The base angle of the cone
  14494. * @returns the emitter
  14495. */
  14496. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14497. /**
  14498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14503. * @returns the emitter
  14504. */
  14505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14506. /**
  14507. * Get hosting scene
  14508. * @returns the scene
  14509. */
  14510. getScene(): Scene;
  14511. }
  14512. }
  14513. declare module BABYLON {
  14514. /**
  14515. * 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.
  14516. * @see https://doc.babylonjs.com/how_to/transformnode
  14517. */
  14518. export class TransformNode extends Node {
  14519. /**
  14520. * Object will not rotate to face the camera
  14521. */
  14522. static BILLBOARDMODE_NONE: number;
  14523. /**
  14524. * Object will rotate to face the camera but only on the x axis
  14525. */
  14526. static BILLBOARDMODE_X: number;
  14527. /**
  14528. * Object will rotate to face the camera but only on the y axis
  14529. */
  14530. static BILLBOARDMODE_Y: number;
  14531. /**
  14532. * Object will rotate to face the camera but only on the z axis
  14533. */
  14534. static BILLBOARDMODE_Z: number;
  14535. /**
  14536. * Object will rotate to face the camera
  14537. */
  14538. static BILLBOARDMODE_ALL: number;
  14539. /**
  14540. * Object will rotate to face the camera's position instead of orientation
  14541. */
  14542. static BILLBOARDMODE_USE_POSITION: number;
  14543. private _forward;
  14544. private _forwardInverted;
  14545. private _up;
  14546. private _right;
  14547. private _rightInverted;
  14548. private _position;
  14549. private _rotation;
  14550. private _rotationQuaternion;
  14551. protected _scaling: Vector3;
  14552. protected _isDirty: boolean;
  14553. private _transformToBoneReferal;
  14554. private _isAbsoluteSynced;
  14555. private _billboardMode;
  14556. /**
  14557. * Gets or sets the billboard mode. Default is 0.
  14558. *
  14559. * | Value | Type | Description |
  14560. * | --- | --- | --- |
  14561. * | 0 | BILLBOARDMODE_NONE | |
  14562. * | 1 | BILLBOARDMODE_X | |
  14563. * | 2 | BILLBOARDMODE_Y | |
  14564. * | 4 | BILLBOARDMODE_Z | |
  14565. * | 7 | BILLBOARDMODE_ALL | |
  14566. *
  14567. */
  14568. get billboardMode(): number;
  14569. set billboardMode(value: number);
  14570. private _preserveParentRotationForBillboard;
  14571. /**
  14572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14574. */
  14575. get preserveParentRotationForBillboard(): boolean;
  14576. set preserveParentRotationForBillboard(value: boolean);
  14577. /**
  14578. * 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
  14579. */
  14580. scalingDeterminant: number;
  14581. private _infiniteDistance;
  14582. /**
  14583. * Gets or sets the distance of the object to max, often used by skybox
  14584. */
  14585. get infiniteDistance(): boolean;
  14586. set infiniteDistance(value: boolean);
  14587. /**
  14588. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14589. * By default the system will update normals to compensate
  14590. */
  14591. ignoreNonUniformScaling: boolean;
  14592. /**
  14593. * 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
  14594. */
  14595. reIntegrateRotationIntoRotationQuaternion: boolean;
  14596. /** @hidden */
  14597. _poseMatrix: Nullable<Matrix>;
  14598. /** @hidden */
  14599. _localMatrix: Matrix;
  14600. private _usePivotMatrix;
  14601. private _absolutePosition;
  14602. private _absoluteScaling;
  14603. private _absoluteRotationQuaternion;
  14604. private _pivotMatrix;
  14605. private _pivotMatrixInverse;
  14606. protected _postMultiplyPivotMatrix: boolean;
  14607. protected _isWorldMatrixFrozen: boolean;
  14608. /** @hidden */
  14609. _indexInSceneTransformNodesArray: number;
  14610. /**
  14611. * An event triggered after the world matrix is updated
  14612. */
  14613. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14614. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14615. /**
  14616. * Gets a string identifying the name of the class
  14617. * @returns "TransformNode" string
  14618. */
  14619. getClassName(): string;
  14620. /**
  14621. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14622. */
  14623. get position(): Vector3;
  14624. set position(newPosition: Vector3);
  14625. /**
  14626. * 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)).
  14627. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14628. */
  14629. get rotation(): Vector3;
  14630. set rotation(newRotation: Vector3);
  14631. /**
  14632. * 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)).
  14633. */
  14634. get scaling(): Vector3;
  14635. set scaling(newScaling: Vector3);
  14636. /**
  14637. * 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).
  14638. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14639. */
  14640. get rotationQuaternion(): Nullable<Quaternion>;
  14641. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14642. /**
  14643. * The forward direction of that transform in world space.
  14644. */
  14645. get forward(): Vector3;
  14646. /**
  14647. * The up direction of that transform in world space.
  14648. */
  14649. get up(): Vector3;
  14650. /**
  14651. * The right direction of that transform in world space.
  14652. */
  14653. get right(): Vector3;
  14654. /**
  14655. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14656. * @param matrix the matrix to copy the pose from
  14657. * @returns this TransformNode.
  14658. */
  14659. updatePoseMatrix(matrix: Matrix): TransformNode;
  14660. /**
  14661. * Returns the mesh Pose matrix.
  14662. * @returns the pose matrix
  14663. */
  14664. getPoseMatrix(): Matrix;
  14665. /** @hidden */
  14666. _isSynchronized(): boolean;
  14667. /** @hidden */
  14668. _initCache(): void;
  14669. /**
  14670. * Flag the transform node as dirty (Forcing it to update everything)
  14671. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14672. * @returns this transform node
  14673. */
  14674. markAsDirty(property: string): TransformNode;
  14675. /**
  14676. * Returns the current mesh absolute position.
  14677. * Returns a Vector3.
  14678. */
  14679. get absolutePosition(): Vector3;
  14680. /**
  14681. * Returns the current mesh absolute scaling.
  14682. * Returns a Vector3.
  14683. */
  14684. get absoluteScaling(): Vector3;
  14685. /**
  14686. * Returns the current mesh absolute rotation.
  14687. * Returns a Quaternion.
  14688. */
  14689. get absoluteRotationQuaternion(): Quaternion;
  14690. /**
  14691. * Sets a new matrix to apply before all other transformation
  14692. * @param matrix defines the transform matrix
  14693. * @returns the current TransformNode
  14694. */
  14695. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14696. /**
  14697. * Sets a new pivot matrix to the current node
  14698. * @param matrix defines the new pivot matrix to use
  14699. * @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
  14700. * @returns the current TransformNode
  14701. */
  14702. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14703. /**
  14704. * Returns the mesh pivot matrix.
  14705. * Default : Identity.
  14706. * @returns the matrix
  14707. */
  14708. getPivotMatrix(): Matrix;
  14709. /**
  14710. * Instantiate (when possible) or clone that node with its hierarchy
  14711. * @param newParent defines the new parent to use for the instance (or clone)
  14712. * @param options defines options to configure how copy is done
  14713. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14714. * @returns an instance (or a clone) of the current node with its hiearchy
  14715. */
  14716. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14717. doNotInstantiate: boolean;
  14718. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14719. /**
  14720. * Prevents the World matrix to be computed any longer
  14721. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14722. * @returns the TransformNode.
  14723. */
  14724. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14725. /**
  14726. * Allows back the World matrix computation.
  14727. * @returns the TransformNode.
  14728. */
  14729. unfreezeWorldMatrix(): this;
  14730. /**
  14731. * True if the World matrix has been frozen.
  14732. */
  14733. get isWorldMatrixFrozen(): boolean;
  14734. /**
  14735. * Retuns the mesh absolute position in the World.
  14736. * @returns a Vector3.
  14737. */
  14738. getAbsolutePosition(): Vector3;
  14739. /**
  14740. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14741. * @param absolutePosition the absolute position to set
  14742. * @returns the TransformNode.
  14743. */
  14744. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14745. /**
  14746. * Sets the mesh position in its local space.
  14747. * @param vector3 the position to set in localspace
  14748. * @returns the TransformNode.
  14749. */
  14750. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14751. /**
  14752. * Returns the mesh position in the local space from the current World matrix values.
  14753. * @returns a new Vector3.
  14754. */
  14755. getPositionExpressedInLocalSpace(): Vector3;
  14756. /**
  14757. * Translates the mesh along the passed Vector3 in its local space.
  14758. * @param vector3 the distance to translate in localspace
  14759. * @returns the TransformNode.
  14760. */
  14761. locallyTranslate(vector3: Vector3): TransformNode;
  14762. private static _lookAtVectorCache;
  14763. /**
  14764. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14765. * @param targetPoint the position (must be in same space as current mesh) to look at
  14766. * @param yawCor optional yaw (y-axis) correction in radians
  14767. * @param pitchCor optional pitch (x-axis) correction in radians
  14768. * @param rollCor optional roll (z-axis) correction in radians
  14769. * @param space the choosen space of the target
  14770. * @returns the TransformNode.
  14771. */
  14772. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14773. /**
  14774. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14775. * This Vector3 is expressed in the World space.
  14776. * @param localAxis axis to rotate
  14777. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14778. */
  14779. getDirection(localAxis: Vector3): Vector3;
  14780. /**
  14781. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14782. * localAxis is expressed in the mesh local space.
  14783. * result is computed in the Wordl space from the mesh World matrix.
  14784. * @param localAxis axis to rotate
  14785. * @param result the resulting transformnode
  14786. * @returns this TransformNode.
  14787. */
  14788. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14789. /**
  14790. * Sets this transform node rotation to the given local axis.
  14791. * @param localAxis the axis in local space
  14792. * @param yawCor optional yaw (y-axis) correction in radians
  14793. * @param pitchCor optional pitch (x-axis) correction in radians
  14794. * @param rollCor optional roll (z-axis) correction in radians
  14795. * @returns this TransformNode
  14796. */
  14797. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14798. /**
  14799. * Sets a new pivot point to the current node
  14800. * @param point defines the new pivot point to use
  14801. * @param space defines if the point is in world or local space (local by default)
  14802. * @returns the current TransformNode
  14803. */
  14804. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14805. /**
  14806. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14807. * @returns the pivot point
  14808. */
  14809. getPivotPoint(): Vector3;
  14810. /**
  14811. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14812. * @param result the vector3 to store the result
  14813. * @returns this TransformNode.
  14814. */
  14815. getPivotPointToRef(result: Vector3): TransformNode;
  14816. /**
  14817. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14818. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14819. */
  14820. getAbsolutePivotPoint(): Vector3;
  14821. /**
  14822. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14823. * @param result vector3 to store the result
  14824. * @returns this TransformNode.
  14825. */
  14826. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14827. /**
  14828. * Defines the passed node as the parent of the current node.
  14829. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14830. * @see https://doc.babylonjs.com/how_to/parenting
  14831. * @param node the node ot set as the parent
  14832. * @returns this TransformNode.
  14833. */
  14834. setParent(node: Nullable<Node>): TransformNode;
  14835. private _nonUniformScaling;
  14836. /**
  14837. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14838. */
  14839. get nonUniformScaling(): boolean;
  14840. /** @hidden */
  14841. _updateNonUniformScalingState(value: boolean): boolean;
  14842. /**
  14843. * Attach the current TransformNode to another TransformNode associated with a bone
  14844. * @param bone Bone affecting the TransformNode
  14845. * @param affectedTransformNode TransformNode associated with the bone
  14846. * @returns this object
  14847. */
  14848. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14849. /**
  14850. * Detach the transform node if its associated with a bone
  14851. * @returns this object
  14852. */
  14853. detachFromBone(): TransformNode;
  14854. private static _rotationAxisCache;
  14855. /**
  14856. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14857. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14858. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14859. * The passed axis is also normalized.
  14860. * @param axis the axis to rotate around
  14861. * @param amount the amount to rotate in radians
  14862. * @param space Space to rotate in (Default: local)
  14863. * @returns the TransformNode.
  14864. */
  14865. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14866. /**
  14867. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14868. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14869. * The passed axis is also normalized. .
  14870. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14871. * @param point the point to rotate around
  14872. * @param axis the axis to rotate around
  14873. * @param amount the amount to rotate in radians
  14874. * @returns the TransformNode
  14875. */
  14876. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14877. /**
  14878. * Translates the mesh along the axis vector for the passed distance in the given space.
  14879. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14880. * @param axis the axis to translate in
  14881. * @param distance the distance to translate
  14882. * @param space Space to rotate in (Default: local)
  14883. * @returns the TransformNode.
  14884. */
  14885. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14886. /**
  14887. * Adds a rotation step to the mesh current rotation.
  14888. * x, y, z are Euler angles expressed in radians.
  14889. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14890. * This means this rotation is made in the mesh local space only.
  14891. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14892. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14893. * ```javascript
  14894. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14895. * ```
  14896. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14897. * 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.
  14898. * @param x Rotation to add
  14899. * @param y Rotation to add
  14900. * @param z Rotation to add
  14901. * @returns the TransformNode.
  14902. */
  14903. addRotation(x: number, y: number, z: number): TransformNode;
  14904. /**
  14905. * @hidden
  14906. */
  14907. protected _getEffectiveParent(): Nullable<Node>;
  14908. /**
  14909. * Computes the world matrix of the node
  14910. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14911. * @returns the world matrix
  14912. */
  14913. computeWorldMatrix(force?: boolean): Matrix;
  14914. /**
  14915. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14916. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14917. */
  14918. resetLocalMatrix(independentOfChildren?: boolean): void;
  14919. protected _afterComputeWorldMatrix(): void;
  14920. /**
  14921. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14922. * @param func callback function to add
  14923. *
  14924. * @returns the TransformNode.
  14925. */
  14926. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14927. /**
  14928. * Removes a registered callback function.
  14929. * @param func callback function to remove
  14930. * @returns the TransformNode.
  14931. */
  14932. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14933. /**
  14934. * Gets the position of the current mesh in camera space
  14935. * @param camera defines the camera to use
  14936. * @returns a position
  14937. */
  14938. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14939. /**
  14940. * Returns the distance from the mesh to the active camera
  14941. * @param camera defines the camera to use
  14942. * @returns the distance
  14943. */
  14944. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14945. /**
  14946. * Clone the current transform node
  14947. * @param name Name of the new clone
  14948. * @param newParent New parent for the clone
  14949. * @param doNotCloneChildren Do not clone children hierarchy
  14950. * @returns the new transform node
  14951. */
  14952. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14953. /**
  14954. * Serializes the objects information.
  14955. * @param currentSerializationObject defines the object to serialize in
  14956. * @returns the serialized object
  14957. */
  14958. serialize(currentSerializationObject?: any): any;
  14959. /**
  14960. * Returns a new TransformNode object parsed from the source provided.
  14961. * @param parsedTransformNode is the source.
  14962. * @param scene the scne the object belongs to
  14963. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14964. * @returns a new TransformNode object parsed from the source provided.
  14965. */
  14966. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14967. /**
  14968. * Get all child-transformNodes of this node
  14969. * @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
  14970. * @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
  14971. * @returns an array of TransformNode
  14972. */
  14973. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14974. /**
  14975. * Releases resources associated with this transform node.
  14976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14978. */
  14979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14980. /**
  14981. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14982. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14983. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14984. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14985. * @returns the current mesh
  14986. */
  14987. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14988. private _syncAbsoluteScalingAndRotation;
  14989. }
  14990. }
  14991. declare module BABYLON {
  14992. /**
  14993. * Class used to override all child animations of a given target
  14994. */
  14995. export class AnimationPropertiesOverride {
  14996. /**
  14997. * Gets or sets a value indicating if animation blending must be used
  14998. */
  14999. enableBlending: boolean;
  15000. /**
  15001. * Gets or sets the blending speed to use when enableBlending is true
  15002. */
  15003. blendingSpeed: number;
  15004. /**
  15005. * Gets or sets the default loop mode to use
  15006. */
  15007. loopMode: number;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Class used to store bone information
  15013. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15014. */
  15015. export class Bone extends Node {
  15016. /**
  15017. * defines the bone name
  15018. */
  15019. name: string;
  15020. private static _tmpVecs;
  15021. private static _tmpQuat;
  15022. private static _tmpMats;
  15023. /**
  15024. * Gets the list of child bones
  15025. */
  15026. children: Bone[];
  15027. /** Gets the animations associated with this bone */
  15028. animations: Animation[];
  15029. /**
  15030. * Gets or sets bone length
  15031. */
  15032. length: number;
  15033. /**
  15034. * @hidden Internal only
  15035. * Set this value to map this bone to a different index in the transform matrices
  15036. * Set this value to -1 to exclude the bone from the transform matrices
  15037. */
  15038. _index: Nullable<number>;
  15039. private _skeleton;
  15040. private _localMatrix;
  15041. private _restPose;
  15042. private _baseMatrix;
  15043. private _absoluteTransform;
  15044. private _invertedAbsoluteTransform;
  15045. private _parent;
  15046. private _scalingDeterminant;
  15047. private _worldTransform;
  15048. private _localScaling;
  15049. private _localRotation;
  15050. private _localPosition;
  15051. private _needToDecompose;
  15052. private _needToCompose;
  15053. /** @hidden */
  15054. _linkedTransformNode: Nullable<TransformNode>;
  15055. /** @hidden */
  15056. _waitingTransformNodeId: Nullable<string>;
  15057. /** @hidden */
  15058. get _matrix(): Matrix;
  15059. /** @hidden */
  15060. set _matrix(value: Matrix);
  15061. /**
  15062. * Create a new bone
  15063. * @param name defines the bone name
  15064. * @param skeleton defines the parent skeleton
  15065. * @param parentBone defines the parent (can be null if the bone is the root)
  15066. * @param localMatrix defines the local matrix
  15067. * @param restPose defines the rest pose matrix
  15068. * @param baseMatrix defines the base matrix
  15069. * @param index defines index of the bone in the hiearchy
  15070. */
  15071. constructor(
  15072. /**
  15073. * defines the bone name
  15074. */
  15075. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15076. /**
  15077. * Gets the current object class name.
  15078. * @return the class name
  15079. */
  15080. getClassName(): string;
  15081. /**
  15082. * Gets the parent skeleton
  15083. * @returns a skeleton
  15084. */
  15085. getSkeleton(): Skeleton;
  15086. /**
  15087. * Gets parent bone
  15088. * @returns a bone or null if the bone is the root of the bone hierarchy
  15089. */
  15090. getParent(): Nullable<Bone>;
  15091. /**
  15092. * Returns an array containing the root bones
  15093. * @returns an array containing the root bones
  15094. */
  15095. getChildren(): Array<Bone>;
  15096. /**
  15097. * Gets the node index in matrix array generated for rendering
  15098. * @returns the node index
  15099. */
  15100. getIndex(): number;
  15101. /**
  15102. * Sets the parent bone
  15103. * @param parent defines the parent (can be null if the bone is the root)
  15104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15105. */
  15106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15107. /**
  15108. * Gets the local matrix
  15109. * @returns a matrix
  15110. */
  15111. getLocalMatrix(): Matrix;
  15112. /**
  15113. * Gets the base matrix (initial matrix which remains unchanged)
  15114. * @returns a matrix
  15115. */
  15116. getBaseMatrix(): Matrix;
  15117. /**
  15118. * Gets the rest pose matrix
  15119. * @returns a matrix
  15120. */
  15121. getRestPose(): Matrix;
  15122. /**
  15123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15124. */
  15125. getWorldMatrix(): Matrix;
  15126. /**
  15127. * Sets the local matrix to rest pose matrix
  15128. */
  15129. returnToRest(): void;
  15130. /**
  15131. * Gets the inverse of the absolute transform matrix.
  15132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15133. * @returns a matrix
  15134. */
  15135. getInvertedAbsoluteTransform(): Matrix;
  15136. /**
  15137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15138. * @returns a matrix
  15139. */
  15140. getAbsoluteTransform(): Matrix;
  15141. /**
  15142. * Links with the given transform node.
  15143. * The local matrix of this bone is copied from the transform node every frame.
  15144. * @param transformNode defines the transform node to link to
  15145. */
  15146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15147. /**
  15148. * Gets the node used to drive the bone's transformation
  15149. * @returns a transform node or null
  15150. */
  15151. getTransformNode(): Nullable<TransformNode>;
  15152. /** Gets or sets current position (in local space) */
  15153. get position(): Vector3;
  15154. set position(newPosition: Vector3);
  15155. /** Gets or sets current rotation (in local space) */
  15156. get rotation(): Vector3;
  15157. set rotation(newRotation: Vector3);
  15158. /** Gets or sets current rotation quaternion (in local space) */
  15159. get rotationQuaternion(): Quaternion;
  15160. set rotationQuaternion(newRotation: Quaternion);
  15161. /** Gets or sets current scaling (in local space) */
  15162. get scaling(): Vector3;
  15163. set scaling(newScaling: Vector3);
  15164. /**
  15165. * Gets the animation properties override
  15166. */
  15167. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15168. private _decompose;
  15169. private _compose;
  15170. /**
  15171. * Update the base and local matrices
  15172. * @param matrix defines the new base or local matrix
  15173. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15174. * @param updateLocalMatrix defines if the local matrix should be updated
  15175. */
  15176. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15177. /** @hidden */
  15178. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15179. /**
  15180. * Flag the bone as dirty (Forcing it to update everything)
  15181. */
  15182. markAsDirty(): void;
  15183. /** @hidden */
  15184. _markAsDirtyAndCompose(): void;
  15185. private _markAsDirtyAndDecompose;
  15186. /**
  15187. * Translate the bone in local or world space
  15188. * @param vec The amount to translate the bone
  15189. * @param space The space that the translation is in
  15190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15191. */
  15192. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15193. /**
  15194. * Set the postion of the bone in local or world space
  15195. * @param position The position to set the bone
  15196. * @param space The space that the position is in
  15197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15198. */
  15199. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15200. /**
  15201. * Set the absolute position of the bone (world space)
  15202. * @param position The position to set the bone
  15203. * @param mesh The mesh that this bone is attached to
  15204. */
  15205. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15206. /**
  15207. * Scale the bone on the x, y and z axes (in local space)
  15208. * @param x The amount to scale the bone on the x axis
  15209. * @param y The amount to scale the bone on the y axis
  15210. * @param z The amount to scale the bone on the z axis
  15211. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15212. */
  15213. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15214. /**
  15215. * Set the bone scaling in local space
  15216. * @param scale defines the scaling vector
  15217. */
  15218. setScale(scale: Vector3): void;
  15219. /**
  15220. * Gets the current scaling in local space
  15221. * @returns the current scaling vector
  15222. */
  15223. getScale(): Vector3;
  15224. /**
  15225. * Gets the current scaling in local space and stores it in a target vector
  15226. * @param result defines the target vector
  15227. */
  15228. getScaleToRef(result: Vector3): void;
  15229. /**
  15230. * Set the yaw, pitch, and roll of the bone in local or world space
  15231. * @param yaw The rotation of the bone on the y axis
  15232. * @param pitch The rotation of the bone on the x axis
  15233. * @param roll The rotation of the bone on the z axis
  15234. * @param space The space that the axes of rotation are in
  15235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15236. */
  15237. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15238. /**
  15239. * Add a rotation to the bone on an axis in local or world space
  15240. * @param axis The axis to rotate the bone on
  15241. * @param amount The amount to rotate the bone
  15242. * @param space The space that the axis is in
  15243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15244. */
  15245. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15246. /**
  15247. * Set the rotation of the bone to a particular axis angle in local or world space
  15248. * @param axis The axis to rotate the bone on
  15249. * @param angle The angle that the bone should be rotated to
  15250. * @param space The space that the axis is in
  15251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15252. */
  15253. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15254. /**
  15255. * Set the euler rotation of the bone in local of world space
  15256. * @param rotation The euler rotation that the bone should be set to
  15257. * @param space The space that the rotation is in
  15258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15259. */
  15260. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15261. /**
  15262. * Set the quaternion rotation of the bone in local of world space
  15263. * @param quat The quaternion rotation that the bone should be set to
  15264. * @param space The space that the rotation is in
  15265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15266. */
  15267. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15268. /**
  15269. * Set the rotation matrix of the bone in local of world space
  15270. * @param rotMat The rotation matrix that the bone should be set to
  15271. * @param space The space that the rotation is in
  15272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15273. */
  15274. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15275. private _rotateWithMatrix;
  15276. private _getNegativeRotationToRef;
  15277. /**
  15278. * Get the position of the bone in local or world space
  15279. * @param space The space that the returned position is in
  15280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15281. * @returns The position of the bone
  15282. */
  15283. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15284. /**
  15285. * Copy the position of the bone to a vector3 in local or world space
  15286. * @param space The space that the returned position is in
  15287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15288. * @param result The vector3 to copy the position to
  15289. */
  15290. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15291. /**
  15292. * Get the absolute position of the bone (world space)
  15293. * @param mesh The mesh that this bone is attached to
  15294. * @returns The absolute position of the bone
  15295. */
  15296. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15297. /**
  15298. * Copy the absolute position of the bone (world space) to the result param
  15299. * @param mesh The mesh that this bone is attached to
  15300. * @param result The vector3 to copy the absolute position to
  15301. */
  15302. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15303. /**
  15304. * Compute the absolute transforms of this bone and its children
  15305. */
  15306. computeAbsoluteTransforms(): void;
  15307. /**
  15308. * Get the world direction from an axis that is in the local space of the bone
  15309. * @param localAxis The local direction that is used to compute the world direction
  15310. * @param mesh The mesh that this bone is attached to
  15311. * @returns The world direction
  15312. */
  15313. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15314. /**
  15315. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15316. * @param localAxis The local direction that is used to compute the world direction
  15317. * @param mesh The mesh that this bone is attached to
  15318. * @param result The vector3 that the world direction will be copied to
  15319. */
  15320. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15321. /**
  15322. * Get the euler rotation of the bone in local or world space
  15323. * @param space The space that the rotation should be in
  15324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15325. * @returns The euler rotation
  15326. */
  15327. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15328. /**
  15329. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15330. * @param space The space that the rotation should be in
  15331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15332. * @param result The vector3 that the rotation should be copied to
  15333. */
  15334. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15335. /**
  15336. * Get the quaternion rotation of the bone in either local or world space
  15337. * @param space The space that the rotation should be in
  15338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15339. * @returns The quaternion rotation
  15340. */
  15341. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15342. /**
  15343. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15344. * @param space The space that the rotation should be in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. * @param result The quaternion that the rotation should be copied to
  15347. */
  15348. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15349. /**
  15350. * Get the rotation matrix of the bone in local or world space
  15351. * @param space The space that the rotation should be in
  15352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15353. * @returns The rotation matrix
  15354. */
  15355. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15356. /**
  15357. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15358. * @param space The space that the rotation should be in
  15359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15360. * @param result The quaternion that the rotation should be copied to
  15361. */
  15362. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15363. /**
  15364. * Get the world position of a point that is in the local space of the bone
  15365. * @param position The local position
  15366. * @param mesh The mesh that this bone is attached to
  15367. * @returns The world position
  15368. */
  15369. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15370. /**
  15371. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15372. * @param position The local position
  15373. * @param mesh The mesh that this bone is attached to
  15374. * @param result The vector3 that the world position should be copied to
  15375. */
  15376. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15377. /**
  15378. * Get the local position of a point that is in world space
  15379. * @param position The world position
  15380. * @param mesh The mesh that this bone is attached to
  15381. * @returns The local position
  15382. */
  15383. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15384. /**
  15385. * Get the local position of a point that is in world space and copy it to the result param
  15386. * @param position The world position
  15387. * @param mesh The mesh that this bone is attached to
  15388. * @param result The vector3 that the local position should be copied to
  15389. */
  15390. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15391. }
  15392. }
  15393. declare module BABYLON {
  15394. /**
  15395. * Defines a runtime animation
  15396. */
  15397. export class RuntimeAnimation {
  15398. private _events;
  15399. /**
  15400. * The current frame of the runtime animation
  15401. */
  15402. private _currentFrame;
  15403. /**
  15404. * The animation used by the runtime animation
  15405. */
  15406. private _animation;
  15407. /**
  15408. * The target of the runtime animation
  15409. */
  15410. private _target;
  15411. /**
  15412. * The initiating animatable
  15413. */
  15414. private _host;
  15415. /**
  15416. * The original value of the runtime animation
  15417. */
  15418. private _originalValue;
  15419. /**
  15420. * The original blend value of the runtime animation
  15421. */
  15422. private _originalBlendValue;
  15423. /**
  15424. * The offsets cache of the runtime animation
  15425. */
  15426. private _offsetsCache;
  15427. /**
  15428. * The high limits cache of the runtime animation
  15429. */
  15430. private _highLimitsCache;
  15431. /**
  15432. * Specifies if the runtime animation has been stopped
  15433. */
  15434. private _stopped;
  15435. /**
  15436. * The blending factor of the runtime animation
  15437. */
  15438. private _blendingFactor;
  15439. /**
  15440. * The BabylonJS scene
  15441. */
  15442. private _scene;
  15443. /**
  15444. * The current value of the runtime animation
  15445. */
  15446. private _currentValue;
  15447. /** @hidden */
  15448. _animationState: _IAnimationState;
  15449. /**
  15450. * The active target of the runtime animation
  15451. */
  15452. private _activeTargets;
  15453. private _currentActiveTarget;
  15454. private _directTarget;
  15455. /**
  15456. * The target path of the runtime animation
  15457. */
  15458. private _targetPath;
  15459. /**
  15460. * The weight of the runtime animation
  15461. */
  15462. private _weight;
  15463. /**
  15464. * The ratio offset of the runtime animation
  15465. */
  15466. private _ratioOffset;
  15467. /**
  15468. * The previous delay of the runtime animation
  15469. */
  15470. private _previousDelay;
  15471. /**
  15472. * The previous ratio of the runtime animation
  15473. */
  15474. private _previousRatio;
  15475. private _enableBlending;
  15476. private _keys;
  15477. private _minFrame;
  15478. private _maxFrame;
  15479. private _minValue;
  15480. private _maxValue;
  15481. private _targetIsArray;
  15482. /**
  15483. * Gets the current frame of the runtime animation
  15484. */
  15485. get currentFrame(): number;
  15486. /**
  15487. * Gets the weight of the runtime animation
  15488. */
  15489. get weight(): number;
  15490. /**
  15491. * Gets the current value of the runtime animation
  15492. */
  15493. get currentValue(): any;
  15494. /**
  15495. * Gets the target path of the runtime animation
  15496. */
  15497. get targetPath(): string;
  15498. /**
  15499. * Gets the actual target of the runtime animation
  15500. */
  15501. get target(): any;
  15502. /**
  15503. * Gets the additive state of the runtime animation
  15504. */
  15505. get isAdditive(): boolean;
  15506. /** @hidden */
  15507. _onLoop: () => void;
  15508. /**
  15509. * Create a new RuntimeAnimation object
  15510. * @param target defines the target of the animation
  15511. * @param animation defines the source animation object
  15512. * @param scene defines the hosting scene
  15513. * @param host defines the initiating Animatable
  15514. */
  15515. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15516. private _preparePath;
  15517. /**
  15518. * Gets the animation from the runtime animation
  15519. */
  15520. get animation(): Animation;
  15521. /**
  15522. * Resets the runtime animation to the beginning
  15523. * @param restoreOriginal defines whether to restore the target property to the original value
  15524. */
  15525. reset(restoreOriginal?: boolean): void;
  15526. /**
  15527. * Specifies if the runtime animation is stopped
  15528. * @returns Boolean specifying if the runtime animation is stopped
  15529. */
  15530. isStopped(): boolean;
  15531. /**
  15532. * Disposes of the runtime animation
  15533. */
  15534. dispose(): void;
  15535. /**
  15536. * Apply the interpolated value to the target
  15537. * @param currentValue defines the value computed by the animation
  15538. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15539. */
  15540. setValue(currentValue: any, weight: number): void;
  15541. private _getOriginalValues;
  15542. private _setValue;
  15543. /**
  15544. * Gets the loop pmode of the runtime animation
  15545. * @returns Loop Mode
  15546. */
  15547. private _getCorrectLoopMode;
  15548. /**
  15549. * Move the current animation to a given frame
  15550. * @param frame defines the frame to move to
  15551. */
  15552. goToFrame(frame: number): void;
  15553. /**
  15554. * @hidden Internal use only
  15555. */
  15556. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15557. /**
  15558. * Execute the current animation
  15559. * @param delay defines the delay to add to the current frame
  15560. * @param from defines the lower bound of the animation range
  15561. * @param to defines the upper bound of the animation range
  15562. * @param loop defines if the current animation must loop
  15563. * @param speedRatio defines the current speed ratio
  15564. * @param weight defines the weight of the animation (default is -1 so no weight)
  15565. * @param onLoop optional callback called when animation loops
  15566. * @returns a boolean indicating if the animation is running
  15567. */
  15568. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15569. }
  15570. }
  15571. declare module BABYLON {
  15572. /**
  15573. * Class used to store an actual running animation
  15574. */
  15575. export class Animatable {
  15576. /** defines the target object */
  15577. target: any;
  15578. /** defines the starting frame number (default is 0) */
  15579. fromFrame: number;
  15580. /** defines the ending frame number (default is 100) */
  15581. toFrame: number;
  15582. /** defines if the animation must loop (default is false) */
  15583. loopAnimation: boolean;
  15584. /** defines a callback to call when animation ends if it is not looping */
  15585. onAnimationEnd?: (() => void) | null | undefined;
  15586. /** defines a callback to call when animation loops */
  15587. onAnimationLoop?: (() => void) | null | undefined;
  15588. /** defines whether the animation should be evaluated additively */
  15589. isAdditive: boolean;
  15590. private _localDelayOffset;
  15591. private _pausedDelay;
  15592. private _runtimeAnimations;
  15593. private _paused;
  15594. private _scene;
  15595. private _speedRatio;
  15596. private _weight;
  15597. private _syncRoot;
  15598. /**
  15599. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15600. * This will only apply for non looping animation (default is true)
  15601. */
  15602. disposeOnEnd: boolean;
  15603. /**
  15604. * Gets a boolean indicating if the animation has started
  15605. */
  15606. animationStarted: boolean;
  15607. /**
  15608. * Observer raised when the animation ends
  15609. */
  15610. onAnimationEndObservable: Observable<Animatable>;
  15611. /**
  15612. * Observer raised when the animation loops
  15613. */
  15614. onAnimationLoopObservable: Observable<Animatable>;
  15615. /**
  15616. * Gets the root Animatable used to synchronize and normalize animations
  15617. */
  15618. get syncRoot(): Nullable<Animatable>;
  15619. /**
  15620. * Gets the current frame of the first RuntimeAnimation
  15621. * Used to synchronize Animatables
  15622. */
  15623. get masterFrame(): number;
  15624. /**
  15625. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15626. */
  15627. get weight(): number;
  15628. set weight(value: number);
  15629. /**
  15630. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15631. */
  15632. get speedRatio(): number;
  15633. set speedRatio(value: number);
  15634. /**
  15635. * Creates a new Animatable
  15636. * @param scene defines the hosting scene
  15637. * @param target defines the target object
  15638. * @param fromFrame defines the starting frame number (default is 0)
  15639. * @param toFrame defines the ending frame number (default is 100)
  15640. * @param loopAnimation defines if the animation must loop (default is false)
  15641. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15642. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15643. * @param animations defines a group of animation to add to the new Animatable
  15644. * @param onAnimationLoop defines a callback to call when animation loops
  15645. * @param isAdditive defines whether the animation should be evaluated additively
  15646. */
  15647. constructor(scene: Scene,
  15648. /** defines the target object */
  15649. target: any,
  15650. /** defines the starting frame number (default is 0) */
  15651. fromFrame?: number,
  15652. /** defines the ending frame number (default is 100) */
  15653. toFrame?: number,
  15654. /** defines if the animation must loop (default is false) */
  15655. loopAnimation?: boolean, speedRatio?: number,
  15656. /** defines a callback to call when animation ends if it is not looping */
  15657. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15658. /** defines a callback to call when animation loops */
  15659. onAnimationLoop?: (() => void) | null | undefined,
  15660. /** defines whether the animation should be evaluated additively */
  15661. isAdditive?: boolean);
  15662. /**
  15663. * Synchronize and normalize current Animatable with a source Animatable
  15664. * This is useful when using animation weights and when animations are not of the same length
  15665. * @param root defines the root Animatable to synchronize with
  15666. * @returns the current Animatable
  15667. */
  15668. syncWith(root: Animatable): Animatable;
  15669. /**
  15670. * Gets the list of runtime animations
  15671. * @returns an array of RuntimeAnimation
  15672. */
  15673. getAnimations(): RuntimeAnimation[];
  15674. /**
  15675. * Adds more animations to the current animatable
  15676. * @param target defines the target of the animations
  15677. * @param animations defines the new animations to add
  15678. */
  15679. appendAnimations(target: any, animations: Animation[]): void;
  15680. /**
  15681. * Gets the source animation for a specific property
  15682. * @param property defines the propertyu to look for
  15683. * @returns null or the source animation for the given property
  15684. */
  15685. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15686. /**
  15687. * Gets the runtime animation for a specific property
  15688. * @param property defines the propertyu to look for
  15689. * @returns null or the runtime animation for the given property
  15690. */
  15691. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15692. /**
  15693. * Resets the animatable to its original state
  15694. */
  15695. reset(): void;
  15696. /**
  15697. * Allows the animatable to blend with current running animations
  15698. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15699. * @param blendingSpeed defines the blending speed to use
  15700. */
  15701. enableBlending(blendingSpeed: number): void;
  15702. /**
  15703. * Disable animation blending
  15704. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15705. */
  15706. disableBlending(): void;
  15707. /**
  15708. * Jump directly to a given frame
  15709. * @param frame defines the frame to jump to
  15710. */
  15711. goToFrame(frame: number): void;
  15712. /**
  15713. * Pause the animation
  15714. */
  15715. pause(): void;
  15716. /**
  15717. * Restart the animation
  15718. */
  15719. restart(): void;
  15720. private _raiseOnAnimationEnd;
  15721. /**
  15722. * Stop and delete the current animation
  15723. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15724. * @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)
  15725. */
  15726. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15727. /**
  15728. * Wait asynchronously for the animation to end
  15729. * @returns a promise which will be fullfilled when the animation ends
  15730. */
  15731. waitAsync(): Promise<Animatable>;
  15732. /** @hidden */
  15733. _animate(delay: number): boolean;
  15734. }
  15735. interface Scene {
  15736. /** @hidden */
  15737. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15738. /** @hidden */
  15739. _processLateAnimationBindingsForMatrices(holder: {
  15740. totalWeight: number;
  15741. totalAdditiveWeight: number;
  15742. animations: RuntimeAnimation[];
  15743. additiveAnimations: RuntimeAnimation[];
  15744. originalValue: Matrix;
  15745. }): any;
  15746. /** @hidden */
  15747. _processLateAnimationBindingsForQuaternions(holder: {
  15748. totalWeight: number;
  15749. totalAdditiveWeight: number;
  15750. animations: RuntimeAnimation[];
  15751. additiveAnimations: RuntimeAnimation[];
  15752. originalValue: Quaternion;
  15753. }, refQuaternion: Quaternion): Quaternion;
  15754. /** @hidden */
  15755. _processLateAnimationBindings(): void;
  15756. /**
  15757. * Will start the animation sequence of a given target
  15758. * @param target defines the target
  15759. * @param from defines from which frame should animation start
  15760. * @param to defines until which frame should animation run.
  15761. * @param weight defines the weight to apply to the animation (1.0 by default)
  15762. * @param loop defines if the animation loops
  15763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15764. * @param onAnimationEnd defines the function to be executed when the animation ends
  15765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15766. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15767. * @param onAnimationLoop defines the callback to call when an animation loops
  15768. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15769. * @returns the animatable object created for this animation
  15770. */
  15771. 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;
  15772. /**
  15773. * Will start the animation sequence of a given target
  15774. * @param target defines the target
  15775. * @param from defines from which frame should animation start
  15776. * @param to defines until which frame should animation run.
  15777. * @param loop defines if the animation loops
  15778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15779. * @param onAnimationEnd defines the function to be executed when the animation ends
  15780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15782. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15783. * @param onAnimationLoop defines the callback to call when an animation loops
  15784. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15785. * @returns the animatable object created for this animation
  15786. */
  15787. 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;
  15788. /**
  15789. * Will start the animation sequence of a given target and its hierarchy
  15790. * @param target defines the target
  15791. * @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.
  15792. * @param from defines from which frame should animation start
  15793. * @param to defines until which frame should animation run.
  15794. * @param loop defines if the animation loops
  15795. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15796. * @param onAnimationEnd defines the function to be executed when the animation ends
  15797. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15798. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15799. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15800. * @param onAnimationLoop defines the callback to call when an animation loops
  15801. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15802. * @returns the list of created animatables
  15803. */
  15804. 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[];
  15805. /**
  15806. * Begin a new animation on a given node
  15807. * @param target defines the target where the animation will take place
  15808. * @param animations defines the list of animations to start
  15809. * @param from defines the initial value
  15810. * @param to defines the final value
  15811. * @param loop defines if you want animation to loop (off by default)
  15812. * @param speedRatio defines the speed ratio to apply to all animations
  15813. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15814. * @param onAnimationLoop defines the callback to call when an animation loops
  15815. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15816. * @returns the list of created animatables
  15817. */
  15818. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15819. /**
  15820. * Begin a new animation on a given node and its hierarchy
  15821. * @param target defines the root node where the animation will take place
  15822. * @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.
  15823. * @param animations defines the list of animations to start
  15824. * @param from defines the initial value
  15825. * @param to defines the final value
  15826. * @param loop defines if you want animation to loop (off by default)
  15827. * @param speedRatio defines the speed ratio to apply to all animations
  15828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15829. * @param onAnimationLoop defines the callback to call when an animation loops
  15830. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15831. * @returns the list of animatables created for all nodes
  15832. */
  15833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15834. /**
  15835. * Gets the animatable associated with a specific target
  15836. * @param target defines the target of the animatable
  15837. * @returns the required animatable if found
  15838. */
  15839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15840. /**
  15841. * Gets all animatables associated with a given target
  15842. * @param target defines the target to look animatables for
  15843. * @returns an array of Animatables
  15844. */
  15845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15846. /**
  15847. * Stops and removes all animations that have been applied to the scene
  15848. */
  15849. stopAllAnimations(): void;
  15850. /**
  15851. * Gets the current delta time used by animation engine
  15852. */
  15853. deltaTime: number;
  15854. }
  15855. interface Bone {
  15856. /**
  15857. * Copy an animation range from another bone
  15858. * @param source defines the source bone
  15859. * @param rangeName defines the range name to copy
  15860. * @param frameOffset defines the frame offset
  15861. * @param rescaleAsRequired defines if rescaling must be applied if required
  15862. * @param skelDimensionsRatio defines the scaling ratio
  15863. * @returns true if operation was successful
  15864. */
  15865. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15866. }
  15867. }
  15868. declare module BABYLON {
  15869. /**
  15870. * Class used to handle skinning animations
  15871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15872. */
  15873. export class Skeleton implements IAnimatable {
  15874. /** defines the skeleton name */
  15875. name: string;
  15876. /** defines the skeleton Id */
  15877. id: string;
  15878. /**
  15879. * Defines the list of child bones
  15880. */
  15881. bones: Bone[];
  15882. /**
  15883. * Defines an estimate of the dimension of the skeleton at rest
  15884. */
  15885. dimensionsAtRest: Vector3;
  15886. /**
  15887. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15888. */
  15889. needInitialSkinMatrix: boolean;
  15890. /**
  15891. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15892. */
  15893. overrideMesh: Nullable<AbstractMesh>;
  15894. /**
  15895. * Gets the list of animations attached to this skeleton
  15896. */
  15897. animations: Array<Animation>;
  15898. private _scene;
  15899. private _isDirty;
  15900. private _transformMatrices;
  15901. private _transformMatrixTexture;
  15902. private _meshesWithPoseMatrix;
  15903. private _animatables;
  15904. private _identity;
  15905. private _synchronizedWithMesh;
  15906. private _ranges;
  15907. private _lastAbsoluteTransformsUpdateId;
  15908. private _canUseTextureForBones;
  15909. private _uniqueId;
  15910. /** @hidden */
  15911. _numBonesWithLinkedTransformNode: number;
  15912. /** @hidden */
  15913. _hasWaitingData: Nullable<boolean>;
  15914. /**
  15915. * Specifies if the skeleton should be serialized
  15916. */
  15917. doNotSerialize: boolean;
  15918. private _useTextureToStoreBoneMatrices;
  15919. /**
  15920. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15921. * Please note that this option is not available if the hardware does not support it
  15922. */
  15923. get useTextureToStoreBoneMatrices(): boolean;
  15924. set useTextureToStoreBoneMatrices(value: boolean);
  15925. private _animationPropertiesOverride;
  15926. /**
  15927. * Gets or sets the animation properties override
  15928. */
  15929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15931. /**
  15932. * List of inspectable custom properties (used by the Inspector)
  15933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15934. */
  15935. inspectableCustomProperties: IInspectable[];
  15936. /**
  15937. * An observable triggered before computing the skeleton's matrices
  15938. */
  15939. onBeforeComputeObservable: Observable<Skeleton>;
  15940. /**
  15941. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15942. */
  15943. get isUsingTextureForMatrices(): boolean;
  15944. /**
  15945. * Gets the unique ID of this skeleton
  15946. */
  15947. get uniqueId(): number;
  15948. /**
  15949. * Creates a new skeleton
  15950. * @param name defines the skeleton name
  15951. * @param id defines the skeleton Id
  15952. * @param scene defines the hosting scene
  15953. */
  15954. constructor(
  15955. /** defines the skeleton name */
  15956. name: string,
  15957. /** defines the skeleton Id */
  15958. id: string, scene: Scene);
  15959. /**
  15960. * Gets the current object class name.
  15961. * @return the class name
  15962. */
  15963. getClassName(): string;
  15964. /**
  15965. * Returns an array containing the root bones
  15966. * @returns an array containing the root bones
  15967. */
  15968. getChildren(): Array<Bone>;
  15969. /**
  15970. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15971. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15972. * @returns a Float32Array containing matrices data
  15973. */
  15974. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15975. /**
  15976. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15977. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15978. * @returns a raw texture containing the data
  15979. */
  15980. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15981. /**
  15982. * Gets the current hosting scene
  15983. * @returns a scene object
  15984. */
  15985. getScene(): Scene;
  15986. /**
  15987. * Gets a string representing the current skeleton data
  15988. * @param fullDetails defines a boolean indicating if we want a verbose version
  15989. * @returns a string representing the current skeleton data
  15990. */
  15991. toString(fullDetails?: boolean): string;
  15992. /**
  15993. * Get bone's index searching by name
  15994. * @param name defines bone's name to search for
  15995. * @return the indice of the bone. Returns -1 if not found
  15996. */
  15997. getBoneIndexByName(name: string): number;
  15998. /**
  15999. * Creater a new animation range
  16000. * @param name defines the name of the range
  16001. * @param from defines the start key
  16002. * @param to defines the end key
  16003. */
  16004. createAnimationRange(name: string, from: number, to: number): void;
  16005. /**
  16006. * Delete a specific animation range
  16007. * @param name defines the name of the range
  16008. * @param deleteFrames defines if frames must be removed as well
  16009. */
  16010. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16011. /**
  16012. * Gets a specific animation range
  16013. * @param name defines the name of the range to look for
  16014. * @returns the requested animation range or null if not found
  16015. */
  16016. getAnimationRange(name: string): Nullable<AnimationRange>;
  16017. /**
  16018. * Gets the list of all animation ranges defined on this skeleton
  16019. * @returns an array
  16020. */
  16021. getAnimationRanges(): Nullable<AnimationRange>[];
  16022. /**
  16023. * Copy animation range from a source skeleton.
  16024. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16025. * @param source defines the source skeleton
  16026. * @param name defines the name of the range to copy
  16027. * @param rescaleAsRequired defines if rescaling must be applied if required
  16028. * @returns true if operation was successful
  16029. */
  16030. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16031. /**
  16032. * Forces the skeleton to go to rest pose
  16033. */
  16034. returnToRest(): void;
  16035. private _getHighestAnimationFrame;
  16036. /**
  16037. * Begin a specific animation range
  16038. * @param name defines the name of the range to start
  16039. * @param loop defines if looping must be turned on (false by default)
  16040. * @param speedRatio defines the speed ratio to apply (1 by default)
  16041. * @param onAnimationEnd defines a callback which will be called when animation will end
  16042. * @returns a new animatable
  16043. */
  16044. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16045. /**
  16046. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16047. * @param skeleton defines the Skeleton containing the animation range to convert
  16048. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16049. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16050. * @returns the original skeleton
  16051. */
  16052. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16053. /** @hidden */
  16054. _markAsDirty(): void;
  16055. /** @hidden */
  16056. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16057. /** @hidden */
  16058. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. private _computeTransformMatrices;
  16060. /**
  16061. * Build all resources required to render a skeleton
  16062. */
  16063. prepare(): void;
  16064. /**
  16065. * Gets the list of animatables currently running for this skeleton
  16066. * @returns an array of animatables
  16067. */
  16068. getAnimatables(): IAnimatable[];
  16069. /**
  16070. * Clone the current skeleton
  16071. * @param name defines the name of the new skeleton
  16072. * @param id defines the id of the new skeleton
  16073. * @returns the new skeleton
  16074. */
  16075. clone(name: string, id?: string): Skeleton;
  16076. /**
  16077. * Enable animation blending for this skeleton
  16078. * @param blendingSpeed defines the blending speed to apply
  16079. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16080. */
  16081. enableBlending(blendingSpeed?: number): void;
  16082. /**
  16083. * Releases all resources associated with the current skeleton
  16084. */
  16085. dispose(): void;
  16086. /**
  16087. * Serialize the skeleton in a JSON object
  16088. * @returns a JSON object
  16089. */
  16090. serialize(): any;
  16091. /**
  16092. * Creates a new skeleton from serialized data
  16093. * @param parsedSkeleton defines the serialized data
  16094. * @param scene defines the hosting scene
  16095. * @returns a new skeleton
  16096. */
  16097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16098. /**
  16099. * Compute all node absolute transforms
  16100. * @param forceUpdate defines if computation must be done even if cache is up to date
  16101. */
  16102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16103. /**
  16104. * Gets the root pose matrix
  16105. * @returns a matrix
  16106. */
  16107. getPoseMatrix(): Nullable<Matrix>;
  16108. /**
  16109. * Sorts bones per internal index
  16110. */
  16111. sortBones(): void;
  16112. private _sortBones;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * Creates an instance based on a source mesh.
  16118. */
  16119. export class InstancedMesh extends AbstractMesh {
  16120. private _sourceMesh;
  16121. private _currentLOD;
  16122. /** @hidden */
  16123. _indexInSourceMeshInstanceArray: number;
  16124. constructor(name: string, source: Mesh);
  16125. /**
  16126. * Returns the string "InstancedMesh".
  16127. */
  16128. getClassName(): string;
  16129. /** Gets the list of lights affecting that mesh */
  16130. get lightSources(): Light[];
  16131. _resyncLightSources(): void;
  16132. _resyncLightSource(light: Light): void;
  16133. _removeLightSource(light: Light, dispose: boolean): void;
  16134. /**
  16135. * If the source mesh receives shadows
  16136. */
  16137. get receiveShadows(): boolean;
  16138. /**
  16139. * The material of the source mesh
  16140. */
  16141. get material(): Nullable<Material>;
  16142. /**
  16143. * Visibility of the source mesh
  16144. */
  16145. get visibility(): number;
  16146. /**
  16147. * Skeleton of the source mesh
  16148. */
  16149. get skeleton(): Nullable<Skeleton>;
  16150. /**
  16151. * Rendering ground id of the source mesh
  16152. */
  16153. get renderingGroupId(): number;
  16154. set renderingGroupId(value: number);
  16155. /**
  16156. * Returns the total number of vertices (integer).
  16157. */
  16158. getTotalVertices(): number;
  16159. /**
  16160. * Returns a positive integer : the total number of indices in this mesh geometry.
  16161. * @returns the numner of indices or zero if the mesh has no geometry.
  16162. */
  16163. getTotalIndices(): number;
  16164. /**
  16165. * The source mesh of the instance
  16166. */
  16167. get sourceMesh(): Mesh;
  16168. /**
  16169. * Creates a new InstancedMesh object from the mesh model.
  16170. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16171. * @param name defines the name of the new instance
  16172. * @returns a new InstancedMesh
  16173. */
  16174. createInstance(name: string): InstancedMesh;
  16175. /**
  16176. * Is this node ready to be used/rendered
  16177. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16178. * @return {boolean} is it ready
  16179. */
  16180. isReady(completeCheck?: boolean): boolean;
  16181. /**
  16182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16183. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16184. * @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.
  16185. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16186. */
  16187. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16188. /**
  16189. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16190. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16191. * The `data` are either a numeric array either a Float32Array.
  16192. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16193. * 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).
  16194. * Note that a new underlying VertexBuffer object is created each call.
  16195. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16196. *
  16197. * Possible `kind` values :
  16198. * - VertexBuffer.PositionKind
  16199. * - VertexBuffer.UVKind
  16200. * - VertexBuffer.UV2Kind
  16201. * - VertexBuffer.UV3Kind
  16202. * - VertexBuffer.UV4Kind
  16203. * - VertexBuffer.UV5Kind
  16204. * - VertexBuffer.UV6Kind
  16205. * - VertexBuffer.ColorKind
  16206. * - VertexBuffer.MatricesIndicesKind
  16207. * - VertexBuffer.MatricesIndicesExtraKind
  16208. * - VertexBuffer.MatricesWeightsKind
  16209. * - VertexBuffer.MatricesWeightsExtraKind
  16210. *
  16211. * Returns the Mesh.
  16212. */
  16213. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16214. /**
  16215. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16216. * If the mesh has no geometry, it is simply returned as it is.
  16217. * The `data` are either a numeric array either a Float32Array.
  16218. * No new underlying VertexBuffer object is created.
  16219. * 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.
  16220. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16221. *
  16222. * Possible `kind` values :
  16223. * - VertexBuffer.PositionKind
  16224. * - VertexBuffer.UVKind
  16225. * - VertexBuffer.UV2Kind
  16226. * - VertexBuffer.UV3Kind
  16227. * - VertexBuffer.UV4Kind
  16228. * - VertexBuffer.UV5Kind
  16229. * - VertexBuffer.UV6Kind
  16230. * - VertexBuffer.ColorKind
  16231. * - VertexBuffer.MatricesIndicesKind
  16232. * - VertexBuffer.MatricesIndicesExtraKind
  16233. * - VertexBuffer.MatricesWeightsKind
  16234. * - VertexBuffer.MatricesWeightsExtraKind
  16235. *
  16236. * Returns the Mesh.
  16237. */
  16238. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16239. /**
  16240. * Sets the mesh indices.
  16241. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16243. * This method creates a new index buffer each call.
  16244. * Returns the Mesh.
  16245. */
  16246. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16247. /**
  16248. * Boolean : True if the mesh owns the requested kind of data.
  16249. */
  16250. isVerticesDataPresent(kind: string): boolean;
  16251. /**
  16252. * Returns an array of indices (IndicesArray).
  16253. */
  16254. getIndices(): Nullable<IndicesArray>;
  16255. get _positions(): Nullable<Vector3[]>;
  16256. /**
  16257. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16258. * This means the mesh underlying bounding box and sphere are recomputed.
  16259. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16260. * @returns the current mesh
  16261. */
  16262. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16263. /** @hidden */
  16264. _preActivate(): InstancedMesh;
  16265. /** @hidden */
  16266. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16267. /** @hidden */
  16268. _postActivate(): void;
  16269. getWorldMatrix(): Matrix;
  16270. get isAnInstance(): boolean;
  16271. /**
  16272. * Returns the current associated LOD AbstractMesh.
  16273. */
  16274. getLOD(camera: Camera): AbstractMesh;
  16275. /** @hidden */
  16276. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16277. /** @hidden */
  16278. _syncSubMeshes(): InstancedMesh;
  16279. /** @hidden */
  16280. _generatePointsArray(): boolean;
  16281. /**
  16282. * Creates a new InstancedMesh from the current mesh.
  16283. * - name (string) : the cloned mesh name
  16284. * - newParent (optional Node) : the optional Node to parent the clone to.
  16285. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16286. *
  16287. * Returns the clone.
  16288. */
  16289. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16290. /**
  16291. * Disposes the InstancedMesh.
  16292. * Returns nothing.
  16293. */
  16294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16295. }
  16296. interface Mesh {
  16297. /**
  16298. * Register a custom buffer that will be instanced
  16299. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16300. * @param kind defines the buffer kind
  16301. * @param stride defines the stride in floats
  16302. */
  16303. registerInstancedBuffer(kind: string, stride: number): void;
  16304. /** @hidden */
  16305. _userInstancedBuffersStorage: {
  16306. data: {
  16307. [key: string]: Float32Array;
  16308. };
  16309. sizes: {
  16310. [key: string]: number;
  16311. };
  16312. vertexBuffers: {
  16313. [key: string]: Nullable<VertexBuffer>;
  16314. };
  16315. strides: {
  16316. [key: string]: number;
  16317. };
  16318. };
  16319. }
  16320. interface AbstractMesh {
  16321. /**
  16322. * Object used to store instanced buffers defined by user
  16323. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16324. */
  16325. instancedBuffers: {
  16326. [key: string]: any;
  16327. };
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Defines the options associated with the creation of a shader material.
  16333. */
  16334. export interface IShaderMaterialOptions {
  16335. /**
  16336. * Does the material work in alpha blend mode
  16337. */
  16338. needAlphaBlending: boolean;
  16339. /**
  16340. * Does the material work in alpha test mode
  16341. */
  16342. needAlphaTesting: boolean;
  16343. /**
  16344. * The list of attribute names used in the shader
  16345. */
  16346. attributes: string[];
  16347. /**
  16348. * The list of unifrom names used in the shader
  16349. */
  16350. uniforms: string[];
  16351. /**
  16352. * The list of UBO names used in the shader
  16353. */
  16354. uniformBuffers: string[];
  16355. /**
  16356. * The list of sampler names used in the shader
  16357. */
  16358. samplers: string[];
  16359. /**
  16360. * The list of defines used in the shader
  16361. */
  16362. defines: string[];
  16363. }
  16364. /**
  16365. * 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.
  16366. *
  16367. * This returned material effects how the mesh will look based on the code in the shaders.
  16368. *
  16369. * @see http://doc.babylonjs.com/how_to/shader_material
  16370. */
  16371. export class ShaderMaterial extends Material {
  16372. private _shaderPath;
  16373. private _options;
  16374. private _textures;
  16375. private _textureArrays;
  16376. private _floats;
  16377. private _ints;
  16378. private _floatsArrays;
  16379. private _colors3;
  16380. private _colors3Arrays;
  16381. private _colors4;
  16382. private _colors4Arrays;
  16383. private _vectors2;
  16384. private _vectors3;
  16385. private _vectors4;
  16386. private _matrices;
  16387. private _matrixArrays;
  16388. private _matrices3x3;
  16389. private _matrices2x2;
  16390. private _vectors2Arrays;
  16391. private _vectors3Arrays;
  16392. private _vectors4Arrays;
  16393. private _cachedWorldViewMatrix;
  16394. private _cachedWorldViewProjectionMatrix;
  16395. private _renderId;
  16396. private _multiview;
  16397. private _cachedDefines;
  16398. /**
  16399. * Instantiate a new shader material.
  16400. * 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.
  16401. * This returned material effects how the mesh will look based on the code in the shaders.
  16402. * @see http://doc.babylonjs.com/how_to/shader_material
  16403. * @param name Define the name of the material in the scene
  16404. * @param scene Define the scene the material belongs to
  16405. * @param shaderPath Defines the route to the shader code in one of three ways:
  16406. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16407. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16408. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16409. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16410. * @param options Define the options used to create the shader
  16411. */
  16412. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16413. /**
  16414. * Gets the shader path used to define the shader code
  16415. * It can be modified to trigger a new compilation
  16416. */
  16417. get shaderPath(): any;
  16418. /**
  16419. * Sets the shader path used to define the shader code
  16420. * It can be modified to trigger a new compilation
  16421. */
  16422. set shaderPath(shaderPath: any);
  16423. /**
  16424. * Gets the options used to compile the shader.
  16425. * They can be modified to trigger a new compilation
  16426. */
  16427. get options(): IShaderMaterialOptions;
  16428. /**
  16429. * Gets the current class name of the material e.g. "ShaderMaterial"
  16430. * Mainly use in serialization.
  16431. * @returns the class name
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Specifies if the material will require alpha blending
  16436. * @returns a boolean specifying if alpha blending is needed
  16437. */
  16438. needAlphaBlending(): boolean;
  16439. /**
  16440. * Specifies if this material should be rendered in alpha test mode
  16441. * @returns a boolean specifying if an alpha test is needed.
  16442. */
  16443. needAlphaTesting(): boolean;
  16444. private _checkUniform;
  16445. /**
  16446. * Set a texture in the shader.
  16447. * @param name Define the name of the uniform samplers as defined in the shader
  16448. * @param texture Define the texture to bind to this sampler
  16449. * @return the material itself allowing "fluent" like uniform updates
  16450. */
  16451. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16452. /**
  16453. * Set a texture array in the shader.
  16454. * @param name Define the name of the uniform sampler array as defined in the shader
  16455. * @param textures Define the list of textures to bind to this sampler
  16456. * @return the material itself allowing "fluent" like uniform updates
  16457. */
  16458. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the material itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ShaderMaterial;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the material itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ShaderMaterial;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the material itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ShaderMaterial;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the material itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ShaderMaterial;
  16487. /**
  16488. * Set a vec3 array in the shader from a Color3 array.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the material itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16494. /**
  16495. * Set a vec4 in the shader from a Color4.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the material itself allowing "fluent" like uniform updates
  16499. */
  16500. setColor4(name: string, value: Color4): ShaderMaterial;
  16501. /**
  16502. * Set a vec4 array in the shader from a Color4 array.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the material itself allowing "fluent" like uniform updates
  16506. */
  16507. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16508. /**
  16509. * Set a vec2 in the shader from a Vector2.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the material itself allowing "fluent" like uniform updates
  16513. */
  16514. setVector2(name: string, value: Vector2): ShaderMaterial;
  16515. /**
  16516. * Set a vec3 in the shader from a Vector3.
  16517. * @param name Define the name of the uniform as defined in the shader
  16518. * @param value Define the value to give to the uniform
  16519. * @return the material itself allowing "fluent" like uniform updates
  16520. */
  16521. setVector3(name: string, value: Vector3): ShaderMaterial;
  16522. /**
  16523. * Set a vec4 in the shader from a Vector4.
  16524. * @param name Define the name of the uniform as defined in the shader
  16525. * @param value Define the value to give to the uniform
  16526. * @return the material itself allowing "fluent" like uniform updates
  16527. */
  16528. setVector4(name: string, value: Vector4): ShaderMaterial;
  16529. /**
  16530. * Set a mat4 in the shader from a Matrix.
  16531. * @param name Define the name of the uniform as defined in the shader
  16532. * @param value Define the value to give to the uniform
  16533. * @return the material itself allowing "fluent" like uniform updates
  16534. */
  16535. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16536. /**
  16537. * Set a float32Array in the shader from a matrix array.
  16538. * @param name Define the name of the uniform as defined in the shader
  16539. * @param value Define the value to give to the uniform
  16540. * @return the material itself allowing "fluent" like uniform updates
  16541. */
  16542. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16543. /**
  16544. * Set a mat3 in the shader from a Float32Array.
  16545. * @param name Define the name of the uniform as defined in the shader
  16546. * @param value Define the value to give to the uniform
  16547. * @return the material itself allowing "fluent" like uniform updates
  16548. */
  16549. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16550. /**
  16551. * Set a mat2 in the shader from a Float32Array.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the material itself allowing "fluent" like uniform updates
  16555. */
  16556. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16557. /**
  16558. * Set a vec2 array in the shader from a number array.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the material itself allowing "fluent" like uniform updates
  16562. */
  16563. setArray2(name: string, value: number[]): ShaderMaterial;
  16564. /**
  16565. * Set a vec3 array in the shader from a number array.
  16566. * @param name Define the name of the uniform as defined in the shader
  16567. * @param value Define the value to give to the uniform
  16568. * @return the material itself allowing "fluent" like uniform updates
  16569. */
  16570. setArray3(name: string, value: number[]): ShaderMaterial;
  16571. /**
  16572. * Set a vec4 array in the shader from a number array.
  16573. * @param name Define the name of the uniform as defined in the shader
  16574. * @param value Define the value to give to the uniform
  16575. * @return the material itself allowing "fluent" like uniform updates
  16576. */
  16577. setArray4(name: string, value: number[]): ShaderMaterial;
  16578. private _checkCache;
  16579. /**
  16580. * Specifies that the submesh is ready to be used
  16581. * @param mesh defines the mesh to check
  16582. * @param subMesh defines which submesh to check
  16583. * @param useInstances specifies that instances should be used
  16584. * @returns a boolean indicating that the submesh is ready or not
  16585. */
  16586. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16587. /**
  16588. * Checks if the material is ready to render the requested mesh
  16589. * @param mesh Define the mesh to render
  16590. * @param useInstances Define whether or not the material is used with instances
  16591. * @returns true if ready, otherwise false
  16592. */
  16593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16594. /**
  16595. * Binds the world matrix to the material
  16596. * @param world defines the world transformation matrix
  16597. * @param effectOverride - If provided, use this effect instead of internal effect
  16598. */
  16599. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16600. /**
  16601. * Binds the submesh to this material by preparing the effect and shader to draw
  16602. * @param world defines the world transformation matrix
  16603. * @param mesh defines the mesh containing the submesh
  16604. * @param subMesh defines the submesh to bind the material to
  16605. */
  16606. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16607. /**
  16608. * Binds the material to the mesh
  16609. * @param world defines the world transformation matrix
  16610. * @param mesh defines the mesh to bind the material to
  16611. * @param effectOverride - If provided, use this effect instead of internal effect
  16612. */
  16613. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16614. protected _afterBind(mesh?: Mesh): void;
  16615. /**
  16616. * Gets the active textures from the material
  16617. * @returns an array of textures
  16618. */
  16619. getActiveTextures(): BaseTexture[];
  16620. /**
  16621. * Specifies if the material uses a texture
  16622. * @param texture defines the texture to check against the material
  16623. * @returns a boolean specifying if the material uses the texture
  16624. */
  16625. hasTexture(texture: BaseTexture): boolean;
  16626. /**
  16627. * Makes a duplicate of the material, and gives it a new name
  16628. * @param name defines the new name for the duplicated material
  16629. * @returns the cloned material
  16630. */
  16631. clone(name: string): ShaderMaterial;
  16632. /**
  16633. * Disposes the material
  16634. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16635. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16636. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16637. */
  16638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16639. /**
  16640. * Serializes this material in a JSON representation
  16641. * @returns the serialized material object
  16642. */
  16643. serialize(): any;
  16644. /**
  16645. * Creates a shader material from parsed shader material data
  16646. * @param source defines the JSON represnetation of the material
  16647. * @param scene defines the hosting scene
  16648. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16649. * @returns a new material
  16650. */
  16651. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16652. }
  16653. }
  16654. declare module BABYLON {
  16655. /** @hidden */
  16656. export var colorPixelShader: {
  16657. name: string;
  16658. shader: string;
  16659. };
  16660. }
  16661. declare module BABYLON {
  16662. /** @hidden */
  16663. export var colorVertexShader: {
  16664. name: string;
  16665. shader: string;
  16666. };
  16667. }
  16668. declare module BABYLON {
  16669. /**
  16670. * Line mesh
  16671. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16672. */
  16673. export class LinesMesh extends Mesh {
  16674. /**
  16675. * If vertex color should be applied to the mesh
  16676. */
  16677. readonly useVertexColor?: boolean | undefined;
  16678. /**
  16679. * If vertex alpha should be applied to the mesh
  16680. */
  16681. readonly useVertexAlpha?: boolean | undefined;
  16682. /**
  16683. * Color of the line (Default: White)
  16684. */
  16685. color: Color3;
  16686. /**
  16687. * Alpha of the line (Default: 1)
  16688. */
  16689. alpha: number;
  16690. /**
  16691. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16692. * This margin is expressed in world space coordinates, so its value may vary.
  16693. * Default value is 0.1
  16694. */
  16695. intersectionThreshold: number;
  16696. private _colorShader;
  16697. private color4;
  16698. /**
  16699. * Creates a new LinesMesh
  16700. * @param name defines the name
  16701. * @param scene defines the hosting scene
  16702. * @param parent defines the parent mesh if any
  16703. * @param source defines the optional source LinesMesh used to clone data from
  16704. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16705. * When false, achieved by calling a clone(), also passing False.
  16706. * This will make creation of children, recursive.
  16707. * @param useVertexColor defines if this LinesMesh supports vertex color
  16708. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16709. */
  16710. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16711. /**
  16712. * If vertex color should be applied to the mesh
  16713. */
  16714. useVertexColor?: boolean | undefined,
  16715. /**
  16716. * If vertex alpha should be applied to the mesh
  16717. */
  16718. useVertexAlpha?: boolean | undefined);
  16719. private _addClipPlaneDefine;
  16720. private _removeClipPlaneDefine;
  16721. isReady(): boolean;
  16722. /**
  16723. * Returns the string "LineMesh"
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * @hidden
  16728. */
  16729. get material(): Material;
  16730. /**
  16731. * @hidden
  16732. */
  16733. set material(value: Material);
  16734. /**
  16735. * @hidden
  16736. */
  16737. get checkCollisions(): boolean;
  16738. /** @hidden */
  16739. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16740. /** @hidden */
  16741. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16742. /**
  16743. * Disposes of the line mesh
  16744. * @param doNotRecurse If children should be disposed
  16745. */
  16746. dispose(doNotRecurse?: boolean): void;
  16747. /**
  16748. * Returns a new LineMesh object cloned from the current one.
  16749. */
  16750. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16751. /**
  16752. * Creates a new InstancedLinesMesh object from the mesh model.
  16753. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16754. * @param name defines the name of the new instance
  16755. * @returns a new InstancedLinesMesh
  16756. */
  16757. createInstance(name: string): InstancedLinesMesh;
  16758. }
  16759. /**
  16760. * Creates an instance based on a source LinesMesh
  16761. */
  16762. export class InstancedLinesMesh extends InstancedMesh {
  16763. /**
  16764. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16765. * This margin is expressed in world space coordinates, so its value may vary.
  16766. * Initilized with the intersectionThreshold value of the source LinesMesh
  16767. */
  16768. intersectionThreshold: number;
  16769. constructor(name: string, source: LinesMesh);
  16770. /**
  16771. * Returns the string "InstancedLinesMesh".
  16772. */
  16773. getClassName(): string;
  16774. }
  16775. }
  16776. declare module BABYLON {
  16777. /** @hidden */
  16778. export var linePixelShader: {
  16779. name: string;
  16780. shader: string;
  16781. };
  16782. }
  16783. declare module BABYLON {
  16784. /** @hidden */
  16785. export var lineVertexShader: {
  16786. name: string;
  16787. shader: string;
  16788. };
  16789. }
  16790. declare module BABYLON {
  16791. interface AbstractMesh {
  16792. /**
  16793. * Gets the edgesRenderer associated with the mesh
  16794. */
  16795. edgesRenderer: Nullable<EdgesRenderer>;
  16796. }
  16797. interface LinesMesh {
  16798. /**
  16799. * Enables the edge rendering mode on the mesh.
  16800. * This mode makes the mesh edges visible
  16801. * @param epsilon defines the maximal distance between two angles to detect a face
  16802. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16803. * @returns the currentAbstractMesh
  16804. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16805. */
  16806. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16807. }
  16808. interface InstancedLinesMesh {
  16809. /**
  16810. * Enables the edge rendering mode on the mesh.
  16811. * This mode makes the mesh edges visible
  16812. * @param epsilon defines the maximal distance between two angles to detect a face
  16813. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16814. * @returns the current InstancedLinesMesh
  16815. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16816. */
  16817. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16818. }
  16819. /**
  16820. * Defines the minimum contract an Edges renderer should follow.
  16821. */
  16822. export interface IEdgesRenderer extends IDisposable {
  16823. /**
  16824. * Gets or sets a boolean indicating if the edgesRenderer is active
  16825. */
  16826. isEnabled: boolean;
  16827. /**
  16828. * Renders the edges of the attached mesh,
  16829. */
  16830. render(): void;
  16831. /**
  16832. * Checks wether or not the edges renderer is ready to render.
  16833. * @return true if ready, otherwise false.
  16834. */
  16835. isReady(): boolean;
  16836. }
  16837. /**
  16838. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16839. */
  16840. export class EdgesRenderer implements IEdgesRenderer {
  16841. /**
  16842. * Define the size of the edges with an orthographic camera
  16843. */
  16844. edgesWidthScalerForOrthographic: number;
  16845. /**
  16846. * Define the size of the edges with a perspective camera
  16847. */
  16848. edgesWidthScalerForPerspective: number;
  16849. protected _source: AbstractMesh;
  16850. protected _linesPositions: number[];
  16851. protected _linesNormals: number[];
  16852. protected _linesIndices: number[];
  16853. protected _epsilon: number;
  16854. protected _indicesCount: number;
  16855. protected _lineShader: ShaderMaterial;
  16856. protected _ib: DataBuffer;
  16857. protected _buffers: {
  16858. [key: string]: Nullable<VertexBuffer>;
  16859. };
  16860. protected _checkVerticesInsteadOfIndices: boolean;
  16861. private _meshRebuildObserver;
  16862. private _meshDisposeObserver;
  16863. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16864. isEnabled: boolean;
  16865. /**
  16866. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16867. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16868. * @param source Mesh used to create edges
  16869. * @param epsilon sum of angles in adjacency to check for edge
  16870. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16871. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16872. */
  16873. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16874. protected _prepareRessources(): void;
  16875. /** @hidden */
  16876. _rebuild(): void;
  16877. /**
  16878. * Releases the required resources for the edges renderer
  16879. */
  16880. dispose(): void;
  16881. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16882. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16883. /**
  16884. * Checks if the pair of p0 and p1 is en edge
  16885. * @param faceIndex
  16886. * @param edge
  16887. * @param faceNormals
  16888. * @param p0
  16889. * @param p1
  16890. * @private
  16891. */
  16892. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16893. /**
  16894. * push line into the position, normal and index buffer
  16895. * @protected
  16896. */
  16897. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16898. /**
  16899. * Generates lines edges from adjacencjes
  16900. * @private
  16901. */
  16902. _generateEdgesLines(): void;
  16903. /**
  16904. * Checks wether or not the edges renderer is ready to render.
  16905. * @return true if ready, otherwise false.
  16906. */
  16907. isReady(): boolean;
  16908. /**
  16909. * Renders the edges of the attached mesh,
  16910. */
  16911. render(): void;
  16912. }
  16913. /**
  16914. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16915. */
  16916. export class LineEdgesRenderer extends EdgesRenderer {
  16917. /**
  16918. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16919. * @param source LineMesh used to generate edges
  16920. * @param epsilon not important (specified angle for edge detection)
  16921. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16922. */
  16923. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16924. /**
  16925. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16926. */
  16927. _generateEdgesLines(): void;
  16928. }
  16929. }
  16930. declare module BABYLON {
  16931. /**
  16932. * This represents the object necessary to create a rendering group.
  16933. * This is exclusively used and created by the rendering manager.
  16934. * To modify the behavior, you use the available helpers in your scene or meshes.
  16935. * @hidden
  16936. */
  16937. export class RenderingGroup {
  16938. index: number;
  16939. private static _zeroVector;
  16940. private _scene;
  16941. private _opaqueSubMeshes;
  16942. private _transparentSubMeshes;
  16943. private _alphaTestSubMeshes;
  16944. private _depthOnlySubMeshes;
  16945. private _particleSystems;
  16946. private _spriteManagers;
  16947. private _opaqueSortCompareFn;
  16948. private _alphaTestSortCompareFn;
  16949. private _transparentSortCompareFn;
  16950. private _renderOpaque;
  16951. private _renderAlphaTest;
  16952. private _renderTransparent;
  16953. /** @hidden */
  16954. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16955. onBeforeTransparentRendering: () => void;
  16956. /**
  16957. * Set the opaque sort comparison function.
  16958. * If null the sub meshes will be render in the order they were created
  16959. */
  16960. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16961. /**
  16962. * Set the alpha test sort comparison function.
  16963. * If null the sub meshes will be render in the order they were created
  16964. */
  16965. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16966. /**
  16967. * Set the transparent sort comparison function.
  16968. * If null the sub meshes will be render in the order they were created
  16969. */
  16970. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16971. /**
  16972. * Creates a new rendering group.
  16973. * @param index The rendering group index
  16974. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16975. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16976. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16977. */
  16978. 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>);
  16979. /**
  16980. * Render all the sub meshes contained in the group.
  16981. * @param customRenderFunction Used to override the default render behaviour of the group.
  16982. * @returns true if rendered some submeshes.
  16983. */
  16984. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16985. /**
  16986. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16987. * @param subMeshes The submeshes to render
  16988. */
  16989. private renderOpaqueSorted;
  16990. /**
  16991. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16992. * @param subMeshes The submeshes to render
  16993. */
  16994. private renderAlphaTestSorted;
  16995. /**
  16996. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16997. * @param subMeshes The submeshes to render
  16998. */
  16999. private renderTransparentSorted;
  17000. /**
  17001. * Renders the submeshes in a specified order.
  17002. * @param subMeshes The submeshes to sort before render
  17003. * @param sortCompareFn The comparison function use to sort
  17004. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17005. * @param transparent Specifies to activate blending if true
  17006. */
  17007. private static renderSorted;
  17008. /**
  17009. * Renders the submeshes in the order they were dispatched (no sort applied).
  17010. * @param subMeshes The submeshes to render
  17011. */
  17012. private static renderUnsorted;
  17013. /**
  17014. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17015. * are rendered back to front if in the same alpha index.
  17016. *
  17017. * @param a The first submesh
  17018. * @param b The second submesh
  17019. * @returns The result of the comparison
  17020. */
  17021. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17022. /**
  17023. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17024. * are rendered back to front.
  17025. *
  17026. * @param a The first submesh
  17027. * @param b The second submesh
  17028. * @returns The result of the comparison
  17029. */
  17030. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17031. /**
  17032. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17033. * are rendered front to back (prevent overdraw).
  17034. *
  17035. * @param a The first submesh
  17036. * @param b The second submesh
  17037. * @returns The result of the comparison
  17038. */
  17039. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17040. /**
  17041. * Resets the different lists of submeshes to prepare a new frame.
  17042. */
  17043. prepare(): void;
  17044. dispose(): void;
  17045. /**
  17046. * Inserts the submesh in its correct queue depending on its material.
  17047. * @param subMesh The submesh to dispatch
  17048. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17049. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17050. */
  17051. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17052. dispatchSprites(spriteManager: ISpriteManager): void;
  17053. dispatchParticles(particleSystem: IParticleSystem): void;
  17054. private _renderParticles;
  17055. private _renderSprites;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /**
  17060. * Interface describing the different options available in the rendering manager
  17061. * regarding Auto Clear between groups.
  17062. */
  17063. export interface IRenderingManagerAutoClearSetup {
  17064. /**
  17065. * Defines whether or not autoclear is enable.
  17066. */
  17067. autoClear: boolean;
  17068. /**
  17069. * Defines whether or not to autoclear the depth buffer.
  17070. */
  17071. depth: boolean;
  17072. /**
  17073. * Defines whether or not to autoclear the stencil buffer.
  17074. */
  17075. stencil: boolean;
  17076. }
  17077. /**
  17078. * This class is used by the onRenderingGroupObservable
  17079. */
  17080. export class RenderingGroupInfo {
  17081. /**
  17082. * The Scene that being rendered
  17083. */
  17084. scene: Scene;
  17085. /**
  17086. * The camera currently used for the rendering pass
  17087. */
  17088. camera: Nullable<Camera>;
  17089. /**
  17090. * The ID of the renderingGroup being processed
  17091. */
  17092. renderingGroupId: number;
  17093. }
  17094. /**
  17095. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17096. * It is enable to manage the different groups as well as the different necessary sort functions.
  17097. * This should not be used directly aside of the few static configurations
  17098. */
  17099. export class RenderingManager {
  17100. /**
  17101. * The max id used for rendering groups (not included)
  17102. */
  17103. static MAX_RENDERINGGROUPS: number;
  17104. /**
  17105. * The min id used for rendering groups (included)
  17106. */
  17107. static MIN_RENDERINGGROUPS: number;
  17108. /**
  17109. * Used to globally prevent autoclearing scenes.
  17110. */
  17111. static AUTOCLEAR: boolean;
  17112. /**
  17113. * @hidden
  17114. */
  17115. _useSceneAutoClearSetup: boolean;
  17116. private _scene;
  17117. private _renderingGroups;
  17118. private _depthStencilBufferAlreadyCleaned;
  17119. private _autoClearDepthStencil;
  17120. private _customOpaqueSortCompareFn;
  17121. private _customAlphaTestSortCompareFn;
  17122. private _customTransparentSortCompareFn;
  17123. private _renderingGroupInfo;
  17124. /**
  17125. * Instantiates a new rendering group for a particular scene
  17126. * @param scene Defines the scene the groups belongs to
  17127. */
  17128. constructor(scene: Scene);
  17129. private _clearDepthStencilBuffer;
  17130. /**
  17131. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17132. * @hidden
  17133. */
  17134. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17135. /**
  17136. * Resets the different information of the group to prepare a new frame
  17137. * @hidden
  17138. */
  17139. reset(): void;
  17140. /**
  17141. * Dispose and release the group and its associated resources.
  17142. * @hidden
  17143. */
  17144. dispose(): void;
  17145. /**
  17146. * Clear the info related to rendering groups preventing retention points during dispose.
  17147. */
  17148. freeRenderingGroups(): void;
  17149. private _prepareRenderingGroup;
  17150. /**
  17151. * Add a sprite manager to the rendering manager in order to render it this frame.
  17152. * @param spriteManager Define the sprite manager to render
  17153. */
  17154. dispatchSprites(spriteManager: ISpriteManager): void;
  17155. /**
  17156. * Add a particle system to the rendering manager in order to render it this frame.
  17157. * @param particleSystem Define the particle system to render
  17158. */
  17159. dispatchParticles(particleSystem: IParticleSystem): void;
  17160. /**
  17161. * Add a submesh to the manager in order to render it this frame
  17162. * @param subMesh The submesh to dispatch
  17163. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17164. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17165. */
  17166. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17167. /**
  17168. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17169. * This allowed control for front to back rendering or reversly depending of the special needs.
  17170. *
  17171. * @param renderingGroupId The rendering group id corresponding to its index
  17172. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17173. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17174. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17175. */
  17176. 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;
  17177. /**
  17178. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17179. *
  17180. * @param renderingGroupId The rendering group id corresponding to its index
  17181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17182. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17183. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17184. */
  17185. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17186. /**
  17187. * Gets the current auto clear configuration for one rendering group of the rendering
  17188. * manager.
  17189. * @param index the rendering group index to get the information for
  17190. * @returns The auto clear setup for the requested rendering group
  17191. */
  17192. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17193. }
  17194. }
  17195. declare module BABYLON {
  17196. /**
  17197. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17198. */
  17199. export interface ICustomShaderOptions {
  17200. /**
  17201. * Gets or sets the custom shader name to use
  17202. */
  17203. shaderName: string;
  17204. /**
  17205. * The list of attribute names used in the shader
  17206. */
  17207. attributes?: string[];
  17208. /**
  17209. * The list of unifrom names used in the shader
  17210. */
  17211. uniforms?: string[];
  17212. /**
  17213. * The list of sampler names used in the shader
  17214. */
  17215. samplers?: string[];
  17216. /**
  17217. * The list of defines used in the shader
  17218. */
  17219. defines?: string[];
  17220. }
  17221. /**
  17222. * Interface to implement to create a shadow generator compatible with BJS.
  17223. */
  17224. export interface IShadowGenerator {
  17225. /**
  17226. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17227. * @returns The render target texture if present otherwise, null
  17228. */
  17229. getShadowMap(): Nullable<RenderTargetTexture>;
  17230. /**
  17231. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17232. * @param subMesh The submesh we want to render in the shadow map
  17233. * @param useInstances Defines wether will draw in the map using instances
  17234. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17235. * @returns true if ready otherwise, false
  17236. */
  17237. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17238. /**
  17239. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17240. * @param defines Defines of the material we want to update
  17241. * @param lightIndex Index of the light in the enabled light list of the material
  17242. */
  17243. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17244. /**
  17245. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17246. * defined in the generator but impacting the effect).
  17247. * It implies the unifroms available on the materials are the standard BJS ones.
  17248. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17249. * @param effect The effect we are binfing the information for
  17250. */
  17251. bindShadowLight(lightIndex: string, effect: Effect): void;
  17252. /**
  17253. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17254. * (eq to shadow prjection matrix * light transform matrix)
  17255. * @returns The transform matrix used to create the shadow map
  17256. */
  17257. getTransformMatrix(): Matrix;
  17258. /**
  17259. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17260. * Cube and 2D textures for instance.
  17261. */
  17262. recreateShadowMap(): void;
  17263. /**
  17264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17265. * @param onCompiled Callback triggered at the and of the effects compilation
  17266. * @param options Sets of optional options forcing the compilation with different modes
  17267. */
  17268. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17269. useInstances: boolean;
  17270. }>): void;
  17271. /**
  17272. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17273. * @param options Sets of optional options forcing the compilation with different modes
  17274. * @returns A promise that resolves when the compilation completes
  17275. */
  17276. forceCompilationAsync(options?: Partial<{
  17277. useInstances: boolean;
  17278. }>): Promise<void>;
  17279. /**
  17280. * Serializes the shadow generator setup to a json object.
  17281. * @returns The serialized JSON object
  17282. */
  17283. serialize(): any;
  17284. /**
  17285. * Disposes the Shadow map and related Textures and effects.
  17286. */
  17287. dispose(): void;
  17288. }
  17289. /**
  17290. * Default implementation IShadowGenerator.
  17291. * This is the main object responsible of generating shadows in the framework.
  17292. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17293. */
  17294. export class ShadowGenerator implements IShadowGenerator {
  17295. /**
  17296. * Name of the shadow generator class
  17297. */
  17298. static CLASSNAME: string;
  17299. /**
  17300. * Shadow generator mode None: no filtering applied.
  17301. */
  17302. static readonly FILTER_NONE: number;
  17303. /**
  17304. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17305. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17306. */
  17307. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17308. /**
  17309. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17310. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17311. */
  17312. static readonly FILTER_POISSONSAMPLING: number;
  17313. /**
  17314. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17316. */
  17317. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17318. /**
  17319. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17320. * edge artifacts on steep falloff.
  17321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17322. */
  17323. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17324. /**
  17325. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17326. * edge artifacts on steep falloff.
  17327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17328. */
  17329. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17330. /**
  17331. * Shadow generator mode PCF: Percentage Closer Filtering
  17332. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17333. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17334. */
  17335. static readonly FILTER_PCF: number;
  17336. /**
  17337. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17338. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17339. * Contact Hardening
  17340. */
  17341. static readonly FILTER_PCSS: number;
  17342. /**
  17343. * Reserved for PCF and PCSS
  17344. * Highest Quality.
  17345. *
  17346. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17347. *
  17348. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17349. */
  17350. static readonly QUALITY_HIGH: number;
  17351. /**
  17352. * Reserved for PCF and PCSS
  17353. * Good tradeoff for quality/perf cross devices
  17354. *
  17355. * Execute PCF on a 3*3 kernel.
  17356. *
  17357. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17358. */
  17359. static readonly QUALITY_MEDIUM: number;
  17360. /**
  17361. * Reserved for PCF and PCSS
  17362. * The lowest quality but the fastest.
  17363. *
  17364. * Execute PCF on a 1*1 kernel.
  17365. *
  17366. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17367. */
  17368. static readonly QUALITY_LOW: number;
  17369. /** Gets or sets the custom shader name to use */
  17370. customShaderOptions: ICustomShaderOptions;
  17371. /**
  17372. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17373. */
  17374. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17375. /**
  17376. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17377. */
  17378. onAfterShadowMapRenderObservable: Observable<Effect>;
  17379. /**
  17380. * Observable triggered before a mesh is rendered in the shadow map.
  17381. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17382. */
  17383. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17384. /**
  17385. * Observable triggered after a mesh is rendered in the shadow map.
  17386. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17387. */
  17388. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17389. protected _bias: number;
  17390. /**
  17391. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17392. */
  17393. get bias(): number;
  17394. /**
  17395. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17396. */
  17397. set bias(bias: number);
  17398. protected _normalBias: number;
  17399. /**
  17400. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17401. */
  17402. get normalBias(): number;
  17403. /**
  17404. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17405. */
  17406. set normalBias(normalBias: number);
  17407. protected _blurBoxOffset: number;
  17408. /**
  17409. * Gets the blur box offset: offset applied during the blur pass.
  17410. * Only useful if useKernelBlur = false
  17411. */
  17412. get blurBoxOffset(): number;
  17413. /**
  17414. * Sets the blur box offset: offset applied during the blur pass.
  17415. * Only useful if useKernelBlur = false
  17416. */
  17417. set blurBoxOffset(value: number);
  17418. protected _blurScale: number;
  17419. /**
  17420. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17421. * 2 means half of the size.
  17422. */
  17423. get blurScale(): number;
  17424. /**
  17425. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17426. * 2 means half of the size.
  17427. */
  17428. set blurScale(value: number);
  17429. protected _blurKernel: number;
  17430. /**
  17431. * Gets the blur kernel: kernel size of the blur pass.
  17432. * Only useful if useKernelBlur = true
  17433. */
  17434. get blurKernel(): number;
  17435. /**
  17436. * Sets the blur kernel: kernel size of the blur pass.
  17437. * Only useful if useKernelBlur = true
  17438. */
  17439. set blurKernel(value: number);
  17440. protected _useKernelBlur: boolean;
  17441. /**
  17442. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17443. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17444. */
  17445. get useKernelBlur(): boolean;
  17446. /**
  17447. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17448. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17449. */
  17450. set useKernelBlur(value: boolean);
  17451. protected _depthScale: number;
  17452. /**
  17453. * Gets the depth scale used in ESM mode.
  17454. */
  17455. get depthScale(): number;
  17456. /**
  17457. * Sets the depth scale used in ESM mode.
  17458. * This can override the scale stored on the light.
  17459. */
  17460. set depthScale(value: number);
  17461. protected _validateFilter(filter: number): number;
  17462. protected _filter: number;
  17463. /**
  17464. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17465. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17466. */
  17467. get filter(): number;
  17468. /**
  17469. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17470. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17471. */
  17472. set filter(value: number);
  17473. /**
  17474. * Gets if the current filter is set to Poisson Sampling.
  17475. */
  17476. get usePoissonSampling(): boolean;
  17477. /**
  17478. * Sets the current filter to Poisson Sampling.
  17479. */
  17480. set usePoissonSampling(value: boolean);
  17481. /**
  17482. * Gets if the current filter is set to ESM.
  17483. */
  17484. get useExponentialShadowMap(): boolean;
  17485. /**
  17486. * Sets the current filter is to ESM.
  17487. */
  17488. set useExponentialShadowMap(value: boolean);
  17489. /**
  17490. * Gets if the current filter is set to filtered ESM.
  17491. */
  17492. get useBlurExponentialShadowMap(): boolean;
  17493. /**
  17494. * Gets if the current filter is set to filtered ESM.
  17495. */
  17496. set useBlurExponentialShadowMap(value: boolean);
  17497. /**
  17498. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17499. * exponential to prevent steep falloff artifacts).
  17500. */
  17501. get useCloseExponentialShadowMap(): boolean;
  17502. /**
  17503. * Sets the current filter to "close ESM" (using the inverse of the
  17504. * exponential to prevent steep falloff artifacts).
  17505. */
  17506. set useCloseExponentialShadowMap(value: boolean);
  17507. /**
  17508. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17509. * exponential to prevent steep falloff artifacts).
  17510. */
  17511. get useBlurCloseExponentialShadowMap(): boolean;
  17512. /**
  17513. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17514. * exponential to prevent steep falloff artifacts).
  17515. */
  17516. set useBlurCloseExponentialShadowMap(value: boolean);
  17517. /**
  17518. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17519. */
  17520. get usePercentageCloserFiltering(): boolean;
  17521. /**
  17522. * Sets the current filter to "PCF" (percentage closer filtering).
  17523. */
  17524. set usePercentageCloserFiltering(value: boolean);
  17525. protected _filteringQuality: number;
  17526. /**
  17527. * Gets the PCF or PCSS Quality.
  17528. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17529. */
  17530. get filteringQuality(): number;
  17531. /**
  17532. * Sets the PCF or PCSS Quality.
  17533. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17534. */
  17535. set filteringQuality(filteringQuality: number);
  17536. /**
  17537. * Gets if the current filter is set to "PCSS" (contact hardening).
  17538. */
  17539. get useContactHardeningShadow(): boolean;
  17540. /**
  17541. * Sets the current filter to "PCSS" (contact hardening).
  17542. */
  17543. set useContactHardeningShadow(value: boolean);
  17544. protected _contactHardeningLightSizeUVRatio: number;
  17545. /**
  17546. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17547. * Using a ratio helps keeping shape stability independently of the map size.
  17548. *
  17549. * It does not account for the light projection as it was having too much
  17550. * instability during the light setup or during light position changes.
  17551. *
  17552. * Only valid if useContactHardeningShadow is true.
  17553. */
  17554. get contactHardeningLightSizeUVRatio(): number;
  17555. /**
  17556. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17557. * Using a ratio helps keeping shape stability independently of the map size.
  17558. *
  17559. * It does not account for the light projection as it was having too much
  17560. * instability during the light setup or during light position changes.
  17561. *
  17562. * Only valid if useContactHardeningShadow is true.
  17563. */
  17564. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17565. protected _darkness: number;
  17566. /** Gets or sets the actual darkness of a shadow */
  17567. get darkness(): number;
  17568. set darkness(value: number);
  17569. /**
  17570. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17571. * 0 means strongest and 1 would means no shadow.
  17572. * @returns the darkness.
  17573. */
  17574. getDarkness(): number;
  17575. /**
  17576. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17577. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17578. * @returns the shadow generator allowing fluent coding.
  17579. */
  17580. setDarkness(darkness: number): ShadowGenerator;
  17581. protected _transparencyShadow: boolean;
  17582. /** Gets or sets the ability to have transparent shadow */
  17583. get transparencyShadow(): boolean;
  17584. set transparencyShadow(value: boolean);
  17585. /**
  17586. * Sets the ability to have transparent shadow (boolean).
  17587. * @param transparent True if transparent else False
  17588. * @returns the shadow generator allowing fluent coding
  17589. */
  17590. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17591. /**
  17592. * Enables or disables shadows with varying strength based on the transparency
  17593. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17594. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17595. * mesh.visibility * alphaTexture.a
  17596. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17597. */
  17598. enableSoftTransparentShadow: boolean;
  17599. protected _shadowMap: Nullable<RenderTargetTexture>;
  17600. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17601. /**
  17602. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17603. * @returns The render target texture if present otherwise, null
  17604. */
  17605. getShadowMap(): Nullable<RenderTargetTexture>;
  17606. /**
  17607. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17608. * @returns The render target texture if the shadow map is present otherwise, null
  17609. */
  17610. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17611. /**
  17612. * Gets the class name of that object
  17613. * @returns "ShadowGenerator"
  17614. */
  17615. getClassName(): string;
  17616. /**
  17617. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17618. * @param mesh Mesh to add
  17619. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17620. * @returns the Shadow Generator itself
  17621. */
  17622. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17623. /**
  17624. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17625. * @param mesh Mesh to remove
  17626. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17627. * @returns the Shadow Generator itself
  17628. */
  17629. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17630. /**
  17631. * Controls the extent to which the shadows fade out at the edge of the frustum
  17632. */
  17633. frustumEdgeFalloff: number;
  17634. protected _light: IShadowLight;
  17635. /**
  17636. * Returns the associated light object.
  17637. * @returns the light generating the shadow
  17638. */
  17639. getLight(): IShadowLight;
  17640. /**
  17641. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17642. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17643. * It might on the other hand introduce peter panning.
  17644. */
  17645. forceBackFacesOnly: boolean;
  17646. protected _scene: Scene;
  17647. protected _lightDirection: Vector3;
  17648. protected _effect: Effect;
  17649. protected _viewMatrix: Matrix;
  17650. protected _projectionMatrix: Matrix;
  17651. protected _transformMatrix: Matrix;
  17652. protected _cachedPosition: Vector3;
  17653. protected _cachedDirection: Vector3;
  17654. protected _cachedDefines: string;
  17655. protected _currentRenderID: number;
  17656. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17657. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17658. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17659. protected _blurPostProcesses: PostProcess[];
  17660. protected _mapSize: number;
  17661. protected _currentFaceIndex: number;
  17662. protected _currentFaceIndexCache: number;
  17663. protected _textureType: number;
  17664. protected _defaultTextureMatrix: Matrix;
  17665. protected _storedUniqueId: Nullable<number>;
  17666. /** @hidden */
  17667. static _SceneComponentInitialization: (scene: Scene) => void;
  17668. /**
  17669. * Creates a ShadowGenerator object.
  17670. * A ShadowGenerator is the required tool to use the shadows.
  17671. * Each light casting shadows needs to use its own ShadowGenerator.
  17672. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17673. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17674. * @param light The light object generating the shadows.
  17675. * @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.
  17676. */
  17677. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17678. protected _initializeGenerator(): void;
  17679. protected _createTargetRenderTexture(): void;
  17680. protected _initializeShadowMap(): void;
  17681. protected _initializeBlurRTTAndPostProcesses(): void;
  17682. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17683. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17684. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17685. protected _applyFilterValues(): void;
  17686. /**
  17687. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17688. * @param onCompiled Callback triggered at the and of the effects compilation
  17689. * @param options Sets of optional options forcing the compilation with different modes
  17690. */
  17691. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17692. useInstances: boolean;
  17693. }>): void;
  17694. /**
  17695. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17696. * @param options Sets of optional options forcing the compilation with different modes
  17697. * @returns A promise that resolves when the compilation completes
  17698. */
  17699. forceCompilationAsync(options?: Partial<{
  17700. useInstances: boolean;
  17701. }>): Promise<void>;
  17702. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17703. private _prepareShadowDefines;
  17704. /**
  17705. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17706. * @param subMesh The submesh we want to render in the shadow map
  17707. * @param useInstances Defines wether will draw in the map using instances
  17708. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17709. * @returns true if ready otherwise, false
  17710. */
  17711. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17712. /**
  17713. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17714. * @param defines Defines of the material we want to update
  17715. * @param lightIndex Index of the light in the enabled light list of the material
  17716. */
  17717. prepareDefines(defines: any, lightIndex: number): void;
  17718. /**
  17719. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17720. * defined in the generator but impacting the effect).
  17721. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17722. * @param effect The effect we are binfing the information for
  17723. */
  17724. bindShadowLight(lightIndex: string, effect: Effect): void;
  17725. /**
  17726. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17727. * (eq to shadow prjection matrix * light transform matrix)
  17728. * @returns The transform matrix used to create the shadow map
  17729. */
  17730. getTransformMatrix(): Matrix;
  17731. /**
  17732. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17733. * Cube and 2D textures for instance.
  17734. */
  17735. recreateShadowMap(): void;
  17736. protected _disposeBlurPostProcesses(): void;
  17737. protected _disposeRTTandPostProcesses(): void;
  17738. /**
  17739. * Disposes the ShadowGenerator.
  17740. * Returns nothing.
  17741. */
  17742. dispose(): void;
  17743. /**
  17744. * Serializes the shadow generator setup to a json object.
  17745. * @returns The serialized JSON object
  17746. */
  17747. serialize(): any;
  17748. /**
  17749. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17750. * @param parsedShadowGenerator The JSON object to parse
  17751. * @param scene The scene to create the shadow map for
  17752. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17753. * @returns The parsed shadow generator
  17754. */
  17755. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17756. }
  17757. }
  17758. declare module BABYLON {
  17759. /**
  17760. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17761. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17762. * 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.
  17763. */
  17764. export abstract class Light extends Node {
  17765. /**
  17766. * Falloff Default: light is falling off following the material specification:
  17767. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17768. */
  17769. static readonly FALLOFF_DEFAULT: number;
  17770. /**
  17771. * Falloff Physical: light is falling off following the inverse squared distance law.
  17772. */
  17773. static readonly FALLOFF_PHYSICAL: number;
  17774. /**
  17775. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17776. * to enhance interoperability with other engines.
  17777. */
  17778. static readonly FALLOFF_GLTF: number;
  17779. /**
  17780. * Falloff Standard: light is falling off like in the standard material
  17781. * to enhance interoperability with other materials.
  17782. */
  17783. static readonly FALLOFF_STANDARD: number;
  17784. /**
  17785. * If every light affecting the material is in this lightmapMode,
  17786. * material.lightmapTexture adds or multiplies
  17787. * (depends on material.useLightmapAsShadowmap)
  17788. * after every other light calculations.
  17789. */
  17790. static readonly LIGHTMAP_DEFAULT: number;
  17791. /**
  17792. * material.lightmapTexture as only diffuse lighting from this light
  17793. * adds only specular lighting from this light
  17794. * adds dynamic shadows
  17795. */
  17796. static readonly LIGHTMAP_SPECULAR: number;
  17797. /**
  17798. * material.lightmapTexture as only lighting
  17799. * no light calculation from this light
  17800. * only adds dynamic shadows from this light
  17801. */
  17802. static readonly LIGHTMAP_SHADOWSONLY: number;
  17803. /**
  17804. * Each light type uses the default quantity according to its type:
  17805. * point/spot lights use luminous intensity
  17806. * directional lights use illuminance
  17807. */
  17808. static readonly INTENSITYMODE_AUTOMATIC: number;
  17809. /**
  17810. * lumen (lm)
  17811. */
  17812. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17813. /**
  17814. * candela (lm/sr)
  17815. */
  17816. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17817. /**
  17818. * lux (lm/m^2)
  17819. */
  17820. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17821. /**
  17822. * nit (cd/m^2)
  17823. */
  17824. static readonly INTENSITYMODE_LUMINANCE: number;
  17825. /**
  17826. * Light type const id of the point light.
  17827. */
  17828. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17829. /**
  17830. * Light type const id of the directional light.
  17831. */
  17832. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17833. /**
  17834. * Light type const id of the spot light.
  17835. */
  17836. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17837. /**
  17838. * Light type const id of the hemispheric light.
  17839. */
  17840. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17841. /**
  17842. * Diffuse gives the basic color to an object.
  17843. */
  17844. diffuse: Color3;
  17845. /**
  17846. * Specular produces a highlight color on an object.
  17847. * Note: This is note affecting PBR materials.
  17848. */
  17849. specular: Color3;
  17850. /**
  17851. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17852. * falling off base on range or angle.
  17853. * This can be set to any values in Light.FALLOFF_x.
  17854. *
  17855. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17856. * other types of materials.
  17857. */
  17858. falloffType: number;
  17859. /**
  17860. * Strength of the light.
  17861. * Note: By default it is define in the framework own unit.
  17862. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17863. */
  17864. intensity: number;
  17865. private _range;
  17866. protected _inverseSquaredRange: number;
  17867. /**
  17868. * Defines how far from the source the light is impacting in scene units.
  17869. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17870. */
  17871. get range(): number;
  17872. /**
  17873. * Defines how far from the source the light is impacting in scene units.
  17874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17875. */
  17876. set range(value: number);
  17877. /**
  17878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17879. * of light.
  17880. */
  17881. private _photometricScale;
  17882. private _intensityMode;
  17883. /**
  17884. * Gets the photometric scale used to interpret the intensity.
  17885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17886. */
  17887. get intensityMode(): number;
  17888. /**
  17889. * Sets the photometric scale used to interpret the intensity.
  17890. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17891. */
  17892. set intensityMode(value: number);
  17893. private _radius;
  17894. /**
  17895. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17896. */
  17897. get radius(): number;
  17898. /**
  17899. * sets the light radius used by PBR Materials to simulate soft area lights.
  17900. */
  17901. set radius(value: number);
  17902. private _renderPriority;
  17903. /**
  17904. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17905. * exceeding the number allowed of the materials.
  17906. */
  17907. renderPriority: number;
  17908. private _shadowEnabled;
  17909. /**
  17910. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17911. * the current shadow generator.
  17912. */
  17913. get shadowEnabled(): boolean;
  17914. /**
  17915. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17916. * the current shadow generator.
  17917. */
  17918. set shadowEnabled(value: boolean);
  17919. private _includedOnlyMeshes;
  17920. /**
  17921. * Gets the only meshes impacted by this light.
  17922. */
  17923. get includedOnlyMeshes(): AbstractMesh[];
  17924. /**
  17925. * Sets the only meshes impacted by this light.
  17926. */
  17927. set includedOnlyMeshes(value: AbstractMesh[]);
  17928. private _excludedMeshes;
  17929. /**
  17930. * Gets the meshes not impacted by this light.
  17931. */
  17932. get excludedMeshes(): AbstractMesh[];
  17933. /**
  17934. * Sets the meshes not impacted by this light.
  17935. */
  17936. set excludedMeshes(value: AbstractMesh[]);
  17937. private _excludeWithLayerMask;
  17938. /**
  17939. * Gets the layer id use to find what meshes are not impacted by the light.
  17940. * Inactive if 0
  17941. */
  17942. get excludeWithLayerMask(): number;
  17943. /**
  17944. * Sets the layer id use to find what meshes are not impacted by the light.
  17945. * Inactive if 0
  17946. */
  17947. set excludeWithLayerMask(value: number);
  17948. private _includeOnlyWithLayerMask;
  17949. /**
  17950. * Gets the layer id use to find what meshes are impacted by the light.
  17951. * Inactive if 0
  17952. */
  17953. get includeOnlyWithLayerMask(): number;
  17954. /**
  17955. * Sets the layer id use to find what meshes are impacted by the light.
  17956. * Inactive if 0
  17957. */
  17958. set includeOnlyWithLayerMask(value: number);
  17959. private _lightmapMode;
  17960. /**
  17961. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17962. */
  17963. get lightmapMode(): number;
  17964. /**
  17965. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17966. */
  17967. set lightmapMode(value: number);
  17968. /**
  17969. * Shadow generator associted to the light.
  17970. * @hidden Internal use only.
  17971. */
  17972. _shadowGenerator: Nullable<IShadowGenerator>;
  17973. /**
  17974. * @hidden Internal use only.
  17975. */
  17976. _excludedMeshesIds: string[];
  17977. /**
  17978. * @hidden Internal use only.
  17979. */
  17980. _includedOnlyMeshesIds: string[];
  17981. /**
  17982. * The current light unifom buffer.
  17983. * @hidden Internal use only.
  17984. */
  17985. _uniformBuffer: UniformBuffer;
  17986. /** @hidden */
  17987. _renderId: number;
  17988. /**
  17989. * Creates a Light object in the scene.
  17990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17991. * @param name The firendly name of the light
  17992. * @param scene The scene the light belongs too
  17993. */
  17994. constructor(name: string, scene: Scene);
  17995. protected abstract _buildUniformLayout(): void;
  17996. /**
  17997. * Sets the passed Effect "effect" with the Light information.
  17998. * @param effect The effect to update
  17999. * @param lightIndex The index of the light in the effect to update
  18000. * @returns The light
  18001. */
  18002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18003. /**
  18004. * Sets the passed Effect "effect" with the Light textures.
  18005. * @param effect The effect to update
  18006. * @param lightIndex The index of the light in the effect to update
  18007. * @returns The light
  18008. */
  18009. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18010. /**
  18011. * Binds the lights information from the scene to the effect for the given mesh.
  18012. * @param lightIndex Light index
  18013. * @param scene The scene where the light belongs to
  18014. * @param effect The effect we are binding the data to
  18015. * @param useSpecular Defines if specular is supported
  18016. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18017. */
  18018. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18019. /**
  18020. * Sets the passed Effect "effect" with the Light information.
  18021. * @param effect The effect to update
  18022. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18023. * @returns The light
  18024. */
  18025. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18026. /**
  18027. * Returns the string "Light".
  18028. * @returns the class name
  18029. */
  18030. getClassName(): string;
  18031. /** @hidden */
  18032. readonly _isLight: boolean;
  18033. /**
  18034. * Converts the light information to a readable string for debug purpose.
  18035. * @param fullDetails Supports for multiple levels of logging within scene loading
  18036. * @returns the human readable light info
  18037. */
  18038. toString(fullDetails?: boolean): string;
  18039. /** @hidden */
  18040. protected _syncParentEnabledState(): void;
  18041. /**
  18042. * Set the enabled state of this node.
  18043. * @param value - the new enabled state
  18044. */
  18045. setEnabled(value: boolean): void;
  18046. /**
  18047. * Returns the Light associated shadow generator if any.
  18048. * @return the associated shadow generator.
  18049. */
  18050. getShadowGenerator(): Nullable<IShadowGenerator>;
  18051. /**
  18052. * Returns a Vector3, the absolute light position in the World.
  18053. * @returns the world space position of the light
  18054. */
  18055. getAbsolutePosition(): Vector3;
  18056. /**
  18057. * Specifies if the light will affect the passed mesh.
  18058. * @param mesh The mesh to test against the light
  18059. * @return true the mesh is affected otherwise, false.
  18060. */
  18061. canAffectMesh(mesh: AbstractMesh): boolean;
  18062. /**
  18063. * Sort function to order lights for rendering.
  18064. * @param a First Light object to compare to second.
  18065. * @param b Second Light object to compare first.
  18066. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18067. */
  18068. static CompareLightsPriority(a: Light, b: Light): number;
  18069. /**
  18070. * Releases resources associated with this node.
  18071. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18072. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18073. */
  18074. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18075. /**
  18076. * Returns the light type ID (integer).
  18077. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18078. */
  18079. getTypeID(): number;
  18080. /**
  18081. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18082. * @returns the scaled intensity in intensity mode unit
  18083. */
  18084. getScaledIntensity(): number;
  18085. /**
  18086. * Returns a new Light object, named "name", from the current one.
  18087. * @param name The name of the cloned light
  18088. * @param newParent The parent of this light, if it has one
  18089. * @returns the new created light
  18090. */
  18091. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18092. /**
  18093. * Serializes the current light into a Serialization object.
  18094. * @returns the serialized object.
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18099. * This new light is named "name" and added to the passed scene.
  18100. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18101. * @param name The friendly name of the light
  18102. * @param scene The scene the new light will belong to
  18103. * @returns the constructor function
  18104. */
  18105. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18106. /**
  18107. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18108. * @param parsedLight The JSON representation of the light
  18109. * @param scene The scene to create the parsed light in
  18110. * @returns the created light after parsing
  18111. */
  18112. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18113. private _hookArrayForExcluded;
  18114. private _hookArrayForIncludedOnly;
  18115. private _resyncMeshes;
  18116. /**
  18117. * Forces the meshes to update their light related information in their rendering used effects
  18118. * @hidden Internal Use Only
  18119. */
  18120. _markMeshesAsLightDirty(): void;
  18121. /**
  18122. * Recomputes the cached photometric scale if needed.
  18123. */
  18124. private _computePhotometricScale;
  18125. /**
  18126. * Returns the Photometric Scale according to the light type and intensity mode.
  18127. */
  18128. private _getPhotometricScale;
  18129. /**
  18130. * Reorder the light in the scene according to their defined priority.
  18131. * @hidden Internal Use Only
  18132. */
  18133. _reorderLightsInScene(): void;
  18134. /**
  18135. * Prepares the list of defines specific to the light type.
  18136. * @param defines the list of defines
  18137. * @param lightIndex defines the index of the light for the effect
  18138. */
  18139. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18145. * This is the base of the follow, arc rotate cameras and Free camera
  18146. * @see http://doc.babylonjs.com/features/cameras
  18147. */
  18148. export class TargetCamera extends Camera {
  18149. private static _RigCamTransformMatrix;
  18150. private static _TargetTransformMatrix;
  18151. private static _TargetFocalPoint;
  18152. /**
  18153. * Define the current direction the camera is moving to
  18154. */
  18155. cameraDirection: Vector3;
  18156. /**
  18157. * Define the current rotation the camera is rotating to
  18158. */
  18159. cameraRotation: Vector2;
  18160. /**
  18161. * When set, the up vector of the camera will be updated by the rotation of the camera
  18162. */
  18163. updateUpVectorFromRotation: boolean;
  18164. private _tmpQuaternion;
  18165. /**
  18166. * Define the current rotation of the camera
  18167. */
  18168. rotation: Vector3;
  18169. /**
  18170. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18171. */
  18172. rotationQuaternion: Quaternion;
  18173. /**
  18174. * Define the current speed of the camera
  18175. */
  18176. speed: number;
  18177. /**
  18178. * Add constraint to the camera to prevent it to move freely in all directions and
  18179. * around all axis.
  18180. */
  18181. noRotationConstraint: boolean;
  18182. /**
  18183. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18184. * panning
  18185. */
  18186. invertRotation: boolean;
  18187. /**
  18188. * Speed multiplier for inverse camera panning
  18189. */
  18190. inverseRotationSpeed: number;
  18191. /**
  18192. * Define the current target of the camera as an object or a position.
  18193. */
  18194. lockedTarget: any;
  18195. /** @hidden */
  18196. _currentTarget: Vector3;
  18197. /** @hidden */
  18198. _initialFocalDistance: number;
  18199. /** @hidden */
  18200. _viewMatrix: Matrix;
  18201. /** @hidden */
  18202. _camMatrix: Matrix;
  18203. /** @hidden */
  18204. _cameraTransformMatrix: Matrix;
  18205. /** @hidden */
  18206. _cameraRotationMatrix: Matrix;
  18207. /** @hidden */
  18208. _referencePoint: Vector3;
  18209. /** @hidden */
  18210. _transformedReferencePoint: Vector3;
  18211. protected _globalCurrentTarget: Vector3;
  18212. protected _globalCurrentUpVector: Vector3;
  18213. /** @hidden */
  18214. _reset: () => void;
  18215. private _defaultUp;
  18216. /**
  18217. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18218. * This is the base of the follow, arc rotate cameras and Free camera
  18219. * @see http://doc.babylonjs.com/features/cameras
  18220. * @param name Defines the name of the camera in the scene
  18221. * @param position Defines the start position of the camera in the scene
  18222. * @param scene Defines the scene the camera belongs to
  18223. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18224. */
  18225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18226. /**
  18227. * Gets the position in front of the camera at a given distance.
  18228. * @param distance The distance from the camera we want the position to be
  18229. * @returns the position
  18230. */
  18231. getFrontPosition(distance: number): Vector3;
  18232. /** @hidden */
  18233. _getLockedTargetPosition(): Nullable<Vector3>;
  18234. private _storedPosition;
  18235. private _storedRotation;
  18236. private _storedRotationQuaternion;
  18237. /**
  18238. * Store current camera state of the camera (fov, position, rotation, etc..)
  18239. * @returns the camera
  18240. */
  18241. storeState(): Camera;
  18242. /**
  18243. * Restored camera state. You must call storeState() first
  18244. * @returns whether it was successful or not
  18245. * @hidden
  18246. */
  18247. _restoreStateValues(): boolean;
  18248. /** @hidden */
  18249. _initCache(): void;
  18250. /** @hidden */
  18251. _updateCache(ignoreParentClass?: boolean): void;
  18252. /** @hidden */
  18253. _isSynchronizedViewMatrix(): boolean;
  18254. /** @hidden */
  18255. _computeLocalCameraSpeed(): number;
  18256. /**
  18257. * Defines the target the camera should look at.
  18258. * @param target Defines the new target as a Vector or a mesh
  18259. */
  18260. setTarget(target: Vector3): void;
  18261. /**
  18262. * Return the current target position of the camera. This value is expressed in local space.
  18263. * @returns the target position
  18264. */
  18265. getTarget(): Vector3;
  18266. /** @hidden */
  18267. _decideIfNeedsToMove(): boolean;
  18268. /** @hidden */
  18269. _updatePosition(): void;
  18270. /** @hidden */
  18271. _checkInputs(): void;
  18272. protected _updateCameraRotationMatrix(): void;
  18273. /**
  18274. * 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)
  18275. * @returns the current camera
  18276. */
  18277. private _rotateUpVectorWithCameraRotationMatrix;
  18278. private _cachedRotationZ;
  18279. private _cachedQuaternionRotationZ;
  18280. /** @hidden */
  18281. _getViewMatrix(): Matrix;
  18282. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18283. /**
  18284. * @hidden
  18285. */
  18286. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18287. /**
  18288. * @hidden
  18289. */
  18290. _updateRigCameras(): void;
  18291. private _getRigCamPositionAndTarget;
  18292. /**
  18293. * Gets the current object class name.
  18294. * @return the class name
  18295. */
  18296. getClassName(): string;
  18297. }
  18298. }
  18299. declare module BABYLON {
  18300. /**
  18301. * Gather the list of keyboard event types as constants.
  18302. */
  18303. export class KeyboardEventTypes {
  18304. /**
  18305. * The keydown event is fired when a key becomes active (pressed).
  18306. */
  18307. static readonly KEYDOWN: number;
  18308. /**
  18309. * The keyup event is fired when a key has been released.
  18310. */
  18311. static readonly KEYUP: number;
  18312. }
  18313. /**
  18314. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18315. */
  18316. export class KeyboardInfo {
  18317. /**
  18318. * Defines the type of event (KeyboardEventTypes)
  18319. */
  18320. type: number;
  18321. /**
  18322. * Defines the related dom event
  18323. */
  18324. event: KeyboardEvent;
  18325. /**
  18326. * Instantiates a new keyboard info.
  18327. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18328. * @param type Defines the type of event (KeyboardEventTypes)
  18329. * @param event Defines the related dom event
  18330. */
  18331. constructor(
  18332. /**
  18333. * Defines the type of event (KeyboardEventTypes)
  18334. */
  18335. type: number,
  18336. /**
  18337. * Defines the related dom event
  18338. */
  18339. event: KeyboardEvent);
  18340. }
  18341. /**
  18342. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18343. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18344. */
  18345. export class KeyboardInfoPre extends KeyboardInfo {
  18346. /**
  18347. * Defines the type of event (KeyboardEventTypes)
  18348. */
  18349. type: number;
  18350. /**
  18351. * Defines the related dom event
  18352. */
  18353. event: KeyboardEvent;
  18354. /**
  18355. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18356. */
  18357. skipOnPointerObservable: boolean;
  18358. /**
  18359. * Instantiates a new keyboard pre info.
  18360. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18361. * @param type Defines the type of event (KeyboardEventTypes)
  18362. * @param event Defines the related dom event
  18363. */
  18364. constructor(
  18365. /**
  18366. * Defines the type of event (KeyboardEventTypes)
  18367. */
  18368. type: number,
  18369. /**
  18370. * Defines the related dom event
  18371. */
  18372. event: KeyboardEvent);
  18373. }
  18374. }
  18375. declare module BABYLON {
  18376. /**
  18377. * Manage the keyboard inputs to control the movement of a free camera.
  18378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18379. */
  18380. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18381. /**
  18382. * Defines the camera the input is attached to.
  18383. */
  18384. camera: FreeCamera;
  18385. /**
  18386. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18387. */
  18388. keysUp: number[];
  18389. /**
  18390. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18391. */
  18392. keysUpward: number[];
  18393. /**
  18394. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18395. */
  18396. keysDown: number[];
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18399. */
  18400. keysDownward: number[];
  18401. /**
  18402. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18403. */
  18404. keysLeft: number[];
  18405. /**
  18406. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18407. */
  18408. keysRight: number[];
  18409. private _keys;
  18410. private _onCanvasBlurObserver;
  18411. private _onKeyboardObserver;
  18412. private _engine;
  18413. private _scene;
  18414. /**
  18415. * Attach the input controls to a specific dom element to get the input from.
  18416. * @param element Defines the element the controls should be listened from
  18417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18418. */
  18419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18420. /**
  18421. * Detach the current controls from the specified dom element.
  18422. * @param element Defines the element to stop listening the inputs from
  18423. */
  18424. detachControl(element: Nullable<HTMLElement>): void;
  18425. /**
  18426. * Update the current camera state depending on the inputs that have been used this frame.
  18427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18428. */
  18429. checkInputs(): void;
  18430. /**
  18431. * Gets the class name of the current intput.
  18432. * @returns the class name
  18433. */
  18434. getClassName(): string;
  18435. /** @hidden */
  18436. _onLostFocus(): void;
  18437. /**
  18438. * Get the friendly name associated with the input class.
  18439. * @returns the input friendly name
  18440. */
  18441. getSimpleName(): string;
  18442. }
  18443. }
  18444. declare module BABYLON {
  18445. /**
  18446. * Gather the list of pointer event types as constants.
  18447. */
  18448. export class PointerEventTypes {
  18449. /**
  18450. * 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.
  18451. */
  18452. static readonly POINTERDOWN: number;
  18453. /**
  18454. * The pointerup event is fired when a pointer is no longer active.
  18455. */
  18456. static readonly POINTERUP: number;
  18457. /**
  18458. * The pointermove event is fired when a pointer changes coordinates.
  18459. */
  18460. static readonly POINTERMOVE: number;
  18461. /**
  18462. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18463. */
  18464. static readonly POINTERWHEEL: number;
  18465. /**
  18466. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18467. */
  18468. static readonly POINTERPICK: number;
  18469. /**
  18470. * The pointertap event is fired when a the object has been touched and released without drag.
  18471. */
  18472. static readonly POINTERTAP: number;
  18473. /**
  18474. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18475. */
  18476. static readonly POINTERDOUBLETAP: number;
  18477. }
  18478. /**
  18479. * Base class of pointer info types.
  18480. */
  18481. export class PointerInfoBase {
  18482. /**
  18483. * Defines the type of event (PointerEventTypes)
  18484. */
  18485. type: number;
  18486. /**
  18487. * Defines the related dom event
  18488. */
  18489. event: PointerEvent | MouseWheelEvent;
  18490. /**
  18491. * Instantiates the base class of pointers info.
  18492. * @param type Defines the type of event (PointerEventTypes)
  18493. * @param event Defines the related dom event
  18494. */
  18495. constructor(
  18496. /**
  18497. * Defines the type of event (PointerEventTypes)
  18498. */
  18499. type: number,
  18500. /**
  18501. * Defines the related dom event
  18502. */
  18503. event: PointerEvent | MouseWheelEvent);
  18504. }
  18505. /**
  18506. * This class is used to store pointer related info for the onPrePointerObservable event.
  18507. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18508. */
  18509. export class PointerInfoPre extends PointerInfoBase {
  18510. /**
  18511. * Ray from a pointer if availible (eg. 6dof controller)
  18512. */
  18513. ray: Nullable<Ray>;
  18514. /**
  18515. * Defines the local position of the pointer on the canvas.
  18516. */
  18517. localPosition: Vector2;
  18518. /**
  18519. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18520. */
  18521. skipOnPointerObservable: boolean;
  18522. /**
  18523. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18524. * @param type Defines the type of event (PointerEventTypes)
  18525. * @param event Defines the related dom event
  18526. * @param localX Defines the local x coordinates of the pointer when the event occured
  18527. * @param localY Defines the local y coordinates of the pointer when the event occured
  18528. */
  18529. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18530. }
  18531. /**
  18532. * This type contains all the data related to a pointer event in Babylon.js.
  18533. * 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.
  18534. */
  18535. export class PointerInfo extends PointerInfoBase {
  18536. /**
  18537. * Defines the picking info associated to the info (if any)\
  18538. */
  18539. pickInfo: Nullable<PickingInfo>;
  18540. /**
  18541. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18542. * @param type Defines the type of event (PointerEventTypes)
  18543. * @param event Defines the related dom event
  18544. * @param pickInfo Defines the picking info associated to the info (if any)\
  18545. */
  18546. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18547. /**
  18548. * Defines the picking info associated to the info (if any)\
  18549. */
  18550. pickInfo: Nullable<PickingInfo>);
  18551. }
  18552. /**
  18553. * Data relating to a touch event on the screen.
  18554. */
  18555. export interface PointerTouch {
  18556. /**
  18557. * X coordinate of touch.
  18558. */
  18559. x: number;
  18560. /**
  18561. * Y coordinate of touch.
  18562. */
  18563. y: number;
  18564. /**
  18565. * Id of touch. Unique for each finger.
  18566. */
  18567. pointerId: number;
  18568. /**
  18569. * Event type passed from DOM.
  18570. */
  18571. type: any;
  18572. }
  18573. }
  18574. declare module BABYLON {
  18575. /**
  18576. * Manage the mouse inputs to control the movement of a free camera.
  18577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18578. */
  18579. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18580. /**
  18581. * Define if touch is enabled in the mouse input
  18582. */
  18583. touchEnabled: boolean;
  18584. /**
  18585. * Defines the camera the input is attached to.
  18586. */
  18587. camera: FreeCamera;
  18588. /**
  18589. * Defines the buttons associated with the input to handle camera move.
  18590. */
  18591. buttons: number[];
  18592. /**
  18593. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18594. */
  18595. angularSensibility: number;
  18596. private _pointerInput;
  18597. private _onMouseMove;
  18598. private _observer;
  18599. private previousPosition;
  18600. /**
  18601. * Observable for when a pointer move event occurs containing the move offset
  18602. */
  18603. onPointerMovedObservable: Observable<{
  18604. offsetX: number;
  18605. offsetY: number;
  18606. }>;
  18607. /**
  18608. * @hidden
  18609. * If the camera should be rotated automatically based on pointer movement
  18610. */
  18611. _allowCameraRotation: boolean;
  18612. /**
  18613. * Manage the mouse inputs to control the movement of a free camera.
  18614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18615. * @param touchEnabled Defines if touch is enabled or not
  18616. */
  18617. constructor(
  18618. /**
  18619. * Define if touch is enabled in the mouse input
  18620. */
  18621. touchEnabled?: boolean);
  18622. /**
  18623. * Attach the input controls to a specific dom element to get the input from.
  18624. * @param element Defines the element the controls should be listened from
  18625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18626. */
  18627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18628. /**
  18629. * Called on JS contextmenu event.
  18630. * Override this method to provide functionality.
  18631. */
  18632. protected onContextMenu(evt: PointerEvent): void;
  18633. /**
  18634. * Detach the current controls from the specified dom element.
  18635. * @param element Defines the element to stop listening the inputs from
  18636. */
  18637. detachControl(element: Nullable<HTMLElement>): void;
  18638. /**
  18639. * Gets the class name of the current intput.
  18640. * @returns the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Get the friendly name associated with the input class.
  18645. * @returns the input friendly name
  18646. */
  18647. getSimpleName(): string;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /**
  18652. * Manage the touch inputs to control the movement of a free camera.
  18653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18654. */
  18655. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18656. /**
  18657. * Defines the camera the input is attached to.
  18658. */
  18659. camera: FreeCamera;
  18660. /**
  18661. * Defines the touch sensibility for rotation.
  18662. * The higher the faster.
  18663. */
  18664. touchAngularSensibility: number;
  18665. /**
  18666. * Defines the touch sensibility for move.
  18667. * The higher the faster.
  18668. */
  18669. touchMoveSensibility: number;
  18670. private _offsetX;
  18671. private _offsetY;
  18672. private _pointerPressed;
  18673. private _pointerInput;
  18674. private _observer;
  18675. private _onLostFocus;
  18676. /**
  18677. * Attach the input controls to a specific dom element to get the input from.
  18678. * @param element Defines the element the controls should be listened from
  18679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18680. */
  18681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18682. /**
  18683. * Detach the current controls from the specified dom element.
  18684. * @param element Defines the element to stop listening the inputs from
  18685. */
  18686. detachControl(element: Nullable<HTMLElement>): void;
  18687. /**
  18688. * Update the current camera state depending on the inputs that have been used this frame.
  18689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18690. */
  18691. checkInputs(): void;
  18692. /**
  18693. * Gets the class name of the current intput.
  18694. * @returns the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Get the friendly name associated with the input class.
  18699. * @returns the input friendly name
  18700. */
  18701. getSimpleName(): string;
  18702. }
  18703. }
  18704. declare module BABYLON {
  18705. /**
  18706. * Default Inputs manager for the FreeCamera.
  18707. * It groups all the default supported inputs for ease of use.
  18708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18709. */
  18710. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18711. /**
  18712. * @hidden
  18713. */
  18714. _mouseInput: Nullable<FreeCameraMouseInput>;
  18715. /**
  18716. * Instantiates a new FreeCameraInputsManager.
  18717. * @param camera Defines the camera the inputs belong to
  18718. */
  18719. constructor(camera: FreeCamera);
  18720. /**
  18721. * Add keyboard input support to the input manager.
  18722. * @returns the current input manager
  18723. */
  18724. addKeyboard(): FreeCameraInputsManager;
  18725. /**
  18726. * Add mouse input support to the input manager.
  18727. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18728. * @returns the current input manager
  18729. */
  18730. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18731. /**
  18732. * Removes the mouse input support from the manager
  18733. * @returns the current input manager
  18734. */
  18735. removeMouse(): FreeCameraInputsManager;
  18736. /**
  18737. * Add touch input support to the input manager.
  18738. * @returns the current input manager
  18739. */
  18740. addTouch(): FreeCameraInputsManager;
  18741. /**
  18742. * Remove all attached input methods from a camera
  18743. */
  18744. clear(): void;
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. /**
  18749. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18750. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18751. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18752. */
  18753. export class FreeCamera extends TargetCamera {
  18754. /**
  18755. * Define the collision ellipsoid of the camera.
  18756. * This is helpful to simulate a camera body like the player body around the camera
  18757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18758. */
  18759. ellipsoid: Vector3;
  18760. /**
  18761. * Define an offset for the position of the ellipsoid around the camera.
  18762. * This can be helpful to determine the center of the body near the gravity center of the body
  18763. * instead of its head.
  18764. */
  18765. ellipsoidOffset: Vector3;
  18766. /**
  18767. * Enable or disable collisions of the camera with the rest of the scene objects.
  18768. */
  18769. checkCollisions: boolean;
  18770. /**
  18771. * Enable or disable gravity on the camera.
  18772. */
  18773. applyGravity: boolean;
  18774. /**
  18775. * Define the input manager associated to the camera.
  18776. */
  18777. inputs: FreeCameraInputsManager;
  18778. /**
  18779. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18780. * Higher values reduce sensitivity.
  18781. */
  18782. get angularSensibility(): number;
  18783. /**
  18784. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18785. * Higher values reduce sensitivity.
  18786. */
  18787. set angularSensibility(value: number);
  18788. /**
  18789. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18790. */
  18791. get keysUp(): number[];
  18792. set keysUp(value: number[]);
  18793. /**
  18794. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18795. */
  18796. get keysUpward(): number[];
  18797. set keysUpward(value: number[]);
  18798. /**
  18799. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18800. */
  18801. get keysDown(): number[];
  18802. set keysDown(value: number[]);
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18805. */
  18806. get keysDownward(): number[];
  18807. set keysDownward(value: number[]);
  18808. /**
  18809. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18810. */
  18811. get keysLeft(): number[];
  18812. set keysLeft(value: number[]);
  18813. /**
  18814. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18815. */
  18816. get keysRight(): number[];
  18817. set keysRight(value: number[]);
  18818. /**
  18819. * Event raised when the camera collide with a mesh in the scene.
  18820. */
  18821. onCollide: (collidedMesh: AbstractMesh) => void;
  18822. private _collider;
  18823. private _needMoveForGravity;
  18824. private _oldPosition;
  18825. private _diffPosition;
  18826. private _newPosition;
  18827. /** @hidden */
  18828. _localDirection: Vector3;
  18829. /** @hidden */
  18830. _transformedDirection: Vector3;
  18831. /**
  18832. * Instantiates a Free Camera.
  18833. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18834. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18835. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18836. * @param name Define the name of the camera in the scene
  18837. * @param position Define the start position of the camera in the scene
  18838. * @param scene Define the scene the camera belongs to
  18839. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18840. */
  18841. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18842. /**
  18843. * Attached controls to the current camera.
  18844. * @param element Defines the element the controls should be listened from
  18845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18846. */
  18847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18848. /**
  18849. * Detach the current controls from the camera.
  18850. * The camera will stop reacting to inputs.
  18851. * @param element Defines the element to stop listening the inputs from
  18852. */
  18853. detachControl(element: HTMLElement): void;
  18854. private _collisionMask;
  18855. /**
  18856. * Define a collision mask to limit the list of object the camera can collide with
  18857. */
  18858. get collisionMask(): number;
  18859. set collisionMask(mask: number);
  18860. /** @hidden */
  18861. _collideWithWorld(displacement: Vector3): void;
  18862. private _onCollisionPositionChange;
  18863. /** @hidden */
  18864. _checkInputs(): void;
  18865. /** @hidden */
  18866. _decideIfNeedsToMove(): boolean;
  18867. /** @hidden */
  18868. _updatePosition(): void;
  18869. /**
  18870. * Destroy the camera and release the current resources hold by it.
  18871. */
  18872. dispose(): void;
  18873. /**
  18874. * Gets the current object class name.
  18875. * @return the class name
  18876. */
  18877. getClassName(): string;
  18878. }
  18879. }
  18880. declare module BABYLON {
  18881. /**
  18882. * Represents a gamepad control stick position
  18883. */
  18884. export class StickValues {
  18885. /**
  18886. * The x component of the control stick
  18887. */
  18888. x: number;
  18889. /**
  18890. * The y component of the control stick
  18891. */
  18892. y: number;
  18893. /**
  18894. * Initializes the gamepad x and y control stick values
  18895. * @param x The x component of the gamepad control stick value
  18896. * @param y The y component of the gamepad control stick value
  18897. */
  18898. constructor(
  18899. /**
  18900. * The x component of the control stick
  18901. */
  18902. x: number,
  18903. /**
  18904. * The y component of the control stick
  18905. */
  18906. y: number);
  18907. }
  18908. /**
  18909. * An interface which manages callbacks for gamepad button changes
  18910. */
  18911. export interface GamepadButtonChanges {
  18912. /**
  18913. * Called when a gamepad has been changed
  18914. */
  18915. changed: boolean;
  18916. /**
  18917. * Called when a gamepad press event has been triggered
  18918. */
  18919. pressChanged: boolean;
  18920. /**
  18921. * Called when a touch event has been triggered
  18922. */
  18923. touchChanged: boolean;
  18924. /**
  18925. * Called when a value has changed
  18926. */
  18927. valueChanged: boolean;
  18928. }
  18929. /**
  18930. * Represents a gamepad
  18931. */
  18932. export class Gamepad {
  18933. /**
  18934. * The id of the gamepad
  18935. */
  18936. id: string;
  18937. /**
  18938. * The index of the gamepad
  18939. */
  18940. index: number;
  18941. /**
  18942. * The browser gamepad
  18943. */
  18944. browserGamepad: any;
  18945. /**
  18946. * Specifies what type of gamepad this represents
  18947. */
  18948. type: number;
  18949. private _leftStick;
  18950. private _rightStick;
  18951. /** @hidden */
  18952. _isConnected: boolean;
  18953. private _leftStickAxisX;
  18954. private _leftStickAxisY;
  18955. private _rightStickAxisX;
  18956. private _rightStickAxisY;
  18957. /**
  18958. * Triggered when the left control stick has been changed
  18959. */
  18960. private _onleftstickchanged;
  18961. /**
  18962. * Triggered when the right control stick has been changed
  18963. */
  18964. private _onrightstickchanged;
  18965. /**
  18966. * Represents a gamepad controller
  18967. */
  18968. static GAMEPAD: number;
  18969. /**
  18970. * Represents a generic controller
  18971. */
  18972. static GENERIC: number;
  18973. /**
  18974. * Represents an XBox controller
  18975. */
  18976. static XBOX: number;
  18977. /**
  18978. * Represents a pose-enabled controller
  18979. */
  18980. static POSE_ENABLED: number;
  18981. /**
  18982. * Represents an Dual Shock controller
  18983. */
  18984. static DUALSHOCK: number;
  18985. /**
  18986. * Specifies whether the left control stick should be Y-inverted
  18987. */
  18988. protected _invertLeftStickY: boolean;
  18989. /**
  18990. * Specifies if the gamepad has been connected
  18991. */
  18992. get isConnected(): boolean;
  18993. /**
  18994. * Initializes the gamepad
  18995. * @param id The id of the gamepad
  18996. * @param index The index of the gamepad
  18997. * @param browserGamepad The browser gamepad
  18998. * @param leftStickX The x component of the left joystick
  18999. * @param leftStickY The y component of the left joystick
  19000. * @param rightStickX The x component of the right joystick
  19001. * @param rightStickY The y component of the right joystick
  19002. */
  19003. constructor(
  19004. /**
  19005. * The id of the gamepad
  19006. */
  19007. id: string,
  19008. /**
  19009. * The index of the gamepad
  19010. */
  19011. index: number,
  19012. /**
  19013. * The browser gamepad
  19014. */
  19015. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19016. /**
  19017. * Callback triggered when the left joystick has changed
  19018. * @param callback
  19019. */
  19020. onleftstickchanged(callback: (values: StickValues) => void): void;
  19021. /**
  19022. * Callback triggered when the right joystick has changed
  19023. * @param callback
  19024. */
  19025. onrightstickchanged(callback: (values: StickValues) => void): void;
  19026. /**
  19027. * Gets the left joystick
  19028. */
  19029. get leftStick(): StickValues;
  19030. /**
  19031. * Sets the left joystick values
  19032. */
  19033. set leftStick(newValues: StickValues);
  19034. /**
  19035. * Gets the right joystick
  19036. */
  19037. get rightStick(): StickValues;
  19038. /**
  19039. * Sets the right joystick value
  19040. */
  19041. set rightStick(newValues: StickValues);
  19042. /**
  19043. * Updates the gamepad joystick positions
  19044. */
  19045. update(): void;
  19046. /**
  19047. * Disposes the gamepad
  19048. */
  19049. dispose(): void;
  19050. }
  19051. /**
  19052. * Represents a generic gamepad
  19053. */
  19054. export class GenericPad extends Gamepad {
  19055. private _buttons;
  19056. private _onbuttondown;
  19057. private _onbuttonup;
  19058. /**
  19059. * Observable triggered when a button has been pressed
  19060. */
  19061. onButtonDownObservable: Observable<number>;
  19062. /**
  19063. * Observable triggered when a button has been released
  19064. */
  19065. onButtonUpObservable: Observable<number>;
  19066. /**
  19067. * Callback triggered when a button has been pressed
  19068. * @param callback Called when a button has been pressed
  19069. */
  19070. onbuttondown(callback: (buttonPressed: number) => void): void;
  19071. /**
  19072. * Callback triggered when a button has been released
  19073. * @param callback Called when a button has been released
  19074. */
  19075. onbuttonup(callback: (buttonReleased: number) => void): void;
  19076. /**
  19077. * Initializes the generic gamepad
  19078. * @param id The id of the generic gamepad
  19079. * @param index The index of the generic gamepad
  19080. * @param browserGamepad The browser gamepad
  19081. */
  19082. constructor(id: string, index: number, browserGamepad: any);
  19083. private _setButtonValue;
  19084. /**
  19085. * Updates the generic gamepad
  19086. */
  19087. update(): void;
  19088. /**
  19089. * Disposes the generic gamepad
  19090. */
  19091. dispose(): void;
  19092. }
  19093. }
  19094. declare module BABYLON {
  19095. /**
  19096. * Defines the types of pose enabled controllers that are supported
  19097. */
  19098. export enum PoseEnabledControllerType {
  19099. /**
  19100. * HTC Vive
  19101. */
  19102. VIVE = 0,
  19103. /**
  19104. * Oculus Rift
  19105. */
  19106. OCULUS = 1,
  19107. /**
  19108. * Windows mixed reality
  19109. */
  19110. WINDOWS = 2,
  19111. /**
  19112. * Samsung gear VR
  19113. */
  19114. GEAR_VR = 3,
  19115. /**
  19116. * Google Daydream
  19117. */
  19118. DAYDREAM = 4,
  19119. /**
  19120. * Generic
  19121. */
  19122. GENERIC = 5
  19123. }
  19124. /**
  19125. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19126. */
  19127. export interface MutableGamepadButton {
  19128. /**
  19129. * Value of the button/trigger
  19130. */
  19131. value: number;
  19132. /**
  19133. * If the button/trigger is currently touched
  19134. */
  19135. touched: boolean;
  19136. /**
  19137. * If the button/trigger is currently pressed
  19138. */
  19139. pressed: boolean;
  19140. }
  19141. /**
  19142. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19143. * @hidden
  19144. */
  19145. export interface ExtendedGamepadButton extends GamepadButton {
  19146. /**
  19147. * If the button/trigger is currently pressed
  19148. */
  19149. readonly pressed: boolean;
  19150. /**
  19151. * If the button/trigger is currently touched
  19152. */
  19153. readonly touched: boolean;
  19154. /**
  19155. * Value of the button/trigger
  19156. */
  19157. readonly value: number;
  19158. }
  19159. /** @hidden */
  19160. export interface _GamePadFactory {
  19161. /**
  19162. * Returns whether or not the current gamepad can be created for this type of controller.
  19163. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19164. * @returns true if it can be created, otherwise false
  19165. */
  19166. canCreate(gamepadInfo: any): boolean;
  19167. /**
  19168. * Creates a new instance of the Gamepad.
  19169. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19170. * @returns the new gamepad instance
  19171. */
  19172. create(gamepadInfo: any): Gamepad;
  19173. }
  19174. /**
  19175. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19176. */
  19177. export class PoseEnabledControllerHelper {
  19178. /** @hidden */
  19179. static _ControllerFactories: _GamePadFactory[];
  19180. /** @hidden */
  19181. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19182. /**
  19183. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19184. * @param vrGamepad the gamepad to initialized
  19185. * @returns a vr controller of the type the gamepad identified as
  19186. */
  19187. static InitiateController(vrGamepad: any): Gamepad;
  19188. }
  19189. /**
  19190. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19191. */
  19192. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19193. /**
  19194. * If the controller is used in a webXR session
  19195. */
  19196. isXR: boolean;
  19197. private _deviceRoomPosition;
  19198. private _deviceRoomRotationQuaternion;
  19199. /**
  19200. * The device position in babylon space
  19201. */
  19202. devicePosition: Vector3;
  19203. /**
  19204. * The device rotation in babylon space
  19205. */
  19206. deviceRotationQuaternion: Quaternion;
  19207. /**
  19208. * The scale factor of the device in babylon space
  19209. */
  19210. deviceScaleFactor: number;
  19211. /**
  19212. * (Likely devicePosition should be used instead) The device position in its room space
  19213. */
  19214. position: Vector3;
  19215. /**
  19216. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19217. */
  19218. rotationQuaternion: Quaternion;
  19219. /**
  19220. * The type of controller (Eg. Windows mixed reality)
  19221. */
  19222. controllerType: PoseEnabledControllerType;
  19223. protected _calculatedPosition: Vector3;
  19224. private _calculatedRotation;
  19225. /**
  19226. * The raw pose from the device
  19227. */
  19228. rawPose: DevicePose;
  19229. private _trackPosition;
  19230. private _maxRotationDistFromHeadset;
  19231. private _draggedRoomRotation;
  19232. /**
  19233. * @hidden
  19234. */
  19235. _disableTrackPosition(fixedPosition: Vector3): void;
  19236. /**
  19237. * Internal, the mesh attached to the controller
  19238. * @hidden
  19239. */
  19240. _mesh: Nullable<AbstractMesh>;
  19241. private _poseControlledCamera;
  19242. private _leftHandSystemQuaternion;
  19243. /**
  19244. * Internal, matrix used to convert room space to babylon space
  19245. * @hidden
  19246. */
  19247. _deviceToWorld: Matrix;
  19248. /**
  19249. * Node to be used when casting a ray from the controller
  19250. * @hidden
  19251. */
  19252. _pointingPoseNode: Nullable<TransformNode>;
  19253. /**
  19254. * Name of the child mesh that can be used to cast a ray from the controller
  19255. */
  19256. static readonly POINTING_POSE: string;
  19257. /**
  19258. * Creates a new PoseEnabledController from a gamepad
  19259. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19260. */
  19261. constructor(browserGamepad: any);
  19262. private _workingMatrix;
  19263. /**
  19264. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19265. */
  19266. update(): void;
  19267. /**
  19268. * Updates only the pose device and mesh without doing any button event checking
  19269. */
  19270. protected _updatePoseAndMesh(): void;
  19271. /**
  19272. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19273. * @param poseData raw pose fromthe device
  19274. */
  19275. updateFromDevice(poseData: DevicePose): void;
  19276. /**
  19277. * @hidden
  19278. */
  19279. _meshAttachedObservable: Observable<AbstractMesh>;
  19280. /**
  19281. * Attaches a mesh to the controller
  19282. * @param mesh the mesh to be attached
  19283. */
  19284. attachToMesh(mesh: AbstractMesh): void;
  19285. /**
  19286. * Attaches the controllers mesh to a camera
  19287. * @param camera the camera the mesh should be attached to
  19288. */
  19289. attachToPoseControlledCamera(camera: TargetCamera): void;
  19290. /**
  19291. * Disposes of the controller
  19292. */
  19293. dispose(): void;
  19294. /**
  19295. * The mesh that is attached to the controller
  19296. */
  19297. get mesh(): Nullable<AbstractMesh>;
  19298. /**
  19299. * Gets the ray of the controller in the direction the controller is pointing
  19300. * @param length the length the resulting ray should be
  19301. * @returns a ray in the direction the controller is pointing
  19302. */
  19303. getForwardRay(length?: number): Ray;
  19304. }
  19305. }
  19306. declare module BABYLON {
  19307. /**
  19308. * Defines the WebVRController object that represents controllers tracked in 3D space
  19309. */
  19310. export abstract class WebVRController extends PoseEnabledController {
  19311. /**
  19312. * Internal, the default controller model for the controller
  19313. */
  19314. protected _defaultModel: Nullable<AbstractMesh>;
  19315. /**
  19316. * Fired when the trigger state has changed
  19317. */
  19318. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19319. /**
  19320. * Fired when the main button state has changed
  19321. */
  19322. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19323. /**
  19324. * Fired when the secondary button state has changed
  19325. */
  19326. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19327. /**
  19328. * Fired when the pad state has changed
  19329. */
  19330. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19331. /**
  19332. * Fired when controllers stick values have changed
  19333. */
  19334. onPadValuesChangedObservable: Observable<StickValues>;
  19335. /**
  19336. * Array of button availible on the controller
  19337. */
  19338. protected _buttons: Array<MutableGamepadButton>;
  19339. private _onButtonStateChange;
  19340. /**
  19341. * Fired when a controller button's state has changed
  19342. * @param callback the callback containing the button that was modified
  19343. */
  19344. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19345. /**
  19346. * X and Y axis corresponding to the controllers joystick
  19347. */
  19348. pad: StickValues;
  19349. /**
  19350. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19351. */
  19352. hand: string;
  19353. /**
  19354. * The default controller model for the controller
  19355. */
  19356. get defaultModel(): Nullable<AbstractMesh>;
  19357. /**
  19358. * Creates a new WebVRController from a gamepad
  19359. * @param vrGamepad the gamepad that the WebVRController should be created from
  19360. */
  19361. constructor(vrGamepad: any);
  19362. /**
  19363. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19364. */
  19365. update(): void;
  19366. /**
  19367. * Function to be called when a button is modified
  19368. */
  19369. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19370. /**
  19371. * Loads a mesh and attaches it to the controller
  19372. * @param scene the scene the mesh should be added to
  19373. * @param meshLoaded callback for when the mesh has been loaded
  19374. */
  19375. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19376. private _setButtonValue;
  19377. private _changes;
  19378. private _checkChanges;
  19379. /**
  19380. * Disposes of th webVRCOntroller
  19381. */
  19382. dispose(): void;
  19383. }
  19384. }
  19385. declare module BABYLON {
  19386. /**
  19387. * The HemisphericLight simulates the ambient environment light,
  19388. * so the passed direction is the light reflection direction, not the incoming direction.
  19389. */
  19390. export class HemisphericLight extends Light {
  19391. /**
  19392. * The groundColor is the light in the opposite direction to the one specified during creation.
  19393. * 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.
  19394. */
  19395. groundColor: Color3;
  19396. /**
  19397. * The light reflection direction, not the incoming direction.
  19398. */
  19399. direction: Vector3;
  19400. /**
  19401. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19402. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19403. * The HemisphericLight can't cast shadows.
  19404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19405. * @param name The friendly name of the light
  19406. * @param direction The direction of the light reflection
  19407. * @param scene The scene the light belongs to
  19408. */
  19409. constructor(name: string, direction: Vector3, scene: Scene);
  19410. protected _buildUniformLayout(): void;
  19411. /**
  19412. * Returns the string "HemisphericLight".
  19413. * @return The class name
  19414. */
  19415. getClassName(): string;
  19416. /**
  19417. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19418. * Returns the updated direction.
  19419. * @param target The target the direction should point to
  19420. * @return The computed direction
  19421. */
  19422. setDirectionToTarget(target: Vector3): Vector3;
  19423. /**
  19424. * Returns the shadow generator associated to the light.
  19425. * @returns Always null for hemispheric lights because it does not support shadows.
  19426. */
  19427. getShadowGenerator(): Nullable<IShadowGenerator>;
  19428. /**
  19429. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19430. * @param effect The effect to update
  19431. * @param lightIndex The index of the light in the effect to update
  19432. * @returns The hemispheric light
  19433. */
  19434. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19435. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19436. /**
  19437. * Computes the world matrix of the node
  19438. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19439. * @param useWasUpdatedFlag defines a reserved property
  19440. * @returns the world matrix
  19441. */
  19442. computeWorldMatrix(): Matrix;
  19443. /**
  19444. * Returns the integer 3.
  19445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19446. */
  19447. getTypeID(): number;
  19448. /**
  19449. * Prepares the list of defines specific to the light type.
  19450. * @param defines the list of defines
  19451. * @param lightIndex defines the index of the light for the effect
  19452. */
  19453. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19454. }
  19455. }
  19456. declare module BABYLON {
  19457. /** @hidden */
  19458. export var vrMultiviewToSingleviewPixelShader: {
  19459. name: string;
  19460. shader: string;
  19461. };
  19462. }
  19463. declare module BABYLON {
  19464. /**
  19465. * Renders to multiple views with a single draw call
  19466. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19467. */
  19468. export class MultiviewRenderTarget extends RenderTargetTexture {
  19469. /**
  19470. * Creates a multiview render target
  19471. * @param scene scene used with the render target
  19472. * @param size the size of the render target (used for each view)
  19473. */
  19474. constructor(scene: Scene, size?: number | {
  19475. width: number;
  19476. height: number;
  19477. } | {
  19478. ratio: number;
  19479. });
  19480. /**
  19481. * @hidden
  19482. * @param faceIndex the face index, if its a cube texture
  19483. */
  19484. _bindFrameBuffer(faceIndex?: number): void;
  19485. /**
  19486. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19487. * @returns the view count
  19488. */
  19489. getViewCount(): number;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. interface Engine {
  19494. /**
  19495. * Creates a new multiview render target
  19496. * @param width defines the width of the texture
  19497. * @param height defines the height of the texture
  19498. * @returns the created multiview texture
  19499. */
  19500. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19501. /**
  19502. * Binds a multiview framebuffer to be drawn to
  19503. * @param multiviewTexture texture to bind
  19504. */
  19505. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19506. }
  19507. interface Camera {
  19508. /**
  19509. * @hidden
  19510. * 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)
  19511. */
  19512. _useMultiviewToSingleView: boolean;
  19513. /**
  19514. * @hidden
  19515. * 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)
  19516. */
  19517. _multiviewTexture: Nullable<RenderTargetTexture>;
  19518. /**
  19519. * @hidden
  19520. * ensures the multiview texture of the camera exists and has the specified width/height
  19521. * @param width height to set on the multiview texture
  19522. * @param height width to set on the multiview texture
  19523. */
  19524. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19525. }
  19526. interface Scene {
  19527. /** @hidden */
  19528. _transformMatrixR: Matrix;
  19529. /** @hidden */
  19530. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19531. /** @hidden */
  19532. _createMultiviewUbo(): void;
  19533. /** @hidden */
  19534. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19535. /** @hidden */
  19536. _renderMultiviewToSingleView(camera: Camera): void;
  19537. }
  19538. }
  19539. declare module BABYLON {
  19540. /**
  19541. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19542. * This will not be used for webXR as it supports displaying texture arrays directly
  19543. */
  19544. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19545. /**
  19546. * Initializes a VRMultiviewToSingleview
  19547. * @param name name of the post process
  19548. * @param camera camera to be applied to
  19549. * @param scaleFactor scaling factor to the size of the output texture
  19550. */
  19551. constructor(name: string, camera: Camera, scaleFactor: number);
  19552. }
  19553. }
  19554. declare module BABYLON {
  19555. /**
  19556. * Interface used to define additional presentation attributes
  19557. */
  19558. export interface IVRPresentationAttributes {
  19559. /**
  19560. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19561. */
  19562. highRefreshRate: boolean;
  19563. /**
  19564. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19565. */
  19566. foveationLevel: number;
  19567. }
  19568. interface Engine {
  19569. /** @hidden */
  19570. _vrDisplay: any;
  19571. /** @hidden */
  19572. _vrSupported: boolean;
  19573. /** @hidden */
  19574. _oldSize: Size;
  19575. /** @hidden */
  19576. _oldHardwareScaleFactor: number;
  19577. /** @hidden */
  19578. _vrExclusivePointerMode: boolean;
  19579. /** @hidden */
  19580. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19581. /** @hidden */
  19582. _onVRDisplayPointerRestricted: () => void;
  19583. /** @hidden */
  19584. _onVRDisplayPointerUnrestricted: () => void;
  19585. /** @hidden */
  19586. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19587. /** @hidden */
  19588. _onVrDisplayDisconnect: Nullable<() => void>;
  19589. /** @hidden */
  19590. _onVrDisplayPresentChange: Nullable<() => void>;
  19591. /**
  19592. * Observable signaled when VR display mode changes
  19593. */
  19594. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19595. /**
  19596. * Observable signaled when VR request present is complete
  19597. */
  19598. onVRRequestPresentComplete: Observable<boolean>;
  19599. /**
  19600. * Observable signaled when VR request present starts
  19601. */
  19602. onVRRequestPresentStart: Observable<Engine>;
  19603. /**
  19604. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19605. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19606. */
  19607. isInVRExclusivePointerMode: boolean;
  19608. /**
  19609. * Gets a boolean indicating if a webVR device was detected
  19610. * @returns true if a webVR device was detected
  19611. */
  19612. isVRDevicePresent(): boolean;
  19613. /**
  19614. * Gets the current webVR device
  19615. * @returns the current webVR device (or null)
  19616. */
  19617. getVRDevice(): any;
  19618. /**
  19619. * Initializes a webVR display and starts listening to display change events
  19620. * The onVRDisplayChangedObservable will be notified upon these changes
  19621. * @returns A promise containing a VRDisplay and if vr is supported
  19622. */
  19623. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19624. /** @hidden */
  19625. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19626. /**
  19627. * Gets or sets the presentation attributes used to configure VR rendering
  19628. */
  19629. vrPresentationAttributes?: IVRPresentationAttributes;
  19630. /**
  19631. * Call this function to switch to webVR mode
  19632. * Will do nothing if webVR is not supported or if there is no webVR device
  19633. * @param options the webvr options provided to the camera. mainly used for multiview
  19634. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19635. */
  19636. enableVR(options: WebVROptions): void;
  19637. /** @hidden */
  19638. _onVRFullScreenTriggered(): void;
  19639. }
  19640. }
  19641. declare module BABYLON {
  19642. /**
  19643. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19644. * IMPORTANT!! The data is right-hand data.
  19645. * @export
  19646. * @interface DevicePose
  19647. */
  19648. export interface DevicePose {
  19649. /**
  19650. * The position of the device, values in array are [x,y,z].
  19651. */
  19652. readonly position: Nullable<Float32Array>;
  19653. /**
  19654. * The linearVelocity of the device, values in array are [x,y,z].
  19655. */
  19656. readonly linearVelocity: Nullable<Float32Array>;
  19657. /**
  19658. * The linearAcceleration of the device, values in array are [x,y,z].
  19659. */
  19660. readonly linearAcceleration: Nullable<Float32Array>;
  19661. /**
  19662. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19663. */
  19664. readonly orientation: Nullable<Float32Array>;
  19665. /**
  19666. * The angularVelocity of the device, values in array are [x,y,z].
  19667. */
  19668. readonly angularVelocity: Nullable<Float32Array>;
  19669. /**
  19670. * The angularAcceleration of the device, values in array are [x,y,z].
  19671. */
  19672. readonly angularAcceleration: Nullable<Float32Array>;
  19673. }
  19674. /**
  19675. * Interface representing a pose controlled object in Babylon.
  19676. * A pose controlled object has both regular pose values as well as pose values
  19677. * from an external device such as a VR head mounted display
  19678. */
  19679. export interface PoseControlled {
  19680. /**
  19681. * The position of the object in babylon space.
  19682. */
  19683. position: Vector3;
  19684. /**
  19685. * The rotation quaternion of the object in babylon space.
  19686. */
  19687. rotationQuaternion: Quaternion;
  19688. /**
  19689. * The position of the device in babylon space.
  19690. */
  19691. devicePosition?: Vector3;
  19692. /**
  19693. * The rotation quaternion of the device in babylon space.
  19694. */
  19695. deviceRotationQuaternion: Quaternion;
  19696. /**
  19697. * The raw pose coming from the device.
  19698. */
  19699. rawPose: Nullable<DevicePose>;
  19700. /**
  19701. * The scale of the device to be used when translating from device space to babylon space.
  19702. */
  19703. deviceScaleFactor: number;
  19704. /**
  19705. * Updates the poseControlled values based on the input device pose.
  19706. * @param poseData the pose data to update the object with
  19707. */
  19708. updateFromDevice(poseData: DevicePose): void;
  19709. }
  19710. /**
  19711. * Set of options to customize the webVRCamera
  19712. */
  19713. export interface WebVROptions {
  19714. /**
  19715. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19716. */
  19717. trackPosition?: boolean;
  19718. /**
  19719. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19720. */
  19721. positionScale?: number;
  19722. /**
  19723. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19724. */
  19725. displayName?: string;
  19726. /**
  19727. * Should the native controller meshes be initialized. (default: true)
  19728. */
  19729. controllerMeshes?: boolean;
  19730. /**
  19731. * Creating a default HemiLight only on controllers. (default: true)
  19732. */
  19733. defaultLightingOnControllers?: boolean;
  19734. /**
  19735. * If you don't want to use the default VR button of the helper. (default: false)
  19736. */
  19737. useCustomVRButton?: boolean;
  19738. /**
  19739. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19740. */
  19741. customVRButton?: HTMLButtonElement;
  19742. /**
  19743. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19744. */
  19745. rayLength?: number;
  19746. /**
  19747. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19748. */
  19749. defaultHeight?: number;
  19750. /**
  19751. * If multiview should be used if availible (default: false)
  19752. */
  19753. useMultiview?: boolean;
  19754. }
  19755. /**
  19756. * This represents a WebVR camera.
  19757. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19758. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19759. */
  19760. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19761. private webVROptions;
  19762. /**
  19763. * @hidden
  19764. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19765. */
  19766. _vrDevice: any;
  19767. /**
  19768. * The rawPose of the vrDevice.
  19769. */
  19770. rawPose: Nullable<DevicePose>;
  19771. private _onVREnabled;
  19772. private _specsVersion;
  19773. private _attached;
  19774. private _frameData;
  19775. protected _descendants: Array<Node>;
  19776. private _deviceRoomPosition;
  19777. /** @hidden */
  19778. _deviceRoomRotationQuaternion: Quaternion;
  19779. private _standingMatrix;
  19780. /**
  19781. * Represents device position in babylon space.
  19782. */
  19783. devicePosition: Vector3;
  19784. /**
  19785. * Represents device rotation in babylon space.
  19786. */
  19787. deviceRotationQuaternion: Quaternion;
  19788. /**
  19789. * The scale of the device to be used when translating from device space to babylon space.
  19790. */
  19791. deviceScaleFactor: number;
  19792. private _deviceToWorld;
  19793. private _worldToDevice;
  19794. /**
  19795. * References to the webVR controllers for the vrDevice.
  19796. */
  19797. controllers: Array<WebVRController>;
  19798. /**
  19799. * Emits an event when a controller is attached.
  19800. */
  19801. onControllersAttachedObservable: Observable<WebVRController[]>;
  19802. /**
  19803. * Emits an event when a controller's mesh has been loaded;
  19804. */
  19805. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19806. /**
  19807. * Emits an event when the HMD's pose has been updated.
  19808. */
  19809. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19810. private _poseSet;
  19811. /**
  19812. * If the rig cameras be used as parent instead of this camera.
  19813. */
  19814. rigParenting: boolean;
  19815. private _lightOnControllers;
  19816. private _defaultHeight?;
  19817. /**
  19818. * Instantiates a WebVRFreeCamera.
  19819. * @param name The name of the WebVRFreeCamera
  19820. * @param position The starting anchor position for the camera
  19821. * @param scene The scene the camera belongs to
  19822. * @param webVROptions a set of customizable options for the webVRCamera
  19823. */
  19824. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19825. /**
  19826. * Gets the device distance from the ground in meters.
  19827. * @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.
  19828. */
  19829. deviceDistanceToRoomGround(): number;
  19830. /**
  19831. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19832. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19833. */
  19834. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19835. /**
  19836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19837. * @returns A promise with a boolean set to if the standing matrix is supported.
  19838. */
  19839. useStandingMatrixAsync(): Promise<boolean>;
  19840. /**
  19841. * Disposes the camera
  19842. */
  19843. dispose(): void;
  19844. /**
  19845. * Gets a vrController by name.
  19846. * @param name The name of the controller to retreive
  19847. * @returns the controller matching the name specified or null if not found
  19848. */
  19849. getControllerByName(name: string): Nullable<WebVRController>;
  19850. private _leftController;
  19851. /**
  19852. * The controller corresponding to the users left hand.
  19853. */
  19854. get leftController(): Nullable<WebVRController>;
  19855. private _rightController;
  19856. /**
  19857. * The controller corresponding to the users right hand.
  19858. */
  19859. get rightController(): Nullable<WebVRController>;
  19860. /**
  19861. * Casts a ray forward from the vrCamera's gaze.
  19862. * @param length Length of the ray (default: 100)
  19863. * @returns the ray corresponding to the gaze
  19864. */
  19865. getForwardRay(length?: number): Ray;
  19866. /**
  19867. * @hidden
  19868. * Updates the camera based on device's frame data
  19869. */
  19870. _checkInputs(): void;
  19871. /**
  19872. * Updates the poseControlled values based on the input device pose.
  19873. * @param poseData Pose coming from the device
  19874. */
  19875. updateFromDevice(poseData: DevicePose): void;
  19876. private _htmlElementAttached;
  19877. private _detachIfAttached;
  19878. /**
  19879. * WebVR's attach control will start broadcasting frames to the device.
  19880. * Note that in certain browsers (chrome for example) this function must be called
  19881. * within a user-interaction callback. Example:
  19882. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19883. *
  19884. * @param element html element to attach the vrDevice to
  19885. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19886. */
  19887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19888. /**
  19889. * Detaches the camera from the html element and disables VR
  19890. *
  19891. * @param element html element to detach from
  19892. */
  19893. detachControl(element: HTMLElement): void;
  19894. /**
  19895. * @returns the name of this class
  19896. */
  19897. getClassName(): string;
  19898. /**
  19899. * Calls resetPose on the vrDisplay
  19900. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19901. */
  19902. resetToCurrentRotation(): void;
  19903. /**
  19904. * @hidden
  19905. * Updates the rig cameras (left and right eye)
  19906. */
  19907. _updateRigCameras(): void;
  19908. private _workingVector;
  19909. private _oneVector;
  19910. private _workingMatrix;
  19911. private updateCacheCalled;
  19912. private _correctPositionIfNotTrackPosition;
  19913. /**
  19914. * @hidden
  19915. * Updates the cached values of the camera
  19916. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19917. */
  19918. _updateCache(ignoreParentClass?: boolean): void;
  19919. /**
  19920. * @hidden
  19921. * Get current device position in babylon world
  19922. */
  19923. _computeDevicePosition(): void;
  19924. /**
  19925. * Updates the current device position and rotation in the babylon world
  19926. */
  19927. update(): void;
  19928. /**
  19929. * @hidden
  19930. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19931. * @returns an identity matrix
  19932. */
  19933. _getViewMatrix(): Matrix;
  19934. private _tmpMatrix;
  19935. /**
  19936. * This function is called by the two RIG cameras.
  19937. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19938. * @hidden
  19939. */
  19940. _getWebVRViewMatrix(): Matrix;
  19941. /** @hidden */
  19942. _getWebVRProjectionMatrix(): Matrix;
  19943. private _onGamepadConnectedObserver;
  19944. private _onGamepadDisconnectedObserver;
  19945. private _updateCacheWhenTrackingDisabledObserver;
  19946. /**
  19947. * Initializes the controllers and their meshes
  19948. */
  19949. initControllers(): void;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * "Static Class" containing the most commonly used helper while dealing with material for
  19955. * rendering purpose.
  19956. *
  19957. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19958. *
  19959. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19960. */
  19961. export class MaterialHelper {
  19962. /**
  19963. * Bind the current view position to an effect.
  19964. * @param effect The effect to be bound
  19965. * @param scene The scene the eyes position is used from
  19966. * @param variableName name of the shader variable that will hold the eye position
  19967. */
  19968. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19969. /**
  19970. * Helps preparing the defines values about the UVs in used in the effect.
  19971. * UVs are shared as much as we can accross channels in the shaders.
  19972. * @param texture The texture we are preparing the UVs for
  19973. * @param defines The defines to update
  19974. * @param key The channel key "diffuse", "specular"... used in the shader
  19975. */
  19976. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19977. /**
  19978. * Binds a texture matrix value to its corrsponding uniform
  19979. * @param texture The texture to bind the matrix for
  19980. * @param uniformBuffer The uniform buffer receivin the data
  19981. * @param key The channel key "diffuse", "specular"... used in the shader
  19982. */
  19983. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19984. /**
  19985. * Gets the current status of the fog (should it be enabled?)
  19986. * @param mesh defines the mesh to evaluate for fog support
  19987. * @param scene defines the hosting scene
  19988. * @returns true if fog must be enabled
  19989. */
  19990. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19991. /**
  19992. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19993. * @param mesh defines the current mesh
  19994. * @param scene defines the current scene
  19995. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19996. * @param pointsCloud defines if point cloud rendering has to be turned on
  19997. * @param fogEnabled defines if fog has to be turned on
  19998. * @param alphaTest defines if alpha testing has to be turned on
  19999. * @param defines defines the current list of defines
  20000. */
  20001. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20002. /**
  20003. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20004. * @param scene defines the current scene
  20005. * @param engine defines the current engine
  20006. * @param defines specifies the list of active defines
  20007. * @param useInstances defines if instances have to be turned on
  20008. * @param useClipPlane defines if clip plane have to be turned on
  20009. * @param useInstances defines if instances have to be turned on
  20010. * @param useThinInstances defines if thin instances have to be turned on
  20011. */
  20012. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20013. /**
  20014. * Prepares the defines for bones
  20015. * @param mesh The mesh containing the geometry data we will draw
  20016. * @param defines The defines to update
  20017. */
  20018. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20019. /**
  20020. * Prepares the defines for morph targets
  20021. * @param mesh The mesh containing the geometry data we will draw
  20022. * @param defines The defines to update
  20023. */
  20024. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20025. /**
  20026. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20027. * @param mesh The mesh containing the geometry data we will draw
  20028. * @param defines The defines to update
  20029. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20030. * @param useBones Precise whether bones should be used or not (override mesh info)
  20031. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20032. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20033. * @returns false if defines are considered not dirty and have not been checked
  20034. */
  20035. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20036. /**
  20037. * Prepares the defines related to multiview
  20038. * @param scene The scene we are intending to draw
  20039. * @param defines The defines to update
  20040. */
  20041. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20042. /**
  20043. * Prepares the defines related to the light information passed in parameter
  20044. * @param scene The scene we are intending to draw
  20045. * @param mesh The mesh the effect is compiling for
  20046. * @param light The light the effect is compiling for
  20047. * @param lightIndex The index of the light
  20048. * @param defines The defines to update
  20049. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20050. * @param state Defines the current state regarding what is needed (normals, etc...)
  20051. */
  20052. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20053. needNormals: boolean;
  20054. needRebuild: boolean;
  20055. shadowEnabled: boolean;
  20056. specularEnabled: boolean;
  20057. lightmapMode: boolean;
  20058. }): void;
  20059. /**
  20060. * Prepares the defines related to the light information passed in parameter
  20061. * @param scene The scene we are intending to draw
  20062. * @param mesh The mesh the effect is compiling for
  20063. * @param defines The defines to update
  20064. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20065. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20066. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20067. * @returns true if normals will be required for the rest of the effect
  20068. */
  20069. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20070. /**
  20071. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20072. * @param lightIndex defines the light index
  20073. * @param uniformsList The uniform list
  20074. * @param samplersList The sampler list
  20075. * @param projectedLightTexture defines if projected texture must be used
  20076. * @param uniformBuffersList defines an optional list of uniform buffers
  20077. */
  20078. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20079. /**
  20080. * Prepares the uniforms and samplers list to be used in the effect
  20081. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20082. * @param samplersList The sampler list
  20083. * @param defines The defines helping in the list generation
  20084. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20085. */
  20086. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20087. /**
  20088. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20089. * @param defines The defines to update while falling back
  20090. * @param fallbacks The authorized effect fallbacks
  20091. * @param maxSimultaneousLights The maximum number of lights allowed
  20092. * @param rank the current rank of the Effect
  20093. * @returns The newly affected rank
  20094. */
  20095. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20096. private static _TmpMorphInfluencers;
  20097. /**
  20098. * Prepares the list of attributes required for morph targets according to the effect defines.
  20099. * @param attribs The current list of supported attribs
  20100. * @param mesh The mesh to prepare the morph targets attributes for
  20101. * @param influencers The number of influencers
  20102. */
  20103. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20104. /**
  20105. * Prepares the list of attributes required for morph targets according to the effect defines.
  20106. * @param attribs The current list of supported attribs
  20107. * @param mesh The mesh to prepare the morph targets attributes for
  20108. * @param defines The current Defines of the effect
  20109. */
  20110. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20111. /**
  20112. * Prepares the list of attributes required for bones according to the effect defines.
  20113. * @param attribs The current list of supported attribs
  20114. * @param mesh The mesh to prepare the bones attributes for
  20115. * @param defines The current Defines of the effect
  20116. * @param fallbacks The current efffect fallback strategy
  20117. */
  20118. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20119. /**
  20120. * Check and prepare the list of attributes required for instances according to the effect defines.
  20121. * @param attribs The current list of supported attribs
  20122. * @param defines The current MaterialDefines of the effect
  20123. */
  20124. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20125. /**
  20126. * Add the list of attributes required for instances to the attribs array.
  20127. * @param attribs The current list of supported attribs
  20128. */
  20129. static PushAttributesForInstances(attribs: string[]): void;
  20130. /**
  20131. * Binds the light information to the effect.
  20132. * @param light The light containing the generator
  20133. * @param effect The effect we are binding the data to
  20134. * @param lightIndex The light index in the effect used to render
  20135. */
  20136. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20137. /**
  20138. * Binds the lights information from the scene to the effect for the given mesh.
  20139. * @param light Light to bind
  20140. * @param lightIndex Light index
  20141. * @param scene The scene where the light belongs to
  20142. * @param effect The effect we are binding the data to
  20143. * @param useSpecular Defines if specular is supported
  20144. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20145. */
  20146. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20147. /**
  20148. * Binds the lights information from the scene to the effect for the given mesh.
  20149. * @param scene The scene the lights belongs to
  20150. * @param mesh The mesh we are binding the information to render
  20151. * @param effect The effect we are binding the data to
  20152. * @param defines The generated defines for the effect
  20153. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20155. */
  20156. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20157. private static _tempFogColor;
  20158. /**
  20159. * Binds the fog information from the scene to the effect for the given mesh.
  20160. * @param scene The scene the lights belongs to
  20161. * @param mesh The mesh we are binding the information to render
  20162. * @param effect The effect we are binding the data to
  20163. * @param linearSpace Defines if the fog effect is applied in linear space
  20164. */
  20165. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20166. /**
  20167. * Binds the bones information from the mesh to the effect.
  20168. * @param mesh The mesh we are binding the information to render
  20169. * @param effect The effect we are binding the data to
  20170. */
  20171. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20172. /**
  20173. * Binds the morph targets information from the mesh to the effect.
  20174. * @param abstractMesh The mesh we are binding the information to render
  20175. * @param effect The effect we are binding the data to
  20176. */
  20177. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20178. /**
  20179. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20180. * @param defines The generated defines used in the effect
  20181. * @param effect The effect we are binding the data to
  20182. * @param scene The scene we are willing to render with logarithmic scale for
  20183. */
  20184. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20185. /**
  20186. * Binds the clip plane information from the scene to the effect.
  20187. * @param scene The scene the clip plane information are extracted from
  20188. * @param effect The effect we are binding the data to
  20189. */
  20190. static BindClipPlane(effect: Effect, scene: Scene): void;
  20191. }
  20192. }
  20193. declare module BABYLON {
  20194. /**
  20195. * Block used to expose an input value
  20196. */
  20197. export class InputBlock extends NodeMaterialBlock {
  20198. private _mode;
  20199. private _associatedVariableName;
  20200. private _storedValue;
  20201. private _valueCallback;
  20202. private _type;
  20203. private _animationType;
  20204. /** Gets or set a value used to limit the range of float values */
  20205. min: number;
  20206. /** Gets or set a value used to limit the range of float values */
  20207. max: number;
  20208. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20209. isBoolean: boolean;
  20210. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20211. matrixMode: number;
  20212. /** @hidden */
  20213. _systemValue: Nullable<NodeMaterialSystemValues>;
  20214. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20215. visibleInInspector: boolean;
  20216. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20217. isConstant: boolean;
  20218. /** Gets or sets the group to use to display this block in the Inspector */
  20219. groupInInspector: string;
  20220. /** Gets an observable raised when the value is changed */
  20221. onValueChangedObservable: Observable<InputBlock>;
  20222. /**
  20223. * Gets or sets the connection point type (default is float)
  20224. */
  20225. get type(): NodeMaterialBlockConnectionPointTypes;
  20226. /**
  20227. * Creates a new InputBlock
  20228. * @param name defines the block name
  20229. * @param target defines the target of that block (Vertex by default)
  20230. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20231. */
  20232. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20233. /**
  20234. * Gets the output component
  20235. */
  20236. get output(): NodeMaterialConnectionPoint;
  20237. /**
  20238. * Set the source of this connection point to a vertex attribute
  20239. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20240. * @returns the current connection point
  20241. */
  20242. setAsAttribute(attributeName?: string): InputBlock;
  20243. /**
  20244. * Set the source of this connection point to a system value
  20245. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20246. * @returns the current connection point
  20247. */
  20248. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20249. /**
  20250. * Gets or sets the value of that point.
  20251. * Please note that this value will be ignored if valueCallback is defined
  20252. */
  20253. get value(): any;
  20254. set value(value: any);
  20255. /**
  20256. * Gets or sets a callback used to get the value of that point.
  20257. * Please note that setting this value will force the connection point to ignore the value property
  20258. */
  20259. get valueCallback(): () => any;
  20260. set valueCallback(value: () => any);
  20261. /**
  20262. * Gets or sets the associated variable name in the shader
  20263. */
  20264. get associatedVariableName(): string;
  20265. set associatedVariableName(value: string);
  20266. /** Gets or sets the type of animation applied to the input */
  20267. get animationType(): AnimatedInputBlockTypes;
  20268. set animationType(value: AnimatedInputBlockTypes);
  20269. /**
  20270. * Gets a boolean indicating that this connection point not defined yet
  20271. */
  20272. get isUndefined(): boolean;
  20273. /**
  20274. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20275. * In this case the connection point name must be the name of the uniform to use.
  20276. * Can only be set on inputs
  20277. */
  20278. get isUniform(): boolean;
  20279. set isUniform(value: boolean);
  20280. /**
  20281. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20282. * In this case the connection point name must be the name of the attribute to use
  20283. * Can only be set on inputs
  20284. */
  20285. get isAttribute(): boolean;
  20286. set isAttribute(value: boolean);
  20287. /**
  20288. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20289. * Can only be set on exit points
  20290. */
  20291. get isVarying(): boolean;
  20292. set isVarying(value: boolean);
  20293. /**
  20294. * Gets a boolean indicating that the current connection point is a system value
  20295. */
  20296. get isSystemValue(): boolean;
  20297. /**
  20298. * Gets or sets the current well known value or null if not defined as a system value
  20299. */
  20300. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20301. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20302. /**
  20303. * Gets the current class name
  20304. * @returns the class name
  20305. */
  20306. getClassName(): string;
  20307. /**
  20308. * Animate the input if animationType !== None
  20309. * @param scene defines the rendering scene
  20310. */
  20311. animate(scene: Scene): void;
  20312. private _emitDefine;
  20313. initialize(state: NodeMaterialBuildState): void;
  20314. /**
  20315. * Set the input block to its default value (based on its type)
  20316. */
  20317. setDefaultValue(): void;
  20318. private _emitConstant;
  20319. /** @hidden */
  20320. get _noContextSwitch(): boolean;
  20321. private _emit;
  20322. /** @hidden */
  20323. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20324. /** @hidden */
  20325. _transmit(effect: Effect, scene: Scene): void;
  20326. protected _buildBlock(state: NodeMaterialBuildState): void;
  20327. protected _dumpPropertiesCode(): string;
  20328. dispose(): void;
  20329. serialize(): any;
  20330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20331. }
  20332. }
  20333. declare module BABYLON {
  20334. /**
  20335. * Enum used to define the compatibility state between two connection points
  20336. */
  20337. export enum NodeMaterialConnectionPointCompatibilityStates {
  20338. /** Points are compatibles */
  20339. Compatible = 0,
  20340. /** Points are incompatible because of their types */
  20341. TypeIncompatible = 1,
  20342. /** Points are incompatible because of their targets (vertex vs fragment) */
  20343. TargetIncompatible = 2
  20344. }
  20345. /**
  20346. * Defines the direction of a connection point
  20347. */
  20348. export enum NodeMaterialConnectionPointDirection {
  20349. /** Input */
  20350. Input = 0,
  20351. /** Output */
  20352. Output = 1
  20353. }
  20354. /**
  20355. * Defines a connection point for a block
  20356. */
  20357. export class NodeMaterialConnectionPoint {
  20358. /** @hidden */
  20359. _ownerBlock: NodeMaterialBlock;
  20360. /** @hidden */
  20361. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20362. private _endpoints;
  20363. private _associatedVariableName;
  20364. private _direction;
  20365. /** @hidden */
  20366. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20367. /** @hidden */
  20368. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20369. private _type;
  20370. /** @hidden */
  20371. _enforceAssociatedVariableName: boolean;
  20372. /** Gets the direction of the point */
  20373. get direction(): NodeMaterialConnectionPointDirection;
  20374. /** Indicates that this connection point needs dual validation before being connected to another point */
  20375. needDualDirectionValidation: boolean;
  20376. /**
  20377. * Gets or sets the additional types supported by this connection point
  20378. */
  20379. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20380. /**
  20381. * Gets or sets the additional types excluded by this connection point
  20382. */
  20383. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20384. /**
  20385. * Observable triggered when this point is connected
  20386. */
  20387. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20388. /**
  20389. * Gets or sets the associated variable name in the shader
  20390. */
  20391. get associatedVariableName(): string;
  20392. set associatedVariableName(value: string);
  20393. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20394. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20395. /**
  20396. * Gets or sets the connection point type (default is float)
  20397. */
  20398. get type(): NodeMaterialBlockConnectionPointTypes;
  20399. set type(value: NodeMaterialBlockConnectionPointTypes);
  20400. /**
  20401. * Gets or sets the connection point name
  20402. */
  20403. name: string;
  20404. /**
  20405. * Gets or sets the connection point name
  20406. */
  20407. displayName: string;
  20408. /**
  20409. * Gets or sets a boolean indicating that this connection point can be omitted
  20410. */
  20411. isOptional: boolean;
  20412. /**
  20413. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20414. */
  20415. define: string;
  20416. /** @hidden */
  20417. _prioritizeVertex: boolean;
  20418. private _target;
  20419. /** Gets or sets the target of that connection point */
  20420. get target(): NodeMaterialBlockTargets;
  20421. set target(value: NodeMaterialBlockTargets);
  20422. /**
  20423. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20424. */
  20425. get isConnected(): boolean;
  20426. /**
  20427. * Gets a boolean indicating that the current point is connected to an input block
  20428. */
  20429. get isConnectedToInputBlock(): boolean;
  20430. /**
  20431. * Gets a the connected input block (if any)
  20432. */
  20433. get connectInputBlock(): Nullable<InputBlock>;
  20434. /** Get the other side of the connection (if any) */
  20435. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20436. /** Get the block that owns this connection point */
  20437. get ownerBlock(): NodeMaterialBlock;
  20438. /** Get the block connected on the other side of this connection (if any) */
  20439. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20440. /** Get the block connected on the endpoints of this connection (if any) */
  20441. get connectedBlocks(): Array<NodeMaterialBlock>;
  20442. /** Gets the list of connected endpoints */
  20443. get endpoints(): NodeMaterialConnectionPoint[];
  20444. /** Gets a boolean indicating if that output point is connected to at least one input */
  20445. get hasEndpoints(): boolean;
  20446. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20447. get isConnectedInVertexShader(): boolean;
  20448. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20449. get isConnectedInFragmentShader(): boolean;
  20450. /**
  20451. * Creates a block suitable to be used as an input for this input point.
  20452. * If null is returned, a block based on the point type will be created.
  20453. * @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
  20454. */
  20455. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20456. /**
  20457. * Creates a new connection point
  20458. * @param name defines the connection point name
  20459. * @param ownerBlock defines the block hosting this connection point
  20460. * @param direction defines the direction of the connection point
  20461. */
  20462. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20463. /**
  20464. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20465. * @returns the class name
  20466. */
  20467. getClassName(): string;
  20468. /**
  20469. * Gets a boolean indicating if the current point can be connected to another point
  20470. * @param connectionPoint defines the other connection point
  20471. * @returns a boolean
  20472. */
  20473. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20474. /**
  20475. * Gets a number indicating if the current point can be connected to another point
  20476. * @param connectionPoint defines the other connection point
  20477. * @returns a number defining the compatibility state
  20478. */
  20479. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20480. /**
  20481. * Connect this point to another connection point
  20482. * @param connectionPoint defines the other connection point
  20483. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20484. * @returns the current connection point
  20485. */
  20486. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20487. /**
  20488. * Disconnect this point from one of his endpoint
  20489. * @param endpoint defines the other connection point
  20490. * @returns the current connection point
  20491. */
  20492. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20493. /**
  20494. * Serializes this point in a JSON representation
  20495. * @param isInput defines if the connection point is an input (default is true)
  20496. * @returns the serialized point object
  20497. */
  20498. serialize(isInput?: boolean): any;
  20499. /**
  20500. * Release resources
  20501. */
  20502. dispose(): void;
  20503. }
  20504. }
  20505. declare module BABYLON {
  20506. /**
  20507. * Enum used to define the material modes
  20508. */
  20509. export enum NodeMaterialModes {
  20510. /** Regular material */
  20511. Material = 0,
  20512. /** For post process */
  20513. PostProcess = 1,
  20514. /** For particle system */
  20515. Particle = 2
  20516. }
  20517. }
  20518. declare module BABYLON {
  20519. /**
  20520. * Block used to read a texture from a sampler
  20521. */
  20522. export class TextureBlock extends NodeMaterialBlock {
  20523. private _defineName;
  20524. private _linearDefineName;
  20525. private _gammaDefineName;
  20526. private _tempTextureRead;
  20527. private _samplerName;
  20528. private _transformedUVName;
  20529. private _textureTransformName;
  20530. private _textureInfoName;
  20531. private _mainUVName;
  20532. private _mainUVDefineName;
  20533. private _fragmentOnly;
  20534. /**
  20535. * Gets or sets the texture associated with the node
  20536. */
  20537. texture: Nullable<Texture>;
  20538. /**
  20539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20540. */
  20541. convertToGammaSpace: boolean;
  20542. /**
  20543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20544. */
  20545. convertToLinearSpace: boolean;
  20546. /**
  20547. * Create a new TextureBlock
  20548. * @param name defines the block name
  20549. */
  20550. constructor(name: string, fragmentOnly?: boolean);
  20551. /**
  20552. * Gets the current class name
  20553. * @returns the class name
  20554. */
  20555. getClassName(): string;
  20556. /**
  20557. * Gets the uv input component
  20558. */
  20559. get uv(): NodeMaterialConnectionPoint;
  20560. /**
  20561. * Gets the rgba output component
  20562. */
  20563. get rgba(): NodeMaterialConnectionPoint;
  20564. /**
  20565. * Gets the rgb output component
  20566. */
  20567. get rgb(): NodeMaterialConnectionPoint;
  20568. /**
  20569. * Gets the r output component
  20570. */
  20571. get r(): NodeMaterialConnectionPoint;
  20572. /**
  20573. * Gets the g output component
  20574. */
  20575. get g(): NodeMaterialConnectionPoint;
  20576. /**
  20577. * Gets the b output component
  20578. */
  20579. get b(): NodeMaterialConnectionPoint;
  20580. /**
  20581. * Gets the a output component
  20582. */
  20583. get a(): NodeMaterialConnectionPoint;
  20584. get target(): NodeMaterialBlockTargets;
  20585. autoConfigure(material: NodeMaterial): void;
  20586. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20588. isReady(): boolean;
  20589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20590. private get _isMixed();
  20591. private _injectVertexCode;
  20592. private _writeTextureRead;
  20593. private _writeOutput;
  20594. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20595. protected _dumpPropertiesCode(): string;
  20596. serialize(): any;
  20597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20598. }
  20599. }
  20600. declare module BABYLON {
  20601. /** @hidden */
  20602. export var reflectionFunction: {
  20603. name: string;
  20604. shader: string;
  20605. };
  20606. }
  20607. declare module BABYLON {
  20608. /**
  20609. * Base block used to read a reflection texture from a sampler
  20610. */
  20611. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20612. /** @hidden */
  20613. _define3DName: string;
  20614. /** @hidden */
  20615. _defineCubicName: string;
  20616. /** @hidden */
  20617. _defineExplicitName: string;
  20618. /** @hidden */
  20619. _defineProjectionName: string;
  20620. /** @hidden */
  20621. _defineLocalCubicName: string;
  20622. /** @hidden */
  20623. _defineSphericalName: string;
  20624. /** @hidden */
  20625. _definePlanarName: string;
  20626. /** @hidden */
  20627. _defineEquirectangularName: string;
  20628. /** @hidden */
  20629. _defineMirroredEquirectangularFixedName: string;
  20630. /** @hidden */
  20631. _defineEquirectangularFixedName: string;
  20632. /** @hidden */
  20633. _defineSkyboxName: string;
  20634. /** @hidden */
  20635. _defineOppositeZ: string;
  20636. /** @hidden */
  20637. _cubeSamplerName: string;
  20638. /** @hidden */
  20639. _2DSamplerName: string;
  20640. protected _positionUVWName: string;
  20641. protected _directionWName: string;
  20642. protected _reflectionVectorName: string;
  20643. /** @hidden */
  20644. _reflectionCoordsName: string;
  20645. /** @hidden */
  20646. _reflectionMatrixName: string;
  20647. protected _reflectionColorName: string;
  20648. /**
  20649. * Gets or sets the texture associated with the node
  20650. */
  20651. texture: Nullable<BaseTexture>;
  20652. /**
  20653. * Create a new ReflectionTextureBaseBlock
  20654. * @param name defines the block name
  20655. */
  20656. constructor(name: string);
  20657. /**
  20658. * Gets the current class name
  20659. * @returns the class name
  20660. */
  20661. getClassName(): string;
  20662. /**
  20663. * Gets the world position input component
  20664. */
  20665. abstract get position(): NodeMaterialConnectionPoint;
  20666. /**
  20667. * Gets the world position input component
  20668. */
  20669. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20670. /**
  20671. * Gets the world normal input component
  20672. */
  20673. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20674. /**
  20675. * Gets the world input component
  20676. */
  20677. abstract get world(): NodeMaterialConnectionPoint;
  20678. /**
  20679. * Gets the camera (or eye) position component
  20680. */
  20681. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20682. /**
  20683. * Gets the view input component
  20684. */
  20685. abstract get view(): NodeMaterialConnectionPoint;
  20686. protected _getTexture(): Nullable<BaseTexture>;
  20687. autoConfigure(material: NodeMaterial): void;
  20688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20689. isReady(): boolean;
  20690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20691. /**
  20692. * Gets the code to inject in the vertex shader
  20693. * @param state current state of the node material building
  20694. * @returns the shader code
  20695. */
  20696. handleVertexSide(state: NodeMaterialBuildState): string;
  20697. /**
  20698. * Handles the inits for the fragment code path
  20699. * @param state node material build state
  20700. */
  20701. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20702. /**
  20703. * Generates the reflection coords code for the fragment code path
  20704. * @param worldNormalVarName name of the world normal variable
  20705. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20706. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20707. * @returns the shader code
  20708. */
  20709. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20710. /**
  20711. * Generates the reflection color code for the fragment code path
  20712. * @param lodVarName name of the lod variable
  20713. * @param swizzleLookupTexture swizzle to use for the final color variable
  20714. * @returns the shader code
  20715. */
  20716. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20717. /**
  20718. * Generates the code corresponding to the connected output points
  20719. * @param state node material build state
  20720. * @param varName name of the variable to output
  20721. * @returns the shader code
  20722. */
  20723. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20724. protected _buildBlock(state: NodeMaterialBuildState): this;
  20725. protected _dumpPropertiesCode(): string;
  20726. serialize(): any;
  20727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * Defines a connection point to be used for points with a custom object type
  20733. */
  20734. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20735. private _blockType;
  20736. private _blockName;
  20737. private _nameForCheking?;
  20738. /**
  20739. * Creates a new connection point
  20740. * @param name defines the connection point name
  20741. * @param ownerBlock defines the block hosting this connection point
  20742. * @param direction defines the direction of the connection point
  20743. */
  20744. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20745. /**
  20746. * Gets a number indicating if the current point can be connected to another point
  20747. * @param connectionPoint defines the other connection point
  20748. * @returns a number defining the compatibility state
  20749. */
  20750. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20751. /**
  20752. * Creates a block suitable to be used as an input for this input point.
  20753. * If null is returned, a block based on the point type will be created.
  20754. * @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
  20755. */
  20756. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20757. }
  20758. }
  20759. declare module BABYLON {
  20760. /**
  20761. * Enum defining the type of properties that can be edited in the property pages in the NME
  20762. */
  20763. export enum PropertyTypeForEdition {
  20764. /** property is a boolean */
  20765. Boolean = 0,
  20766. /** property is a float */
  20767. Float = 1,
  20768. /** property is a Vector2 */
  20769. Vector2 = 2,
  20770. /** property is a list of values */
  20771. List = 3
  20772. }
  20773. /**
  20774. * Interface that defines an option in a variable of type list
  20775. */
  20776. export interface IEditablePropertyListOption {
  20777. /** label of the option */
  20778. "label": string;
  20779. /** value of the option */
  20780. "value": number;
  20781. }
  20782. /**
  20783. * Interface that defines the options available for an editable property
  20784. */
  20785. export interface IEditablePropertyOption {
  20786. /** min value */
  20787. "min"?: number;
  20788. /** max value */
  20789. "max"?: number;
  20790. /** notifiers: indicates which actions to take when the property is changed */
  20791. "notifiers"?: {
  20792. /** the material should be rebuilt */
  20793. "rebuild"?: boolean;
  20794. /** the preview should be updated */
  20795. "update"?: boolean;
  20796. };
  20797. /** list of the options for a variable of type list */
  20798. "options"?: IEditablePropertyListOption[];
  20799. }
  20800. /**
  20801. * Interface that describes an editable property
  20802. */
  20803. export interface IPropertyDescriptionForEdition {
  20804. /** name of the property */
  20805. "propertyName": string;
  20806. /** display name of the property */
  20807. "displayName": string;
  20808. /** type of the property */
  20809. "type": PropertyTypeForEdition;
  20810. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20811. "groupName": string;
  20812. /** options for the property */
  20813. "options": IEditablePropertyOption;
  20814. }
  20815. /**
  20816. * Decorator that flags a property in a node material block as being editable
  20817. */
  20818. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20819. }
  20820. declare module BABYLON {
  20821. /**
  20822. * Block used to implement the refraction part of the sub surface module of the PBR material
  20823. */
  20824. export class RefractionBlock extends NodeMaterialBlock {
  20825. /** @hidden */
  20826. _define3DName: string;
  20827. /** @hidden */
  20828. _refractionMatrixName: string;
  20829. /** @hidden */
  20830. _defineLODRefractionAlpha: string;
  20831. /** @hidden */
  20832. _defineLinearSpecularRefraction: string;
  20833. /** @hidden */
  20834. _defineOppositeZ: string;
  20835. /** @hidden */
  20836. _cubeSamplerName: string;
  20837. /** @hidden */
  20838. _2DSamplerName: string;
  20839. /** @hidden */
  20840. _vRefractionMicrosurfaceInfosName: string;
  20841. /** @hidden */
  20842. _vRefractionInfosName: string;
  20843. private _scene;
  20844. /**
  20845. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20846. * Materials half opaque for instance using refraction could benefit from this control.
  20847. */
  20848. linkRefractionWithTransparency: boolean;
  20849. /**
  20850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20851. */
  20852. invertRefractionY: boolean;
  20853. /**
  20854. * Gets or sets the texture associated with the node
  20855. */
  20856. texture: Nullable<BaseTexture>;
  20857. /**
  20858. * Create a new RefractionBlock
  20859. * @param name defines the block name
  20860. */
  20861. constructor(name: string);
  20862. /**
  20863. * Gets the current class name
  20864. * @returns the class name
  20865. */
  20866. getClassName(): string;
  20867. /**
  20868. * Gets the intensity input component
  20869. */
  20870. get intensity(): NodeMaterialConnectionPoint;
  20871. /**
  20872. * Gets the index of refraction input component
  20873. */
  20874. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20875. /**
  20876. * Gets the tint at distance input component
  20877. */
  20878. get tintAtDistance(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Gets the view input component
  20881. */
  20882. get view(): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Gets the refraction object output component
  20885. */
  20886. get refraction(): NodeMaterialConnectionPoint;
  20887. /**
  20888. * Returns true if the block has a texture
  20889. */
  20890. get hasTexture(): boolean;
  20891. protected _getTexture(): Nullable<BaseTexture>;
  20892. autoConfigure(material: NodeMaterial): void;
  20893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20894. isReady(): boolean;
  20895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20896. /**
  20897. * Gets the main code of the block (fragment side)
  20898. * @param state current state of the node material building
  20899. * @returns the shader code
  20900. */
  20901. getCode(state: NodeMaterialBuildState): string;
  20902. protected _buildBlock(state: NodeMaterialBuildState): this;
  20903. protected _dumpPropertiesCode(): string;
  20904. serialize(): any;
  20905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20906. }
  20907. }
  20908. declare module BABYLON {
  20909. /**
  20910. * Base block used as input for post process
  20911. */
  20912. export class CurrentScreenBlock extends NodeMaterialBlock {
  20913. private _samplerName;
  20914. private _linearDefineName;
  20915. private _gammaDefineName;
  20916. private _mainUVName;
  20917. private _tempTextureRead;
  20918. /**
  20919. * Gets or sets the texture associated with the node
  20920. */
  20921. texture: Nullable<BaseTexture>;
  20922. /**
  20923. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20924. */
  20925. convertToGammaSpace: boolean;
  20926. /**
  20927. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20928. */
  20929. convertToLinearSpace: boolean;
  20930. /**
  20931. * Create a new CurrentScreenBlock
  20932. * @param name defines the block name
  20933. */
  20934. constructor(name: string);
  20935. /**
  20936. * Gets the current class name
  20937. * @returns the class name
  20938. */
  20939. getClassName(): string;
  20940. /**
  20941. * Gets the uv input component
  20942. */
  20943. get uv(): NodeMaterialConnectionPoint;
  20944. /**
  20945. * Gets the rgba output component
  20946. */
  20947. get rgba(): NodeMaterialConnectionPoint;
  20948. /**
  20949. * Gets the rgb output component
  20950. */
  20951. get rgb(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the r output component
  20954. */
  20955. get r(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the g output component
  20958. */
  20959. get g(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the b output component
  20962. */
  20963. get b(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the a output component
  20966. */
  20967. get a(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Initialize the block and prepare the context for build
  20970. * @param state defines the state that will be used for the build
  20971. */
  20972. initialize(state: NodeMaterialBuildState): void;
  20973. get target(): NodeMaterialBlockTargets;
  20974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20975. isReady(): boolean;
  20976. private _injectVertexCode;
  20977. private _writeTextureRead;
  20978. private _writeOutput;
  20979. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20980. serialize(): any;
  20981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20982. }
  20983. }
  20984. declare module BABYLON {
  20985. /**
  20986. * Base block used for the particle texture
  20987. */
  20988. export class ParticleTextureBlock extends NodeMaterialBlock {
  20989. private _samplerName;
  20990. private _linearDefineName;
  20991. private _gammaDefineName;
  20992. private _tempTextureRead;
  20993. /**
  20994. * Gets or sets the texture associated with the node
  20995. */
  20996. texture: Nullable<BaseTexture>;
  20997. /**
  20998. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20999. */
  21000. convertToGammaSpace: boolean;
  21001. /**
  21002. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21003. */
  21004. convertToLinearSpace: boolean;
  21005. /**
  21006. * Create a new ParticleTextureBlock
  21007. * @param name defines the block name
  21008. */
  21009. constructor(name: string);
  21010. /**
  21011. * Gets the current class name
  21012. * @returns the class name
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Gets the uv input component
  21017. */
  21018. get uv(): NodeMaterialConnectionPoint;
  21019. /**
  21020. * Gets the rgba output component
  21021. */
  21022. get rgba(): NodeMaterialConnectionPoint;
  21023. /**
  21024. * Gets the rgb output component
  21025. */
  21026. get rgb(): NodeMaterialConnectionPoint;
  21027. /**
  21028. * Gets the r output component
  21029. */
  21030. get r(): NodeMaterialConnectionPoint;
  21031. /**
  21032. * Gets the g output component
  21033. */
  21034. get g(): NodeMaterialConnectionPoint;
  21035. /**
  21036. * Gets the b output component
  21037. */
  21038. get b(): NodeMaterialConnectionPoint;
  21039. /**
  21040. * Gets the a output component
  21041. */
  21042. get a(): NodeMaterialConnectionPoint;
  21043. /**
  21044. * Initialize the block and prepare the context for build
  21045. * @param state defines the state that will be used for the build
  21046. */
  21047. initialize(state: NodeMaterialBuildState): void;
  21048. autoConfigure(material: NodeMaterial): void;
  21049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21050. isReady(): boolean;
  21051. private _writeOutput;
  21052. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21053. serialize(): any;
  21054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21055. }
  21056. }
  21057. declare module BABYLON {
  21058. /**
  21059. * Class used to store shared data between 2 NodeMaterialBuildState
  21060. */
  21061. export class NodeMaterialBuildStateSharedData {
  21062. /**
  21063. * Gets the list of emitted varyings
  21064. */
  21065. temps: string[];
  21066. /**
  21067. * Gets the list of emitted varyings
  21068. */
  21069. varyings: string[];
  21070. /**
  21071. * Gets the varying declaration string
  21072. */
  21073. varyingDeclaration: string;
  21074. /**
  21075. * Input blocks
  21076. */
  21077. inputBlocks: InputBlock[];
  21078. /**
  21079. * Input blocks
  21080. */
  21081. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21082. /**
  21083. * Bindable blocks (Blocks that need to set data to the effect)
  21084. */
  21085. bindableBlocks: NodeMaterialBlock[];
  21086. /**
  21087. * List of blocks that can provide a compilation fallback
  21088. */
  21089. blocksWithFallbacks: NodeMaterialBlock[];
  21090. /**
  21091. * List of blocks that can provide a define update
  21092. */
  21093. blocksWithDefines: NodeMaterialBlock[];
  21094. /**
  21095. * List of blocks that can provide a repeatable content
  21096. */
  21097. repeatableContentBlocks: NodeMaterialBlock[];
  21098. /**
  21099. * List of blocks that can provide a dynamic list of uniforms
  21100. */
  21101. dynamicUniformBlocks: NodeMaterialBlock[];
  21102. /**
  21103. * List of blocks that can block the isReady function for the material
  21104. */
  21105. blockingBlocks: NodeMaterialBlock[];
  21106. /**
  21107. * Gets the list of animated inputs
  21108. */
  21109. animatedInputs: InputBlock[];
  21110. /**
  21111. * Build Id used to avoid multiple recompilations
  21112. */
  21113. buildId: number;
  21114. /** List of emitted variables */
  21115. variableNames: {
  21116. [key: string]: number;
  21117. };
  21118. /** List of emitted defines */
  21119. defineNames: {
  21120. [key: string]: number;
  21121. };
  21122. /** Should emit comments? */
  21123. emitComments: boolean;
  21124. /** Emit build activity */
  21125. verbose: boolean;
  21126. /** Gets or sets the hosting scene */
  21127. scene: Scene;
  21128. /**
  21129. * Gets the compilation hints emitted at compilation time
  21130. */
  21131. hints: {
  21132. needWorldViewMatrix: boolean;
  21133. needWorldViewProjectionMatrix: boolean;
  21134. needAlphaBlending: boolean;
  21135. needAlphaTesting: boolean;
  21136. };
  21137. /**
  21138. * List of compilation checks
  21139. */
  21140. checks: {
  21141. emitVertex: boolean;
  21142. emitFragment: boolean;
  21143. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21144. };
  21145. /**
  21146. * Is vertex program allowed to be empty?
  21147. */
  21148. allowEmptyVertexProgram: boolean;
  21149. /** Creates a new shared data */
  21150. constructor();
  21151. /**
  21152. * Emits console errors and exceptions if there is a failing check
  21153. */
  21154. emitErrors(): void;
  21155. }
  21156. }
  21157. declare module BABYLON {
  21158. /**
  21159. * Class used to store node based material build state
  21160. */
  21161. export class NodeMaterialBuildState {
  21162. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21163. supportUniformBuffers: boolean;
  21164. /**
  21165. * Gets the list of emitted attributes
  21166. */
  21167. attributes: string[];
  21168. /**
  21169. * Gets the list of emitted uniforms
  21170. */
  21171. uniforms: string[];
  21172. /**
  21173. * Gets the list of emitted constants
  21174. */
  21175. constants: string[];
  21176. /**
  21177. * Gets the list of emitted samplers
  21178. */
  21179. samplers: string[];
  21180. /**
  21181. * Gets the list of emitted functions
  21182. */
  21183. functions: {
  21184. [key: string]: string;
  21185. };
  21186. /**
  21187. * Gets the list of emitted extensions
  21188. */
  21189. extensions: {
  21190. [key: string]: string;
  21191. };
  21192. /**
  21193. * Gets the target of the compilation state
  21194. */
  21195. target: NodeMaterialBlockTargets;
  21196. /**
  21197. * Gets the list of emitted counters
  21198. */
  21199. counters: {
  21200. [key: string]: number;
  21201. };
  21202. /**
  21203. * Shared data between multiple NodeMaterialBuildState instances
  21204. */
  21205. sharedData: NodeMaterialBuildStateSharedData;
  21206. /** @hidden */
  21207. _vertexState: NodeMaterialBuildState;
  21208. /** @hidden */
  21209. _attributeDeclaration: string;
  21210. /** @hidden */
  21211. _uniformDeclaration: string;
  21212. /** @hidden */
  21213. _constantDeclaration: string;
  21214. /** @hidden */
  21215. _samplerDeclaration: string;
  21216. /** @hidden */
  21217. _varyingTransfer: string;
  21218. /** @hidden */
  21219. _injectAtEnd: string;
  21220. private _repeatableContentAnchorIndex;
  21221. /** @hidden */
  21222. _builtCompilationString: string;
  21223. /**
  21224. * Gets the emitted compilation strings
  21225. */
  21226. compilationString: string;
  21227. /**
  21228. * Finalize the compilation strings
  21229. * @param state defines the current compilation state
  21230. */
  21231. finalize(state: NodeMaterialBuildState): void;
  21232. /** @hidden */
  21233. get _repeatableContentAnchor(): string;
  21234. /** @hidden */
  21235. _getFreeVariableName(prefix: string): string;
  21236. /** @hidden */
  21237. _getFreeDefineName(prefix: string): string;
  21238. /** @hidden */
  21239. _excludeVariableName(name: string): void;
  21240. /** @hidden */
  21241. _emit2DSampler(name: string): void;
  21242. /** @hidden */
  21243. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21244. /** @hidden */
  21245. _emitExtension(name: string, extension: string, define?: string): void;
  21246. /** @hidden */
  21247. _emitFunction(name: string, code: string, comments: string): void;
  21248. /** @hidden */
  21249. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21250. replaceStrings?: {
  21251. search: RegExp;
  21252. replace: string;
  21253. }[];
  21254. repeatKey?: string;
  21255. }): string;
  21256. /** @hidden */
  21257. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21258. repeatKey?: string;
  21259. removeAttributes?: boolean;
  21260. removeUniforms?: boolean;
  21261. removeVaryings?: boolean;
  21262. removeIfDef?: boolean;
  21263. replaceStrings?: {
  21264. search: RegExp;
  21265. replace: string;
  21266. }[];
  21267. }, storeKey?: string): void;
  21268. /** @hidden */
  21269. _registerTempVariable(name: string): boolean;
  21270. /** @hidden */
  21271. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21272. /** @hidden */
  21273. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21274. /** @hidden */
  21275. _emitFloat(value: number): string;
  21276. }
  21277. }
  21278. declare module BABYLON {
  21279. /**
  21280. * Helper class used to generate session unique ID
  21281. */
  21282. export class UniqueIdGenerator {
  21283. private static _UniqueIdCounter;
  21284. /**
  21285. * Gets an unique (relatively to the current scene) Id
  21286. */
  21287. static get UniqueId(): number;
  21288. }
  21289. }
  21290. declare module BABYLON {
  21291. /**
  21292. * Defines a block that can be used inside a node based material
  21293. */
  21294. export class NodeMaterialBlock {
  21295. private _buildId;
  21296. private _buildTarget;
  21297. private _target;
  21298. private _isFinalMerger;
  21299. private _isInput;
  21300. protected _isUnique: boolean;
  21301. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21302. inputsAreExclusive: boolean;
  21303. /** @hidden */
  21304. _codeVariableName: string;
  21305. /** @hidden */
  21306. _inputs: NodeMaterialConnectionPoint[];
  21307. /** @hidden */
  21308. _outputs: NodeMaterialConnectionPoint[];
  21309. /** @hidden */
  21310. _preparationId: number;
  21311. /**
  21312. * Gets or sets the name of the block
  21313. */
  21314. name: string;
  21315. /**
  21316. * Gets or sets the unique id of the node
  21317. */
  21318. uniqueId: number;
  21319. /**
  21320. * Gets or sets the comments associated with this block
  21321. */
  21322. comments: string;
  21323. /**
  21324. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21325. */
  21326. get isUnique(): boolean;
  21327. /**
  21328. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21329. */
  21330. get isFinalMerger(): boolean;
  21331. /**
  21332. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21333. */
  21334. get isInput(): boolean;
  21335. /**
  21336. * Gets or sets the build Id
  21337. */
  21338. get buildId(): number;
  21339. set buildId(value: number);
  21340. /**
  21341. * Gets or sets the target of the block
  21342. */
  21343. get target(): NodeMaterialBlockTargets;
  21344. set target(value: NodeMaterialBlockTargets);
  21345. /**
  21346. * Gets the list of input points
  21347. */
  21348. get inputs(): NodeMaterialConnectionPoint[];
  21349. /** Gets the list of output points */
  21350. get outputs(): NodeMaterialConnectionPoint[];
  21351. /**
  21352. * Find an input by its name
  21353. * @param name defines the name of the input to look for
  21354. * @returns the input or null if not found
  21355. */
  21356. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21357. /**
  21358. * Find an output by its name
  21359. * @param name defines the name of the outputto look for
  21360. * @returns the output or null if not found
  21361. */
  21362. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21363. /**
  21364. * Creates a new NodeMaterialBlock
  21365. * @param name defines the block name
  21366. * @param target defines the target of that block (Vertex by default)
  21367. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21368. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21369. */
  21370. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21371. /**
  21372. * Initialize the block and prepare the context for build
  21373. * @param state defines the state that will be used for the build
  21374. */
  21375. initialize(state: NodeMaterialBuildState): void;
  21376. /**
  21377. * Bind data to effect. Will only be called for blocks with isBindable === true
  21378. * @param effect defines the effect to bind data to
  21379. * @param nodeMaterial defines the hosting NodeMaterial
  21380. * @param mesh defines the mesh that will be rendered
  21381. * @param subMesh defines the submesh that will be rendered
  21382. */
  21383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21384. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21385. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21386. protected _writeFloat(value: number): string;
  21387. /**
  21388. * Gets the current class name e.g. "NodeMaterialBlock"
  21389. * @returns the class name
  21390. */
  21391. getClassName(): string;
  21392. /**
  21393. * Register a new input. Must be called inside a block constructor
  21394. * @param name defines the connection point name
  21395. * @param type defines the connection point type
  21396. * @param isOptional defines a boolean indicating that this input can be omitted
  21397. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21398. * @param point an already created connection point. If not provided, create a new one
  21399. * @returns the current block
  21400. */
  21401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21402. /**
  21403. * Register a new output. Must be called inside a block constructor
  21404. * @param name defines the connection point name
  21405. * @param type defines the connection point type
  21406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21407. * @param point an already created connection point. If not provided, create a new one
  21408. * @returns the current block
  21409. */
  21410. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21411. /**
  21412. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21413. * @param forOutput defines an optional connection point to check compatibility with
  21414. * @returns the first available input or null
  21415. */
  21416. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21417. /**
  21418. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21419. * @param forBlock defines an optional block to check compatibility with
  21420. * @returns the first available input or null
  21421. */
  21422. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21423. /**
  21424. * Gets the sibling of the given output
  21425. * @param current defines the current output
  21426. * @returns the next output in the list or null
  21427. */
  21428. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21429. /**
  21430. * Connect current block with another block
  21431. * @param other defines the block to connect with
  21432. * @param options define the various options to help pick the right connections
  21433. * @returns the current block
  21434. */
  21435. connectTo(other: NodeMaterialBlock, options?: {
  21436. input?: string;
  21437. output?: string;
  21438. outputSwizzle?: string;
  21439. }): this | undefined;
  21440. protected _buildBlock(state: NodeMaterialBuildState): void;
  21441. /**
  21442. * Add uniforms, samplers and uniform buffers at compilation time
  21443. * @param state defines the state to update
  21444. * @param nodeMaterial defines the node material requesting the update
  21445. * @param defines defines the material defines to update
  21446. * @param uniformBuffers defines the list of uniform buffer names
  21447. */
  21448. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21449. /**
  21450. * Add potential fallbacks if shader compilation fails
  21451. * @param mesh defines the mesh to be rendered
  21452. * @param fallbacks defines the current prioritized list of fallbacks
  21453. */
  21454. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21455. /**
  21456. * Initialize defines for shader compilation
  21457. * @param mesh defines the mesh to be rendered
  21458. * @param nodeMaterial defines the node material requesting the update
  21459. * @param defines defines the material defines to update
  21460. * @param useInstances specifies that instances should be used
  21461. */
  21462. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21463. /**
  21464. * Update defines for shader compilation
  21465. * @param mesh defines the mesh to be rendered
  21466. * @param nodeMaterial defines the node material requesting the update
  21467. * @param defines defines the material defines to update
  21468. * @param useInstances specifies that instances should be used
  21469. * @param subMesh defines which submesh to render
  21470. */
  21471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21472. /**
  21473. * Lets the block try to connect some inputs automatically
  21474. * @param material defines the hosting NodeMaterial
  21475. */
  21476. autoConfigure(material: NodeMaterial): void;
  21477. /**
  21478. * Function called when a block is declared as repeatable content generator
  21479. * @param vertexShaderState defines the current compilation state for the vertex shader
  21480. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21481. * @param mesh defines the mesh to be rendered
  21482. * @param defines defines the material defines to update
  21483. */
  21484. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21485. /**
  21486. * Checks if the block is ready
  21487. * @param mesh defines the mesh to be rendered
  21488. * @param nodeMaterial defines the node material requesting the update
  21489. * @param defines defines the material defines to update
  21490. * @param useInstances specifies that instances should be used
  21491. * @returns true if the block is ready
  21492. */
  21493. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21494. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21495. private _processBuild;
  21496. /**
  21497. * Compile the current node and generate the shader code
  21498. * @param state defines the current compilation state (uniforms, samplers, current string)
  21499. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21500. * @returns true if already built
  21501. */
  21502. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21503. protected _inputRename(name: string): string;
  21504. protected _outputRename(name: string): string;
  21505. protected _dumpPropertiesCode(): string;
  21506. /** @hidden */
  21507. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21508. /** @hidden */
  21509. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21510. /**
  21511. * Clone the current block to a new identical block
  21512. * @param scene defines the hosting scene
  21513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21514. * @returns a copy of the current block
  21515. */
  21516. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21517. /**
  21518. * Serializes this block in a JSON representation
  21519. * @returns the serialized block object
  21520. */
  21521. serialize(): any;
  21522. /** @hidden */
  21523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21524. private _deserializePortDisplayNames;
  21525. /**
  21526. * Release resources
  21527. */
  21528. dispose(): void;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * Base class of materials working in push mode in babylon JS
  21534. * @hidden
  21535. */
  21536. export class PushMaterial extends Material {
  21537. protected _activeEffect: Effect;
  21538. protected _normalMatrix: Matrix;
  21539. /**
  21540. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21541. * This means that the material can keep using a previous shader while a new one is being compiled.
  21542. * This is mostly used when shader parallel compilation is supported (true by default)
  21543. */
  21544. allowShaderHotSwapping: boolean;
  21545. constructor(name: string, scene: Scene);
  21546. getEffect(): Effect;
  21547. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21548. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21549. /**
  21550. * Binds the given world matrix to the active effect
  21551. *
  21552. * @param world the matrix to bind
  21553. */
  21554. bindOnlyWorldMatrix(world: Matrix): void;
  21555. /**
  21556. * Binds the given normal matrix to the active effect
  21557. *
  21558. * @param normalMatrix the matrix to bind
  21559. */
  21560. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21561. bind(world: Matrix, mesh?: Mesh): void;
  21562. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21563. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21564. }
  21565. }
  21566. declare module BABYLON {
  21567. /**
  21568. * Root class for all node material optimizers
  21569. */
  21570. export class NodeMaterialOptimizer {
  21571. /**
  21572. * Function used to optimize a NodeMaterial graph
  21573. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21574. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21575. */
  21576. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21577. }
  21578. }
  21579. declare module BABYLON {
  21580. /**
  21581. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21582. */
  21583. export class TransformBlock extends NodeMaterialBlock {
  21584. /**
  21585. * Defines the value to use to complement W value to transform it to a Vector4
  21586. */
  21587. complementW: number;
  21588. /**
  21589. * Defines the value to use to complement z value to transform it to a Vector4
  21590. */
  21591. complementZ: number;
  21592. /**
  21593. * Creates a new TransformBlock
  21594. * @param name defines the block name
  21595. */
  21596. constructor(name: string);
  21597. /**
  21598. * Gets the current class name
  21599. * @returns the class name
  21600. */
  21601. getClassName(): string;
  21602. /**
  21603. * Gets the vector input
  21604. */
  21605. get vector(): NodeMaterialConnectionPoint;
  21606. /**
  21607. * Gets the output component
  21608. */
  21609. get output(): NodeMaterialConnectionPoint;
  21610. /**
  21611. * Gets the xyz output component
  21612. */
  21613. get xyz(): NodeMaterialConnectionPoint;
  21614. /**
  21615. * Gets the matrix transform input
  21616. */
  21617. get transform(): NodeMaterialConnectionPoint;
  21618. protected _buildBlock(state: NodeMaterialBuildState): this;
  21619. /**
  21620. * Update defines for shader compilation
  21621. * @param mesh defines the mesh to be rendered
  21622. * @param nodeMaterial defines the node material requesting the update
  21623. * @param defines defines the material defines to update
  21624. * @param useInstances specifies that instances should be used
  21625. * @param subMesh defines which submesh to render
  21626. */
  21627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21628. serialize(): any;
  21629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21630. protected _dumpPropertiesCode(): string;
  21631. }
  21632. }
  21633. declare module BABYLON {
  21634. /**
  21635. * Block used to output the vertex position
  21636. */
  21637. export class VertexOutputBlock extends NodeMaterialBlock {
  21638. /**
  21639. * Creates a new VertexOutputBlock
  21640. * @param name defines the block name
  21641. */
  21642. constructor(name: string);
  21643. /**
  21644. * Gets the current class name
  21645. * @returns the class name
  21646. */
  21647. getClassName(): string;
  21648. /**
  21649. * Gets the vector input component
  21650. */
  21651. get vector(): NodeMaterialConnectionPoint;
  21652. protected _buildBlock(state: NodeMaterialBuildState): this;
  21653. }
  21654. }
  21655. declare module BABYLON {
  21656. /**
  21657. * Block used to output the final color
  21658. */
  21659. export class FragmentOutputBlock extends NodeMaterialBlock {
  21660. /**
  21661. * Create a new FragmentOutputBlock
  21662. * @param name defines the block name
  21663. */
  21664. constructor(name: string);
  21665. /**
  21666. * Gets the current class name
  21667. * @returns the class name
  21668. */
  21669. getClassName(): string;
  21670. /**
  21671. * Gets the rgba input component
  21672. */
  21673. get rgba(): NodeMaterialConnectionPoint;
  21674. /**
  21675. * Gets the rgb input component
  21676. */
  21677. get rgb(): NodeMaterialConnectionPoint;
  21678. /**
  21679. * Gets the a input component
  21680. */
  21681. get a(): NodeMaterialConnectionPoint;
  21682. protected _buildBlock(state: NodeMaterialBuildState): this;
  21683. }
  21684. }
  21685. declare module BABYLON {
  21686. /**
  21687. * Block used for the particle ramp gradient section
  21688. */
  21689. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21690. /**
  21691. * Create a new ParticleRampGradientBlock
  21692. * @param name defines the block name
  21693. */
  21694. constructor(name: string);
  21695. /**
  21696. * Gets the current class name
  21697. * @returns the class name
  21698. */
  21699. getClassName(): string;
  21700. /**
  21701. * Gets the color input component
  21702. */
  21703. get color(): NodeMaterialConnectionPoint;
  21704. /**
  21705. * Gets the rampColor output component
  21706. */
  21707. get rampColor(): NodeMaterialConnectionPoint;
  21708. /**
  21709. * Initialize the block and prepare the context for build
  21710. * @param state defines the state that will be used for the build
  21711. */
  21712. initialize(state: NodeMaterialBuildState): void;
  21713. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21714. }
  21715. }
  21716. declare module BABYLON {
  21717. /**
  21718. * Block used for the particle blend multiply section
  21719. */
  21720. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21721. /**
  21722. * Create a new ParticleBlendMultiplyBlock
  21723. * @param name defines the block name
  21724. */
  21725. constructor(name: string);
  21726. /**
  21727. * Gets the current class name
  21728. * @returns the class name
  21729. */
  21730. getClassName(): string;
  21731. /**
  21732. * Gets the color input component
  21733. */
  21734. get color(): NodeMaterialConnectionPoint;
  21735. /**
  21736. * Gets the alphaTexture input component
  21737. */
  21738. get alphaTexture(): NodeMaterialConnectionPoint;
  21739. /**
  21740. * Gets the alphaColor input component
  21741. */
  21742. get alphaColor(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the blendColor output component
  21745. */
  21746. get blendColor(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Initialize the block and prepare the context for build
  21749. * @param state defines the state that will be used for the build
  21750. */
  21751. initialize(state: NodeMaterialBuildState): void;
  21752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21753. }
  21754. }
  21755. declare module BABYLON {
  21756. /**
  21757. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21758. */
  21759. export class VectorMergerBlock extends NodeMaterialBlock {
  21760. /**
  21761. * Create a new VectorMergerBlock
  21762. * @param name defines the block name
  21763. */
  21764. constructor(name: string);
  21765. /**
  21766. * Gets the current class name
  21767. * @returns the class name
  21768. */
  21769. getClassName(): string;
  21770. /**
  21771. * Gets the xyz component (input)
  21772. */
  21773. get xyzIn(): NodeMaterialConnectionPoint;
  21774. /**
  21775. * Gets the xy component (input)
  21776. */
  21777. get xyIn(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the x component (input)
  21780. */
  21781. get x(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the y component (input)
  21784. */
  21785. get y(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Gets the z component (input)
  21788. */
  21789. get z(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the w component (input)
  21792. */
  21793. get w(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Gets the xyzw component (output)
  21796. */
  21797. get xyzw(): NodeMaterialConnectionPoint;
  21798. /**
  21799. * Gets the xyz component (output)
  21800. */
  21801. get xyzOut(): NodeMaterialConnectionPoint;
  21802. /**
  21803. * Gets the xy component (output)
  21804. */
  21805. get xyOut(): NodeMaterialConnectionPoint;
  21806. /**
  21807. * Gets the xy component (output)
  21808. * @deprecated Please use xyOut instead.
  21809. */
  21810. get xy(): NodeMaterialConnectionPoint;
  21811. /**
  21812. * Gets the xyz component (output)
  21813. * @deprecated Please use xyzOut instead.
  21814. */
  21815. get xyz(): NodeMaterialConnectionPoint;
  21816. protected _buildBlock(state: NodeMaterialBuildState): this;
  21817. }
  21818. }
  21819. declare module BABYLON {
  21820. /**
  21821. * Block used to remap a float from a range to a new one
  21822. */
  21823. export class RemapBlock extends NodeMaterialBlock {
  21824. /**
  21825. * Gets or sets the source range
  21826. */
  21827. sourceRange: Vector2;
  21828. /**
  21829. * Gets or sets the target range
  21830. */
  21831. targetRange: Vector2;
  21832. /**
  21833. * Creates a new RemapBlock
  21834. * @param name defines the block name
  21835. */
  21836. constructor(name: string);
  21837. /**
  21838. * Gets the current class name
  21839. * @returns the class name
  21840. */
  21841. getClassName(): string;
  21842. /**
  21843. * Gets the input component
  21844. */
  21845. get input(): NodeMaterialConnectionPoint;
  21846. /**
  21847. * Gets the source min input component
  21848. */
  21849. get sourceMin(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the source max input component
  21852. */
  21853. get sourceMax(): NodeMaterialConnectionPoint;
  21854. /**
  21855. * Gets the target min input component
  21856. */
  21857. get targetMin(): NodeMaterialConnectionPoint;
  21858. /**
  21859. * Gets the target max input component
  21860. */
  21861. get targetMax(): NodeMaterialConnectionPoint;
  21862. /**
  21863. * Gets the output component
  21864. */
  21865. get output(): NodeMaterialConnectionPoint;
  21866. protected _buildBlock(state: NodeMaterialBuildState): this;
  21867. protected _dumpPropertiesCode(): string;
  21868. serialize(): any;
  21869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21870. }
  21871. }
  21872. declare module BABYLON {
  21873. /**
  21874. * Block used to multiply 2 values
  21875. */
  21876. export class MultiplyBlock extends NodeMaterialBlock {
  21877. /**
  21878. * Creates a new MultiplyBlock
  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 left operand input component
  21889. */
  21890. get left(): NodeMaterialConnectionPoint;
  21891. /**
  21892. * Gets the right operand input component
  21893. */
  21894. get right(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the output component
  21897. */
  21898. get output(): NodeMaterialConnectionPoint;
  21899. protected _buildBlock(state: NodeMaterialBuildState): this;
  21900. }
  21901. }
  21902. declare module BABYLON {
  21903. /**
  21904. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21905. */
  21906. export class ColorSplitterBlock extends NodeMaterialBlock {
  21907. /**
  21908. * Create a new ColorSplitterBlock
  21909. * @param name defines the block name
  21910. */
  21911. constructor(name: string);
  21912. /**
  21913. * Gets the current class name
  21914. * @returns the class name
  21915. */
  21916. getClassName(): string;
  21917. /**
  21918. * Gets the rgba component (input)
  21919. */
  21920. get rgba(): NodeMaterialConnectionPoint;
  21921. /**
  21922. * Gets the rgb component (input)
  21923. */
  21924. get rgbIn(): NodeMaterialConnectionPoint;
  21925. /**
  21926. * Gets the rgb component (output)
  21927. */
  21928. get rgbOut(): NodeMaterialConnectionPoint;
  21929. /**
  21930. * Gets the r component (output)
  21931. */
  21932. get r(): NodeMaterialConnectionPoint;
  21933. /**
  21934. * Gets the g component (output)
  21935. */
  21936. get g(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the b component (output)
  21939. */
  21940. get b(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the a component (output)
  21943. */
  21944. get a(): NodeMaterialConnectionPoint;
  21945. protected _inputRename(name: string): string;
  21946. protected _outputRename(name: string): string;
  21947. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21948. }
  21949. }
  21950. declare module BABYLON {
  21951. /**
  21952. * Interface used to configure the node material editor
  21953. */
  21954. export interface INodeMaterialEditorOptions {
  21955. /** Define the URl to load node editor script */
  21956. editorURL?: string;
  21957. }
  21958. /** @hidden */
  21959. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21960. NORMAL: boolean;
  21961. TANGENT: boolean;
  21962. UV1: boolean;
  21963. /** BONES */
  21964. NUM_BONE_INFLUENCERS: number;
  21965. BonesPerMesh: number;
  21966. BONETEXTURE: boolean;
  21967. /** MORPH TARGETS */
  21968. MORPHTARGETS: boolean;
  21969. MORPHTARGETS_NORMAL: boolean;
  21970. MORPHTARGETS_TANGENT: boolean;
  21971. MORPHTARGETS_UV: boolean;
  21972. NUM_MORPH_INFLUENCERS: number;
  21973. /** IMAGE PROCESSING */
  21974. IMAGEPROCESSING: boolean;
  21975. VIGNETTE: boolean;
  21976. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21977. VIGNETTEBLENDMODEOPAQUE: boolean;
  21978. TONEMAPPING: boolean;
  21979. TONEMAPPING_ACES: boolean;
  21980. CONTRAST: boolean;
  21981. EXPOSURE: boolean;
  21982. COLORCURVES: boolean;
  21983. COLORGRADING: boolean;
  21984. COLORGRADING3D: boolean;
  21985. SAMPLER3DGREENDEPTH: boolean;
  21986. SAMPLER3DBGRMAP: boolean;
  21987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21988. /** MISC. */
  21989. BUMPDIRECTUV: number;
  21990. constructor();
  21991. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21992. }
  21993. /**
  21994. * Class used to configure NodeMaterial
  21995. */
  21996. export interface INodeMaterialOptions {
  21997. /**
  21998. * Defines if blocks should emit comments
  21999. */
  22000. emitComments: boolean;
  22001. }
  22002. /**
  22003. * Class used to create a node based material built by assembling shader blocks
  22004. */
  22005. export class NodeMaterial extends PushMaterial {
  22006. private static _BuildIdGenerator;
  22007. private _options;
  22008. private _vertexCompilationState;
  22009. private _fragmentCompilationState;
  22010. private _sharedData;
  22011. private _buildId;
  22012. private _buildWasSuccessful;
  22013. private _cachedWorldViewMatrix;
  22014. private _cachedWorldViewProjectionMatrix;
  22015. private _optimizers;
  22016. private _animationFrame;
  22017. /** Define the Url to load node editor script */
  22018. static EditorURL: string;
  22019. /** Define the Url to load snippets */
  22020. static SnippetUrl: string;
  22021. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22022. static IgnoreTexturesAtLoadTime: boolean;
  22023. private BJSNODEMATERIALEDITOR;
  22024. /** Get the inspector from bundle or global */
  22025. private _getGlobalNodeMaterialEditor;
  22026. /**
  22027. * Snippet ID if the material was created from the snippet server
  22028. */
  22029. snippetId: string;
  22030. /**
  22031. * Gets or sets data used by visual editor
  22032. * @see https://nme.babylonjs.com
  22033. */
  22034. editorData: any;
  22035. /**
  22036. * 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)
  22037. */
  22038. ignoreAlpha: boolean;
  22039. /**
  22040. * Defines the maximum number of lights that can be used in the material
  22041. */
  22042. maxSimultaneousLights: number;
  22043. /**
  22044. * Observable raised when the material is built
  22045. */
  22046. onBuildObservable: Observable<NodeMaterial>;
  22047. /**
  22048. * Gets or sets the root nodes of the material vertex shader
  22049. */
  22050. _vertexOutputNodes: NodeMaterialBlock[];
  22051. /**
  22052. * Gets or sets the root nodes of the material fragment (pixel) shader
  22053. */
  22054. _fragmentOutputNodes: NodeMaterialBlock[];
  22055. /** Gets or sets options to control the node material overall behavior */
  22056. get options(): INodeMaterialOptions;
  22057. set options(options: INodeMaterialOptions);
  22058. /**
  22059. * Default configuration related to image processing available in the standard Material.
  22060. */
  22061. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22062. /**
  22063. * Gets the image processing configuration used either in this material.
  22064. */
  22065. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22066. /**
  22067. * Sets the Default image processing configuration used either in the this material.
  22068. *
  22069. * If sets to null, the scene one is in use.
  22070. */
  22071. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22072. /**
  22073. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22074. */
  22075. attachedBlocks: NodeMaterialBlock[];
  22076. /**
  22077. * Specifies the mode of the node material
  22078. * @hidden
  22079. */
  22080. _mode: NodeMaterialModes;
  22081. /**
  22082. * Gets the mode property
  22083. */
  22084. get mode(): NodeMaterialModes;
  22085. /**
  22086. * Create a new node based material
  22087. * @param name defines the material name
  22088. * @param scene defines the hosting scene
  22089. * @param options defines creation option
  22090. */
  22091. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22092. /**
  22093. * Gets the current class name of the material e.g. "NodeMaterial"
  22094. * @returns the class name
  22095. */
  22096. getClassName(): string;
  22097. /**
  22098. * Keep track of the image processing observer to allow dispose and replace.
  22099. */
  22100. private _imageProcessingObserver;
  22101. /**
  22102. * Attaches a new image processing configuration to the Standard Material.
  22103. * @param configuration
  22104. */
  22105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22106. /**
  22107. * Get a block by its name
  22108. * @param name defines the name of the block to retrieve
  22109. * @returns the required block or null if not found
  22110. */
  22111. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22112. /**
  22113. * Get a block by its name
  22114. * @param predicate defines the predicate used to find the good candidate
  22115. * @returns the required block or null if not found
  22116. */
  22117. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22118. /**
  22119. * Get an input block by its name
  22120. * @param predicate defines the predicate used to find the good candidate
  22121. * @returns the required input block or null if not found
  22122. */
  22123. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22124. /**
  22125. * Gets the list of input blocks attached to this material
  22126. * @returns an array of InputBlocks
  22127. */
  22128. getInputBlocks(): InputBlock[];
  22129. /**
  22130. * Adds a new optimizer to the list of optimizers
  22131. * @param optimizer defines the optimizers to add
  22132. * @returns the current material
  22133. */
  22134. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22135. /**
  22136. * Remove an optimizer from the list of optimizers
  22137. * @param optimizer defines the optimizers to remove
  22138. * @returns the current material
  22139. */
  22140. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22141. /**
  22142. * Add a new block to the list of output nodes
  22143. * @param node defines the node to add
  22144. * @returns the current material
  22145. */
  22146. addOutputNode(node: NodeMaterialBlock): this;
  22147. /**
  22148. * Remove a block from the list of root nodes
  22149. * @param node defines the node to remove
  22150. * @returns the current material
  22151. */
  22152. removeOutputNode(node: NodeMaterialBlock): this;
  22153. private _addVertexOutputNode;
  22154. private _removeVertexOutputNode;
  22155. private _addFragmentOutputNode;
  22156. private _removeFragmentOutputNode;
  22157. /**
  22158. * Specifies if the material will require alpha blending
  22159. * @returns a boolean specifying if alpha blending is needed
  22160. */
  22161. needAlphaBlending(): boolean;
  22162. /**
  22163. * Specifies if this material should be rendered in alpha test mode
  22164. * @returns a boolean specifying if an alpha test is needed.
  22165. */
  22166. needAlphaTesting(): boolean;
  22167. private _initializeBlock;
  22168. private _resetDualBlocks;
  22169. /**
  22170. * Remove a block from the current node material
  22171. * @param block defines the block to remove
  22172. */
  22173. removeBlock(block: NodeMaterialBlock): void;
  22174. /**
  22175. * Build the material and generates the inner effect
  22176. * @param verbose defines if the build should log activity
  22177. */
  22178. build(verbose?: boolean): void;
  22179. /**
  22180. * Runs an otpimization phase to try to improve the shader code
  22181. */
  22182. optimize(): void;
  22183. private _prepareDefinesForAttributes;
  22184. /**
  22185. * Create a post process from the material
  22186. * @param camera The camera to apply the render pass to.
  22187. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22189. * @param engine The engine which the post process will be applied. (default: current engine)
  22190. * @param reusable If the post process can be reused on the same frame. (default: false)
  22191. * @param textureType Type of textures used when performing the post process. (default: 0)
  22192. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22193. * @returns the post process created
  22194. */
  22195. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22196. /**
  22197. * Create the post process effect from the material
  22198. * @param postProcess The post process to create the effect for
  22199. */
  22200. createEffectForPostProcess(postProcess: PostProcess): void;
  22201. private _createEffectOrPostProcess;
  22202. private _createEffectForParticles;
  22203. /**
  22204. * Create the effect to be used as the custom effect for a particle system
  22205. * @param particleSystem Particle system to create the effect for
  22206. * @param onCompiled defines a function to call when the effect creation is successful
  22207. * @param onError defines a function to call when the effect creation has failed
  22208. */
  22209. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22210. private _processDefines;
  22211. /**
  22212. * Get if the submesh is ready to be used and all its information available.
  22213. * Child classes can use it to update shaders
  22214. * @param mesh defines the mesh to check
  22215. * @param subMesh defines which submesh to check
  22216. * @param useInstances specifies that instances should be used
  22217. * @returns a boolean indicating that the submesh is ready or not
  22218. */
  22219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22220. /**
  22221. * Get a string representing the shaders built by the current node graph
  22222. */
  22223. get compiledShaders(): string;
  22224. /**
  22225. * Binds the world matrix to the material
  22226. * @param world defines the world transformation matrix
  22227. */
  22228. bindOnlyWorldMatrix(world: Matrix): void;
  22229. /**
  22230. * Binds the submesh to this material by preparing the effect and shader to draw
  22231. * @param world defines the world transformation matrix
  22232. * @param mesh defines the mesh containing the submesh
  22233. * @param subMesh defines the submesh to bind the material to
  22234. */
  22235. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22236. /**
  22237. * Gets the active textures from the material
  22238. * @returns an array of textures
  22239. */
  22240. getActiveTextures(): BaseTexture[];
  22241. /**
  22242. * Gets the list of texture blocks
  22243. * @returns an array of texture blocks
  22244. */
  22245. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22246. /**
  22247. * Specifies if the material uses a texture
  22248. * @param texture defines the texture to check against the material
  22249. * @returns a boolean specifying if the material uses the texture
  22250. */
  22251. hasTexture(texture: BaseTexture): boolean;
  22252. /**
  22253. * Disposes the material
  22254. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22255. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22256. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22257. */
  22258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22259. /** Creates the node editor window. */
  22260. private _createNodeEditor;
  22261. /**
  22262. * Launch the node material editor
  22263. * @param config Define the configuration of the editor
  22264. * @return a promise fulfilled when the node editor is visible
  22265. */
  22266. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22267. /**
  22268. * Clear the current material
  22269. */
  22270. clear(): void;
  22271. /**
  22272. * Clear the current material and set it to a default state
  22273. */
  22274. setToDefault(): void;
  22275. /**
  22276. * Clear the current material and set it to a default state for post process
  22277. */
  22278. setToDefaultPostProcess(): void;
  22279. /**
  22280. * Clear the current material and set it to a default state for particle
  22281. */
  22282. setToDefaultParticle(): void;
  22283. /**
  22284. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22285. * @param url defines the url to load from
  22286. * @returns a promise that will fullfil when the material is fully loaded
  22287. */
  22288. loadAsync(url: string): Promise<void>;
  22289. private _gatherBlocks;
  22290. /**
  22291. * Generate a string containing the code declaration required to create an equivalent of this material
  22292. * @returns a string
  22293. */
  22294. generateCode(): string;
  22295. /**
  22296. * Serializes this material in a JSON representation
  22297. * @returns the serialized material object
  22298. */
  22299. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22300. private _restoreConnections;
  22301. /**
  22302. * Clear the current graph and load a new one from a serialization object
  22303. * @param source defines the JSON representation of the material
  22304. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22305. */
  22306. loadFromSerialization(source: any, rootUrl?: string): void;
  22307. /**
  22308. * Makes a duplicate of the current material.
  22309. * @param name - name to use for the new material.
  22310. */
  22311. clone(name: string): NodeMaterial;
  22312. /**
  22313. * Creates a node material from parsed material data
  22314. * @param source defines the JSON representation of the material
  22315. * @param scene defines the hosting scene
  22316. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22317. * @returns a new node material
  22318. */
  22319. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22320. /**
  22321. * Creates a node material from a snippet saved in a remote file
  22322. * @param name defines the name of the material to create
  22323. * @param url defines the url to load from
  22324. * @param scene defines the hosting scene
  22325. * @returns a promise that will resolve to the new node material
  22326. */
  22327. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22328. /**
  22329. * Creates a node material from a snippet saved by the node material editor
  22330. * @param snippetId defines the snippet to load
  22331. * @param scene defines the hosting scene
  22332. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22333. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22334. * @returns a promise that will resolve to the new node material
  22335. */
  22336. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22337. /**
  22338. * Creates a new node material set to default basic configuration
  22339. * @param name defines the name of the material
  22340. * @param scene defines the hosting scene
  22341. * @returns a new NodeMaterial
  22342. */
  22343. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Size options for a post process
  22349. */
  22350. export type PostProcessOptions = {
  22351. width: number;
  22352. height: number;
  22353. };
  22354. /**
  22355. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22356. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22357. */
  22358. export class PostProcess {
  22359. /** Name of the PostProcess. */
  22360. name: string;
  22361. /**
  22362. * Gets or sets the unique id of the post process
  22363. */
  22364. uniqueId: number;
  22365. /**
  22366. * Width of the texture to apply the post process on
  22367. */
  22368. width: number;
  22369. /**
  22370. * Height of the texture to apply the post process on
  22371. */
  22372. height: number;
  22373. /**
  22374. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22375. */
  22376. nodeMaterialSource: Nullable<NodeMaterial>;
  22377. /**
  22378. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22379. * @hidden
  22380. */
  22381. _outputTexture: Nullable<InternalTexture>;
  22382. /**
  22383. * Sampling mode used by the shader
  22384. * See https://doc.babylonjs.com/classes/3.1/texture
  22385. */
  22386. renderTargetSamplingMode: number;
  22387. /**
  22388. * Clear color to use when screen clearing
  22389. */
  22390. clearColor: Color4;
  22391. /**
  22392. * If the buffer needs to be cleared before applying the post process. (default: true)
  22393. * Should be set to false if shader will overwrite all previous pixels.
  22394. */
  22395. autoClear: boolean;
  22396. /**
  22397. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22398. */
  22399. alphaMode: number;
  22400. /**
  22401. * Sets the setAlphaBlendConstants of the babylon engine
  22402. */
  22403. alphaConstants: Color4;
  22404. /**
  22405. * Animations to be used for the post processing
  22406. */
  22407. animations: Animation[];
  22408. /**
  22409. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22410. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22411. */
  22412. enablePixelPerfectMode: boolean;
  22413. /**
  22414. * Force the postprocess to be applied without taking in account viewport
  22415. */
  22416. forceFullscreenViewport: boolean;
  22417. /**
  22418. * List of inspectable custom properties (used by the Inspector)
  22419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22420. */
  22421. inspectableCustomProperties: IInspectable[];
  22422. /**
  22423. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22424. *
  22425. * | Value | Type | Description |
  22426. * | ----- | ----------------------------------- | ----------- |
  22427. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22428. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22429. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22430. *
  22431. */
  22432. scaleMode: number;
  22433. /**
  22434. * Force textures to be a power of two (default: false)
  22435. */
  22436. alwaysForcePOT: boolean;
  22437. private _samples;
  22438. /**
  22439. * Number of sample textures (default: 1)
  22440. */
  22441. get samples(): number;
  22442. set samples(n: number);
  22443. /**
  22444. * Modify the scale of the post process to be the same as the viewport (default: false)
  22445. */
  22446. adaptScaleToCurrentViewport: boolean;
  22447. private _camera;
  22448. private _scene;
  22449. private _engine;
  22450. private _options;
  22451. private _reusable;
  22452. private _textureType;
  22453. private _textureFormat;
  22454. /**
  22455. * Smart array of input and output textures for the post process.
  22456. * @hidden
  22457. */
  22458. _textures: SmartArray<InternalTexture>;
  22459. /**
  22460. * The index in _textures that corresponds to the output texture.
  22461. * @hidden
  22462. */
  22463. _currentRenderTextureInd: number;
  22464. private _effect;
  22465. private _samplers;
  22466. private _fragmentUrl;
  22467. private _vertexUrl;
  22468. private _parameters;
  22469. private _scaleRatio;
  22470. protected _indexParameters: any;
  22471. private _shareOutputWithPostProcess;
  22472. private _texelSize;
  22473. private _forcedOutputTexture;
  22474. /**
  22475. * Returns the fragment url or shader name used in the post process.
  22476. * @returns the fragment url or name in the shader store.
  22477. */
  22478. getEffectName(): string;
  22479. /**
  22480. * An event triggered when the postprocess is activated.
  22481. */
  22482. onActivateObservable: Observable<Camera>;
  22483. private _onActivateObserver;
  22484. /**
  22485. * A function that is added to the onActivateObservable
  22486. */
  22487. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22488. /**
  22489. * An event triggered when the postprocess changes its size.
  22490. */
  22491. onSizeChangedObservable: Observable<PostProcess>;
  22492. private _onSizeChangedObserver;
  22493. /**
  22494. * A function that is added to the onSizeChangedObservable
  22495. */
  22496. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22497. /**
  22498. * An event triggered when the postprocess applies its effect.
  22499. */
  22500. onApplyObservable: Observable<Effect>;
  22501. private _onApplyObserver;
  22502. /**
  22503. * A function that is added to the onApplyObservable
  22504. */
  22505. set onApply(callback: (effect: Effect) => void);
  22506. /**
  22507. * An event triggered before rendering the postprocess
  22508. */
  22509. onBeforeRenderObservable: Observable<Effect>;
  22510. private _onBeforeRenderObserver;
  22511. /**
  22512. * A function that is added to the onBeforeRenderObservable
  22513. */
  22514. set onBeforeRender(callback: (effect: Effect) => void);
  22515. /**
  22516. * An event triggered after rendering the postprocess
  22517. */
  22518. onAfterRenderObservable: Observable<Effect>;
  22519. private _onAfterRenderObserver;
  22520. /**
  22521. * A function that is added to the onAfterRenderObservable
  22522. */
  22523. set onAfterRender(callback: (efect: Effect) => void);
  22524. /**
  22525. * 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
  22526. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22527. */
  22528. get inputTexture(): InternalTexture;
  22529. set inputTexture(value: InternalTexture);
  22530. /**
  22531. * Gets the camera which post process is applied to.
  22532. * @returns The camera the post process is applied to.
  22533. */
  22534. getCamera(): Camera;
  22535. /**
  22536. * Gets the texel size of the postprocess.
  22537. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22538. */
  22539. get texelSize(): Vector2;
  22540. /**
  22541. * Creates a new instance PostProcess
  22542. * @param name The name of the PostProcess.
  22543. * @param fragmentUrl The url of the fragment shader to be used.
  22544. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22545. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22546. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22547. * @param camera The camera to apply the render pass to.
  22548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22549. * @param engine The engine which the post process will be applied. (default: current engine)
  22550. * @param reusable If the post process can be reused on the same frame. (default: false)
  22551. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22552. * @param textureType Type of textures used when performing the post process. (default: 0)
  22553. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22554. * @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
  22555. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22556. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22557. */
  22558. constructor(
  22559. /** Name of the PostProcess. */
  22560. 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);
  22561. /**
  22562. * Gets a string idenfifying the name of the class
  22563. * @returns "PostProcess" string
  22564. */
  22565. getClassName(): string;
  22566. /**
  22567. * Gets the engine which this post process belongs to.
  22568. * @returns The engine the post process was enabled with.
  22569. */
  22570. getEngine(): Engine;
  22571. /**
  22572. * The effect that is created when initializing the post process.
  22573. * @returns The created effect corresponding the the postprocess.
  22574. */
  22575. getEffect(): Effect;
  22576. /**
  22577. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22578. * @param postProcess The post process to share the output with.
  22579. * @returns This post process.
  22580. */
  22581. shareOutputWith(postProcess: PostProcess): PostProcess;
  22582. /**
  22583. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22584. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22585. */
  22586. useOwnOutput(): void;
  22587. /**
  22588. * Updates the effect with the current post process compile time values and recompiles the shader.
  22589. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22590. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22591. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22592. * @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
  22593. * @param onCompiled Called when the shader has been compiled.
  22594. * @param onError Called if there is an error when compiling a shader.
  22595. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22596. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22597. */
  22598. 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;
  22599. /**
  22600. * The post process is reusable if it can be used multiple times within one frame.
  22601. * @returns If the post process is reusable
  22602. */
  22603. isReusable(): boolean;
  22604. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22605. markTextureDirty(): void;
  22606. /**
  22607. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22608. * 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.
  22609. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22610. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22611. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22612. * @returns The target texture that was bound to be written to.
  22613. */
  22614. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22615. /**
  22616. * If the post process is supported.
  22617. */
  22618. get isSupported(): boolean;
  22619. /**
  22620. * The aspect ratio of the output texture.
  22621. */
  22622. get aspectRatio(): number;
  22623. /**
  22624. * Get a value indicating if the post-process is ready to be used
  22625. * @returns true if the post-process is ready (shader is compiled)
  22626. */
  22627. isReady(): boolean;
  22628. /**
  22629. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22630. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22631. */
  22632. apply(): Nullable<Effect>;
  22633. private _disposeTextures;
  22634. /**
  22635. * Disposes the post process.
  22636. * @param camera The camera to dispose the post process on.
  22637. */
  22638. dispose(camera?: Camera): void;
  22639. }
  22640. }
  22641. declare module BABYLON {
  22642. /** @hidden */
  22643. export var kernelBlurVaryingDeclaration: {
  22644. name: string;
  22645. shader: string;
  22646. };
  22647. }
  22648. declare module BABYLON {
  22649. /** @hidden */
  22650. export var kernelBlurFragment: {
  22651. name: string;
  22652. shader: string;
  22653. };
  22654. }
  22655. declare module BABYLON {
  22656. /** @hidden */
  22657. export var kernelBlurFragment2: {
  22658. name: string;
  22659. shader: string;
  22660. };
  22661. }
  22662. declare module BABYLON {
  22663. /** @hidden */
  22664. export var kernelBlurPixelShader: {
  22665. name: string;
  22666. shader: string;
  22667. };
  22668. }
  22669. declare module BABYLON {
  22670. /** @hidden */
  22671. export var kernelBlurVertex: {
  22672. name: string;
  22673. shader: string;
  22674. };
  22675. }
  22676. declare module BABYLON {
  22677. /** @hidden */
  22678. export var kernelBlurVertexShader: {
  22679. name: string;
  22680. shader: string;
  22681. };
  22682. }
  22683. declare module BABYLON {
  22684. /**
  22685. * The Blur Post Process which blurs an image based on a kernel and direction.
  22686. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22687. */
  22688. export class BlurPostProcess extends PostProcess {
  22689. /** The direction in which to blur the image. */
  22690. direction: Vector2;
  22691. private blockCompilation;
  22692. protected _kernel: number;
  22693. protected _idealKernel: number;
  22694. protected _packedFloat: boolean;
  22695. private _staticDefines;
  22696. /**
  22697. * Sets the length in pixels of the blur sample region
  22698. */
  22699. set kernel(v: number);
  22700. /**
  22701. * Gets the length in pixels of the blur sample region
  22702. */
  22703. get kernel(): number;
  22704. /**
  22705. * Sets wether or not the blur needs to unpack/repack floats
  22706. */
  22707. set packedFloat(v: boolean);
  22708. /**
  22709. * Gets wether or not the blur is unpacking/repacking floats
  22710. */
  22711. get packedFloat(): boolean;
  22712. /**
  22713. * Creates a new instance BlurPostProcess
  22714. * @param name The name of the effect.
  22715. * @param direction The direction in which to blur the image.
  22716. * @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.
  22717. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22718. * @param camera The camera to apply the render pass to.
  22719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22720. * @param engine The engine which the post process will be applied. (default: current engine)
  22721. * @param reusable If the post process can be reused on the same frame. (default: false)
  22722. * @param textureType Type of textures used when performing the post process. (default: 0)
  22723. * @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)
  22724. */
  22725. constructor(name: string,
  22726. /** The direction in which to blur the image. */
  22727. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22728. /**
  22729. * Updates the effect with the current post process compile time values and recompiles the shader.
  22730. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22731. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22732. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22733. * @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
  22734. * @param onCompiled Called when the shader has been compiled.
  22735. * @param onError Called if there is an error when compiling a shader.
  22736. */
  22737. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22738. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22739. /**
  22740. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22741. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22742. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22743. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22744. * The gaps between physical kernels are compensated for in the weighting of the samples
  22745. * @param idealKernel Ideal blur kernel.
  22746. * @return Nearest best kernel.
  22747. */
  22748. protected _nearestBestKernel(idealKernel: number): number;
  22749. /**
  22750. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22751. * @param x The point on the Gaussian distribution to sample.
  22752. * @return the value of the Gaussian function at x.
  22753. */
  22754. protected _gaussianWeight(x: number): number;
  22755. /**
  22756. * Generates a string that can be used as a floating point number in GLSL.
  22757. * @param x Value to print.
  22758. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22759. * @return GLSL float string.
  22760. */
  22761. protected _glslFloat(x: number, decimalFigures?: number): string;
  22762. }
  22763. }
  22764. declare module BABYLON {
  22765. /**
  22766. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22767. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22768. * You can then easily use it as a reflectionTexture on a flat surface.
  22769. * In case the surface is not a plane, please consider relying on reflection probes.
  22770. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22771. */
  22772. export class MirrorTexture extends RenderTargetTexture {
  22773. private scene;
  22774. /**
  22775. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22776. * 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.
  22777. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22778. */
  22779. mirrorPlane: Plane;
  22780. /**
  22781. * Define the blur ratio used to blur the reflection if needed.
  22782. */
  22783. set blurRatio(value: number);
  22784. get blurRatio(): number;
  22785. /**
  22786. * Define the adaptive blur kernel used to blur the reflection if needed.
  22787. * This will autocompute the closest best match for the `blurKernel`
  22788. */
  22789. set adaptiveBlurKernel(value: number);
  22790. /**
  22791. * Define the blur kernel used to blur the reflection if needed.
  22792. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22793. */
  22794. set blurKernel(value: number);
  22795. /**
  22796. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22797. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22798. */
  22799. set blurKernelX(value: number);
  22800. get blurKernelX(): number;
  22801. /**
  22802. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22803. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22804. */
  22805. set blurKernelY(value: number);
  22806. get blurKernelY(): number;
  22807. private _autoComputeBlurKernel;
  22808. protected _onRatioRescale(): void;
  22809. private _updateGammaSpace;
  22810. private _imageProcessingConfigChangeObserver;
  22811. private _transformMatrix;
  22812. private _mirrorMatrix;
  22813. private _savedViewMatrix;
  22814. private _blurX;
  22815. private _blurY;
  22816. private _adaptiveBlurKernel;
  22817. private _blurKernelX;
  22818. private _blurKernelY;
  22819. private _blurRatio;
  22820. /**
  22821. * Instantiates a Mirror Texture.
  22822. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22823. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22824. * You can then easily use it as a reflectionTexture on a flat surface.
  22825. * In case the surface is not a plane, please consider relying on reflection probes.
  22826. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22827. * @param name
  22828. * @param size
  22829. * @param scene
  22830. * @param generateMipMaps
  22831. * @param type
  22832. * @param samplingMode
  22833. * @param generateDepthBuffer
  22834. */
  22835. constructor(name: string, size: number | {
  22836. width: number;
  22837. height: number;
  22838. } | {
  22839. ratio: number;
  22840. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22841. private _preparePostProcesses;
  22842. /**
  22843. * Clone the mirror texture.
  22844. * @returns the cloned texture
  22845. */
  22846. clone(): MirrorTexture;
  22847. /**
  22848. * Serialize the texture to a JSON representation you could use in Parse later on
  22849. * @returns the serialized JSON representation
  22850. */
  22851. serialize(): any;
  22852. /**
  22853. * Dispose the texture and release its associated resources.
  22854. */
  22855. dispose(): void;
  22856. }
  22857. }
  22858. declare module BABYLON {
  22859. /**
  22860. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22861. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22862. */
  22863. export class Texture extends BaseTexture {
  22864. /**
  22865. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22866. */
  22867. static SerializeBuffers: boolean;
  22868. /** @hidden */
  22869. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22870. /** @hidden */
  22871. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22872. /** @hidden */
  22873. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22874. /** nearest is mag = nearest and min = nearest and mip = linear */
  22875. static readonly NEAREST_SAMPLINGMODE: number;
  22876. /** nearest is mag = nearest and min = nearest and mip = linear */
  22877. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22879. static readonly BILINEAR_SAMPLINGMODE: number;
  22880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22881. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22882. /** Trilinear is mag = linear and min = linear and mip = linear */
  22883. static readonly TRILINEAR_SAMPLINGMODE: number;
  22884. /** Trilinear is mag = linear and min = linear and mip = linear */
  22885. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22886. /** mag = nearest and min = nearest and mip = nearest */
  22887. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22888. /** mag = nearest and min = linear and mip = nearest */
  22889. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22890. /** mag = nearest and min = linear and mip = linear */
  22891. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22892. /** mag = nearest and min = linear and mip = none */
  22893. static readonly NEAREST_LINEAR: number;
  22894. /** mag = nearest and min = nearest and mip = none */
  22895. static readonly NEAREST_NEAREST: number;
  22896. /** mag = linear and min = nearest and mip = nearest */
  22897. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22898. /** mag = linear and min = nearest and mip = linear */
  22899. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22900. /** mag = linear and min = linear and mip = none */
  22901. static readonly LINEAR_LINEAR: number;
  22902. /** mag = linear and min = nearest and mip = none */
  22903. static readonly LINEAR_NEAREST: number;
  22904. /** Explicit coordinates mode */
  22905. static readonly EXPLICIT_MODE: number;
  22906. /** Spherical coordinates mode */
  22907. static readonly SPHERICAL_MODE: number;
  22908. /** Planar coordinates mode */
  22909. static readonly PLANAR_MODE: number;
  22910. /** Cubic coordinates mode */
  22911. static readonly CUBIC_MODE: number;
  22912. /** Projection coordinates mode */
  22913. static readonly PROJECTION_MODE: number;
  22914. /** Inverse Cubic coordinates mode */
  22915. static readonly SKYBOX_MODE: number;
  22916. /** Inverse Cubic coordinates mode */
  22917. static readonly INVCUBIC_MODE: number;
  22918. /** Equirectangular coordinates mode */
  22919. static readonly EQUIRECTANGULAR_MODE: number;
  22920. /** Equirectangular Fixed coordinates mode */
  22921. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22922. /** Equirectangular Fixed Mirrored coordinates mode */
  22923. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22924. /** Texture is not repeating outside of 0..1 UVs */
  22925. static readonly CLAMP_ADDRESSMODE: number;
  22926. /** Texture is repeating outside of 0..1 UVs */
  22927. static readonly WRAP_ADDRESSMODE: number;
  22928. /** Texture is repeating and mirrored */
  22929. static readonly MIRROR_ADDRESSMODE: number;
  22930. /**
  22931. * 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
  22932. */
  22933. static UseSerializedUrlIfAny: boolean;
  22934. /**
  22935. * Define the url of the texture.
  22936. */
  22937. url: Nullable<string>;
  22938. /**
  22939. * Define an offset on the texture to offset the u coordinates of the UVs
  22940. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22941. */
  22942. uOffset: number;
  22943. /**
  22944. * Define an offset on the texture to offset the v coordinates of the UVs
  22945. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22946. */
  22947. vOffset: number;
  22948. /**
  22949. * Define an offset on the texture to scale the u coordinates of the UVs
  22950. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22951. */
  22952. uScale: number;
  22953. /**
  22954. * Define an offset on the texture to scale the v coordinates of the UVs
  22955. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22956. */
  22957. vScale: number;
  22958. /**
  22959. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22960. * @see http://doc.babylonjs.com/how_to/more_materials
  22961. */
  22962. uAng: number;
  22963. /**
  22964. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22965. * @see http://doc.babylonjs.com/how_to/more_materials
  22966. */
  22967. vAng: number;
  22968. /**
  22969. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22970. * @see http://doc.babylonjs.com/how_to/more_materials
  22971. */
  22972. wAng: number;
  22973. /**
  22974. * Defines the center of rotation (U)
  22975. */
  22976. uRotationCenter: number;
  22977. /**
  22978. * Defines the center of rotation (V)
  22979. */
  22980. vRotationCenter: number;
  22981. /**
  22982. * Defines the center of rotation (W)
  22983. */
  22984. wRotationCenter: number;
  22985. /**
  22986. * Are mip maps generated for this texture or not.
  22987. */
  22988. get noMipmap(): boolean;
  22989. /**
  22990. * List of inspectable custom properties (used by the Inspector)
  22991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22992. */
  22993. inspectableCustomProperties: Nullable<IInspectable[]>;
  22994. private _noMipmap;
  22995. /** @hidden */
  22996. _invertY: boolean;
  22997. private _rowGenerationMatrix;
  22998. private _cachedTextureMatrix;
  22999. private _projectionModeMatrix;
  23000. private _t0;
  23001. private _t1;
  23002. private _t2;
  23003. private _cachedUOffset;
  23004. private _cachedVOffset;
  23005. private _cachedUScale;
  23006. private _cachedVScale;
  23007. private _cachedUAng;
  23008. private _cachedVAng;
  23009. private _cachedWAng;
  23010. private _cachedProjectionMatrixId;
  23011. private _cachedCoordinatesMode;
  23012. /** @hidden */
  23013. protected _initialSamplingMode: number;
  23014. /** @hidden */
  23015. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23016. private _deleteBuffer;
  23017. protected _format: Nullable<number>;
  23018. private _delayedOnLoad;
  23019. private _delayedOnError;
  23020. private _mimeType?;
  23021. /**
  23022. * Observable triggered once the texture has been loaded.
  23023. */
  23024. onLoadObservable: Observable<Texture>;
  23025. protected _isBlocking: boolean;
  23026. /**
  23027. * Is the texture preventing material to render while loading.
  23028. * If false, a default texture will be used instead of the loading one during the preparation step.
  23029. */
  23030. set isBlocking(value: boolean);
  23031. get isBlocking(): boolean;
  23032. /**
  23033. * Get the current sampling mode associated with the texture.
  23034. */
  23035. get samplingMode(): number;
  23036. /**
  23037. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23038. */
  23039. get invertY(): boolean;
  23040. /**
  23041. * Instantiates a new texture.
  23042. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23043. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23044. * @param url defines the url of the picture to load as a texture
  23045. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23046. * @param noMipmap defines if the texture will require mip maps or not
  23047. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23048. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23049. * @param onLoad defines a callback triggered when the texture has been loaded
  23050. * @param onError defines a callback triggered when an error occurred during the loading session
  23051. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23052. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23053. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23054. * @param mimeType defines an optional mime type information
  23055. */
  23056. 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);
  23057. /**
  23058. * Update the url (and optional buffer) of this texture if url was null during construction.
  23059. * @param url the url of the texture
  23060. * @param buffer the buffer of the texture (defaults to null)
  23061. * @param onLoad callback called when the texture is loaded (defaults to null)
  23062. */
  23063. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23064. /**
  23065. * Finish the loading sequence of a texture flagged as delayed load.
  23066. * @hidden
  23067. */
  23068. delayLoad(): void;
  23069. private _prepareRowForTextureGeneration;
  23070. /**
  23071. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23072. * @returns the transform matrix of the texture.
  23073. */
  23074. getTextureMatrix(uBase?: number): Matrix;
  23075. /**
  23076. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23077. * @returns The reflection texture transform
  23078. */
  23079. getReflectionTextureMatrix(): Matrix;
  23080. /**
  23081. * Clones the texture.
  23082. * @returns the cloned texture
  23083. */
  23084. clone(): Texture;
  23085. /**
  23086. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23087. * @returns The JSON representation of the texture
  23088. */
  23089. serialize(): any;
  23090. /**
  23091. * Get the current class name of the texture useful for serialization or dynamic coding.
  23092. * @returns "Texture"
  23093. */
  23094. getClassName(): string;
  23095. /**
  23096. * Dispose the texture and release its associated resources.
  23097. */
  23098. dispose(): void;
  23099. /**
  23100. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23101. * @param parsedTexture Define the JSON representation of the texture
  23102. * @param scene Define the scene the parsed texture should be instantiated in
  23103. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23104. * @returns The parsed texture if successful
  23105. */
  23106. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23107. /**
  23108. * Creates a texture from its base 64 representation.
  23109. * @param data Define the base64 payload without the data: prefix
  23110. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23111. * @param scene Define the scene the texture should belong to
  23112. * @param noMipmap Forces the texture to not create mip map information if true
  23113. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23114. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23115. * @param onLoad define a callback triggered when the texture has been loaded
  23116. * @param onError define a callback triggered when an error occurred during the loading session
  23117. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23118. * @returns the created texture
  23119. */
  23120. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23121. /**
  23122. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23123. * @param data Define the base64 payload without the data: prefix
  23124. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23125. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23126. * @param scene Define the scene the texture should belong to
  23127. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23128. * @param noMipmap Forces the texture to not create mip map information if true
  23129. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23130. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23131. * @param onLoad define a callback triggered when the texture has been loaded
  23132. * @param onError define a callback triggered when an error occurred during the loading session
  23133. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23134. * @returns the created texture
  23135. */
  23136. 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;
  23137. }
  23138. }
  23139. declare module BABYLON {
  23140. /**
  23141. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23142. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23143. */
  23144. export class PostProcessManager {
  23145. private _scene;
  23146. private _indexBuffer;
  23147. private _vertexBuffers;
  23148. /**
  23149. * Creates a new instance PostProcess
  23150. * @param scene The scene that the post process is associated with.
  23151. */
  23152. constructor(scene: Scene);
  23153. private _prepareBuffers;
  23154. private _buildIndexBuffer;
  23155. /**
  23156. * Rebuilds the vertex buffers of the manager.
  23157. * @hidden
  23158. */
  23159. _rebuild(): void;
  23160. /**
  23161. * Prepares a frame to be run through a post process.
  23162. * @param sourceTexture The input texture to the post procesess. (default: null)
  23163. * @param postProcesses An array of post processes to be run. (default: null)
  23164. * @returns True if the post processes were able to be run.
  23165. * @hidden
  23166. */
  23167. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23168. /**
  23169. * Manually render a set of post processes to a texture.
  23170. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23171. * @param postProcesses An array of post processes to be run.
  23172. * @param targetTexture The target texture to render to.
  23173. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23174. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23175. * @param lodLevel defines which lod of the texture to render to
  23176. */
  23177. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23178. /**
  23179. * Finalize the result of the output of the postprocesses.
  23180. * @param doNotPresent If true the result will not be displayed to the screen.
  23181. * @param targetTexture The target texture to render to.
  23182. * @param faceIndex The index of the face to bind the target texture to.
  23183. * @param postProcesses The array of post processes to render.
  23184. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23185. * @hidden
  23186. */
  23187. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23188. /**
  23189. * Disposes of the post process manager.
  23190. */
  23191. dispose(): void;
  23192. }
  23193. }
  23194. declare module BABYLON {
  23195. /**
  23196. * This Helps creating a texture that will be created from a camera in your scene.
  23197. * It is basically a dynamic texture that could be used to create special effects for instance.
  23198. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23199. */
  23200. export class RenderTargetTexture extends Texture {
  23201. isCube: boolean;
  23202. /**
  23203. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23204. */
  23205. static readonly REFRESHRATE_RENDER_ONCE: number;
  23206. /**
  23207. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23208. */
  23209. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23210. /**
  23211. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23212. * the central point of your effect and can save a lot of performances.
  23213. */
  23214. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23215. /**
  23216. * Use this predicate to dynamically define the list of mesh you want to render.
  23217. * If set, the renderList property will be overwritten.
  23218. */
  23219. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23220. private _renderList;
  23221. /**
  23222. * Use this list to define the list of mesh you want to render.
  23223. */
  23224. get renderList(): Nullable<Array<AbstractMesh>>;
  23225. set renderList(value: Nullable<Array<AbstractMesh>>);
  23226. /**
  23227. * Use this function to overload the renderList array at rendering time.
  23228. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23229. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23230. * the cube (if the RTT is a cube, else layerOrFace=0).
  23231. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23232. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23233. * hold dummy elements!
  23234. */
  23235. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23236. private _hookArray;
  23237. /**
  23238. * Define if particles should be rendered in your texture.
  23239. */
  23240. renderParticles: boolean;
  23241. /**
  23242. * Define if sprites should be rendered in your texture.
  23243. */
  23244. renderSprites: boolean;
  23245. /**
  23246. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23247. */
  23248. coordinatesMode: number;
  23249. /**
  23250. * Define the camera used to render the texture.
  23251. */
  23252. activeCamera: Nullable<Camera>;
  23253. /**
  23254. * Override the mesh isReady function with your own one.
  23255. */
  23256. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23257. /**
  23258. * Override the render function of the texture with your own one.
  23259. */
  23260. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23261. /**
  23262. * Define if camera post processes should be use while rendering the texture.
  23263. */
  23264. useCameraPostProcesses: boolean;
  23265. /**
  23266. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23267. */
  23268. ignoreCameraViewport: boolean;
  23269. private _postProcessManager;
  23270. private _postProcesses;
  23271. private _resizeObserver;
  23272. /**
  23273. * An event triggered when the texture is unbind.
  23274. */
  23275. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23276. /**
  23277. * An event triggered when the texture is unbind.
  23278. */
  23279. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23280. private _onAfterUnbindObserver;
  23281. /**
  23282. * Set a after unbind callback in the texture.
  23283. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23284. */
  23285. set onAfterUnbind(callback: () => void);
  23286. /**
  23287. * An event triggered before rendering the texture
  23288. */
  23289. onBeforeRenderObservable: Observable<number>;
  23290. private _onBeforeRenderObserver;
  23291. /**
  23292. * Set a before render callback in the texture.
  23293. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23294. */
  23295. set onBeforeRender(callback: (faceIndex: number) => void);
  23296. /**
  23297. * An event triggered after rendering the texture
  23298. */
  23299. onAfterRenderObservable: Observable<number>;
  23300. private _onAfterRenderObserver;
  23301. /**
  23302. * Set a after render callback in the texture.
  23303. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23304. */
  23305. set onAfterRender(callback: (faceIndex: number) => void);
  23306. /**
  23307. * An event triggered after the texture clear
  23308. */
  23309. onClearObservable: Observable<Engine>;
  23310. private _onClearObserver;
  23311. /**
  23312. * Set a clear callback in the texture.
  23313. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23314. */
  23315. set onClear(callback: (Engine: Engine) => void);
  23316. /**
  23317. * An event triggered when the texture is resized.
  23318. */
  23319. onResizeObservable: Observable<RenderTargetTexture>;
  23320. /**
  23321. * Define the clear color of the Render Target if it should be different from the scene.
  23322. */
  23323. clearColor: Color4;
  23324. protected _size: number | {
  23325. width: number;
  23326. height: number;
  23327. layers?: number;
  23328. };
  23329. protected _initialSizeParameter: number | {
  23330. width: number;
  23331. height: number;
  23332. } | {
  23333. ratio: number;
  23334. };
  23335. protected _sizeRatio: Nullable<number>;
  23336. /** @hidden */
  23337. _generateMipMaps: boolean;
  23338. protected _renderingManager: RenderingManager;
  23339. /** @hidden */
  23340. _waitingRenderList: string[];
  23341. protected _doNotChangeAspectRatio: boolean;
  23342. protected _currentRefreshId: number;
  23343. protected _refreshRate: number;
  23344. protected _textureMatrix: Matrix;
  23345. protected _samples: number;
  23346. protected _renderTargetOptions: RenderTargetCreationOptions;
  23347. /**
  23348. * Gets render target creation options that were used.
  23349. */
  23350. get renderTargetOptions(): RenderTargetCreationOptions;
  23351. protected _onRatioRescale(): void;
  23352. /**
  23353. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23354. * It must define where the camera used to render the texture is set
  23355. */
  23356. boundingBoxPosition: Vector3;
  23357. private _boundingBoxSize;
  23358. /**
  23359. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23360. * When defined, the cubemap will switch to local mode
  23361. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23362. * @example https://www.babylonjs-playground.com/#RNASML
  23363. */
  23364. set boundingBoxSize(value: Vector3);
  23365. get boundingBoxSize(): Vector3;
  23366. /**
  23367. * In case the RTT has been created with a depth texture, get the associated
  23368. * depth texture.
  23369. * Otherwise, return null.
  23370. */
  23371. get depthStencilTexture(): Nullable<InternalTexture>;
  23372. /**
  23373. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23374. * or used a shadow, depth texture...
  23375. * @param name The friendly name of the texture
  23376. * @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)
  23377. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23378. * @param generateMipMaps True if mip maps need to be generated after render.
  23379. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23380. * @param type The type of the buffer in the RTT (int, half float, float...)
  23381. * @param isCube True if a cube texture needs to be created
  23382. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23383. * @param generateDepthBuffer True to generate a depth buffer
  23384. * @param generateStencilBuffer True to generate a stencil buffer
  23385. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23386. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23387. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23388. */
  23389. constructor(name: string, size: number | {
  23390. width: number;
  23391. height: number;
  23392. layers?: number;
  23393. } | {
  23394. ratio: number;
  23395. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23396. /**
  23397. * Creates a depth stencil texture.
  23398. * This is only available in WebGL 2 or with the depth texture extension available.
  23399. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23400. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23401. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23402. */
  23403. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23404. private _processSizeParameter;
  23405. /**
  23406. * Define the number of samples to use in case of MSAA.
  23407. * It defaults to one meaning no MSAA has been enabled.
  23408. */
  23409. get samples(): number;
  23410. set samples(value: number);
  23411. /**
  23412. * Resets the refresh counter of the texture and start bak from scratch.
  23413. * Could be useful to regenerate the texture if it is setup to render only once.
  23414. */
  23415. resetRefreshCounter(): void;
  23416. /**
  23417. * Define the refresh rate of the texture or the rendering frequency.
  23418. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23419. */
  23420. get refreshRate(): number;
  23421. set refreshRate(value: number);
  23422. /**
  23423. * Adds a post process to the render target rendering passes.
  23424. * @param postProcess define the post process to add
  23425. */
  23426. addPostProcess(postProcess: PostProcess): void;
  23427. /**
  23428. * Clear all the post processes attached to the render target
  23429. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23430. */
  23431. clearPostProcesses(dispose?: boolean): void;
  23432. /**
  23433. * Remove one of the post process from the list of attached post processes to the texture
  23434. * @param postProcess define the post process to remove from the list
  23435. */
  23436. removePostProcess(postProcess: PostProcess): void;
  23437. /** @hidden */
  23438. _shouldRender(): boolean;
  23439. /**
  23440. * Gets the actual render size of the texture.
  23441. * @returns the width of the render size
  23442. */
  23443. getRenderSize(): number;
  23444. /**
  23445. * Gets the actual render width of the texture.
  23446. * @returns the width of the render size
  23447. */
  23448. getRenderWidth(): number;
  23449. /**
  23450. * Gets the actual render height of the texture.
  23451. * @returns the height of the render size
  23452. */
  23453. getRenderHeight(): number;
  23454. /**
  23455. * Gets the actual number of layers of the texture.
  23456. * @returns the number of layers
  23457. */
  23458. getRenderLayers(): number;
  23459. /**
  23460. * Get if the texture can be rescaled or not.
  23461. */
  23462. get canRescale(): boolean;
  23463. /**
  23464. * Resize the texture using a ratio.
  23465. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23466. */
  23467. scale(ratio: number): void;
  23468. /**
  23469. * Get the texture reflection matrix used to rotate/transform the reflection.
  23470. * @returns the reflection matrix
  23471. */
  23472. getReflectionTextureMatrix(): Matrix;
  23473. /**
  23474. * Resize the texture to a new desired size.
  23475. * Be carrefull as it will recreate all the data in the new texture.
  23476. * @param size Define the new size. It can be:
  23477. * - a number for squared texture,
  23478. * - an object containing { width: number, height: number }
  23479. * - or an object containing a ratio { ratio: number }
  23480. */
  23481. resize(size: number | {
  23482. width: number;
  23483. height: number;
  23484. } | {
  23485. ratio: number;
  23486. }): void;
  23487. private _defaultRenderListPrepared;
  23488. /**
  23489. * Renders all the objects from the render list into the texture.
  23490. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23491. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23492. */
  23493. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23494. private _bestReflectionRenderTargetDimension;
  23495. private _prepareRenderingManager;
  23496. /**
  23497. * @hidden
  23498. * @param faceIndex face index to bind to if this is a cubetexture
  23499. * @param layer defines the index of the texture to bind in the array
  23500. */
  23501. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23502. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23503. private renderToTarget;
  23504. /**
  23505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23506. * This allowed control for front to back rendering or reversly depending of the special needs.
  23507. *
  23508. * @param renderingGroupId The rendering group id corresponding to its index
  23509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23512. */
  23513. 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;
  23514. /**
  23515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23516. *
  23517. * @param renderingGroupId The rendering group id corresponding to its index
  23518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23519. */
  23520. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23521. /**
  23522. * Clones the texture.
  23523. * @returns the cloned texture
  23524. */
  23525. clone(): RenderTargetTexture;
  23526. /**
  23527. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23528. * @returns The JSON representation of the texture
  23529. */
  23530. serialize(): any;
  23531. /**
  23532. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23533. */
  23534. disposeFramebufferObjects(): void;
  23535. /**
  23536. * Dispose the texture and release its associated resources.
  23537. */
  23538. dispose(): void;
  23539. /** @hidden */
  23540. _rebuild(): void;
  23541. /**
  23542. * Clear the info related to rendering groups preventing retention point in material dispose.
  23543. */
  23544. freeRenderingGroups(): void;
  23545. /**
  23546. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23547. * @returns the view count
  23548. */
  23549. getViewCount(): number;
  23550. }
  23551. }
  23552. declare module BABYLON {
  23553. /**
  23554. * Class used to manipulate GUIDs
  23555. */
  23556. export class GUID {
  23557. /**
  23558. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23559. * Be aware Math.random() could cause collisions, but:
  23560. * "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"
  23561. * @returns a pseudo random id
  23562. */
  23563. static RandomId(): string;
  23564. }
  23565. }
  23566. declare module BABYLON {
  23567. /**
  23568. * Options to be used when creating a shadow depth material
  23569. */
  23570. export interface IIOptionShadowDepthMaterial {
  23571. /** Variables in the vertex shader code that need to have their names remapped.
  23572. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23573. * "var_name" should be either: worldPos or vNormalW
  23574. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23575. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23576. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23577. */
  23578. remappedVariables?: string[];
  23579. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23580. standalone?: boolean;
  23581. }
  23582. /**
  23583. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23584. */
  23585. export class ShadowDepthWrapper {
  23586. private _scene;
  23587. private _options?;
  23588. private _baseMaterial;
  23589. private _onEffectCreatedObserver;
  23590. private _subMeshToEffect;
  23591. private _subMeshToDepthEffect;
  23592. private _meshes;
  23593. /** @hidden */
  23594. _matriceNames: any;
  23595. /** Gets the standalone status of the wrapper */
  23596. get standalone(): boolean;
  23597. /** Gets the base material the wrapper is built upon */
  23598. get baseMaterial(): Material;
  23599. /**
  23600. * Instantiate a new shadow depth wrapper.
  23601. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23602. * generate the shadow depth map. For more information, please refer to the documentation:
  23603. * https://doc.babylonjs.com/babylon101/shadows
  23604. * @param baseMaterial Material to wrap
  23605. * @param scene Define the scene the material belongs to
  23606. * @param options Options used to create the wrapper
  23607. */
  23608. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23609. /**
  23610. * Gets the effect to use to generate the depth map
  23611. * @param subMesh subMesh to get the effect for
  23612. * @param shadowGenerator shadow generator to get the effect for
  23613. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23614. */
  23615. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23616. /**
  23617. * Specifies that the submesh is ready to be used for depth rendering
  23618. * @param subMesh submesh to check
  23619. * @param defines the list of defines to take into account when checking the effect
  23620. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23621. * @param useInstances specifies that instances should be used
  23622. * @returns a boolean indicating that the submesh is ready or not
  23623. */
  23624. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23625. /**
  23626. * Disposes the resources
  23627. */
  23628. dispose(): void;
  23629. private _makeEffect;
  23630. }
  23631. }
  23632. declare module BABYLON {
  23633. /**
  23634. * Options for compiling materials.
  23635. */
  23636. export interface IMaterialCompilationOptions {
  23637. /**
  23638. * Defines whether clip planes are enabled.
  23639. */
  23640. clipPlane: boolean;
  23641. /**
  23642. * Defines whether instances are enabled.
  23643. */
  23644. useInstances: boolean;
  23645. }
  23646. /**
  23647. * Options passed when calling customShaderNameResolve
  23648. */
  23649. export interface ICustomShaderNameResolveOptions {
  23650. /**
  23651. * 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
  23652. */
  23653. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23654. }
  23655. /**
  23656. * Base class for the main features of a material in Babylon.js
  23657. */
  23658. export class Material implements IAnimatable {
  23659. /**
  23660. * Returns the triangle fill mode
  23661. */
  23662. static readonly TriangleFillMode: number;
  23663. /**
  23664. * Returns the wireframe mode
  23665. */
  23666. static readonly WireFrameFillMode: number;
  23667. /**
  23668. * Returns the point fill mode
  23669. */
  23670. static readonly PointFillMode: number;
  23671. /**
  23672. * Returns the point list draw mode
  23673. */
  23674. static readonly PointListDrawMode: number;
  23675. /**
  23676. * Returns the line list draw mode
  23677. */
  23678. static readonly LineListDrawMode: number;
  23679. /**
  23680. * Returns the line loop draw mode
  23681. */
  23682. static readonly LineLoopDrawMode: number;
  23683. /**
  23684. * Returns the line strip draw mode
  23685. */
  23686. static readonly LineStripDrawMode: number;
  23687. /**
  23688. * Returns the triangle strip draw mode
  23689. */
  23690. static readonly TriangleStripDrawMode: number;
  23691. /**
  23692. * Returns the triangle fan draw mode
  23693. */
  23694. static readonly TriangleFanDrawMode: number;
  23695. /**
  23696. * Stores the clock-wise side orientation
  23697. */
  23698. static readonly ClockWiseSideOrientation: number;
  23699. /**
  23700. * Stores the counter clock-wise side orientation
  23701. */
  23702. static readonly CounterClockWiseSideOrientation: number;
  23703. /**
  23704. * The dirty texture flag value
  23705. */
  23706. static readonly TextureDirtyFlag: number;
  23707. /**
  23708. * The dirty light flag value
  23709. */
  23710. static readonly LightDirtyFlag: number;
  23711. /**
  23712. * The dirty fresnel flag value
  23713. */
  23714. static readonly FresnelDirtyFlag: number;
  23715. /**
  23716. * The dirty attribute flag value
  23717. */
  23718. static readonly AttributesDirtyFlag: number;
  23719. /**
  23720. * The dirty misc flag value
  23721. */
  23722. static readonly MiscDirtyFlag: number;
  23723. /**
  23724. * The all dirty flag value
  23725. */
  23726. static readonly AllDirtyFlag: number;
  23727. /**
  23728. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23729. */
  23730. static readonly MATERIAL_OPAQUE: number;
  23731. /**
  23732. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23733. */
  23734. static readonly MATERIAL_ALPHATEST: number;
  23735. /**
  23736. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23737. */
  23738. static readonly MATERIAL_ALPHABLEND: number;
  23739. /**
  23740. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23741. * They are also discarded below the alpha cutoff threshold to improve performances.
  23742. */
  23743. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23744. /**
  23745. * Custom callback helping to override the default shader used in the material.
  23746. */
  23747. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23748. /**
  23749. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23750. */
  23751. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23752. /**
  23753. * The ID of the material
  23754. */
  23755. id: string;
  23756. /**
  23757. * Gets or sets the unique id of the material
  23758. */
  23759. uniqueId: number;
  23760. /**
  23761. * The name of the material
  23762. */
  23763. name: string;
  23764. /**
  23765. * Gets or sets user defined metadata
  23766. */
  23767. metadata: any;
  23768. /**
  23769. * For internal use only. Please do not use.
  23770. */
  23771. reservedDataStore: any;
  23772. /**
  23773. * Specifies if the ready state should be checked on each call
  23774. */
  23775. checkReadyOnEveryCall: boolean;
  23776. /**
  23777. * Specifies if the ready state should be checked once
  23778. */
  23779. checkReadyOnlyOnce: boolean;
  23780. /**
  23781. * The state of the material
  23782. */
  23783. state: string;
  23784. /**
  23785. * The alpha value of the material
  23786. */
  23787. protected _alpha: number;
  23788. /**
  23789. * List of inspectable custom properties (used by the Inspector)
  23790. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23791. */
  23792. inspectableCustomProperties: IInspectable[];
  23793. /**
  23794. * Sets the alpha value of the material
  23795. */
  23796. set alpha(value: number);
  23797. /**
  23798. * Gets the alpha value of the material
  23799. */
  23800. get alpha(): number;
  23801. /**
  23802. * Specifies if back face culling is enabled
  23803. */
  23804. protected _backFaceCulling: boolean;
  23805. /**
  23806. * Sets the back-face culling state
  23807. */
  23808. set backFaceCulling(value: boolean);
  23809. /**
  23810. * Gets the back-face culling state
  23811. */
  23812. get backFaceCulling(): boolean;
  23813. /**
  23814. * Stores the value for side orientation
  23815. */
  23816. sideOrientation: number;
  23817. /**
  23818. * Callback triggered when the material is compiled
  23819. */
  23820. onCompiled: Nullable<(effect: Effect) => void>;
  23821. /**
  23822. * Callback triggered when an error occurs
  23823. */
  23824. onError: Nullable<(effect: Effect, errors: string) => void>;
  23825. /**
  23826. * Callback triggered to get the render target textures
  23827. */
  23828. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23829. /**
  23830. * Gets a boolean indicating that current material needs to register RTT
  23831. */
  23832. get hasRenderTargetTextures(): boolean;
  23833. /**
  23834. * Specifies if the material should be serialized
  23835. */
  23836. doNotSerialize: boolean;
  23837. /**
  23838. * @hidden
  23839. */
  23840. _storeEffectOnSubMeshes: boolean;
  23841. /**
  23842. * Stores the animations for the material
  23843. */
  23844. animations: Nullable<Array<Animation>>;
  23845. /**
  23846. * An event triggered when the material is disposed
  23847. */
  23848. onDisposeObservable: Observable<Material>;
  23849. /**
  23850. * An observer which watches for dispose events
  23851. */
  23852. private _onDisposeObserver;
  23853. private _onUnBindObservable;
  23854. /**
  23855. * Called during a dispose event
  23856. */
  23857. set onDispose(callback: () => void);
  23858. private _onBindObservable;
  23859. /**
  23860. * An event triggered when the material is bound
  23861. */
  23862. get onBindObservable(): Observable<AbstractMesh>;
  23863. /**
  23864. * An observer which watches for bind events
  23865. */
  23866. private _onBindObserver;
  23867. /**
  23868. * Called during a bind event
  23869. */
  23870. set onBind(callback: (Mesh: AbstractMesh) => void);
  23871. /**
  23872. * An event triggered when the material is unbound
  23873. */
  23874. get onUnBindObservable(): Observable<Material>;
  23875. protected _onEffectCreatedObservable: Nullable<Observable<{
  23876. effect: Effect;
  23877. subMesh: Nullable<SubMesh>;
  23878. }>>;
  23879. /**
  23880. * An event triggered when the effect is (re)created
  23881. */
  23882. get onEffectCreatedObservable(): Observable<{
  23883. effect: Effect;
  23884. subMesh: Nullable<SubMesh>;
  23885. }>;
  23886. /**
  23887. * Stores the value of the alpha mode
  23888. */
  23889. private _alphaMode;
  23890. /**
  23891. * Sets the value of the alpha mode.
  23892. *
  23893. * | Value | Type | Description |
  23894. * | --- | --- | --- |
  23895. * | 0 | ALPHA_DISABLE | |
  23896. * | 1 | ALPHA_ADD | |
  23897. * | 2 | ALPHA_COMBINE | |
  23898. * | 3 | ALPHA_SUBTRACT | |
  23899. * | 4 | ALPHA_MULTIPLY | |
  23900. * | 5 | ALPHA_MAXIMIZED | |
  23901. * | 6 | ALPHA_ONEONE | |
  23902. * | 7 | ALPHA_PREMULTIPLIED | |
  23903. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23904. * | 9 | ALPHA_INTERPOLATE | |
  23905. * | 10 | ALPHA_SCREENMODE | |
  23906. *
  23907. */
  23908. set alphaMode(value: number);
  23909. /**
  23910. * Gets the value of the alpha mode
  23911. */
  23912. get alphaMode(): number;
  23913. /**
  23914. * Stores the state of the need depth pre-pass value
  23915. */
  23916. private _needDepthPrePass;
  23917. /**
  23918. * Sets the need depth pre-pass value
  23919. */
  23920. set needDepthPrePass(value: boolean);
  23921. /**
  23922. * Gets the depth pre-pass value
  23923. */
  23924. get needDepthPrePass(): boolean;
  23925. /**
  23926. * Specifies if depth writing should be disabled
  23927. */
  23928. disableDepthWrite: boolean;
  23929. /**
  23930. * Specifies if color writing should be disabled
  23931. */
  23932. disableColorWrite: boolean;
  23933. /**
  23934. * Specifies if depth writing should be forced
  23935. */
  23936. forceDepthWrite: boolean;
  23937. /**
  23938. * Specifies the depth function that should be used. 0 means the default engine function
  23939. */
  23940. depthFunction: number;
  23941. /**
  23942. * Specifies if there should be a separate pass for culling
  23943. */
  23944. separateCullingPass: boolean;
  23945. /**
  23946. * Stores the state specifing if fog should be enabled
  23947. */
  23948. private _fogEnabled;
  23949. /**
  23950. * Sets the state for enabling fog
  23951. */
  23952. set fogEnabled(value: boolean);
  23953. /**
  23954. * Gets the value of the fog enabled state
  23955. */
  23956. get fogEnabled(): boolean;
  23957. /**
  23958. * Stores the size of points
  23959. */
  23960. pointSize: number;
  23961. /**
  23962. * Stores the z offset value
  23963. */
  23964. zOffset: number;
  23965. get wireframe(): boolean;
  23966. /**
  23967. * Sets the state of wireframe mode
  23968. */
  23969. set wireframe(value: boolean);
  23970. /**
  23971. * Gets the value specifying if point clouds are enabled
  23972. */
  23973. get pointsCloud(): boolean;
  23974. /**
  23975. * Sets the state of point cloud mode
  23976. */
  23977. set pointsCloud(value: boolean);
  23978. /**
  23979. * Gets the material fill mode
  23980. */
  23981. get fillMode(): number;
  23982. /**
  23983. * Sets the material fill mode
  23984. */
  23985. set fillMode(value: number);
  23986. /**
  23987. * @hidden
  23988. * Stores the effects for the material
  23989. */
  23990. _effect: Nullable<Effect>;
  23991. /**
  23992. * Specifies if uniform buffers should be used
  23993. */
  23994. private _useUBO;
  23995. /**
  23996. * Stores a reference to the scene
  23997. */
  23998. private _scene;
  23999. /**
  24000. * Stores the fill mode state
  24001. */
  24002. private _fillMode;
  24003. /**
  24004. * Specifies if the depth write state should be cached
  24005. */
  24006. private _cachedDepthWriteState;
  24007. /**
  24008. * Specifies if the color write state should be cached
  24009. */
  24010. private _cachedColorWriteState;
  24011. /**
  24012. * Specifies if the depth function state should be cached
  24013. */
  24014. private _cachedDepthFunctionState;
  24015. /**
  24016. * Stores the uniform buffer
  24017. */
  24018. protected _uniformBuffer: UniformBuffer;
  24019. /** @hidden */
  24020. _indexInSceneMaterialArray: number;
  24021. /** @hidden */
  24022. meshMap: Nullable<{
  24023. [id: string]: AbstractMesh | undefined;
  24024. }>;
  24025. /**
  24026. * Creates a material instance
  24027. * @param name defines the name of the material
  24028. * @param scene defines the scene to reference
  24029. * @param doNotAdd specifies if the material should be added to the scene
  24030. */
  24031. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24032. /**
  24033. * Returns a string representation of the current material
  24034. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24035. * @returns a string with material information
  24036. */
  24037. toString(fullDetails?: boolean): string;
  24038. /**
  24039. * Gets the class name of the material
  24040. * @returns a string with the class name of the material
  24041. */
  24042. getClassName(): string;
  24043. /**
  24044. * Specifies if updates for the material been locked
  24045. */
  24046. get isFrozen(): boolean;
  24047. /**
  24048. * Locks updates for the material
  24049. */
  24050. freeze(): void;
  24051. /**
  24052. * Unlocks updates for the material
  24053. */
  24054. unfreeze(): void;
  24055. /**
  24056. * Specifies if the material is ready to be used
  24057. * @param mesh defines the mesh to check
  24058. * @param useInstances specifies if instances should be used
  24059. * @returns a boolean indicating if the material is ready to be used
  24060. */
  24061. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24062. /**
  24063. * Specifies that the submesh is ready to be used
  24064. * @param mesh defines the mesh to check
  24065. * @param subMesh defines which submesh to check
  24066. * @param useInstances specifies that instances should be used
  24067. * @returns a boolean indicating that the submesh is ready or not
  24068. */
  24069. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24070. /**
  24071. * Returns the material effect
  24072. * @returns the effect associated with the material
  24073. */
  24074. getEffect(): Nullable<Effect>;
  24075. /**
  24076. * Returns the current scene
  24077. * @returns a Scene
  24078. */
  24079. getScene(): Scene;
  24080. /**
  24081. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24082. */
  24083. protected _forceAlphaTest: boolean;
  24084. /**
  24085. * The transparency mode of the material.
  24086. */
  24087. protected _transparencyMode: Nullable<number>;
  24088. /**
  24089. * Gets the current transparency mode.
  24090. */
  24091. get transparencyMode(): Nullable<number>;
  24092. /**
  24093. * Sets the transparency mode of the material.
  24094. *
  24095. * | Value | Type | Description |
  24096. * | ----- | ----------------------------------- | ----------- |
  24097. * | 0 | OPAQUE | |
  24098. * | 1 | ALPHATEST | |
  24099. * | 2 | ALPHABLEND | |
  24100. * | 3 | ALPHATESTANDBLEND | |
  24101. *
  24102. */
  24103. set transparencyMode(value: Nullable<number>);
  24104. /**
  24105. * Returns true if alpha blending should be disabled.
  24106. */
  24107. protected get _disableAlphaBlending(): boolean;
  24108. /**
  24109. * Specifies whether or not this material should be rendered in alpha blend mode.
  24110. * @returns a boolean specifying if alpha blending is needed
  24111. */
  24112. needAlphaBlending(): boolean;
  24113. /**
  24114. * Specifies if the mesh will require alpha blending
  24115. * @param mesh defines the mesh to check
  24116. * @returns a boolean specifying if alpha blending is needed for the mesh
  24117. */
  24118. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24119. /**
  24120. * Specifies whether or not this material should be rendered in alpha test mode.
  24121. * @returns a boolean specifying if an alpha test is needed.
  24122. */
  24123. needAlphaTesting(): boolean;
  24124. /**
  24125. * Specifies if material alpha testing should be turned on for the mesh
  24126. * @param mesh defines the mesh to check
  24127. */
  24128. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24129. /**
  24130. * Gets the texture used for the alpha test
  24131. * @returns the texture to use for alpha testing
  24132. */
  24133. getAlphaTestTexture(): Nullable<BaseTexture>;
  24134. /**
  24135. * Marks the material to indicate that it needs to be re-calculated
  24136. */
  24137. markDirty(): void;
  24138. /** @hidden */
  24139. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24140. /**
  24141. * Binds the material to the mesh
  24142. * @param world defines the world transformation matrix
  24143. * @param mesh defines the mesh to bind the material to
  24144. */
  24145. bind(world: Matrix, mesh?: Mesh): void;
  24146. /**
  24147. * Binds the submesh to the material
  24148. * @param world defines the world transformation matrix
  24149. * @param mesh defines the mesh containing the submesh
  24150. * @param subMesh defines the submesh to bind the material to
  24151. */
  24152. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24153. /**
  24154. * Binds the world matrix to the material
  24155. * @param world defines the world transformation matrix
  24156. */
  24157. bindOnlyWorldMatrix(world: Matrix): void;
  24158. /**
  24159. * Binds the scene's uniform buffer to the effect.
  24160. * @param effect defines the effect to bind to the scene uniform buffer
  24161. * @param sceneUbo defines the uniform buffer storing scene data
  24162. */
  24163. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24164. /**
  24165. * Binds the view matrix to the effect
  24166. * @param effect defines the effect to bind the view matrix to
  24167. */
  24168. bindView(effect: Effect): void;
  24169. /**
  24170. * Binds the view projection matrix to the effect
  24171. * @param effect defines the effect to bind the view projection matrix to
  24172. */
  24173. bindViewProjection(effect: Effect): void;
  24174. /**
  24175. * Processes to execute after binding the material to a mesh
  24176. * @param mesh defines the rendered mesh
  24177. */
  24178. protected _afterBind(mesh?: Mesh): void;
  24179. /**
  24180. * Unbinds the material from the mesh
  24181. */
  24182. unbind(): void;
  24183. /**
  24184. * Gets the active textures from the material
  24185. * @returns an array of textures
  24186. */
  24187. getActiveTextures(): BaseTexture[];
  24188. /**
  24189. * Specifies if the material uses a texture
  24190. * @param texture defines the texture to check against the material
  24191. * @returns a boolean specifying if the material uses the texture
  24192. */
  24193. hasTexture(texture: BaseTexture): boolean;
  24194. /**
  24195. * Makes a duplicate of the material, and gives it a new name
  24196. * @param name defines the new name for the duplicated material
  24197. * @returns the cloned material
  24198. */
  24199. clone(name: string): Nullable<Material>;
  24200. /**
  24201. * Gets the meshes bound to the material
  24202. * @returns an array of meshes bound to the material
  24203. */
  24204. getBindedMeshes(): AbstractMesh[];
  24205. /**
  24206. * Force shader compilation
  24207. * @param mesh defines the mesh associated with this material
  24208. * @param onCompiled defines a function to execute once the material is compiled
  24209. * @param options defines the options to configure the compilation
  24210. * @param onError defines a function to execute if the material fails compiling
  24211. */
  24212. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24213. /**
  24214. * Force shader compilation
  24215. * @param mesh defines the mesh that will use this material
  24216. * @param options defines additional options for compiling the shaders
  24217. * @returns a promise that resolves when the compilation completes
  24218. */
  24219. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24220. private static readonly _AllDirtyCallBack;
  24221. private static readonly _ImageProcessingDirtyCallBack;
  24222. private static readonly _TextureDirtyCallBack;
  24223. private static readonly _FresnelDirtyCallBack;
  24224. private static readonly _MiscDirtyCallBack;
  24225. private static readonly _LightsDirtyCallBack;
  24226. private static readonly _AttributeDirtyCallBack;
  24227. private static _FresnelAndMiscDirtyCallBack;
  24228. private static _TextureAndMiscDirtyCallBack;
  24229. private static readonly _DirtyCallbackArray;
  24230. private static readonly _RunDirtyCallBacks;
  24231. /**
  24232. * Marks a define in the material to indicate that it needs to be re-computed
  24233. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24234. */
  24235. markAsDirty(flag: number): void;
  24236. /**
  24237. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24238. * @param func defines a function which checks material defines against the submeshes
  24239. */
  24240. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24241. /**
  24242. * Indicates that we need to re-calculated for all submeshes
  24243. */
  24244. protected _markAllSubMeshesAsAllDirty(): void;
  24245. /**
  24246. * Indicates that image processing needs to be re-calculated for all submeshes
  24247. */
  24248. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24249. /**
  24250. * Indicates that textures need to be re-calculated for all submeshes
  24251. */
  24252. protected _markAllSubMeshesAsTexturesDirty(): void;
  24253. /**
  24254. * Indicates that fresnel needs to be re-calculated for all submeshes
  24255. */
  24256. protected _markAllSubMeshesAsFresnelDirty(): void;
  24257. /**
  24258. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24259. */
  24260. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24261. /**
  24262. * Indicates that lights need to be re-calculated for all submeshes
  24263. */
  24264. protected _markAllSubMeshesAsLightsDirty(): void;
  24265. /**
  24266. * Indicates that attributes need to be re-calculated for all submeshes
  24267. */
  24268. protected _markAllSubMeshesAsAttributesDirty(): void;
  24269. /**
  24270. * Indicates that misc needs to be re-calculated for all submeshes
  24271. */
  24272. protected _markAllSubMeshesAsMiscDirty(): void;
  24273. /**
  24274. * Indicates that textures and misc need to be re-calculated for all submeshes
  24275. */
  24276. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24277. /**
  24278. * Disposes the material
  24279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24281. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24282. */
  24283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24284. /** @hidden */
  24285. private releaseVertexArrayObject;
  24286. /**
  24287. * Serializes this material
  24288. * @returns the serialized material object
  24289. */
  24290. serialize(): any;
  24291. /**
  24292. * Creates a material from parsed material data
  24293. * @param parsedMaterial defines parsed material data
  24294. * @param scene defines the hosting scene
  24295. * @param rootUrl defines the root URL to use to load textures
  24296. * @returns a new material
  24297. */
  24298. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24299. }
  24300. }
  24301. declare module BABYLON {
  24302. /**
  24303. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24304. * separate meshes. This can be use to improve performances.
  24305. * @see http://doc.babylonjs.com/how_to/multi_materials
  24306. */
  24307. export class MultiMaterial extends Material {
  24308. private _subMaterials;
  24309. /**
  24310. * Gets or Sets the list of Materials used within the multi material.
  24311. * They need to be ordered according to the submeshes order in the associated mesh
  24312. */
  24313. get subMaterials(): Nullable<Material>[];
  24314. set subMaterials(value: Nullable<Material>[]);
  24315. /**
  24316. * Function used to align with Node.getChildren()
  24317. * @returns the list of Materials used within the multi material
  24318. */
  24319. getChildren(): Nullable<Material>[];
  24320. /**
  24321. * Instantiates a new Multi Material
  24322. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24323. * separate meshes. This can be use to improve performances.
  24324. * @see http://doc.babylonjs.com/how_to/multi_materials
  24325. * @param name Define the name in the scene
  24326. * @param scene Define the scene the material belongs to
  24327. */
  24328. constructor(name: string, scene: Scene);
  24329. private _hookArray;
  24330. /**
  24331. * Get one of the submaterial by its index in the submaterials array
  24332. * @param index The index to look the sub material at
  24333. * @returns The Material if the index has been defined
  24334. */
  24335. getSubMaterial(index: number): Nullable<Material>;
  24336. /**
  24337. * Get the list of active textures for the whole sub materials list.
  24338. * @returns All the textures that will be used during the rendering
  24339. */
  24340. getActiveTextures(): BaseTexture[];
  24341. /**
  24342. * Gets the current class name of the material e.g. "MultiMaterial"
  24343. * Mainly use in serialization.
  24344. * @returns the class name
  24345. */
  24346. getClassName(): string;
  24347. /**
  24348. * Checks if the material is ready to render the requested sub mesh
  24349. * @param mesh Define the mesh the submesh belongs to
  24350. * @param subMesh Define the sub mesh to look readyness for
  24351. * @param useInstances Define whether or not the material is used with instances
  24352. * @returns true if ready, otherwise false
  24353. */
  24354. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24355. /**
  24356. * Clones the current material and its related sub materials
  24357. * @param name Define the name of the newly cloned material
  24358. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24359. * @returns the cloned material
  24360. */
  24361. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24362. /**
  24363. * Serializes the materials into a JSON representation.
  24364. * @returns the JSON representation
  24365. */
  24366. serialize(): any;
  24367. /**
  24368. * Dispose the material and release its associated resources
  24369. * @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)
  24370. * @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)
  24371. * @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)
  24372. */
  24373. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24374. /**
  24375. * Creates a MultiMaterial from parsed MultiMaterial data.
  24376. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24377. * @param scene defines the hosting scene
  24378. * @returns a new MultiMaterial
  24379. */
  24380. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24381. }
  24382. }
  24383. declare module BABYLON {
  24384. /**
  24385. * Defines a subdivision inside a mesh
  24386. */
  24387. export class SubMesh implements ICullable {
  24388. /** the material index to use */
  24389. materialIndex: number;
  24390. /** vertex index start */
  24391. verticesStart: number;
  24392. /** vertices count */
  24393. verticesCount: number;
  24394. /** index start */
  24395. indexStart: number;
  24396. /** indices count */
  24397. indexCount: number;
  24398. /** @hidden */
  24399. _materialDefines: Nullable<MaterialDefines>;
  24400. /** @hidden */
  24401. _materialEffect: Nullable<Effect>;
  24402. /** @hidden */
  24403. _effectOverride: Nullable<Effect>;
  24404. /**
  24405. * Gets material defines used by the effect associated to the sub mesh
  24406. */
  24407. get materialDefines(): Nullable<MaterialDefines>;
  24408. /**
  24409. * Sets material defines used by the effect associated to the sub mesh
  24410. */
  24411. set materialDefines(defines: Nullable<MaterialDefines>);
  24412. /**
  24413. * Gets associated effect
  24414. */
  24415. get effect(): Nullable<Effect>;
  24416. /**
  24417. * Sets associated effect (effect used to render this submesh)
  24418. * @param effect defines the effect to associate with
  24419. * @param defines defines the set of defines used to compile this effect
  24420. */
  24421. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24422. /** @hidden */
  24423. _linesIndexCount: number;
  24424. private _mesh;
  24425. private _renderingMesh;
  24426. private _boundingInfo;
  24427. private _linesIndexBuffer;
  24428. /** @hidden */
  24429. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24430. /** @hidden */
  24431. _trianglePlanes: Plane[];
  24432. /** @hidden */
  24433. _lastColliderTransformMatrix: Nullable<Matrix>;
  24434. /** @hidden */
  24435. _renderId: number;
  24436. /** @hidden */
  24437. _alphaIndex: number;
  24438. /** @hidden */
  24439. _distanceToCamera: number;
  24440. /** @hidden */
  24441. _id: number;
  24442. private _currentMaterial;
  24443. /**
  24444. * Add a new submesh to a mesh
  24445. * @param materialIndex defines the material index to use
  24446. * @param verticesStart defines vertex index start
  24447. * @param verticesCount defines vertices count
  24448. * @param indexStart defines index start
  24449. * @param indexCount defines indices count
  24450. * @param mesh defines the parent mesh
  24451. * @param renderingMesh defines an optional rendering mesh
  24452. * @param createBoundingBox defines if bounding box should be created for this submesh
  24453. * @returns the new submesh
  24454. */
  24455. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24456. /**
  24457. * Creates a new submesh
  24458. * @param materialIndex defines the material index to use
  24459. * @param verticesStart defines vertex index start
  24460. * @param verticesCount defines vertices count
  24461. * @param indexStart defines index start
  24462. * @param indexCount defines indices count
  24463. * @param mesh defines the parent mesh
  24464. * @param renderingMesh defines an optional rendering mesh
  24465. * @param createBoundingBox defines if bounding box should be created for this submesh
  24466. */
  24467. constructor(
  24468. /** the material index to use */
  24469. materialIndex: number,
  24470. /** vertex index start */
  24471. verticesStart: number,
  24472. /** vertices count */
  24473. verticesCount: number,
  24474. /** index start */
  24475. indexStart: number,
  24476. /** indices count */
  24477. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24478. /**
  24479. * Returns true if this submesh covers the entire parent mesh
  24480. * @ignorenaming
  24481. */
  24482. get IsGlobal(): boolean;
  24483. /**
  24484. * Returns the submesh BoudingInfo object
  24485. * @returns current bounding info (or mesh's one if the submesh is global)
  24486. */
  24487. getBoundingInfo(): BoundingInfo;
  24488. /**
  24489. * Sets the submesh BoundingInfo
  24490. * @param boundingInfo defines the new bounding info to use
  24491. * @returns the SubMesh
  24492. */
  24493. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24494. /**
  24495. * Returns the mesh of the current submesh
  24496. * @return the parent mesh
  24497. */
  24498. getMesh(): AbstractMesh;
  24499. /**
  24500. * Returns the rendering mesh of the submesh
  24501. * @returns the rendering mesh (could be different from parent mesh)
  24502. */
  24503. getRenderingMesh(): Mesh;
  24504. /**
  24505. * Returns the replacement mesh of the submesh
  24506. * @returns the replacement mesh (could be different from parent mesh)
  24507. */
  24508. getReplacementMesh(): Nullable<AbstractMesh>;
  24509. /**
  24510. * Returns the effective mesh of the submesh
  24511. * @returns the effective mesh (could be different from parent mesh)
  24512. */
  24513. getEffectiveMesh(): AbstractMesh;
  24514. /**
  24515. * Returns the submesh material
  24516. * @returns null or the current material
  24517. */
  24518. getMaterial(): Nullable<Material>;
  24519. /**
  24520. * Sets a new updated BoundingInfo object to the submesh
  24521. * @param data defines an optional position array to use to determine the bounding info
  24522. * @returns the SubMesh
  24523. */
  24524. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24525. /** @hidden */
  24526. _checkCollision(collider: Collider): boolean;
  24527. /**
  24528. * Updates the submesh BoundingInfo
  24529. * @param world defines the world matrix to use to update the bounding info
  24530. * @returns the submesh
  24531. */
  24532. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24533. /**
  24534. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24535. * @param frustumPlanes defines the frustum planes
  24536. * @returns true if the submesh is intersecting with the frustum
  24537. */
  24538. isInFrustum(frustumPlanes: Plane[]): boolean;
  24539. /**
  24540. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24541. * @param frustumPlanes defines the frustum planes
  24542. * @returns true if the submesh is inside the frustum
  24543. */
  24544. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24545. /**
  24546. * Renders the submesh
  24547. * @param enableAlphaMode defines if alpha needs to be used
  24548. * @returns the submesh
  24549. */
  24550. render(enableAlphaMode: boolean): SubMesh;
  24551. /**
  24552. * @hidden
  24553. */
  24554. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24555. /**
  24556. * Checks if the submesh intersects with a ray
  24557. * @param ray defines the ray to test
  24558. * @returns true is the passed ray intersects the submesh bounding box
  24559. */
  24560. canIntersects(ray: Ray): boolean;
  24561. /**
  24562. * Intersects current submesh with a ray
  24563. * @param ray defines the ray to test
  24564. * @param positions defines mesh's positions array
  24565. * @param indices defines mesh's indices array
  24566. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24567. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24568. * @returns intersection info or null if no intersection
  24569. */
  24570. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24571. /** @hidden */
  24572. private _intersectLines;
  24573. /** @hidden */
  24574. private _intersectUnIndexedLines;
  24575. /** @hidden */
  24576. private _intersectTriangles;
  24577. /** @hidden */
  24578. private _intersectUnIndexedTriangles;
  24579. /** @hidden */
  24580. _rebuild(): void;
  24581. /**
  24582. * Creates a new submesh from the passed mesh
  24583. * @param newMesh defines the new hosting mesh
  24584. * @param newRenderingMesh defines an optional rendering mesh
  24585. * @returns the new submesh
  24586. */
  24587. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24588. /**
  24589. * Release associated resources
  24590. */
  24591. dispose(): void;
  24592. /**
  24593. * Gets the class name
  24594. * @returns the string "SubMesh".
  24595. */
  24596. getClassName(): string;
  24597. /**
  24598. * Creates a new submesh from indices data
  24599. * @param materialIndex the index of the main mesh material
  24600. * @param startIndex the index where to start the copy in the mesh indices array
  24601. * @param indexCount the number of indices to copy then from the startIndex
  24602. * @param mesh the main mesh to create the submesh from
  24603. * @param renderingMesh the optional rendering mesh
  24604. * @returns a new submesh
  24605. */
  24606. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24607. }
  24608. }
  24609. declare module BABYLON {
  24610. /**
  24611. * Class used to represent data loading progression
  24612. */
  24613. export class SceneLoaderFlags {
  24614. private static _ForceFullSceneLoadingForIncremental;
  24615. private static _ShowLoadingScreen;
  24616. private static _CleanBoneMatrixWeights;
  24617. private static _loggingLevel;
  24618. /**
  24619. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24620. */
  24621. static get ForceFullSceneLoadingForIncremental(): boolean;
  24622. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24623. /**
  24624. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24625. */
  24626. static get ShowLoadingScreen(): boolean;
  24627. static set ShowLoadingScreen(value: boolean);
  24628. /**
  24629. * Defines the current logging level (while loading the scene)
  24630. * @ignorenaming
  24631. */
  24632. static get loggingLevel(): number;
  24633. static set loggingLevel(value: number);
  24634. /**
  24635. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24636. */
  24637. static get CleanBoneMatrixWeights(): boolean;
  24638. static set CleanBoneMatrixWeights(value: boolean);
  24639. }
  24640. }
  24641. declare module BABYLON {
  24642. /**
  24643. * Class used to store geometry data (vertex buffers + index buffer)
  24644. */
  24645. export class Geometry implements IGetSetVerticesData {
  24646. /**
  24647. * Gets or sets the ID of the geometry
  24648. */
  24649. id: string;
  24650. /**
  24651. * Gets or sets the unique ID of the geometry
  24652. */
  24653. uniqueId: number;
  24654. /**
  24655. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24656. */
  24657. delayLoadState: number;
  24658. /**
  24659. * Gets the file containing the data to load when running in delay load state
  24660. */
  24661. delayLoadingFile: Nullable<string>;
  24662. /**
  24663. * Callback called when the geometry is updated
  24664. */
  24665. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24666. private _scene;
  24667. private _engine;
  24668. private _meshes;
  24669. private _totalVertices;
  24670. /** @hidden */
  24671. _indices: IndicesArray;
  24672. /** @hidden */
  24673. _vertexBuffers: {
  24674. [key: string]: VertexBuffer;
  24675. };
  24676. private _isDisposed;
  24677. private _extend;
  24678. private _boundingBias;
  24679. /** @hidden */
  24680. _delayInfo: Array<string>;
  24681. private _indexBuffer;
  24682. private _indexBufferIsUpdatable;
  24683. /** @hidden */
  24684. _boundingInfo: Nullable<BoundingInfo>;
  24685. /** @hidden */
  24686. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24687. /** @hidden */
  24688. _softwareSkinningFrameId: number;
  24689. private _vertexArrayObjects;
  24690. private _updatable;
  24691. /** @hidden */
  24692. _positions: Nullable<Vector3[]>;
  24693. /**
  24694. * 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
  24695. */
  24696. get boundingBias(): Vector2;
  24697. /**
  24698. * 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
  24699. */
  24700. set boundingBias(value: Vector2);
  24701. /**
  24702. * Static function used to attach a new empty geometry to a mesh
  24703. * @param mesh defines the mesh to attach the geometry to
  24704. * @returns the new Geometry
  24705. */
  24706. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24707. /** Get the list of meshes using this geometry */
  24708. get meshes(): Mesh[];
  24709. /**
  24710. * Creates a new geometry
  24711. * @param id defines the unique ID
  24712. * @param scene defines the hosting scene
  24713. * @param vertexData defines the VertexData used to get geometry data
  24714. * @param updatable defines if geometry must be updatable (false by default)
  24715. * @param mesh defines the mesh that will be associated with the geometry
  24716. */
  24717. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24718. /**
  24719. * Gets the current extend of the geometry
  24720. */
  24721. get extend(): {
  24722. minimum: Vector3;
  24723. maximum: Vector3;
  24724. };
  24725. /**
  24726. * Gets the hosting scene
  24727. * @returns the hosting Scene
  24728. */
  24729. getScene(): Scene;
  24730. /**
  24731. * Gets the hosting engine
  24732. * @returns the hosting Engine
  24733. */
  24734. getEngine(): Engine;
  24735. /**
  24736. * Defines if the geometry is ready to use
  24737. * @returns true if the geometry is ready to be used
  24738. */
  24739. isReady(): boolean;
  24740. /**
  24741. * Gets a value indicating that the geometry should not be serialized
  24742. */
  24743. get doNotSerialize(): boolean;
  24744. /** @hidden */
  24745. _rebuild(): void;
  24746. /**
  24747. * Affects all geometry data in one call
  24748. * @param vertexData defines the geometry data
  24749. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24750. */
  24751. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24752. /**
  24753. * Set specific vertex data
  24754. * @param kind defines the data kind (Position, normal, etc...)
  24755. * @param data defines the vertex data to use
  24756. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24757. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24758. */
  24759. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24760. /**
  24761. * Removes a specific vertex data
  24762. * @param kind defines the data kind (Position, normal, etc...)
  24763. */
  24764. removeVerticesData(kind: string): void;
  24765. /**
  24766. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24767. * @param buffer defines the vertex buffer to use
  24768. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24769. */
  24770. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24771. /**
  24772. * Update a specific vertex buffer
  24773. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24774. * It will do nothing if the buffer is not updatable
  24775. * @param kind defines the data kind (Position, normal, etc...)
  24776. * @param data defines the data to use
  24777. * @param offset defines the offset in the target buffer where to store the data
  24778. * @param useBytes set to true if the offset is in bytes
  24779. */
  24780. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24781. /**
  24782. * Update a specific vertex buffer
  24783. * This function will create a new buffer if the current one is not updatable
  24784. * @param kind defines the data kind (Position, normal, etc...)
  24785. * @param data defines the data to use
  24786. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24787. */
  24788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24789. private _updateBoundingInfo;
  24790. /** @hidden */
  24791. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24792. /**
  24793. * Gets total number of vertices
  24794. * @returns the total number of vertices
  24795. */
  24796. getTotalVertices(): number;
  24797. /**
  24798. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24799. * @param kind defines the data kind (Position, normal, etc...)
  24800. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24802. * @returns a float array containing vertex data
  24803. */
  24804. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24805. /**
  24806. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24807. * @param kind defines the data kind (Position, normal, etc...)
  24808. * @returns true if the vertex buffer with the specified kind is updatable
  24809. */
  24810. isVertexBufferUpdatable(kind: string): boolean;
  24811. /**
  24812. * Gets a specific vertex buffer
  24813. * @param kind defines the data kind (Position, normal, etc...)
  24814. * @returns a VertexBuffer
  24815. */
  24816. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24817. /**
  24818. * Returns all vertex buffers
  24819. * @return an object holding all vertex buffers indexed by kind
  24820. */
  24821. getVertexBuffers(): Nullable<{
  24822. [key: string]: VertexBuffer;
  24823. }>;
  24824. /**
  24825. * Gets a boolean indicating if specific vertex buffer is present
  24826. * @param kind defines the data kind (Position, normal, etc...)
  24827. * @returns true if data is present
  24828. */
  24829. isVerticesDataPresent(kind: string): boolean;
  24830. /**
  24831. * Gets a list of all attached data kinds (Position, normal, etc...)
  24832. * @returns a list of string containing all kinds
  24833. */
  24834. getVerticesDataKinds(): string[];
  24835. /**
  24836. * Update index buffer
  24837. * @param indices defines the indices to store in the index buffer
  24838. * @param offset defines the offset in the target buffer where to store the data
  24839. * @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)
  24840. */
  24841. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24842. /**
  24843. * Creates a new index buffer
  24844. * @param indices defines the indices to store in the index buffer
  24845. * @param totalVertices defines the total number of vertices (could be null)
  24846. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24847. */
  24848. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24849. /**
  24850. * Return the total number of indices
  24851. * @returns the total number of indices
  24852. */
  24853. getTotalIndices(): number;
  24854. /**
  24855. * Gets the index buffer array
  24856. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24857. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24858. * @returns the index buffer array
  24859. */
  24860. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24861. /**
  24862. * Gets the index buffer
  24863. * @return the index buffer
  24864. */
  24865. getIndexBuffer(): Nullable<DataBuffer>;
  24866. /** @hidden */
  24867. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24868. /**
  24869. * Release the associated resources for a specific mesh
  24870. * @param mesh defines the source mesh
  24871. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24872. */
  24873. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24874. /**
  24875. * Apply current geometry to a given mesh
  24876. * @param mesh defines the mesh to apply geometry to
  24877. */
  24878. applyToMesh(mesh: Mesh): void;
  24879. private _updateExtend;
  24880. private _applyToMesh;
  24881. private notifyUpdate;
  24882. /**
  24883. * Load the geometry if it was flagged as delay loaded
  24884. * @param scene defines the hosting scene
  24885. * @param onLoaded defines a callback called when the geometry is loaded
  24886. */
  24887. load(scene: Scene, onLoaded?: () => void): void;
  24888. private _queueLoad;
  24889. /**
  24890. * Invert the geometry to move from a right handed system to a left handed one.
  24891. */
  24892. toLeftHanded(): void;
  24893. /** @hidden */
  24894. _resetPointsArrayCache(): void;
  24895. /** @hidden */
  24896. _generatePointsArray(): boolean;
  24897. /**
  24898. * Gets a value indicating if the geometry is disposed
  24899. * @returns true if the geometry was disposed
  24900. */
  24901. isDisposed(): boolean;
  24902. private _disposeVertexArrayObjects;
  24903. /**
  24904. * Free all associated resources
  24905. */
  24906. dispose(): void;
  24907. /**
  24908. * Clone the current geometry into a new geometry
  24909. * @param id defines the unique ID of the new geometry
  24910. * @returns a new geometry object
  24911. */
  24912. copy(id: string): Geometry;
  24913. /**
  24914. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24915. * @return a JSON representation of the current geometry data (without the vertices data)
  24916. */
  24917. serialize(): any;
  24918. private toNumberArray;
  24919. /**
  24920. * Serialize all vertices data into a JSON oject
  24921. * @returns a JSON representation of the current geometry data
  24922. */
  24923. serializeVerticeData(): any;
  24924. /**
  24925. * Extracts a clone of a mesh geometry
  24926. * @param mesh defines the source mesh
  24927. * @param id defines the unique ID of the new geometry object
  24928. * @returns the new geometry object
  24929. */
  24930. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24931. /**
  24932. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24933. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24934. * Be aware Math.random() could cause collisions, but:
  24935. * "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"
  24936. * @returns a string containing a new GUID
  24937. */
  24938. static RandomId(): string;
  24939. /** @hidden */
  24940. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24941. private static _CleanMatricesWeights;
  24942. /**
  24943. * Create a new geometry from persisted data (Using .babylon file format)
  24944. * @param parsedVertexData defines the persisted data
  24945. * @param scene defines the hosting scene
  24946. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24947. * @returns the new geometry object
  24948. */
  24949. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24950. }
  24951. }
  24952. declare module BABYLON {
  24953. /**
  24954. * Define an interface for all classes that will get and set the data on vertices
  24955. */
  24956. export interface IGetSetVerticesData {
  24957. /**
  24958. * Gets a boolean indicating if specific vertex data is present
  24959. * @param kind defines the vertex data kind to use
  24960. * @returns true is data kind is present
  24961. */
  24962. isVerticesDataPresent(kind: string): boolean;
  24963. /**
  24964. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24965. * @param kind defines the data kind (Position, normal, etc...)
  24966. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24967. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24968. * @returns a float array containing vertex data
  24969. */
  24970. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24971. /**
  24972. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24973. * @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.
  24974. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24975. * @returns the indices array or an empty array if the mesh has no geometry
  24976. */
  24977. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24978. /**
  24979. * Set specific vertex data
  24980. * @param kind defines the data kind (Position, normal, etc...)
  24981. * @param data defines the vertex data to use
  24982. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24983. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24984. */
  24985. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24986. /**
  24987. * Update a specific associated vertex buffer
  24988. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24989. * - VertexBuffer.PositionKind
  24990. * - VertexBuffer.UVKind
  24991. * - VertexBuffer.UV2Kind
  24992. * - VertexBuffer.UV3Kind
  24993. * - VertexBuffer.UV4Kind
  24994. * - VertexBuffer.UV5Kind
  24995. * - VertexBuffer.UV6Kind
  24996. * - VertexBuffer.ColorKind
  24997. * - VertexBuffer.MatricesIndicesKind
  24998. * - VertexBuffer.MatricesIndicesExtraKind
  24999. * - VertexBuffer.MatricesWeightsKind
  25000. * - VertexBuffer.MatricesWeightsExtraKind
  25001. * @param data defines the data source
  25002. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25003. * @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)
  25004. */
  25005. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25006. /**
  25007. * Creates a new index buffer
  25008. * @param indices defines the indices to store in the index buffer
  25009. * @param totalVertices defines the total number of vertices (could be null)
  25010. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25011. */
  25012. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25013. }
  25014. /**
  25015. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25016. */
  25017. export class VertexData {
  25018. /**
  25019. * Mesh side orientation : usually the external or front surface
  25020. */
  25021. static readonly FRONTSIDE: number;
  25022. /**
  25023. * Mesh side orientation : usually the internal or back surface
  25024. */
  25025. static readonly BACKSIDE: number;
  25026. /**
  25027. * Mesh side orientation : both internal and external or front and back surfaces
  25028. */
  25029. static readonly DOUBLESIDE: number;
  25030. /**
  25031. * Mesh side orientation : by default, `FRONTSIDE`
  25032. */
  25033. static readonly DEFAULTSIDE: number;
  25034. /**
  25035. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25036. */
  25037. positions: Nullable<FloatArray>;
  25038. /**
  25039. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25040. */
  25041. normals: Nullable<FloatArray>;
  25042. /**
  25043. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25044. */
  25045. tangents: Nullable<FloatArray>;
  25046. /**
  25047. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25048. */
  25049. uvs: Nullable<FloatArray>;
  25050. /**
  25051. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25052. */
  25053. uvs2: Nullable<FloatArray>;
  25054. /**
  25055. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25056. */
  25057. uvs3: Nullable<FloatArray>;
  25058. /**
  25059. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25060. */
  25061. uvs4: Nullable<FloatArray>;
  25062. /**
  25063. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25064. */
  25065. uvs5: Nullable<FloatArray>;
  25066. /**
  25067. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25068. */
  25069. uvs6: Nullable<FloatArray>;
  25070. /**
  25071. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25072. */
  25073. colors: Nullable<FloatArray>;
  25074. /**
  25075. * 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).
  25076. */
  25077. matricesIndices: Nullable<FloatArray>;
  25078. /**
  25079. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25080. */
  25081. matricesWeights: Nullable<FloatArray>;
  25082. /**
  25083. * An array extending the number of possible indices
  25084. */
  25085. matricesIndicesExtra: Nullable<FloatArray>;
  25086. /**
  25087. * An array extending the number of possible weights when the number of indices is extended
  25088. */
  25089. matricesWeightsExtra: Nullable<FloatArray>;
  25090. /**
  25091. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25092. */
  25093. indices: Nullable<IndicesArray>;
  25094. /**
  25095. * Uses the passed data array to set the set the values for the specified kind of data
  25096. * @param data a linear array of floating numbers
  25097. * @param kind the type of data that is being set, eg positions, colors etc
  25098. */
  25099. set(data: FloatArray, kind: string): void;
  25100. /**
  25101. * Associates the vertexData to the passed Mesh.
  25102. * Sets it as updatable or not (default `false`)
  25103. * @param mesh the mesh the vertexData is applied to
  25104. * @param updatable when used and having the value true allows new data to update the vertexData
  25105. * @returns the VertexData
  25106. */
  25107. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25108. /**
  25109. * Associates the vertexData to the passed Geometry.
  25110. * Sets it as updatable or not (default `false`)
  25111. * @param geometry the geometry the vertexData is applied to
  25112. * @param updatable when used and having the value true allows new data to update the vertexData
  25113. * @returns VertexData
  25114. */
  25115. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25116. /**
  25117. * Updates the associated mesh
  25118. * @param mesh the mesh to be updated
  25119. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25120. * @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
  25121. * @returns VertexData
  25122. */
  25123. updateMesh(mesh: Mesh): VertexData;
  25124. /**
  25125. * Updates the associated geometry
  25126. * @param geometry the geometry to be updated
  25127. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25128. * @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
  25129. * @returns VertexData.
  25130. */
  25131. updateGeometry(geometry: Geometry): VertexData;
  25132. private _applyTo;
  25133. private _update;
  25134. /**
  25135. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25136. * @param matrix the transforming matrix
  25137. * @returns the VertexData
  25138. */
  25139. transform(matrix: Matrix): VertexData;
  25140. /**
  25141. * Merges the passed VertexData into the current one
  25142. * @param other the VertexData to be merged into the current one
  25143. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25144. * @returns the modified VertexData
  25145. */
  25146. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25147. private _mergeElement;
  25148. private _validate;
  25149. /**
  25150. * Serializes the VertexData
  25151. * @returns a serialized object
  25152. */
  25153. serialize(): any;
  25154. /**
  25155. * Extracts the vertexData from a mesh
  25156. * @param mesh the mesh from which to extract the VertexData
  25157. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25158. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25159. * @returns the object VertexData associated to the passed mesh
  25160. */
  25161. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25162. /**
  25163. * Extracts the vertexData from the geometry
  25164. * @param geometry the geometry from which to extract the VertexData
  25165. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25166. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25167. * @returns the object VertexData associated to the passed mesh
  25168. */
  25169. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25170. private static _ExtractFrom;
  25171. /**
  25172. * Creates the VertexData for a Ribbon
  25173. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25174. * * pathArray array of paths, each of which an array of successive Vector3
  25175. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25176. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25177. * * 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
  25178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25179. * * 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)
  25180. * * 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)
  25181. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25182. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25183. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25184. * @returns the VertexData of the ribbon
  25185. */
  25186. static CreateRibbon(options: {
  25187. pathArray: Vector3[][];
  25188. closeArray?: boolean;
  25189. closePath?: boolean;
  25190. offset?: number;
  25191. sideOrientation?: number;
  25192. frontUVs?: Vector4;
  25193. backUVs?: Vector4;
  25194. invertUV?: boolean;
  25195. uvs?: Vector2[];
  25196. colors?: Color4[];
  25197. }): VertexData;
  25198. /**
  25199. * Creates the VertexData for a box
  25200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25201. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25202. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25203. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25204. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25205. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25206. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25208. * * 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)
  25209. * * 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)
  25210. * @returns the VertexData of the box
  25211. */
  25212. static CreateBox(options: {
  25213. size?: number;
  25214. width?: number;
  25215. height?: number;
  25216. depth?: number;
  25217. faceUV?: Vector4[];
  25218. faceColors?: Color4[];
  25219. sideOrientation?: number;
  25220. frontUVs?: Vector4;
  25221. backUVs?: Vector4;
  25222. }): VertexData;
  25223. /**
  25224. * Creates the VertexData for a tiled box
  25225. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25226. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25227. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25228. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25229. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25230. * @returns the VertexData of the box
  25231. */
  25232. static CreateTiledBox(options: {
  25233. pattern?: number;
  25234. width?: number;
  25235. height?: number;
  25236. depth?: number;
  25237. tileSize?: number;
  25238. tileWidth?: number;
  25239. tileHeight?: number;
  25240. alignHorizontal?: number;
  25241. alignVertical?: number;
  25242. faceUV?: Vector4[];
  25243. faceColors?: Color4[];
  25244. sideOrientation?: number;
  25245. }): VertexData;
  25246. /**
  25247. * Creates the VertexData for a tiled plane
  25248. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25249. * * pattern a limited pattern arrangement depending on the number
  25250. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25251. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25252. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25254. * * 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)
  25255. * * 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)
  25256. * @returns the VertexData of the tiled plane
  25257. */
  25258. static CreateTiledPlane(options: {
  25259. pattern?: number;
  25260. tileSize?: number;
  25261. tileWidth?: number;
  25262. tileHeight?: number;
  25263. size?: number;
  25264. width?: number;
  25265. height?: number;
  25266. alignHorizontal?: number;
  25267. alignVertical?: number;
  25268. sideOrientation?: number;
  25269. frontUVs?: Vector4;
  25270. backUVs?: Vector4;
  25271. }): VertexData;
  25272. /**
  25273. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25274. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25275. * * segments sets the number of horizontal strips optional, default 32
  25276. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25277. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25278. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25279. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25280. * * 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
  25281. * * 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
  25282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25283. * * 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)
  25284. * * 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)
  25285. * @returns the VertexData of the ellipsoid
  25286. */
  25287. static CreateSphere(options: {
  25288. segments?: number;
  25289. diameter?: number;
  25290. diameterX?: number;
  25291. diameterY?: number;
  25292. diameterZ?: number;
  25293. arc?: number;
  25294. slice?: number;
  25295. sideOrientation?: number;
  25296. frontUVs?: Vector4;
  25297. backUVs?: Vector4;
  25298. }): VertexData;
  25299. /**
  25300. * Creates the VertexData for a cylinder, cone or prism
  25301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25302. * * height sets the height (y direction) of the cylinder, optional, default 2
  25303. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25304. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25305. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25306. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25307. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25308. * * 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
  25309. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25310. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25311. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25312. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25313. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25314. * * 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)
  25315. * * 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)
  25316. * @returns the VertexData of the cylinder, cone or prism
  25317. */
  25318. static CreateCylinder(options: {
  25319. height?: number;
  25320. diameterTop?: number;
  25321. diameterBottom?: number;
  25322. diameter?: number;
  25323. tessellation?: number;
  25324. subdivisions?: number;
  25325. arc?: number;
  25326. faceColors?: Color4[];
  25327. faceUV?: Vector4[];
  25328. hasRings?: boolean;
  25329. enclose?: boolean;
  25330. sideOrientation?: number;
  25331. frontUVs?: Vector4;
  25332. backUVs?: Vector4;
  25333. }): VertexData;
  25334. /**
  25335. * Creates the VertexData for a torus
  25336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25337. * * diameter the diameter of the torus, optional default 1
  25338. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25339. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25341. * * 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)
  25342. * * 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)
  25343. * @returns the VertexData of the torus
  25344. */
  25345. static CreateTorus(options: {
  25346. diameter?: number;
  25347. thickness?: number;
  25348. tessellation?: number;
  25349. sideOrientation?: number;
  25350. frontUVs?: Vector4;
  25351. backUVs?: Vector4;
  25352. }): VertexData;
  25353. /**
  25354. * Creates the VertexData of the LineSystem
  25355. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25356. * - lines an array of lines, each line being an array of successive Vector3
  25357. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25358. * @returns the VertexData of the LineSystem
  25359. */
  25360. static CreateLineSystem(options: {
  25361. lines: Vector3[][];
  25362. colors?: Nullable<Color4[][]>;
  25363. }): VertexData;
  25364. /**
  25365. * Create the VertexData for a DashedLines
  25366. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25367. * - points an array successive Vector3
  25368. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25369. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25370. * - dashNb the intended total number of dashes, optional, default 200
  25371. * @returns the VertexData for the DashedLines
  25372. */
  25373. static CreateDashedLines(options: {
  25374. points: Vector3[];
  25375. dashSize?: number;
  25376. gapSize?: number;
  25377. dashNb?: number;
  25378. }): VertexData;
  25379. /**
  25380. * Creates the VertexData for a Ground
  25381. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25382. * - width the width (x direction) of the ground, optional, default 1
  25383. * - height the height (z direction) of the ground, optional, default 1
  25384. * - subdivisions the number of subdivisions per side, optional, default 1
  25385. * @returns the VertexData of the Ground
  25386. */
  25387. static CreateGround(options: {
  25388. width?: number;
  25389. height?: number;
  25390. subdivisions?: number;
  25391. subdivisionsX?: number;
  25392. subdivisionsY?: number;
  25393. }): VertexData;
  25394. /**
  25395. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25397. * * xmin the ground minimum X coordinate, optional, default -1
  25398. * * zmin the ground minimum Z coordinate, optional, default -1
  25399. * * xmax the ground maximum X coordinate, optional, default 1
  25400. * * zmax the ground maximum Z coordinate, optional, default 1
  25401. * * 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}
  25402. * * 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}
  25403. * @returns the VertexData of the TiledGround
  25404. */
  25405. static CreateTiledGround(options: {
  25406. xmin: number;
  25407. zmin: number;
  25408. xmax: number;
  25409. zmax: number;
  25410. subdivisions?: {
  25411. w: number;
  25412. h: number;
  25413. };
  25414. precision?: {
  25415. w: number;
  25416. h: number;
  25417. };
  25418. }): VertexData;
  25419. /**
  25420. * Creates the VertexData of the Ground designed from a heightmap
  25421. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25422. * * width the width (x direction) of the ground
  25423. * * height the height (z direction) of the ground
  25424. * * subdivisions the number of subdivisions per side
  25425. * * minHeight the minimum altitude on the ground, optional, default 0
  25426. * * maxHeight the maximum altitude on the ground, optional default 1
  25427. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25428. * * buffer the array holding the image color data
  25429. * * bufferWidth the width of image
  25430. * * bufferHeight the height of image
  25431. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25432. * @returns the VertexData of the Ground designed from a heightmap
  25433. */
  25434. static CreateGroundFromHeightMap(options: {
  25435. width: number;
  25436. height: number;
  25437. subdivisions: number;
  25438. minHeight: number;
  25439. maxHeight: number;
  25440. colorFilter: Color3;
  25441. buffer: Uint8Array;
  25442. bufferWidth: number;
  25443. bufferHeight: number;
  25444. alphaFilter: number;
  25445. }): VertexData;
  25446. /**
  25447. * Creates the VertexData for a Plane
  25448. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25449. * * size sets the width and height of the plane to the value of size, optional default 1
  25450. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25451. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25453. * * 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)
  25454. * * 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)
  25455. * @returns the VertexData of the box
  25456. */
  25457. static CreatePlane(options: {
  25458. size?: number;
  25459. width?: number;
  25460. height?: number;
  25461. sideOrientation?: number;
  25462. frontUVs?: Vector4;
  25463. backUVs?: Vector4;
  25464. }): VertexData;
  25465. /**
  25466. * Creates the VertexData of the Disc or regular Polygon
  25467. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25468. * * radius the radius of the disc, optional default 0.5
  25469. * * tessellation the number of polygon sides, optional, default 64
  25470. * * 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
  25471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25472. * * 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)
  25473. * * 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)
  25474. * @returns the VertexData of the box
  25475. */
  25476. static CreateDisc(options: {
  25477. radius?: number;
  25478. tessellation?: number;
  25479. arc?: number;
  25480. sideOrientation?: number;
  25481. frontUVs?: Vector4;
  25482. backUVs?: Vector4;
  25483. }): VertexData;
  25484. /**
  25485. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25486. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25487. * @param polygon a mesh built from polygonTriangulation.build()
  25488. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25489. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25490. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25491. * @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)
  25492. * @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)
  25493. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25494. * @returns the VertexData of the Polygon
  25495. */
  25496. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25497. /**
  25498. * Creates the VertexData of the IcoSphere
  25499. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25500. * * radius the radius of the IcoSphere, optional default 1
  25501. * * radiusX allows stretching in the x direction, optional, default radius
  25502. * * radiusY allows stretching in the y direction, optional, default radius
  25503. * * radiusZ allows stretching in the z direction, optional, default radius
  25504. * * flat when true creates a flat shaded mesh, optional, default true
  25505. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25507. * * 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)
  25508. * * 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)
  25509. * @returns the VertexData of the IcoSphere
  25510. */
  25511. static CreateIcoSphere(options: {
  25512. radius?: number;
  25513. radiusX?: number;
  25514. radiusY?: number;
  25515. radiusZ?: number;
  25516. flat?: boolean;
  25517. subdivisions?: number;
  25518. sideOrientation?: number;
  25519. frontUVs?: Vector4;
  25520. backUVs?: Vector4;
  25521. }): VertexData;
  25522. /**
  25523. * Creates the VertexData for a Polyhedron
  25524. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25525. * * type provided types are:
  25526. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25527. * * 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)
  25528. * * size the size of the IcoSphere, optional default 1
  25529. * * sizeX allows stretching in the x direction, optional, default size
  25530. * * sizeY allows stretching in the y direction, optional, default size
  25531. * * sizeZ allows stretching in the z direction, optional, default size
  25532. * * 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
  25533. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25534. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25535. * * flat when true creates a flat shaded mesh, optional, default true
  25536. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25538. * * 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)
  25539. * * 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)
  25540. * @returns the VertexData of the Polyhedron
  25541. */
  25542. static CreatePolyhedron(options: {
  25543. type?: number;
  25544. size?: number;
  25545. sizeX?: number;
  25546. sizeY?: number;
  25547. sizeZ?: number;
  25548. custom?: any;
  25549. faceUV?: Vector4[];
  25550. faceColors?: Color4[];
  25551. flat?: boolean;
  25552. sideOrientation?: number;
  25553. frontUVs?: Vector4;
  25554. backUVs?: Vector4;
  25555. }): VertexData;
  25556. /**
  25557. * Creates the VertexData for a TorusKnot
  25558. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25559. * * radius the radius of the torus knot, optional, default 2
  25560. * * tube the thickness of the tube, optional, default 0.5
  25561. * * radialSegments the number of sides on each tube segments, optional, default 32
  25562. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25563. * * p the number of windings around the z axis, optional, default 2
  25564. * * q the number of windings around the x axis, optional, default 3
  25565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25566. * * 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)
  25567. * * 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)
  25568. * @returns the VertexData of the Torus Knot
  25569. */
  25570. static CreateTorusKnot(options: {
  25571. radius?: number;
  25572. tube?: number;
  25573. radialSegments?: number;
  25574. tubularSegments?: number;
  25575. p?: number;
  25576. q?: number;
  25577. sideOrientation?: number;
  25578. frontUVs?: Vector4;
  25579. backUVs?: Vector4;
  25580. }): VertexData;
  25581. /**
  25582. * Compute normals for given positions and indices
  25583. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25584. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25585. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25586. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25587. * * facetNormals : optional array of facet normals (vector3)
  25588. * * facetPositions : optional array of facet positions (vector3)
  25589. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25590. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25591. * * bInfo : optional bounding info, required for facetPartitioning computation
  25592. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25593. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25594. * * useRightHandedSystem: optional boolean to for right handed system computation
  25595. * * depthSort : optional boolean to enable the facet depth sort computation
  25596. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25597. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25598. */
  25599. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25600. facetNormals?: any;
  25601. facetPositions?: any;
  25602. facetPartitioning?: any;
  25603. ratio?: number;
  25604. bInfo?: any;
  25605. bbSize?: Vector3;
  25606. subDiv?: any;
  25607. useRightHandedSystem?: boolean;
  25608. depthSort?: boolean;
  25609. distanceTo?: Vector3;
  25610. depthSortedFacets?: any;
  25611. }): void;
  25612. /** @hidden */
  25613. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25614. /**
  25615. * Applies VertexData created from the imported parameters to the geometry
  25616. * @param parsedVertexData the parsed data from an imported file
  25617. * @param geometry the geometry to apply the VertexData to
  25618. */
  25619. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25620. }
  25621. }
  25622. declare module BABYLON {
  25623. /**
  25624. * Defines a target to use with MorphTargetManager
  25625. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25626. */
  25627. export class MorphTarget implements IAnimatable {
  25628. /** defines the name of the target */
  25629. name: string;
  25630. /**
  25631. * Gets or sets the list of animations
  25632. */
  25633. animations: Animation[];
  25634. private _scene;
  25635. private _positions;
  25636. private _normals;
  25637. private _tangents;
  25638. private _uvs;
  25639. private _influence;
  25640. private _uniqueId;
  25641. /**
  25642. * Observable raised when the influence changes
  25643. */
  25644. onInfluenceChanged: Observable<boolean>;
  25645. /** @hidden */
  25646. _onDataLayoutChanged: Observable<void>;
  25647. /**
  25648. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25649. */
  25650. get influence(): number;
  25651. set influence(influence: number);
  25652. /**
  25653. * Gets or sets the id of the morph Target
  25654. */
  25655. id: string;
  25656. private _animationPropertiesOverride;
  25657. /**
  25658. * Gets or sets the animation properties override
  25659. */
  25660. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25661. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25662. /**
  25663. * Creates a new MorphTarget
  25664. * @param name defines the name of the target
  25665. * @param influence defines the influence to use
  25666. * @param scene defines the scene the morphtarget belongs to
  25667. */
  25668. constructor(
  25669. /** defines the name of the target */
  25670. name: string, influence?: number, scene?: Nullable<Scene>);
  25671. /**
  25672. * Gets the unique ID of this manager
  25673. */
  25674. get uniqueId(): number;
  25675. /**
  25676. * Gets a boolean defining if the target contains position data
  25677. */
  25678. get hasPositions(): boolean;
  25679. /**
  25680. * Gets a boolean defining if the target contains normal data
  25681. */
  25682. get hasNormals(): boolean;
  25683. /**
  25684. * Gets a boolean defining if the target contains tangent data
  25685. */
  25686. get hasTangents(): boolean;
  25687. /**
  25688. * Gets a boolean defining if the target contains texture coordinates data
  25689. */
  25690. get hasUVs(): boolean;
  25691. /**
  25692. * Affects position data to this target
  25693. * @param data defines the position data to use
  25694. */
  25695. setPositions(data: Nullable<FloatArray>): void;
  25696. /**
  25697. * Gets the position data stored in this target
  25698. * @returns a FloatArray containing the position data (or null if not present)
  25699. */
  25700. getPositions(): Nullable<FloatArray>;
  25701. /**
  25702. * Affects normal data to this target
  25703. * @param data defines the normal data to use
  25704. */
  25705. setNormals(data: Nullable<FloatArray>): void;
  25706. /**
  25707. * Gets the normal data stored in this target
  25708. * @returns a FloatArray containing the normal data (or null if not present)
  25709. */
  25710. getNormals(): Nullable<FloatArray>;
  25711. /**
  25712. * Affects tangent data to this target
  25713. * @param data defines the tangent data to use
  25714. */
  25715. setTangents(data: Nullable<FloatArray>): void;
  25716. /**
  25717. * Gets the tangent data stored in this target
  25718. * @returns a FloatArray containing the tangent data (or null if not present)
  25719. */
  25720. getTangents(): Nullable<FloatArray>;
  25721. /**
  25722. * Affects texture coordinates data to this target
  25723. * @param data defines the texture coordinates data to use
  25724. */
  25725. setUVs(data: Nullable<FloatArray>): void;
  25726. /**
  25727. * Gets the texture coordinates data stored in this target
  25728. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25729. */
  25730. getUVs(): Nullable<FloatArray>;
  25731. /**
  25732. * Clone the current target
  25733. * @returns a new MorphTarget
  25734. */
  25735. clone(): MorphTarget;
  25736. /**
  25737. * Serializes the current target into a Serialization object
  25738. * @returns the serialized object
  25739. */
  25740. serialize(): any;
  25741. /**
  25742. * Returns the string "MorphTarget"
  25743. * @returns "MorphTarget"
  25744. */
  25745. getClassName(): string;
  25746. /**
  25747. * Creates a new target from serialized data
  25748. * @param serializationObject defines the serialized data to use
  25749. * @returns a new MorphTarget
  25750. */
  25751. static Parse(serializationObject: any): MorphTarget;
  25752. /**
  25753. * Creates a MorphTarget from mesh data
  25754. * @param mesh defines the source mesh
  25755. * @param name defines the name to use for the new target
  25756. * @param influence defines the influence to attach to the target
  25757. * @returns a new MorphTarget
  25758. */
  25759. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25760. }
  25761. }
  25762. declare module BABYLON {
  25763. /**
  25764. * This class is used to deform meshes using morphing between different targets
  25765. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25766. */
  25767. export class MorphTargetManager {
  25768. private _targets;
  25769. private _targetInfluenceChangedObservers;
  25770. private _targetDataLayoutChangedObservers;
  25771. private _activeTargets;
  25772. private _scene;
  25773. private _influences;
  25774. private _supportsNormals;
  25775. private _supportsTangents;
  25776. private _supportsUVs;
  25777. private _vertexCount;
  25778. private _uniqueId;
  25779. private _tempInfluences;
  25780. /**
  25781. * Gets or sets a boolean indicating if normals must be morphed
  25782. */
  25783. enableNormalMorphing: boolean;
  25784. /**
  25785. * Gets or sets a boolean indicating if tangents must be morphed
  25786. */
  25787. enableTangentMorphing: boolean;
  25788. /**
  25789. * Gets or sets a boolean indicating if UV must be morphed
  25790. */
  25791. enableUVMorphing: boolean;
  25792. /**
  25793. * Creates a new MorphTargetManager
  25794. * @param scene defines the current scene
  25795. */
  25796. constructor(scene?: Nullable<Scene>);
  25797. /**
  25798. * Gets the unique ID of this manager
  25799. */
  25800. get uniqueId(): number;
  25801. /**
  25802. * Gets the number of vertices handled by this manager
  25803. */
  25804. get vertexCount(): number;
  25805. /**
  25806. * Gets a boolean indicating if this manager supports morphing of normals
  25807. */
  25808. get supportsNormals(): boolean;
  25809. /**
  25810. * Gets a boolean indicating if this manager supports morphing of tangents
  25811. */
  25812. get supportsTangents(): boolean;
  25813. /**
  25814. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25815. */
  25816. get supportsUVs(): boolean;
  25817. /**
  25818. * Gets the number of targets stored in this manager
  25819. */
  25820. get numTargets(): number;
  25821. /**
  25822. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25823. */
  25824. get numInfluencers(): number;
  25825. /**
  25826. * Gets the list of influences (one per target)
  25827. */
  25828. get influences(): Float32Array;
  25829. /**
  25830. * Gets the active target at specified index. An active target is a target with an influence > 0
  25831. * @param index defines the index to check
  25832. * @returns the requested target
  25833. */
  25834. getActiveTarget(index: number): MorphTarget;
  25835. /**
  25836. * Gets the target at specified index
  25837. * @param index defines the index to check
  25838. * @returns the requested target
  25839. */
  25840. getTarget(index: number): MorphTarget;
  25841. /**
  25842. * Add a new target to this manager
  25843. * @param target defines the target to add
  25844. */
  25845. addTarget(target: MorphTarget): void;
  25846. /**
  25847. * Removes a target from the manager
  25848. * @param target defines the target to remove
  25849. */
  25850. removeTarget(target: MorphTarget): void;
  25851. /**
  25852. * Clone the current manager
  25853. * @returns a new MorphTargetManager
  25854. */
  25855. clone(): MorphTargetManager;
  25856. /**
  25857. * Serializes the current manager into a Serialization object
  25858. * @returns the serialized object
  25859. */
  25860. serialize(): any;
  25861. private _syncActiveTargets;
  25862. /**
  25863. * Syncrhonize the targets with all the meshes using this morph target manager
  25864. */
  25865. synchronize(): void;
  25866. /**
  25867. * Creates a new MorphTargetManager from serialized data
  25868. * @param serializationObject defines the serialized data
  25869. * @param scene defines the hosting scene
  25870. * @returns the new MorphTargetManager
  25871. */
  25872. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25873. }
  25874. }
  25875. declare module BABYLON {
  25876. /**
  25877. * Class used to represent a specific level of detail of a mesh
  25878. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25879. */
  25880. export class MeshLODLevel {
  25881. /** Defines the distance where this level should start being displayed */
  25882. distance: number;
  25883. /** Defines the mesh to use to render this level */
  25884. mesh: Nullable<Mesh>;
  25885. /**
  25886. * Creates a new LOD level
  25887. * @param distance defines the distance where this level should star being displayed
  25888. * @param mesh defines the mesh to use to render this level
  25889. */
  25890. constructor(
  25891. /** Defines the distance where this level should start being displayed */
  25892. distance: number,
  25893. /** Defines the mesh to use to render this level */
  25894. mesh: Nullable<Mesh>);
  25895. }
  25896. }
  25897. declare module BABYLON {
  25898. /**
  25899. * Mesh representing the gorund
  25900. */
  25901. export class GroundMesh extends Mesh {
  25902. /** If octree should be generated */
  25903. generateOctree: boolean;
  25904. private _heightQuads;
  25905. /** @hidden */
  25906. _subdivisionsX: number;
  25907. /** @hidden */
  25908. _subdivisionsY: number;
  25909. /** @hidden */
  25910. _width: number;
  25911. /** @hidden */
  25912. _height: number;
  25913. /** @hidden */
  25914. _minX: number;
  25915. /** @hidden */
  25916. _maxX: number;
  25917. /** @hidden */
  25918. _minZ: number;
  25919. /** @hidden */
  25920. _maxZ: number;
  25921. constructor(name: string, scene: Scene);
  25922. /**
  25923. * "GroundMesh"
  25924. * @returns "GroundMesh"
  25925. */
  25926. getClassName(): string;
  25927. /**
  25928. * The minimum of x and y subdivisions
  25929. */
  25930. get subdivisions(): number;
  25931. /**
  25932. * X subdivisions
  25933. */
  25934. get subdivisionsX(): number;
  25935. /**
  25936. * Y subdivisions
  25937. */
  25938. get subdivisionsY(): number;
  25939. /**
  25940. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25941. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25942. * @param chunksCount the number of subdivisions for x and y
  25943. * @param octreeBlocksSize (Default: 32)
  25944. */
  25945. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25946. /**
  25947. * Returns a height (y) value in the Worl system :
  25948. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25949. * @param x x coordinate
  25950. * @param z z coordinate
  25951. * @returns the ground y position if (x, z) are outside the ground surface.
  25952. */
  25953. getHeightAtCoordinates(x: number, z: number): number;
  25954. /**
  25955. * Returns a normalized vector (Vector3) orthogonal to the ground
  25956. * at the ground coordinates (x, z) expressed in the World system.
  25957. * @param x x coordinate
  25958. * @param z z coordinate
  25959. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25960. */
  25961. getNormalAtCoordinates(x: number, z: number): Vector3;
  25962. /**
  25963. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25964. * at the ground coordinates (x, z) expressed in the World system.
  25965. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25966. * @param x x coordinate
  25967. * @param z z coordinate
  25968. * @param ref vector to store the result
  25969. * @returns the GroundMesh.
  25970. */
  25971. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25972. /**
  25973. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25974. * if the ground has been updated.
  25975. * This can be used in the render loop.
  25976. * @returns the GroundMesh.
  25977. */
  25978. updateCoordinateHeights(): GroundMesh;
  25979. private _getFacetAt;
  25980. private _initHeightQuads;
  25981. private _computeHeightQuads;
  25982. /**
  25983. * Serializes this ground mesh
  25984. * @param serializationObject object to write serialization to
  25985. */
  25986. serialize(serializationObject: any): void;
  25987. /**
  25988. * Parses a serialized ground mesh
  25989. * @param parsedMesh the serialized mesh
  25990. * @param scene the scene to create the ground mesh in
  25991. * @returns the created ground mesh
  25992. */
  25993. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25994. }
  25995. }
  25996. declare module BABYLON {
  25997. /**
  25998. * Interface for Physics-Joint data
  25999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26000. */
  26001. export interface PhysicsJointData {
  26002. /**
  26003. * The main pivot of the joint
  26004. */
  26005. mainPivot?: Vector3;
  26006. /**
  26007. * The connected pivot of the joint
  26008. */
  26009. connectedPivot?: Vector3;
  26010. /**
  26011. * The main axis of the joint
  26012. */
  26013. mainAxis?: Vector3;
  26014. /**
  26015. * The connected axis of the joint
  26016. */
  26017. connectedAxis?: Vector3;
  26018. /**
  26019. * The collision of the joint
  26020. */
  26021. collision?: boolean;
  26022. /**
  26023. * Native Oimo/Cannon/Energy data
  26024. */
  26025. nativeParams?: any;
  26026. }
  26027. /**
  26028. * This is a holder class for the physics joint created by the physics plugin
  26029. * It holds a set of functions to control the underlying joint
  26030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26031. */
  26032. export class PhysicsJoint {
  26033. /**
  26034. * The type of the physics joint
  26035. */
  26036. type: number;
  26037. /**
  26038. * The data for the physics joint
  26039. */
  26040. jointData: PhysicsJointData;
  26041. private _physicsJoint;
  26042. protected _physicsPlugin: IPhysicsEnginePlugin;
  26043. /**
  26044. * Initializes the physics joint
  26045. * @param type The type of the physics joint
  26046. * @param jointData The data for the physics joint
  26047. */
  26048. constructor(
  26049. /**
  26050. * The type of the physics joint
  26051. */
  26052. type: number,
  26053. /**
  26054. * The data for the physics joint
  26055. */
  26056. jointData: PhysicsJointData);
  26057. /**
  26058. * Gets the physics joint
  26059. */
  26060. get physicsJoint(): any;
  26061. /**
  26062. * Sets the physics joint
  26063. */
  26064. set physicsJoint(newJoint: any);
  26065. /**
  26066. * Sets the physics plugin
  26067. */
  26068. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26069. /**
  26070. * Execute a function that is physics-plugin specific.
  26071. * @param {Function} func the function that will be executed.
  26072. * It accepts two parameters: the physics world and the physics joint
  26073. */
  26074. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26075. /**
  26076. * Distance-Joint type
  26077. */
  26078. static DistanceJoint: number;
  26079. /**
  26080. * Hinge-Joint type
  26081. */
  26082. static HingeJoint: number;
  26083. /**
  26084. * Ball-and-Socket joint type
  26085. */
  26086. static BallAndSocketJoint: number;
  26087. /**
  26088. * Wheel-Joint type
  26089. */
  26090. static WheelJoint: number;
  26091. /**
  26092. * Slider-Joint type
  26093. */
  26094. static SliderJoint: number;
  26095. /**
  26096. * Prismatic-Joint type
  26097. */
  26098. static PrismaticJoint: number;
  26099. /**
  26100. * Universal-Joint type
  26101. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26102. */
  26103. static UniversalJoint: number;
  26104. /**
  26105. * Hinge-Joint 2 type
  26106. */
  26107. static Hinge2Joint: number;
  26108. /**
  26109. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26110. */
  26111. static PointToPointJoint: number;
  26112. /**
  26113. * Spring-Joint type
  26114. */
  26115. static SpringJoint: number;
  26116. /**
  26117. * Lock-Joint type
  26118. */
  26119. static LockJoint: number;
  26120. }
  26121. /**
  26122. * A class representing a physics distance joint
  26123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26124. */
  26125. export class DistanceJoint extends PhysicsJoint {
  26126. /**
  26127. *
  26128. * @param jointData The data for the Distance-Joint
  26129. */
  26130. constructor(jointData: DistanceJointData);
  26131. /**
  26132. * Update the predefined distance.
  26133. * @param maxDistance The maximum preferred distance
  26134. * @param minDistance The minimum preferred distance
  26135. */
  26136. updateDistance(maxDistance: number, minDistance?: number): void;
  26137. }
  26138. /**
  26139. * Represents a Motor-Enabled Joint
  26140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26141. */
  26142. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26143. /**
  26144. * Initializes the Motor-Enabled Joint
  26145. * @param type The type of the joint
  26146. * @param jointData The physica joint data for the joint
  26147. */
  26148. constructor(type: number, jointData: PhysicsJointData);
  26149. /**
  26150. * Set the motor values.
  26151. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26152. * @param force the force to apply
  26153. * @param maxForce max force for this motor.
  26154. */
  26155. setMotor(force?: number, maxForce?: number): void;
  26156. /**
  26157. * Set the motor's limits.
  26158. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26159. * @param upperLimit The upper limit of the motor
  26160. * @param lowerLimit The lower limit of the motor
  26161. */
  26162. setLimit(upperLimit: number, lowerLimit?: number): void;
  26163. }
  26164. /**
  26165. * This class represents a single physics Hinge-Joint
  26166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26167. */
  26168. export class HingeJoint extends MotorEnabledJoint {
  26169. /**
  26170. * Initializes the Hinge-Joint
  26171. * @param jointData The joint data for the Hinge-Joint
  26172. */
  26173. constructor(jointData: PhysicsJointData);
  26174. /**
  26175. * Set the motor values.
  26176. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26177. * @param {number} force the force to apply
  26178. * @param {number} maxForce max force for this motor.
  26179. */
  26180. setMotor(force?: number, maxForce?: number): void;
  26181. /**
  26182. * Set the motor's limits.
  26183. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26184. * @param upperLimit The upper limit of the motor
  26185. * @param lowerLimit The lower limit of the motor
  26186. */
  26187. setLimit(upperLimit: number, lowerLimit?: number): void;
  26188. }
  26189. /**
  26190. * This class represents a dual hinge physics joint (same as wheel joint)
  26191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26192. */
  26193. export class Hinge2Joint extends MotorEnabledJoint {
  26194. /**
  26195. * Initializes the Hinge2-Joint
  26196. * @param jointData The joint data for the Hinge2-Joint
  26197. */
  26198. constructor(jointData: PhysicsJointData);
  26199. /**
  26200. * Set the motor values.
  26201. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26202. * @param {number} targetSpeed the speed the motor is to reach
  26203. * @param {number} maxForce max force for this motor.
  26204. * @param {motorIndex} the motor's index, 0 or 1.
  26205. */
  26206. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26207. /**
  26208. * Set the motor limits.
  26209. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26210. * @param {number} upperLimit the upper limit
  26211. * @param {number} lowerLimit lower limit
  26212. * @param {motorIndex} the motor's index, 0 or 1.
  26213. */
  26214. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26215. }
  26216. /**
  26217. * Interface for a motor enabled joint
  26218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26219. */
  26220. export interface IMotorEnabledJoint {
  26221. /**
  26222. * Physics joint
  26223. */
  26224. physicsJoint: any;
  26225. /**
  26226. * Sets the motor of the motor-enabled joint
  26227. * @param force The force of the motor
  26228. * @param maxForce The maximum force of the motor
  26229. * @param motorIndex The index of the motor
  26230. */
  26231. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26232. /**
  26233. * Sets the limit of the motor
  26234. * @param upperLimit The upper limit of the motor
  26235. * @param lowerLimit The lower limit of the motor
  26236. * @param motorIndex The index of the motor
  26237. */
  26238. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26239. }
  26240. /**
  26241. * Joint data for a Distance-Joint
  26242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26243. */
  26244. export interface DistanceJointData extends PhysicsJointData {
  26245. /**
  26246. * Max distance the 2 joint objects can be apart
  26247. */
  26248. maxDistance: number;
  26249. }
  26250. /**
  26251. * Joint data from a spring joint
  26252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26253. */
  26254. export interface SpringJointData extends PhysicsJointData {
  26255. /**
  26256. * Length of the spring
  26257. */
  26258. length: number;
  26259. /**
  26260. * Stiffness of the spring
  26261. */
  26262. stiffness: number;
  26263. /**
  26264. * Damping of the spring
  26265. */
  26266. damping: number;
  26267. /** this callback will be called when applying the force to the impostors. */
  26268. forceApplicationCallback: () => void;
  26269. }
  26270. }
  26271. declare module BABYLON {
  26272. /**
  26273. * Holds the data for the raycast result
  26274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26275. */
  26276. export class PhysicsRaycastResult {
  26277. private _hasHit;
  26278. private _hitDistance;
  26279. private _hitNormalWorld;
  26280. private _hitPointWorld;
  26281. private _rayFromWorld;
  26282. private _rayToWorld;
  26283. /**
  26284. * Gets if there was a hit
  26285. */
  26286. get hasHit(): boolean;
  26287. /**
  26288. * Gets the distance from the hit
  26289. */
  26290. get hitDistance(): number;
  26291. /**
  26292. * Gets the hit normal/direction in the world
  26293. */
  26294. get hitNormalWorld(): Vector3;
  26295. /**
  26296. * Gets the hit point in the world
  26297. */
  26298. get hitPointWorld(): Vector3;
  26299. /**
  26300. * Gets the ray "start point" of the ray in the world
  26301. */
  26302. get rayFromWorld(): Vector3;
  26303. /**
  26304. * Gets the ray "end point" of the ray in the world
  26305. */
  26306. get rayToWorld(): Vector3;
  26307. /**
  26308. * Sets the hit data (normal & point in world space)
  26309. * @param hitNormalWorld defines the normal in world space
  26310. * @param hitPointWorld defines the point in world space
  26311. */
  26312. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26313. /**
  26314. * Sets the distance from the start point to the hit point
  26315. * @param distance
  26316. */
  26317. setHitDistance(distance: number): void;
  26318. /**
  26319. * Calculates the distance manually
  26320. */
  26321. calculateHitDistance(): void;
  26322. /**
  26323. * Resets all the values to default
  26324. * @param from The from point on world space
  26325. * @param to The to point on world space
  26326. */
  26327. reset(from?: Vector3, to?: Vector3): void;
  26328. }
  26329. /**
  26330. * Interface for the size containing width and height
  26331. */
  26332. interface IXYZ {
  26333. /**
  26334. * X
  26335. */
  26336. x: number;
  26337. /**
  26338. * Y
  26339. */
  26340. y: number;
  26341. /**
  26342. * Z
  26343. */
  26344. z: number;
  26345. }
  26346. }
  26347. declare module BABYLON {
  26348. /**
  26349. * Interface used to describe a physics joint
  26350. */
  26351. export interface PhysicsImpostorJoint {
  26352. /** Defines the main impostor to which the joint is linked */
  26353. mainImpostor: PhysicsImpostor;
  26354. /** Defines the impostor that is connected to the main impostor using this joint */
  26355. connectedImpostor: PhysicsImpostor;
  26356. /** Defines the joint itself */
  26357. joint: PhysicsJoint;
  26358. }
  26359. /** @hidden */
  26360. export interface IPhysicsEnginePlugin {
  26361. world: any;
  26362. name: string;
  26363. setGravity(gravity: Vector3): void;
  26364. setTimeStep(timeStep: number): void;
  26365. getTimeStep(): number;
  26366. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26367. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26368. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26370. removePhysicsBody(impostor: PhysicsImpostor): void;
  26371. generateJoint(joint: PhysicsImpostorJoint): void;
  26372. removeJoint(joint: PhysicsImpostorJoint): void;
  26373. isSupported(): boolean;
  26374. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26375. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26376. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26377. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26378. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26379. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26380. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26381. getBodyMass(impostor: PhysicsImpostor): number;
  26382. getBodyFriction(impostor: PhysicsImpostor): number;
  26383. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26384. getBodyRestitution(impostor: PhysicsImpostor): number;
  26385. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26386. getBodyPressure?(impostor: PhysicsImpostor): number;
  26387. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26388. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26389. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26390. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26391. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26392. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26393. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26394. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26395. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26396. sleepBody(impostor: PhysicsImpostor): void;
  26397. wakeUpBody(impostor: PhysicsImpostor): void;
  26398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26399. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26400. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26401. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26402. getRadius(impostor: PhysicsImpostor): number;
  26403. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26404. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26405. dispose(): void;
  26406. }
  26407. /**
  26408. * Interface used to define a physics engine
  26409. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26410. */
  26411. export interface IPhysicsEngine {
  26412. /**
  26413. * Gets the gravity vector used by the simulation
  26414. */
  26415. gravity: Vector3;
  26416. /**
  26417. * Sets the gravity vector used by the simulation
  26418. * @param gravity defines the gravity vector to use
  26419. */
  26420. setGravity(gravity: Vector3): void;
  26421. /**
  26422. * Set the time step of the physics engine.
  26423. * Default is 1/60.
  26424. * To slow it down, enter 1/600 for example.
  26425. * To speed it up, 1/30
  26426. * @param newTimeStep the new timestep to apply to this world.
  26427. */
  26428. setTimeStep(newTimeStep: number): void;
  26429. /**
  26430. * Get the time step of the physics engine.
  26431. * @returns the current time step
  26432. */
  26433. getTimeStep(): number;
  26434. /**
  26435. * Set the sub time step of the physics engine.
  26436. * Default is 0 meaning there is no sub steps
  26437. * To increase physics resolution precision, set a small value (like 1 ms)
  26438. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26439. */
  26440. setSubTimeStep(subTimeStep: number): void;
  26441. /**
  26442. * Get the sub time step of the physics engine.
  26443. * @returns the current sub time step
  26444. */
  26445. getSubTimeStep(): number;
  26446. /**
  26447. * Release all resources
  26448. */
  26449. dispose(): void;
  26450. /**
  26451. * Gets the name of the current physics plugin
  26452. * @returns the name of the plugin
  26453. */
  26454. getPhysicsPluginName(): string;
  26455. /**
  26456. * Adding a new impostor for the impostor tracking.
  26457. * This will be done by the impostor itself.
  26458. * @param impostor the impostor to add
  26459. */
  26460. addImpostor(impostor: PhysicsImpostor): void;
  26461. /**
  26462. * Remove an impostor from the engine.
  26463. * This impostor and its mesh will not longer be updated by the physics engine.
  26464. * @param impostor the impostor to remove
  26465. */
  26466. removeImpostor(impostor: PhysicsImpostor): void;
  26467. /**
  26468. * Add a joint to the physics engine
  26469. * @param mainImpostor defines the main impostor to which the joint is added.
  26470. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26471. * @param joint defines the joint that will connect both impostors.
  26472. */
  26473. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26474. /**
  26475. * Removes a joint from the simulation
  26476. * @param mainImpostor defines the impostor used with the joint
  26477. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26478. * @param joint defines the joint to remove
  26479. */
  26480. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26481. /**
  26482. * Gets the current plugin used to run the simulation
  26483. * @returns current plugin
  26484. */
  26485. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26486. /**
  26487. * Gets the list of physic impostors
  26488. * @returns an array of PhysicsImpostor
  26489. */
  26490. getImpostors(): Array<PhysicsImpostor>;
  26491. /**
  26492. * Gets the impostor for a physics enabled object
  26493. * @param object defines the object impersonated by the impostor
  26494. * @returns the PhysicsImpostor or null if not found
  26495. */
  26496. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26497. /**
  26498. * Gets the impostor for a physics body object
  26499. * @param body defines physics body used by the impostor
  26500. * @returns the PhysicsImpostor or null if not found
  26501. */
  26502. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26503. /**
  26504. * Does a raycast in the physics world
  26505. * @param from when should the ray start?
  26506. * @param to when should the ray end?
  26507. * @returns PhysicsRaycastResult
  26508. */
  26509. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26510. /**
  26511. * Called by the scene. No need to call it.
  26512. * @param delta defines the timespam between frames
  26513. */
  26514. _step(delta: number): void;
  26515. }
  26516. }
  26517. declare module BABYLON {
  26518. /**
  26519. * The interface for the physics imposter parameters
  26520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26521. */
  26522. export interface PhysicsImpostorParameters {
  26523. /**
  26524. * The mass of the physics imposter
  26525. */
  26526. mass: number;
  26527. /**
  26528. * The friction of the physics imposter
  26529. */
  26530. friction?: number;
  26531. /**
  26532. * The coefficient of restitution of the physics imposter
  26533. */
  26534. restitution?: number;
  26535. /**
  26536. * The native options of the physics imposter
  26537. */
  26538. nativeOptions?: any;
  26539. /**
  26540. * Specifies if the parent should be ignored
  26541. */
  26542. ignoreParent?: boolean;
  26543. /**
  26544. * Specifies if bi-directional transformations should be disabled
  26545. */
  26546. disableBidirectionalTransformation?: boolean;
  26547. /**
  26548. * The pressure inside the physics imposter, soft object only
  26549. */
  26550. pressure?: number;
  26551. /**
  26552. * The stiffness the physics imposter, soft object only
  26553. */
  26554. stiffness?: number;
  26555. /**
  26556. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26557. */
  26558. velocityIterations?: number;
  26559. /**
  26560. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26561. */
  26562. positionIterations?: number;
  26563. /**
  26564. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26565. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26566. * Add to fix multiple points
  26567. */
  26568. fixedPoints?: number;
  26569. /**
  26570. * The collision margin around a soft object
  26571. */
  26572. margin?: number;
  26573. /**
  26574. * The collision margin around a soft object
  26575. */
  26576. damping?: number;
  26577. /**
  26578. * The path for a rope based on an extrusion
  26579. */
  26580. path?: any;
  26581. /**
  26582. * The shape of an extrusion used for a rope based on an extrusion
  26583. */
  26584. shape?: any;
  26585. }
  26586. /**
  26587. * Interface for a physics-enabled object
  26588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26589. */
  26590. export interface IPhysicsEnabledObject {
  26591. /**
  26592. * The position of the physics-enabled object
  26593. */
  26594. position: Vector3;
  26595. /**
  26596. * The rotation of the physics-enabled object
  26597. */
  26598. rotationQuaternion: Nullable<Quaternion>;
  26599. /**
  26600. * The scale of the physics-enabled object
  26601. */
  26602. scaling: Vector3;
  26603. /**
  26604. * The rotation of the physics-enabled object
  26605. */
  26606. rotation?: Vector3;
  26607. /**
  26608. * The parent of the physics-enabled object
  26609. */
  26610. parent?: any;
  26611. /**
  26612. * The bounding info of the physics-enabled object
  26613. * @returns The bounding info of the physics-enabled object
  26614. */
  26615. getBoundingInfo(): BoundingInfo;
  26616. /**
  26617. * Computes the world matrix
  26618. * @param force Specifies if the world matrix should be computed by force
  26619. * @returns A world matrix
  26620. */
  26621. computeWorldMatrix(force: boolean): Matrix;
  26622. /**
  26623. * Gets the world matrix
  26624. * @returns A world matrix
  26625. */
  26626. getWorldMatrix?(): Matrix;
  26627. /**
  26628. * Gets the child meshes
  26629. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26630. * @returns An array of abstract meshes
  26631. */
  26632. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26633. /**
  26634. * Gets the vertex data
  26635. * @param kind The type of vertex data
  26636. * @returns A nullable array of numbers, or a float32 array
  26637. */
  26638. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26639. /**
  26640. * Gets the indices from the mesh
  26641. * @returns A nullable array of index arrays
  26642. */
  26643. getIndices?(): Nullable<IndicesArray>;
  26644. /**
  26645. * Gets the scene from the mesh
  26646. * @returns the indices array or null
  26647. */
  26648. getScene?(): Scene;
  26649. /**
  26650. * Gets the absolute position from the mesh
  26651. * @returns the absolute position
  26652. */
  26653. getAbsolutePosition(): Vector3;
  26654. /**
  26655. * Gets the absolute pivot point from the mesh
  26656. * @returns the absolute pivot point
  26657. */
  26658. getAbsolutePivotPoint(): Vector3;
  26659. /**
  26660. * Rotates the mesh
  26661. * @param axis The axis of rotation
  26662. * @param amount The amount of rotation
  26663. * @param space The space of the rotation
  26664. * @returns The rotation transform node
  26665. */
  26666. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26667. /**
  26668. * Translates the mesh
  26669. * @param axis The axis of translation
  26670. * @param distance The distance of translation
  26671. * @param space The space of the translation
  26672. * @returns The transform node
  26673. */
  26674. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26675. /**
  26676. * Sets the absolute position of the mesh
  26677. * @param absolutePosition The absolute position of the mesh
  26678. * @returns The transform node
  26679. */
  26680. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26681. /**
  26682. * Gets the class name of the mesh
  26683. * @returns The class name
  26684. */
  26685. getClassName(): string;
  26686. }
  26687. /**
  26688. * Represents a physics imposter
  26689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26690. */
  26691. export class PhysicsImpostor {
  26692. /**
  26693. * The physics-enabled object used as the physics imposter
  26694. */
  26695. object: IPhysicsEnabledObject;
  26696. /**
  26697. * The type of the physics imposter
  26698. */
  26699. type: number;
  26700. private _options;
  26701. private _scene?;
  26702. /**
  26703. * The default object size of the imposter
  26704. */
  26705. static DEFAULT_OBJECT_SIZE: Vector3;
  26706. /**
  26707. * The identity quaternion of the imposter
  26708. */
  26709. static IDENTITY_QUATERNION: Quaternion;
  26710. /** @hidden */
  26711. _pluginData: any;
  26712. private _physicsEngine;
  26713. private _physicsBody;
  26714. private _bodyUpdateRequired;
  26715. private _onBeforePhysicsStepCallbacks;
  26716. private _onAfterPhysicsStepCallbacks;
  26717. /** @hidden */
  26718. _onPhysicsCollideCallbacks: Array<{
  26719. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26720. otherImpostors: Array<PhysicsImpostor>;
  26721. }>;
  26722. private _deltaPosition;
  26723. private _deltaRotation;
  26724. private _deltaRotationConjugated;
  26725. /** @hidden */
  26726. _isFromLine: boolean;
  26727. private _parent;
  26728. private _isDisposed;
  26729. private static _tmpVecs;
  26730. private static _tmpQuat;
  26731. /**
  26732. * Specifies if the physics imposter is disposed
  26733. */
  26734. get isDisposed(): boolean;
  26735. /**
  26736. * Gets the mass of the physics imposter
  26737. */
  26738. get mass(): number;
  26739. set mass(value: number);
  26740. /**
  26741. * Gets the coefficient of friction
  26742. */
  26743. get friction(): number;
  26744. /**
  26745. * Sets the coefficient of friction
  26746. */
  26747. set friction(value: number);
  26748. /**
  26749. * Gets the coefficient of restitution
  26750. */
  26751. get restitution(): number;
  26752. /**
  26753. * Sets the coefficient of restitution
  26754. */
  26755. set restitution(value: number);
  26756. /**
  26757. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26758. */
  26759. get pressure(): number;
  26760. /**
  26761. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26762. */
  26763. set pressure(value: number);
  26764. /**
  26765. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26766. */
  26767. get stiffness(): number;
  26768. /**
  26769. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26770. */
  26771. set stiffness(value: number);
  26772. /**
  26773. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26774. */
  26775. get velocityIterations(): number;
  26776. /**
  26777. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26778. */
  26779. set velocityIterations(value: number);
  26780. /**
  26781. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26782. */
  26783. get positionIterations(): number;
  26784. /**
  26785. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26786. */
  26787. set positionIterations(value: number);
  26788. /**
  26789. * The unique id of the physics imposter
  26790. * set by the physics engine when adding this impostor to the array
  26791. */
  26792. uniqueId: number;
  26793. /**
  26794. * @hidden
  26795. */
  26796. soft: boolean;
  26797. /**
  26798. * @hidden
  26799. */
  26800. segments: number;
  26801. private _joints;
  26802. /**
  26803. * Initializes the physics imposter
  26804. * @param object The physics-enabled object used as the physics imposter
  26805. * @param type The type of the physics imposter
  26806. * @param _options The options for the physics imposter
  26807. * @param _scene The Babylon scene
  26808. */
  26809. constructor(
  26810. /**
  26811. * The physics-enabled object used as the physics imposter
  26812. */
  26813. object: IPhysicsEnabledObject,
  26814. /**
  26815. * The type of the physics imposter
  26816. */
  26817. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26818. /**
  26819. * This function will completly initialize this impostor.
  26820. * It will create a new body - but only if this mesh has no parent.
  26821. * If it has, this impostor will not be used other than to define the impostor
  26822. * of the child mesh.
  26823. * @hidden
  26824. */
  26825. _init(): void;
  26826. private _getPhysicsParent;
  26827. /**
  26828. * Should a new body be generated.
  26829. * @returns boolean specifying if body initialization is required
  26830. */
  26831. isBodyInitRequired(): boolean;
  26832. /**
  26833. * Sets the updated scaling
  26834. * @param updated Specifies if the scaling is updated
  26835. */
  26836. setScalingUpdated(): void;
  26837. /**
  26838. * Force a regeneration of this or the parent's impostor's body.
  26839. * Use under cautious - This will remove all joints already implemented.
  26840. */
  26841. forceUpdate(): void;
  26842. /**
  26843. * Gets the body that holds this impostor. Either its own, or its parent.
  26844. */
  26845. get physicsBody(): any;
  26846. /**
  26847. * Get the parent of the physics imposter
  26848. * @returns Physics imposter or null
  26849. */
  26850. get parent(): Nullable<PhysicsImpostor>;
  26851. /**
  26852. * Sets the parent of the physics imposter
  26853. */
  26854. set parent(value: Nullable<PhysicsImpostor>);
  26855. /**
  26856. * Set the physics body. Used mainly by the physics engine/plugin
  26857. */
  26858. set physicsBody(physicsBody: any);
  26859. /**
  26860. * Resets the update flags
  26861. */
  26862. resetUpdateFlags(): void;
  26863. /**
  26864. * Gets the object extend size
  26865. * @returns the object extend size
  26866. */
  26867. getObjectExtendSize(): Vector3;
  26868. /**
  26869. * Gets the object center
  26870. * @returns The object center
  26871. */
  26872. getObjectCenter(): Vector3;
  26873. /**
  26874. * Get a specific parameter from the options parameters
  26875. * @param paramName The object parameter name
  26876. * @returns The object parameter
  26877. */
  26878. getParam(paramName: string): any;
  26879. /**
  26880. * Sets a specific parameter in the options given to the physics plugin
  26881. * @param paramName The parameter name
  26882. * @param value The value of the parameter
  26883. */
  26884. setParam(paramName: string, value: number): void;
  26885. /**
  26886. * Specifically change the body's mass option. Won't recreate the physics body object
  26887. * @param mass The mass of the physics imposter
  26888. */
  26889. setMass(mass: number): void;
  26890. /**
  26891. * Gets the linear velocity
  26892. * @returns linear velocity or null
  26893. */
  26894. getLinearVelocity(): Nullable<Vector3>;
  26895. /**
  26896. * Sets the linear velocity
  26897. * @param velocity linear velocity or null
  26898. */
  26899. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26900. /**
  26901. * Gets the angular velocity
  26902. * @returns angular velocity or null
  26903. */
  26904. getAngularVelocity(): Nullable<Vector3>;
  26905. /**
  26906. * Sets the angular velocity
  26907. * @param velocity The velocity or null
  26908. */
  26909. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26910. /**
  26911. * Execute a function with the physics plugin native code
  26912. * Provide a function the will have two variables - the world object and the physics body object
  26913. * @param func The function to execute with the physics plugin native code
  26914. */
  26915. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26916. /**
  26917. * Register a function that will be executed before the physics world is stepping forward
  26918. * @param func The function to execute before the physics world is stepped forward
  26919. */
  26920. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26921. /**
  26922. * Unregister a function that will be executed before the physics world is stepping forward
  26923. * @param func The function to execute before the physics world is stepped forward
  26924. */
  26925. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26926. /**
  26927. * Register a function that will be executed after the physics step
  26928. * @param func The function to execute after physics step
  26929. */
  26930. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26931. /**
  26932. * Unregisters a function that will be executed after the physics step
  26933. * @param func The function to execute after physics step
  26934. */
  26935. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26936. /**
  26937. * register a function that will be executed when this impostor collides against a different body
  26938. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26939. * @param func Callback that is executed on collision
  26940. */
  26941. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26942. /**
  26943. * Unregisters the physics imposter on contact
  26944. * @param collideAgainst The physics object to collide against
  26945. * @param func Callback to execute on collision
  26946. */
  26947. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26948. private _tmpQuat;
  26949. private _tmpQuat2;
  26950. /**
  26951. * Get the parent rotation
  26952. * @returns The parent rotation
  26953. */
  26954. getParentsRotation(): Quaternion;
  26955. /**
  26956. * this function is executed by the physics engine.
  26957. */
  26958. beforeStep: () => void;
  26959. /**
  26960. * this function is executed by the physics engine
  26961. */
  26962. afterStep: () => void;
  26963. /**
  26964. * Legacy collision detection event support
  26965. */
  26966. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26967. /**
  26968. * event and body object due to cannon's event-based architecture.
  26969. */
  26970. onCollide: (e: {
  26971. body: any;
  26972. }) => void;
  26973. /**
  26974. * Apply a force
  26975. * @param force The force to apply
  26976. * @param contactPoint The contact point for the force
  26977. * @returns The physics imposter
  26978. */
  26979. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26980. /**
  26981. * Apply an impulse
  26982. * @param force The impulse force
  26983. * @param contactPoint The contact point for the impulse force
  26984. * @returns The physics imposter
  26985. */
  26986. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26987. /**
  26988. * A help function to create a joint
  26989. * @param otherImpostor A physics imposter used to create a joint
  26990. * @param jointType The type of joint
  26991. * @param jointData The data for the joint
  26992. * @returns The physics imposter
  26993. */
  26994. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26995. /**
  26996. * Add a joint to this impostor with a different impostor
  26997. * @param otherImpostor A physics imposter used to add a joint
  26998. * @param joint The joint to add
  26999. * @returns The physics imposter
  27000. */
  27001. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27002. /**
  27003. * Add an anchor to a cloth impostor
  27004. * @param otherImpostor rigid impostor to anchor to
  27005. * @param width ratio across width from 0 to 1
  27006. * @param height ratio up height from 0 to 1
  27007. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27008. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27009. * @returns impostor the soft imposter
  27010. */
  27011. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27012. /**
  27013. * Add a hook to a rope impostor
  27014. * @param otherImpostor rigid impostor to anchor to
  27015. * @param length ratio across rope from 0 to 1
  27016. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27017. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27018. * @returns impostor the rope imposter
  27019. */
  27020. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27021. /**
  27022. * Will keep this body still, in a sleep mode.
  27023. * @returns the physics imposter
  27024. */
  27025. sleep(): PhysicsImpostor;
  27026. /**
  27027. * Wake the body up.
  27028. * @returns The physics imposter
  27029. */
  27030. wakeUp(): PhysicsImpostor;
  27031. /**
  27032. * Clones the physics imposter
  27033. * @param newObject The physics imposter clones to this physics-enabled object
  27034. * @returns A nullable physics imposter
  27035. */
  27036. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27037. /**
  27038. * Disposes the physics imposter
  27039. */
  27040. dispose(): void;
  27041. /**
  27042. * Sets the delta position
  27043. * @param position The delta position amount
  27044. */
  27045. setDeltaPosition(position: Vector3): void;
  27046. /**
  27047. * Sets the delta rotation
  27048. * @param rotation The delta rotation amount
  27049. */
  27050. setDeltaRotation(rotation: Quaternion): void;
  27051. /**
  27052. * Gets the box size of the physics imposter and stores the result in the input parameter
  27053. * @param result Stores the box size
  27054. * @returns The physics imposter
  27055. */
  27056. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27057. /**
  27058. * Gets the radius of the physics imposter
  27059. * @returns Radius of the physics imposter
  27060. */
  27061. getRadius(): number;
  27062. /**
  27063. * Sync a bone with this impostor
  27064. * @param bone The bone to sync to the impostor.
  27065. * @param boneMesh The mesh that the bone is influencing.
  27066. * @param jointPivot The pivot of the joint / bone in local space.
  27067. * @param distToJoint Optional distance from the impostor to the joint.
  27068. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27069. */
  27070. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27071. /**
  27072. * Sync impostor to a bone
  27073. * @param bone The bone that the impostor will be synced to.
  27074. * @param boneMesh The mesh that the bone is influencing.
  27075. * @param jointPivot The pivot of the joint / bone in local space.
  27076. * @param distToJoint Optional distance from the impostor to the joint.
  27077. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27078. * @param boneAxis Optional vector3 axis the bone is aligned with
  27079. */
  27080. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27081. /**
  27082. * No-Imposter type
  27083. */
  27084. static NoImpostor: number;
  27085. /**
  27086. * Sphere-Imposter type
  27087. */
  27088. static SphereImpostor: number;
  27089. /**
  27090. * Box-Imposter type
  27091. */
  27092. static BoxImpostor: number;
  27093. /**
  27094. * Plane-Imposter type
  27095. */
  27096. static PlaneImpostor: number;
  27097. /**
  27098. * Mesh-imposter type
  27099. */
  27100. static MeshImpostor: number;
  27101. /**
  27102. * Capsule-Impostor type (Ammo.js plugin only)
  27103. */
  27104. static CapsuleImpostor: number;
  27105. /**
  27106. * Cylinder-Imposter type
  27107. */
  27108. static CylinderImpostor: number;
  27109. /**
  27110. * Particle-Imposter type
  27111. */
  27112. static ParticleImpostor: number;
  27113. /**
  27114. * Heightmap-Imposter type
  27115. */
  27116. static HeightmapImpostor: number;
  27117. /**
  27118. * ConvexHull-Impostor type (Ammo.js plugin only)
  27119. */
  27120. static ConvexHullImpostor: number;
  27121. /**
  27122. * Custom-Imposter type (Ammo.js plugin only)
  27123. */
  27124. static CustomImpostor: number;
  27125. /**
  27126. * Rope-Imposter type
  27127. */
  27128. static RopeImpostor: number;
  27129. /**
  27130. * Cloth-Imposter type
  27131. */
  27132. static ClothImpostor: number;
  27133. /**
  27134. * Softbody-Imposter type
  27135. */
  27136. static SoftbodyImpostor: number;
  27137. }
  27138. }
  27139. declare module BABYLON {
  27140. /**
  27141. * @hidden
  27142. **/
  27143. export class _CreationDataStorage {
  27144. closePath?: boolean;
  27145. closeArray?: boolean;
  27146. idx: number[];
  27147. dashSize: number;
  27148. gapSize: number;
  27149. path3D: Path3D;
  27150. pathArray: Vector3[][];
  27151. arc: number;
  27152. radius: number;
  27153. cap: number;
  27154. tessellation: number;
  27155. }
  27156. /**
  27157. * @hidden
  27158. **/
  27159. class _InstanceDataStorage {
  27160. visibleInstances: any;
  27161. batchCache: _InstancesBatch;
  27162. instancesBufferSize: number;
  27163. instancesBuffer: Nullable<Buffer>;
  27164. instancesData: Float32Array;
  27165. overridenInstanceCount: number;
  27166. isFrozen: boolean;
  27167. previousBatch: Nullable<_InstancesBatch>;
  27168. hardwareInstancedRendering: boolean;
  27169. sideOrientation: number;
  27170. manualUpdate: boolean;
  27171. }
  27172. /**
  27173. * @hidden
  27174. **/
  27175. export class _InstancesBatch {
  27176. mustReturn: boolean;
  27177. visibleInstances: Nullable<InstancedMesh[]>[];
  27178. renderSelf: boolean[];
  27179. hardwareInstancedRendering: boolean[];
  27180. }
  27181. /**
  27182. * @hidden
  27183. **/
  27184. class _ThinInstanceDataStorage {
  27185. instancesCount: number;
  27186. matrixBuffer: Nullable<Buffer>;
  27187. matrixBufferSize: number;
  27188. matrixData: Nullable<Float32Array>;
  27189. boundingVectors: Array<Vector3>;
  27190. }
  27191. /**
  27192. * Class used to represent renderable models
  27193. */
  27194. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27195. /**
  27196. * Mesh side orientation : usually the external or front surface
  27197. */
  27198. static readonly FRONTSIDE: number;
  27199. /**
  27200. * Mesh side orientation : usually the internal or back surface
  27201. */
  27202. static readonly BACKSIDE: number;
  27203. /**
  27204. * Mesh side orientation : both internal and external or front and back surfaces
  27205. */
  27206. static readonly DOUBLESIDE: number;
  27207. /**
  27208. * Mesh side orientation : by default, `FRONTSIDE`
  27209. */
  27210. static readonly DEFAULTSIDE: number;
  27211. /**
  27212. * Mesh cap setting : no cap
  27213. */
  27214. static readonly NO_CAP: number;
  27215. /**
  27216. * Mesh cap setting : one cap at the beginning of the mesh
  27217. */
  27218. static readonly CAP_START: number;
  27219. /**
  27220. * Mesh cap setting : one cap at the end of the mesh
  27221. */
  27222. static readonly CAP_END: number;
  27223. /**
  27224. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27225. */
  27226. static readonly CAP_ALL: number;
  27227. /**
  27228. * Mesh pattern setting : no flip or rotate
  27229. */
  27230. static readonly NO_FLIP: number;
  27231. /**
  27232. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27233. */
  27234. static readonly FLIP_TILE: number;
  27235. /**
  27236. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27237. */
  27238. static readonly ROTATE_TILE: number;
  27239. /**
  27240. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27241. */
  27242. static readonly FLIP_ROW: number;
  27243. /**
  27244. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27245. */
  27246. static readonly ROTATE_ROW: number;
  27247. /**
  27248. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27249. */
  27250. static readonly FLIP_N_ROTATE_TILE: number;
  27251. /**
  27252. * Mesh pattern setting : rotate pattern and rotate
  27253. */
  27254. static readonly FLIP_N_ROTATE_ROW: number;
  27255. /**
  27256. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27257. */
  27258. static readonly CENTER: number;
  27259. /**
  27260. * Mesh tile positioning : part tiles on left
  27261. */
  27262. static readonly LEFT: number;
  27263. /**
  27264. * Mesh tile positioning : part tiles on right
  27265. */
  27266. static readonly RIGHT: number;
  27267. /**
  27268. * Mesh tile positioning : part tiles on top
  27269. */
  27270. static readonly TOP: number;
  27271. /**
  27272. * Mesh tile positioning : part tiles on bottom
  27273. */
  27274. static readonly BOTTOM: number;
  27275. /**
  27276. * Gets the default side orientation.
  27277. * @param orientation the orientation to value to attempt to get
  27278. * @returns the default orientation
  27279. * @hidden
  27280. */
  27281. static _GetDefaultSideOrientation(orientation?: number): number;
  27282. private _internalMeshDataInfo;
  27283. /**
  27284. * An event triggered before rendering the mesh
  27285. */
  27286. get onBeforeRenderObservable(): Observable<Mesh>;
  27287. /**
  27288. * An event triggered before binding the mesh
  27289. */
  27290. get onBeforeBindObservable(): Observable<Mesh>;
  27291. /**
  27292. * An event triggered after rendering the mesh
  27293. */
  27294. get onAfterRenderObservable(): Observable<Mesh>;
  27295. /**
  27296. * An event triggered before drawing the mesh
  27297. */
  27298. get onBeforeDrawObservable(): Observable<Mesh>;
  27299. private _onBeforeDrawObserver;
  27300. /**
  27301. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27302. */
  27303. set onBeforeDraw(callback: () => void);
  27304. get hasInstances(): boolean;
  27305. get hasThinInstances(): boolean;
  27306. /**
  27307. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27308. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27309. */
  27310. delayLoadState: number;
  27311. /**
  27312. * Gets the list of instances created from this mesh
  27313. * it is not supposed to be modified manually.
  27314. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27316. */
  27317. instances: InstancedMesh[];
  27318. /**
  27319. * Gets the file containing delay loading data for this mesh
  27320. */
  27321. delayLoadingFile: string;
  27322. /** @hidden */
  27323. _binaryInfo: any;
  27324. /**
  27325. * User defined function used to change how LOD level selection is done
  27326. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27327. */
  27328. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27329. /**
  27330. * Gets or sets the morph target manager
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27332. */
  27333. get morphTargetManager(): Nullable<MorphTargetManager>;
  27334. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27335. /** @hidden */
  27336. _creationDataStorage: Nullable<_CreationDataStorage>;
  27337. /** @hidden */
  27338. _geometry: Nullable<Geometry>;
  27339. /** @hidden */
  27340. _delayInfo: Array<string>;
  27341. /** @hidden */
  27342. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27343. /** @hidden */
  27344. _instanceDataStorage: _InstanceDataStorage;
  27345. /** @hidden */
  27346. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27347. private _effectiveMaterial;
  27348. /** @hidden */
  27349. _shouldGenerateFlatShading: boolean;
  27350. /** @hidden */
  27351. _originalBuilderSideOrientation: number;
  27352. /**
  27353. * Use this property to change the original side orientation defined at construction time
  27354. */
  27355. overrideMaterialSideOrientation: Nullable<number>;
  27356. /**
  27357. * Gets the source mesh (the one used to clone this one from)
  27358. */
  27359. get source(): Nullable<Mesh>;
  27360. /**
  27361. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27362. */
  27363. get isUnIndexed(): boolean;
  27364. set isUnIndexed(value: boolean);
  27365. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27366. get worldMatrixInstancedBuffer(): Float32Array;
  27367. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27368. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27369. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27370. /**
  27371. * @constructor
  27372. * @param name The value used by scene.getMeshByName() to do a lookup.
  27373. * @param scene The scene to add this mesh to.
  27374. * @param parent The parent of this mesh, if it has one
  27375. * @param source An optional Mesh from which geometry is shared, cloned.
  27376. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27377. * When false, achieved by calling a clone(), also passing False.
  27378. * This will make creation of children, recursive.
  27379. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27380. */
  27381. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27382. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27383. doNotInstantiate: boolean;
  27384. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27385. /**
  27386. * Gets the class name
  27387. * @returns the string "Mesh".
  27388. */
  27389. getClassName(): string;
  27390. /** @hidden */
  27391. get _isMesh(): boolean;
  27392. /**
  27393. * Returns a description of this mesh
  27394. * @param fullDetails define if full details about this mesh must be used
  27395. * @returns a descriptive string representing this mesh
  27396. */
  27397. toString(fullDetails?: boolean): string;
  27398. /** @hidden */
  27399. _unBindEffect(): void;
  27400. /**
  27401. * Gets a boolean indicating if this mesh has LOD
  27402. */
  27403. get hasLODLevels(): boolean;
  27404. /**
  27405. * Gets the list of MeshLODLevel associated with the current mesh
  27406. * @returns an array of MeshLODLevel
  27407. */
  27408. getLODLevels(): MeshLODLevel[];
  27409. private _sortLODLevels;
  27410. /**
  27411. * Add a mesh as LOD level triggered at the given distance.
  27412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27413. * @param distance The distance from the center of the object to show this level
  27414. * @param mesh The mesh to be added as LOD level (can be null)
  27415. * @return This mesh (for chaining)
  27416. */
  27417. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27418. /**
  27419. * Returns the LOD level mesh at the passed distance or null if not found.
  27420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27421. * @param distance The distance from the center of the object to show this level
  27422. * @returns a Mesh or `null`
  27423. */
  27424. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27425. /**
  27426. * Remove a mesh from the LOD array
  27427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27428. * @param mesh defines the mesh to be removed
  27429. * @return This mesh (for chaining)
  27430. */
  27431. removeLODLevel(mesh: Mesh): Mesh;
  27432. /**
  27433. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27434. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27435. * @param camera defines the camera to use to compute distance
  27436. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27437. * @return This mesh (for chaining)
  27438. */
  27439. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27440. /**
  27441. * Gets the mesh internal Geometry object
  27442. */
  27443. get geometry(): Nullable<Geometry>;
  27444. /**
  27445. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27446. * @returns the total number of vertices
  27447. */
  27448. getTotalVertices(): number;
  27449. /**
  27450. * Returns the content of an associated vertex buffer
  27451. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27452. * - VertexBuffer.PositionKind
  27453. * - VertexBuffer.UVKind
  27454. * - VertexBuffer.UV2Kind
  27455. * - VertexBuffer.UV3Kind
  27456. * - VertexBuffer.UV4Kind
  27457. * - VertexBuffer.UV5Kind
  27458. * - VertexBuffer.UV6Kind
  27459. * - VertexBuffer.ColorKind
  27460. * - VertexBuffer.MatricesIndicesKind
  27461. * - VertexBuffer.MatricesIndicesExtraKind
  27462. * - VertexBuffer.MatricesWeightsKind
  27463. * - VertexBuffer.MatricesWeightsExtraKind
  27464. * @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
  27465. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27466. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27467. */
  27468. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27469. /**
  27470. * Returns the mesh VertexBuffer object from the requested `kind`
  27471. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27472. * - VertexBuffer.PositionKind
  27473. * - VertexBuffer.NormalKind
  27474. * - VertexBuffer.UVKind
  27475. * - VertexBuffer.UV2Kind
  27476. * - VertexBuffer.UV3Kind
  27477. * - VertexBuffer.UV4Kind
  27478. * - VertexBuffer.UV5Kind
  27479. * - VertexBuffer.UV6Kind
  27480. * - VertexBuffer.ColorKind
  27481. * - VertexBuffer.MatricesIndicesKind
  27482. * - VertexBuffer.MatricesIndicesExtraKind
  27483. * - VertexBuffer.MatricesWeightsKind
  27484. * - VertexBuffer.MatricesWeightsExtraKind
  27485. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27486. */
  27487. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27488. /**
  27489. * Tests if a specific vertex buffer is associated with this mesh
  27490. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27491. * - VertexBuffer.PositionKind
  27492. * - VertexBuffer.NormalKind
  27493. * - VertexBuffer.UVKind
  27494. * - VertexBuffer.UV2Kind
  27495. * - VertexBuffer.UV3Kind
  27496. * - VertexBuffer.UV4Kind
  27497. * - VertexBuffer.UV5Kind
  27498. * - VertexBuffer.UV6Kind
  27499. * - VertexBuffer.ColorKind
  27500. * - VertexBuffer.MatricesIndicesKind
  27501. * - VertexBuffer.MatricesIndicesExtraKind
  27502. * - VertexBuffer.MatricesWeightsKind
  27503. * - VertexBuffer.MatricesWeightsExtraKind
  27504. * @returns a boolean
  27505. */
  27506. isVerticesDataPresent(kind: string): boolean;
  27507. /**
  27508. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27509. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27510. * - VertexBuffer.PositionKind
  27511. * - VertexBuffer.UVKind
  27512. * - VertexBuffer.UV2Kind
  27513. * - VertexBuffer.UV3Kind
  27514. * - VertexBuffer.UV4Kind
  27515. * - VertexBuffer.UV5Kind
  27516. * - VertexBuffer.UV6Kind
  27517. * - VertexBuffer.ColorKind
  27518. * - VertexBuffer.MatricesIndicesKind
  27519. * - VertexBuffer.MatricesIndicesExtraKind
  27520. * - VertexBuffer.MatricesWeightsKind
  27521. * - VertexBuffer.MatricesWeightsExtraKind
  27522. * @returns a boolean
  27523. */
  27524. isVertexBufferUpdatable(kind: string): boolean;
  27525. /**
  27526. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27527. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27528. * - VertexBuffer.PositionKind
  27529. * - VertexBuffer.NormalKind
  27530. * - VertexBuffer.UVKind
  27531. * - VertexBuffer.UV2Kind
  27532. * - VertexBuffer.UV3Kind
  27533. * - VertexBuffer.UV4Kind
  27534. * - VertexBuffer.UV5Kind
  27535. * - VertexBuffer.UV6Kind
  27536. * - VertexBuffer.ColorKind
  27537. * - VertexBuffer.MatricesIndicesKind
  27538. * - VertexBuffer.MatricesIndicesExtraKind
  27539. * - VertexBuffer.MatricesWeightsKind
  27540. * - VertexBuffer.MatricesWeightsExtraKind
  27541. * @returns an array of strings
  27542. */
  27543. getVerticesDataKinds(): string[];
  27544. /**
  27545. * Returns a positive integer : the total number of indices in this mesh geometry.
  27546. * @returns the numner of indices or zero if the mesh has no geometry.
  27547. */
  27548. getTotalIndices(): number;
  27549. /**
  27550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27551. * @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.
  27552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27553. * @returns the indices array or an empty array if the mesh has no geometry
  27554. */
  27555. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27556. get isBlocked(): boolean;
  27557. /**
  27558. * Determine if the current mesh is ready to be rendered
  27559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27560. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27561. * @returns true if all associated assets are ready (material, textures, shaders)
  27562. */
  27563. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27564. /**
  27565. * 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.
  27566. */
  27567. get areNormalsFrozen(): boolean;
  27568. /**
  27569. * 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.
  27570. * @returns the current mesh
  27571. */
  27572. freezeNormals(): Mesh;
  27573. /**
  27574. * 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
  27575. * @returns the current mesh
  27576. */
  27577. unfreezeNormals(): Mesh;
  27578. /**
  27579. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27580. */
  27581. set overridenInstanceCount(count: number);
  27582. /** @hidden */
  27583. _preActivate(): Mesh;
  27584. /** @hidden */
  27585. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27586. /** @hidden */
  27587. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27588. protected _afterComputeWorldMatrix(): void;
  27589. /**
  27590. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27591. * This means the mesh underlying bounding box and sphere are recomputed.
  27592. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27593. * @returns the current mesh
  27594. */
  27595. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27596. /** @hidden */
  27597. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27598. /**
  27599. * This function will subdivide the mesh into multiple submeshes
  27600. * @param count defines the expected number of submeshes
  27601. */
  27602. subdivide(count: number): void;
  27603. /**
  27604. * Copy a FloatArray into a specific associated vertex buffer
  27605. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27606. * - VertexBuffer.PositionKind
  27607. * - VertexBuffer.UVKind
  27608. * - VertexBuffer.UV2Kind
  27609. * - VertexBuffer.UV3Kind
  27610. * - VertexBuffer.UV4Kind
  27611. * - VertexBuffer.UV5Kind
  27612. * - VertexBuffer.UV6Kind
  27613. * - VertexBuffer.ColorKind
  27614. * - VertexBuffer.MatricesIndicesKind
  27615. * - VertexBuffer.MatricesIndicesExtraKind
  27616. * - VertexBuffer.MatricesWeightsKind
  27617. * - VertexBuffer.MatricesWeightsExtraKind
  27618. * @param data defines the data source
  27619. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27620. * @param stride defines the data stride size (can be null)
  27621. * @returns the current mesh
  27622. */
  27623. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27624. /**
  27625. * Delete a vertex buffer associated with this mesh
  27626. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27627. * - VertexBuffer.PositionKind
  27628. * - VertexBuffer.UVKind
  27629. * - VertexBuffer.UV2Kind
  27630. * - VertexBuffer.UV3Kind
  27631. * - VertexBuffer.UV4Kind
  27632. * - VertexBuffer.UV5Kind
  27633. * - VertexBuffer.UV6Kind
  27634. * - VertexBuffer.ColorKind
  27635. * - VertexBuffer.MatricesIndicesKind
  27636. * - VertexBuffer.MatricesIndicesExtraKind
  27637. * - VertexBuffer.MatricesWeightsKind
  27638. * - VertexBuffer.MatricesWeightsExtraKind
  27639. */
  27640. removeVerticesData(kind: string): void;
  27641. /**
  27642. * Flags an associated vertex buffer as updatable
  27643. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27644. * - VertexBuffer.PositionKind
  27645. * - VertexBuffer.UVKind
  27646. * - VertexBuffer.UV2Kind
  27647. * - VertexBuffer.UV3Kind
  27648. * - VertexBuffer.UV4Kind
  27649. * - VertexBuffer.UV5Kind
  27650. * - VertexBuffer.UV6Kind
  27651. * - VertexBuffer.ColorKind
  27652. * - VertexBuffer.MatricesIndicesKind
  27653. * - VertexBuffer.MatricesIndicesExtraKind
  27654. * - VertexBuffer.MatricesWeightsKind
  27655. * - VertexBuffer.MatricesWeightsExtraKind
  27656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27657. */
  27658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27659. /**
  27660. * Sets the mesh global Vertex Buffer
  27661. * @param buffer defines the buffer to use
  27662. * @returns the current mesh
  27663. */
  27664. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27665. /**
  27666. * Update a specific associated vertex buffer
  27667. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27668. * - VertexBuffer.PositionKind
  27669. * - VertexBuffer.UVKind
  27670. * - VertexBuffer.UV2Kind
  27671. * - VertexBuffer.UV3Kind
  27672. * - VertexBuffer.UV4Kind
  27673. * - VertexBuffer.UV5Kind
  27674. * - VertexBuffer.UV6Kind
  27675. * - VertexBuffer.ColorKind
  27676. * - VertexBuffer.MatricesIndicesKind
  27677. * - VertexBuffer.MatricesIndicesExtraKind
  27678. * - VertexBuffer.MatricesWeightsKind
  27679. * - VertexBuffer.MatricesWeightsExtraKind
  27680. * @param data defines the data source
  27681. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27682. * @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)
  27683. * @returns the current mesh
  27684. */
  27685. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27686. /**
  27687. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27689. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27690. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27691. * @returns the current mesh
  27692. */
  27693. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27694. /**
  27695. * Creates a un-shared specific occurence of the geometry for the mesh.
  27696. * @returns the current mesh
  27697. */
  27698. makeGeometryUnique(): Mesh;
  27699. /**
  27700. * Set the index buffer of this mesh
  27701. * @param indices defines the source data
  27702. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27703. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27704. * @returns the current mesh
  27705. */
  27706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27707. /**
  27708. * Update the current index buffer
  27709. * @param indices defines the source data
  27710. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27711. * @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)
  27712. * @returns the current mesh
  27713. */
  27714. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27715. /**
  27716. * Invert the geometry to move from a right handed system to a left handed one.
  27717. * @returns the current mesh
  27718. */
  27719. toLeftHanded(): Mesh;
  27720. /** @hidden */
  27721. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27722. /** @hidden */
  27723. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27724. /**
  27725. * Registers for this mesh a javascript function called just before the rendering process
  27726. * @param func defines the function to call before rendering this mesh
  27727. * @returns the current mesh
  27728. */
  27729. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27730. /**
  27731. * Disposes a previously registered javascript function called before the rendering
  27732. * @param func defines the function to remove
  27733. * @returns the current mesh
  27734. */
  27735. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27736. /**
  27737. * Registers for this mesh a javascript function called just after the rendering is complete
  27738. * @param func defines the function to call after rendering this mesh
  27739. * @returns the current mesh
  27740. */
  27741. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27742. /**
  27743. * Disposes a previously registered javascript function called after the rendering.
  27744. * @param func defines the function to remove
  27745. * @returns the current mesh
  27746. */
  27747. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27748. /** @hidden */
  27749. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27750. /** @hidden */
  27751. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27752. /** @hidden */
  27753. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27754. /** @hidden */
  27755. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27756. /** @hidden */
  27757. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27758. /** @hidden */
  27759. _rebuild(): void;
  27760. /** @hidden */
  27761. _freeze(): void;
  27762. /** @hidden */
  27763. _unFreeze(): void;
  27764. /**
  27765. * 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
  27766. * @param subMesh defines the subMesh to render
  27767. * @param enableAlphaMode defines if alpha mode can be changed
  27768. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27769. * @returns the current mesh
  27770. */
  27771. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27772. private _onBeforeDraw;
  27773. /**
  27774. * Renormalize the mesh and patch it up if there are no weights
  27775. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27776. * However in the case of zero weights then we set just a single influence to 1.
  27777. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27778. */
  27779. cleanMatrixWeights(): void;
  27780. private normalizeSkinFourWeights;
  27781. private normalizeSkinWeightsAndExtra;
  27782. /**
  27783. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27784. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27785. * the user know there was an issue with importing the mesh
  27786. * @returns a validation object with skinned, valid and report string
  27787. */
  27788. validateSkinning(): {
  27789. skinned: boolean;
  27790. valid: boolean;
  27791. report: string;
  27792. };
  27793. /** @hidden */
  27794. _checkDelayState(): Mesh;
  27795. private _queueLoad;
  27796. /**
  27797. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27798. * A mesh is in the frustum if its bounding box intersects the frustum
  27799. * @param frustumPlanes defines the frustum to test
  27800. * @returns true if the mesh is in the frustum planes
  27801. */
  27802. isInFrustum(frustumPlanes: Plane[]): boolean;
  27803. /**
  27804. * Sets the mesh material by the material or multiMaterial `id` property
  27805. * @param id is a string identifying the material or the multiMaterial
  27806. * @returns the current mesh
  27807. */
  27808. setMaterialByID(id: string): Mesh;
  27809. /**
  27810. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27811. * @returns an array of IAnimatable
  27812. */
  27813. getAnimatables(): IAnimatable[];
  27814. /**
  27815. * Modifies the mesh geometry according to the passed transformation matrix.
  27816. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27817. * The mesh normals are modified using the same transformation.
  27818. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27819. * @param transform defines the transform matrix to use
  27820. * @see http://doc.babylonjs.com/resources/baking_transformations
  27821. * @returns the current mesh
  27822. */
  27823. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27824. /**
  27825. * Modifies the mesh geometry according to its own current World Matrix.
  27826. * The mesh World Matrix is then reset.
  27827. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27829. * @see http://doc.babylonjs.com/resources/baking_transformations
  27830. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27831. * @returns the current mesh
  27832. */
  27833. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27834. /** @hidden */
  27835. get _positions(): Nullable<Vector3[]>;
  27836. /** @hidden */
  27837. _resetPointsArrayCache(): Mesh;
  27838. /** @hidden */
  27839. _generatePointsArray(): boolean;
  27840. /**
  27841. * Returns a new Mesh object generated from the current mesh properties.
  27842. * This method must not get confused with createInstance()
  27843. * @param name is a string, the name given to the new mesh
  27844. * @param newParent can be any Node object (default `null`)
  27845. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27846. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27847. * @returns a new mesh
  27848. */
  27849. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27850. /**
  27851. * Releases resources associated with this mesh.
  27852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27854. */
  27855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27856. /** @hidden */
  27857. _disposeInstanceSpecificData(): void;
  27858. /** @hidden */
  27859. _disposeThinInstanceSpecificData(): void;
  27860. /**
  27861. * Modifies the mesh geometry according to a displacement map.
  27862. * 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.
  27863. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27864. * @param url is a string, the URL from the image file is to be downloaded.
  27865. * @param minHeight is the lower limit of the displacement.
  27866. * @param maxHeight is the upper limit of the displacement.
  27867. * @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.
  27868. * @param uvOffset is an optional vector2 used to offset UV.
  27869. * @param uvScale is an optional vector2 used to scale UV.
  27870. * @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.
  27871. * @returns the Mesh.
  27872. */
  27873. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27874. /**
  27875. * Modifies the mesh geometry according to a displacementMap buffer.
  27876. * 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.
  27877. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27878. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27879. * @param heightMapWidth is the width of the buffer image.
  27880. * @param heightMapHeight is the height of the buffer image.
  27881. * @param minHeight is the lower limit of the displacement.
  27882. * @param maxHeight is the upper limit of the displacement.
  27883. * @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.
  27884. * @param uvOffset is an optional vector2 used to offset UV.
  27885. * @param uvScale is an optional vector2 used to scale UV.
  27886. * @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.
  27887. * @returns the Mesh.
  27888. */
  27889. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27890. /**
  27891. * Modify the mesh to get a flat shading rendering.
  27892. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27893. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27894. * @returns current mesh
  27895. */
  27896. convertToFlatShadedMesh(): Mesh;
  27897. /**
  27898. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27899. * In other words, more vertices, no more indices and a single bigger VBO.
  27900. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27901. * @returns current mesh
  27902. */
  27903. convertToUnIndexedMesh(): Mesh;
  27904. /**
  27905. * Inverses facet orientations.
  27906. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27907. * @param flipNormals will also inverts the normals
  27908. * @returns current mesh
  27909. */
  27910. flipFaces(flipNormals?: boolean): Mesh;
  27911. /**
  27912. * Increase the number of facets and hence vertices in a mesh
  27913. * Vertex normals are interpolated from existing vertex normals
  27914. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27915. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27916. */
  27917. increaseVertices(numberPerEdge: number): void;
  27918. /**
  27919. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27920. * This will undo any application of covertToFlatShadedMesh
  27921. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27922. */
  27923. forceSharedVertices(): void;
  27924. /** @hidden */
  27925. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27926. /** @hidden */
  27927. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27928. /**
  27929. * Creates a new InstancedMesh object from the mesh model.
  27930. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27931. * @param name defines the name of the new instance
  27932. * @returns a new InstancedMesh
  27933. */
  27934. createInstance(name: string): InstancedMesh;
  27935. /**
  27936. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27937. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27938. * @returns the current mesh
  27939. */
  27940. synchronizeInstances(): Mesh;
  27941. /**
  27942. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27943. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27944. * This should be used together with the simplification to avoid disappearing triangles.
  27945. * @param successCallback an optional success callback to be called after the optimization finished.
  27946. * @returns the current mesh
  27947. */
  27948. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27949. /**
  27950. * Serialize current mesh
  27951. * @param serializationObject defines the object which will receive the serialization data
  27952. */
  27953. serialize(serializationObject: any): void;
  27954. /** @hidden */
  27955. _syncGeometryWithMorphTargetManager(): void;
  27956. /** @hidden */
  27957. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27958. /**
  27959. * Returns a new Mesh object parsed from the source provided.
  27960. * @param parsedMesh is the source
  27961. * @param scene defines the hosting scene
  27962. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27963. * @returns a new Mesh
  27964. */
  27965. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27966. /**
  27967. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27968. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27969. * @param name defines the name of the mesh to create
  27970. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27971. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27972. * @param closePath creates a seam between the first and the last points of each path of the path array
  27973. * @param offset is taken in account only if the `pathArray` is containing a single path
  27974. * @param scene defines the hosting scene
  27975. * @param updatable defines if the mesh must be flagged as updatable
  27976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27977. * @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)
  27978. * @returns a new Mesh
  27979. */
  27980. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27981. /**
  27982. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27983. * @param name defines the name of the mesh to create
  27984. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27985. * @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
  27986. * @param scene defines the hosting scene
  27987. * @param updatable defines if the mesh must be flagged as updatable
  27988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27989. * @returns a new Mesh
  27990. */
  27991. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27992. /**
  27993. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27994. * @param name defines the name of the mesh to create
  27995. * @param size sets the size (float) of each box side (default 1)
  27996. * @param scene defines the hosting scene
  27997. * @param updatable defines if the mesh must be flagged as updatable
  27998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27999. * @returns a new Mesh
  28000. */
  28001. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28002. /**
  28003. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28004. * @param name defines the name of the mesh to create
  28005. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28006. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28007. * @param scene defines the hosting scene
  28008. * @param updatable defines if the mesh must be flagged as updatable
  28009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28010. * @returns a new Mesh
  28011. */
  28012. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28013. /**
  28014. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28015. * @param name defines the name of the mesh to create
  28016. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28017. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28018. * @param scene defines the hosting scene
  28019. * @returns a new Mesh
  28020. */
  28021. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28022. /**
  28023. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28024. * @param name defines the name of the mesh to create
  28025. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28026. * @param diameterTop set the top cap diameter (floats, default 1)
  28027. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28028. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28029. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28030. * @param scene defines the hosting scene
  28031. * @param updatable defines if the mesh must be flagged as updatable
  28032. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28033. * @returns a new Mesh
  28034. */
  28035. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28036. /**
  28037. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28038. * @param name defines the name of the mesh to create
  28039. * @param diameter sets the diameter size (float) of the torus (default 1)
  28040. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28041. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28042. * @param scene defines the hosting scene
  28043. * @param updatable defines if the mesh must be flagged as updatable
  28044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28045. * @returns a new Mesh
  28046. */
  28047. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28048. /**
  28049. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28050. * @param name defines the name of the mesh to create
  28051. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28052. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28053. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28054. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28055. * @param p the number of windings on X axis (positive integers, default 2)
  28056. * @param q the number of windings on Y axis (positive integers, default 3)
  28057. * @param scene defines the hosting scene
  28058. * @param updatable defines if the mesh must be flagged as updatable
  28059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28060. * @returns a new Mesh
  28061. */
  28062. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28063. /**
  28064. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28065. * @param name defines the name of the mesh to create
  28066. * @param points is an array successive Vector3
  28067. * @param scene defines the hosting scene
  28068. * @param updatable defines if the mesh must be flagged as updatable
  28069. * @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).
  28070. * @returns a new Mesh
  28071. */
  28072. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28073. /**
  28074. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28075. * @param name defines the name of the mesh to create
  28076. * @param points is an array successive Vector3
  28077. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28078. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28079. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28080. * @param scene defines the hosting scene
  28081. * @param updatable defines if the mesh must be flagged as updatable
  28082. * @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)
  28083. * @returns a new Mesh
  28084. */
  28085. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28086. /**
  28087. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28088. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28089. * 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.
  28090. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28091. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28092. * Remember you can only change the shape positions, not their number when updating a polygon.
  28093. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28094. * @param name defines the name of the mesh to create
  28095. * @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
  28096. * @param scene defines the hosting scene
  28097. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28098. * @param updatable defines if the mesh must be flagged as updatable
  28099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28100. * @param earcutInjection can be used to inject your own earcut reference
  28101. * @returns a new Mesh
  28102. */
  28103. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28104. /**
  28105. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28107. * @param name defines the name of the mesh to create
  28108. * @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
  28109. * @param depth defines the height of extrusion
  28110. * @param scene defines the hosting scene
  28111. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28112. * @param updatable defines if the mesh must be flagged as updatable
  28113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28114. * @param earcutInjection can be used to inject your own earcut reference
  28115. * @returns a new Mesh
  28116. */
  28117. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28118. /**
  28119. * Creates an extruded shape mesh.
  28120. * 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
  28121. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28123. * @param name defines the name of the mesh to create
  28124. * @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
  28125. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28126. * @param scale is the value to scale the shape
  28127. * @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
  28128. * @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
  28129. * @param scene defines the hosting scene
  28130. * @param updatable defines if the mesh must be flagged as updatable
  28131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28132. * @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)
  28133. * @returns a new Mesh
  28134. */
  28135. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28136. /**
  28137. * Creates an custom extruded shape mesh.
  28138. * The custom extrusion is a parametric shape.
  28139. * It has no predefined shape. Its final shape will depend on the input parameters.
  28140. * Please consider using the same method from the MeshBuilder class instead
  28141. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28142. * @param name defines the name of the mesh to create
  28143. * @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
  28144. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28145. * @param scaleFunction is a custom Javascript function called on each path point
  28146. * @param rotationFunction is a custom Javascript function called on each path point
  28147. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28148. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28149. * @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
  28150. * @param scene defines the hosting scene
  28151. * @param updatable defines if the mesh must be flagged as updatable
  28152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28153. * @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)
  28154. * @returns a new Mesh
  28155. */
  28156. 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;
  28157. /**
  28158. * Creates lathe mesh.
  28159. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28160. * Please consider using the same method from the MeshBuilder class instead
  28161. * @param name defines the name of the mesh to create
  28162. * @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
  28163. * @param radius is the radius value of the lathe
  28164. * @param tessellation is the side number of the lathe.
  28165. * @param scene defines the hosting scene
  28166. * @param updatable defines if the mesh must be flagged as updatable
  28167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28168. * @returns a new Mesh
  28169. */
  28170. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28171. /**
  28172. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28173. * @param name defines the name of the mesh to create
  28174. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28175. * @param scene defines the hosting scene
  28176. * @param updatable defines if the mesh must be flagged as updatable
  28177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28178. * @returns a new Mesh
  28179. */
  28180. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28181. /**
  28182. * Creates a ground mesh.
  28183. * Please consider using the same method from the MeshBuilder class instead
  28184. * @param name defines the name of the mesh to create
  28185. * @param width set the width of the ground
  28186. * @param height set the height of the ground
  28187. * @param subdivisions sets the number of subdivisions per side
  28188. * @param scene defines the hosting scene
  28189. * @param updatable defines if the mesh must be flagged as updatable
  28190. * @returns a new Mesh
  28191. */
  28192. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28193. /**
  28194. * Creates a tiled ground mesh.
  28195. * Please consider using the same method from the MeshBuilder class instead
  28196. * @param name defines the name of the mesh to create
  28197. * @param xmin set the ground minimum X coordinate
  28198. * @param zmin set the ground minimum Y coordinate
  28199. * @param xmax set the ground maximum X coordinate
  28200. * @param zmax set the ground maximum Z coordinate
  28201. * @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
  28202. * @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
  28203. * @param scene defines the hosting scene
  28204. * @param updatable defines if the mesh must be flagged as updatable
  28205. * @returns a new Mesh
  28206. */
  28207. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28208. w: number;
  28209. h: number;
  28210. }, precision: {
  28211. w: number;
  28212. h: number;
  28213. }, scene: Scene, updatable?: boolean): Mesh;
  28214. /**
  28215. * Creates a ground mesh from a height map.
  28216. * Please consider using the same method from the MeshBuilder class instead
  28217. * @see http://doc.babylonjs.com/babylon101/height_map
  28218. * @param name defines the name of the mesh to create
  28219. * @param url sets the URL of the height map image resource
  28220. * @param width set the ground width size
  28221. * @param height set the ground height size
  28222. * @param subdivisions sets the number of subdivision per side
  28223. * @param minHeight is the minimum altitude on the ground
  28224. * @param maxHeight is the maximum altitude on the ground
  28225. * @param scene defines the hosting scene
  28226. * @param updatable defines if the mesh must be flagged as updatable
  28227. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28228. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28229. * @returns a new Mesh
  28230. */
  28231. 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;
  28232. /**
  28233. * Creates a tube mesh.
  28234. * The tube is a parametric shape.
  28235. * It has no predefined shape. Its final shape will depend on the input parameters.
  28236. * Please consider using the same method from the MeshBuilder class instead
  28237. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28238. * @param name defines the name of the mesh to create
  28239. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28240. * @param radius sets the tube radius size
  28241. * @param tessellation is the number of sides on the tubular surface
  28242. * @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
  28243. * @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
  28244. * @param scene defines the hosting scene
  28245. * @param updatable defines if the mesh must be flagged as updatable
  28246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28247. * @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)
  28248. * @returns a new Mesh
  28249. */
  28250. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28251. (i: number, distance: number): number;
  28252. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28253. /**
  28254. * Creates a polyhedron mesh.
  28255. * Please consider using the same method from the MeshBuilder class instead.
  28256. * * 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
  28257. * * The parameter `size` (positive float, default 1) sets the polygon size
  28258. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28259. * * 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`
  28260. * * 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
  28261. * * 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)`)
  28262. * * 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
  28263. * * 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
  28264. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28265. * * 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
  28266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28267. * @param name defines the name of the mesh to create
  28268. * @param options defines the options used to create the mesh
  28269. * @param scene defines the hosting scene
  28270. * @returns a new Mesh
  28271. */
  28272. static CreatePolyhedron(name: string, options: {
  28273. type?: number;
  28274. size?: number;
  28275. sizeX?: number;
  28276. sizeY?: number;
  28277. sizeZ?: number;
  28278. custom?: any;
  28279. faceUV?: Vector4[];
  28280. faceColors?: Color4[];
  28281. updatable?: boolean;
  28282. sideOrientation?: number;
  28283. }, scene: Scene): Mesh;
  28284. /**
  28285. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28286. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28287. * * 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`)
  28288. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28289. * * 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
  28290. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28291. * * 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
  28292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28293. * @param name defines the name of the mesh
  28294. * @param options defines the options used to create the mesh
  28295. * @param scene defines the hosting scene
  28296. * @returns a new Mesh
  28297. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28298. */
  28299. static CreateIcoSphere(name: string, options: {
  28300. radius?: number;
  28301. flat?: boolean;
  28302. subdivisions?: number;
  28303. sideOrientation?: number;
  28304. updatable?: boolean;
  28305. }, scene: Scene): Mesh;
  28306. /**
  28307. * Creates a decal mesh.
  28308. * Please consider using the same method from the MeshBuilder class instead.
  28309. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28310. * @param name defines the name of the mesh
  28311. * @param sourceMesh defines the mesh receiving the decal
  28312. * @param position sets the position of the decal in world coordinates
  28313. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28314. * @param size sets the decal scaling
  28315. * @param angle sets the angle to rotate the decal
  28316. * @returns a new Mesh
  28317. */
  28318. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28319. /**
  28320. * Prepare internal position array for software CPU skinning
  28321. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28322. */
  28323. setPositionsForCPUSkinning(): Float32Array;
  28324. /**
  28325. * Prepare internal normal array for software CPU skinning
  28326. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28327. */
  28328. setNormalsForCPUSkinning(): Float32Array;
  28329. /**
  28330. * Updates the vertex buffer by applying transformation from the bones
  28331. * @param skeleton defines the skeleton to apply to current mesh
  28332. * @returns the current mesh
  28333. */
  28334. applySkeleton(skeleton: Skeleton): Mesh;
  28335. /**
  28336. * 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
  28337. * @param meshes defines the list of meshes to scan
  28338. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28339. */
  28340. static MinMax(meshes: AbstractMesh[]): {
  28341. min: Vector3;
  28342. max: Vector3;
  28343. };
  28344. /**
  28345. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28346. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28347. * @returns a vector3
  28348. */
  28349. static Center(meshesOrMinMaxVector: {
  28350. min: Vector3;
  28351. max: Vector3;
  28352. } | AbstractMesh[]): Vector3;
  28353. /**
  28354. * Merge the array of meshes into a single mesh for performance reasons.
  28355. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28356. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28357. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28358. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28359. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28360. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28361. * @returns a new mesh
  28362. */
  28363. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28364. /** @hidden */
  28365. addInstance(instance: InstancedMesh): void;
  28366. /** @hidden */
  28367. removeInstance(instance: InstancedMesh): void;
  28368. }
  28369. }
  28370. declare module BABYLON {
  28371. /**
  28372. * This is the base class of all the camera used in the application.
  28373. * @see http://doc.babylonjs.com/features/cameras
  28374. */
  28375. export class Camera extends Node {
  28376. /** @hidden */
  28377. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28378. /**
  28379. * This is the default projection mode used by the cameras.
  28380. * It helps recreating a feeling of perspective and better appreciate depth.
  28381. * This is the best way to simulate real life cameras.
  28382. */
  28383. static readonly PERSPECTIVE_CAMERA: number;
  28384. /**
  28385. * This helps creating camera with an orthographic mode.
  28386. * 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.
  28387. */
  28388. static readonly ORTHOGRAPHIC_CAMERA: number;
  28389. /**
  28390. * This is the default FOV mode for perspective cameras.
  28391. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28392. */
  28393. static readonly FOVMODE_VERTICAL_FIXED: number;
  28394. /**
  28395. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28396. */
  28397. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28398. /**
  28399. * This specifies ther is no need for a camera rig.
  28400. * Basically only one eye is rendered corresponding to the camera.
  28401. */
  28402. static readonly RIG_MODE_NONE: number;
  28403. /**
  28404. * Simulates a camera Rig with one blue eye and one red eye.
  28405. * This can be use with 3d blue and red glasses.
  28406. */
  28407. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28408. /**
  28409. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28410. */
  28411. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28412. /**
  28413. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28414. */
  28415. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28416. /**
  28417. * Defines that both eyes of the camera will be rendered over under each other.
  28418. */
  28419. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28420. /**
  28421. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28422. */
  28423. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28424. /**
  28425. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28426. */
  28427. static readonly RIG_MODE_VR: number;
  28428. /**
  28429. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28430. */
  28431. static readonly RIG_MODE_WEBVR: number;
  28432. /**
  28433. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28434. */
  28435. static readonly RIG_MODE_CUSTOM: number;
  28436. /**
  28437. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28438. */
  28439. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28440. /**
  28441. * Define the input manager associated with the camera.
  28442. */
  28443. inputs: CameraInputsManager<Camera>;
  28444. /** @hidden */
  28445. _position: Vector3;
  28446. /**
  28447. * Define the current local position of the camera in the scene
  28448. */
  28449. get position(): Vector3;
  28450. set position(newPosition: Vector3);
  28451. /**
  28452. * The vector the camera should consider as up.
  28453. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28454. */
  28455. upVector: Vector3;
  28456. /**
  28457. * Define the current limit on the left side for an orthographic camera
  28458. * In scene unit
  28459. */
  28460. orthoLeft: Nullable<number>;
  28461. /**
  28462. * Define the current limit on the right side for an orthographic camera
  28463. * In scene unit
  28464. */
  28465. orthoRight: Nullable<number>;
  28466. /**
  28467. * Define the current limit on the bottom side for an orthographic camera
  28468. * In scene unit
  28469. */
  28470. orthoBottom: Nullable<number>;
  28471. /**
  28472. * Define the current limit on the top side for an orthographic camera
  28473. * In scene unit
  28474. */
  28475. orthoTop: Nullable<number>;
  28476. /**
  28477. * Field Of View is set in Radians. (default is 0.8)
  28478. */
  28479. fov: number;
  28480. /**
  28481. * Define the minimum distance the camera can see from.
  28482. * This is important to note that the depth buffer are not infinite and the closer it starts
  28483. * the more your scene might encounter depth fighting issue.
  28484. */
  28485. minZ: number;
  28486. /**
  28487. * Define the maximum distance the camera can see to.
  28488. * This is important to note that the depth buffer are not infinite and the further it end
  28489. * the more your scene might encounter depth fighting issue.
  28490. */
  28491. maxZ: number;
  28492. /**
  28493. * Define the default inertia of the camera.
  28494. * This helps giving a smooth feeling to the camera movement.
  28495. */
  28496. inertia: number;
  28497. /**
  28498. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28499. */
  28500. mode: number;
  28501. /**
  28502. * Define whether the camera is intermediate.
  28503. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28504. */
  28505. isIntermediate: boolean;
  28506. /**
  28507. * Define the viewport of the camera.
  28508. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28509. */
  28510. viewport: Viewport;
  28511. /**
  28512. * Restricts the camera to viewing objects with the same layerMask.
  28513. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28514. */
  28515. layerMask: number;
  28516. /**
  28517. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28518. */
  28519. fovMode: number;
  28520. /**
  28521. * Rig mode of the camera.
  28522. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28523. * This is normally controlled byt the camera themselves as internal use.
  28524. */
  28525. cameraRigMode: number;
  28526. /**
  28527. * Defines the distance between both "eyes" in case of a RIG
  28528. */
  28529. interaxialDistance: number;
  28530. /**
  28531. * Defines if stereoscopic rendering is done side by side or over under.
  28532. */
  28533. isStereoscopicSideBySide: boolean;
  28534. /**
  28535. * 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
  28536. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28537. * else in the scene. (Eg. security camera)
  28538. *
  28539. * 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)
  28540. */
  28541. customRenderTargets: RenderTargetTexture[];
  28542. /**
  28543. * When set, the camera will render to this render target instead of the default canvas
  28544. *
  28545. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28546. */
  28547. outputRenderTarget: Nullable<RenderTargetTexture>;
  28548. /**
  28549. * Observable triggered when the camera view matrix has changed.
  28550. */
  28551. onViewMatrixChangedObservable: Observable<Camera>;
  28552. /**
  28553. * Observable triggered when the camera Projection matrix has changed.
  28554. */
  28555. onProjectionMatrixChangedObservable: Observable<Camera>;
  28556. /**
  28557. * Observable triggered when the inputs have been processed.
  28558. */
  28559. onAfterCheckInputsObservable: Observable<Camera>;
  28560. /**
  28561. * Observable triggered when reset has been called and applied to the camera.
  28562. */
  28563. onRestoreStateObservable: Observable<Camera>;
  28564. /**
  28565. * Is this camera a part of a rig system?
  28566. */
  28567. isRigCamera: boolean;
  28568. /**
  28569. * If isRigCamera set to true this will be set with the parent camera.
  28570. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28571. */
  28572. rigParent?: Camera;
  28573. /** @hidden */
  28574. _cameraRigParams: any;
  28575. /** @hidden */
  28576. _rigCameras: Camera[];
  28577. /** @hidden */
  28578. _rigPostProcess: Nullable<PostProcess>;
  28579. protected _webvrViewMatrix: Matrix;
  28580. /** @hidden */
  28581. _skipRendering: boolean;
  28582. /** @hidden */
  28583. _projectionMatrix: Matrix;
  28584. /** @hidden */
  28585. _postProcesses: Nullable<PostProcess>[];
  28586. /** @hidden */
  28587. _activeMeshes: SmartArray<AbstractMesh>;
  28588. protected _globalPosition: Vector3;
  28589. /** @hidden */
  28590. _computedViewMatrix: Matrix;
  28591. private _doNotComputeProjectionMatrix;
  28592. private _transformMatrix;
  28593. private _frustumPlanes;
  28594. private _refreshFrustumPlanes;
  28595. private _storedFov;
  28596. private _stateStored;
  28597. /**
  28598. * Instantiates a new camera object.
  28599. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28600. * @see http://doc.babylonjs.com/features/cameras
  28601. * @param name Defines the name of the camera in the scene
  28602. * @param position Defines the position of the camera
  28603. * @param scene Defines the scene the camera belongs too
  28604. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28605. */
  28606. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28607. /**
  28608. * Store current camera state (fov, position, etc..)
  28609. * @returns the camera
  28610. */
  28611. storeState(): Camera;
  28612. /**
  28613. * Restores the camera state values if it has been stored. You must call storeState() first
  28614. */
  28615. protected _restoreStateValues(): boolean;
  28616. /**
  28617. * Restored camera state. You must call storeState() first.
  28618. * @returns true if restored and false otherwise
  28619. */
  28620. restoreState(): boolean;
  28621. /**
  28622. * Gets the class name of the camera.
  28623. * @returns the class name
  28624. */
  28625. getClassName(): string;
  28626. /** @hidden */
  28627. readonly _isCamera: boolean;
  28628. /**
  28629. * Gets a string representation of the camera useful for debug purpose.
  28630. * @param fullDetails Defines that a more verboe level of logging is required
  28631. * @returns the string representation
  28632. */
  28633. toString(fullDetails?: boolean): string;
  28634. /**
  28635. * Gets the current world space position of the camera.
  28636. */
  28637. get globalPosition(): Vector3;
  28638. /**
  28639. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28640. * @returns the active meshe list
  28641. */
  28642. getActiveMeshes(): SmartArray<AbstractMesh>;
  28643. /**
  28644. * Check whether a mesh is part of the current active mesh list of the camera
  28645. * @param mesh Defines the mesh to check
  28646. * @returns true if active, false otherwise
  28647. */
  28648. isActiveMesh(mesh: Mesh): boolean;
  28649. /**
  28650. * Is this camera ready to be used/rendered
  28651. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28652. * @return true if the camera is ready
  28653. */
  28654. isReady(completeCheck?: boolean): boolean;
  28655. /** @hidden */
  28656. _initCache(): void;
  28657. /** @hidden */
  28658. _updateCache(ignoreParentClass?: boolean): void;
  28659. /** @hidden */
  28660. _isSynchronized(): boolean;
  28661. /** @hidden */
  28662. _isSynchronizedViewMatrix(): boolean;
  28663. /** @hidden */
  28664. _isSynchronizedProjectionMatrix(): boolean;
  28665. /**
  28666. * Attach the input controls to a specific dom element to get the input from.
  28667. * @param element Defines the element the controls should be listened from
  28668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28669. */
  28670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28671. /**
  28672. * Detach the current controls from the specified dom element.
  28673. * @param element Defines the element to stop listening the inputs from
  28674. */
  28675. detachControl(element: HTMLElement): void;
  28676. /**
  28677. * Update the camera state according to the different inputs gathered during the frame.
  28678. */
  28679. update(): void;
  28680. /** @hidden */
  28681. _checkInputs(): void;
  28682. /** @hidden */
  28683. get rigCameras(): Camera[];
  28684. /**
  28685. * Gets the post process used by the rig cameras
  28686. */
  28687. get rigPostProcess(): Nullable<PostProcess>;
  28688. /**
  28689. * Internal, gets the first post proces.
  28690. * @returns the first post process to be run on this camera.
  28691. */
  28692. _getFirstPostProcess(): Nullable<PostProcess>;
  28693. private _cascadePostProcessesToRigCams;
  28694. /**
  28695. * Attach a post process to the camera.
  28696. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28697. * @param postProcess The post process to attach to the camera
  28698. * @param insertAt The position of the post process in case several of them are in use in the scene
  28699. * @returns the position the post process has been inserted at
  28700. */
  28701. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28702. /**
  28703. * Detach a post process to the camera.
  28704. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28705. * @param postProcess The post process to detach from the camera
  28706. */
  28707. detachPostProcess(postProcess: PostProcess): void;
  28708. /**
  28709. * Gets the current world matrix of the camera
  28710. */
  28711. getWorldMatrix(): Matrix;
  28712. /** @hidden */
  28713. _getViewMatrix(): Matrix;
  28714. /**
  28715. * Gets the current view matrix of the camera.
  28716. * @param force forces the camera to recompute the matrix without looking at the cached state
  28717. * @returns the view matrix
  28718. */
  28719. getViewMatrix(force?: boolean): Matrix;
  28720. /**
  28721. * Freeze the projection matrix.
  28722. * It will prevent the cache check of the camera projection compute and can speed up perf
  28723. * if no parameter of the camera are meant to change
  28724. * @param projection Defines manually a projection if necessary
  28725. */
  28726. freezeProjectionMatrix(projection?: Matrix): void;
  28727. /**
  28728. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28729. */
  28730. unfreezeProjectionMatrix(): void;
  28731. /**
  28732. * Gets the current projection matrix of the camera.
  28733. * @param force forces the camera to recompute the matrix without looking at the cached state
  28734. * @returns the projection matrix
  28735. */
  28736. getProjectionMatrix(force?: boolean): Matrix;
  28737. /**
  28738. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28739. * @returns a Matrix
  28740. */
  28741. getTransformationMatrix(): Matrix;
  28742. private _updateFrustumPlanes;
  28743. /**
  28744. * Checks if a cullable object (mesh...) is in the camera frustum
  28745. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28746. * @param target The object to check
  28747. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28748. * @returns true if the object is in frustum otherwise false
  28749. */
  28750. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28751. /**
  28752. * Checks if a cullable object (mesh...) is in the camera frustum
  28753. * Unlike isInFrustum this cheks the full bounding box
  28754. * @param target The object to check
  28755. * @returns true if the object is in frustum otherwise false
  28756. */
  28757. isCompletelyInFrustum(target: ICullable): boolean;
  28758. /**
  28759. * Gets a ray in the forward direction from the camera.
  28760. * @param length Defines the length of the ray to create
  28761. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28762. * @param origin Defines the start point of the ray which defaults to the camera position
  28763. * @returns the forward ray
  28764. */
  28765. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28766. /**
  28767. * Releases resources associated with this node.
  28768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28770. */
  28771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28772. /** @hidden */
  28773. _isLeftCamera: boolean;
  28774. /**
  28775. * Gets the left camera of a rig setup in case of Rigged Camera
  28776. */
  28777. get isLeftCamera(): boolean;
  28778. /** @hidden */
  28779. _isRightCamera: boolean;
  28780. /**
  28781. * Gets the right camera of a rig setup in case of Rigged Camera
  28782. */
  28783. get isRightCamera(): boolean;
  28784. /**
  28785. * Gets the left camera of a rig setup in case of Rigged Camera
  28786. */
  28787. get leftCamera(): Nullable<FreeCamera>;
  28788. /**
  28789. * Gets the right camera of a rig setup in case of Rigged Camera
  28790. */
  28791. get rightCamera(): Nullable<FreeCamera>;
  28792. /**
  28793. * Gets the left camera target of a rig setup in case of Rigged Camera
  28794. * @returns the target position
  28795. */
  28796. getLeftTarget(): Nullable<Vector3>;
  28797. /**
  28798. * Gets the right camera target of a rig setup in case of Rigged Camera
  28799. * @returns the target position
  28800. */
  28801. getRightTarget(): Nullable<Vector3>;
  28802. /**
  28803. * @hidden
  28804. */
  28805. setCameraRigMode(mode: number, rigParams: any): void;
  28806. /** @hidden */
  28807. static _setStereoscopicRigMode(camera: Camera): void;
  28808. /** @hidden */
  28809. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28810. /** @hidden */
  28811. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28812. /** @hidden */
  28813. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28814. /** @hidden */
  28815. _getVRProjectionMatrix(): Matrix;
  28816. protected _updateCameraRotationMatrix(): void;
  28817. protected _updateWebVRCameraRotationMatrix(): void;
  28818. /**
  28819. * This function MUST be overwritten by the different WebVR cameras available.
  28820. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28821. * @hidden
  28822. */
  28823. _getWebVRProjectionMatrix(): Matrix;
  28824. /**
  28825. * This function MUST be overwritten by the different WebVR cameras available.
  28826. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28827. * @hidden
  28828. */
  28829. _getWebVRViewMatrix(): Matrix;
  28830. /** @hidden */
  28831. setCameraRigParameter(name: string, value: any): void;
  28832. /**
  28833. * needs to be overridden by children so sub has required properties to be copied
  28834. * @hidden
  28835. */
  28836. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28837. /**
  28838. * May need to be overridden by children
  28839. * @hidden
  28840. */
  28841. _updateRigCameras(): void;
  28842. /** @hidden */
  28843. _setupInputs(): void;
  28844. /**
  28845. * Serialiaze the camera setup to a json represention
  28846. * @returns the JSON representation
  28847. */
  28848. serialize(): any;
  28849. /**
  28850. * Clones the current camera.
  28851. * @param name The cloned camera name
  28852. * @returns the cloned camera
  28853. */
  28854. clone(name: string): Camera;
  28855. /**
  28856. * Gets the direction of the camera relative to a given local axis.
  28857. * @param localAxis Defines the reference axis to provide a relative direction.
  28858. * @return the direction
  28859. */
  28860. getDirection(localAxis: Vector3): Vector3;
  28861. /**
  28862. * Returns the current camera absolute rotation
  28863. */
  28864. get absoluteRotation(): Quaternion;
  28865. /**
  28866. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28867. * @param localAxis Defines the reference axis to provide a relative direction.
  28868. * @param result Defines the vector to store the result in
  28869. */
  28870. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28871. /**
  28872. * Gets a camera constructor for a given camera type
  28873. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28874. * @param name The name of the camera the result will be able to instantiate
  28875. * @param scene The scene the result will construct the camera in
  28876. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28877. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28878. * @returns a factory method to construc the camera
  28879. */
  28880. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28881. /**
  28882. * Compute the world matrix of the camera.
  28883. * @returns the camera world matrix
  28884. */
  28885. computeWorldMatrix(): Matrix;
  28886. /**
  28887. * Parse a JSON and creates the camera from the parsed information
  28888. * @param parsedCamera The JSON to parse
  28889. * @param scene The scene to instantiate the camera in
  28890. * @returns the newly constructed camera
  28891. */
  28892. static Parse(parsedCamera: any, scene: Scene): Camera;
  28893. }
  28894. }
  28895. declare module BABYLON {
  28896. /**
  28897. * Class containing static functions to help procedurally build meshes
  28898. */
  28899. export class DiscBuilder {
  28900. /**
  28901. * Creates a plane polygonal mesh. By default, this is a disc
  28902. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28903. * * 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
  28904. * * 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
  28905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28906. * * 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
  28907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28908. * @param name defines the name of the mesh
  28909. * @param options defines the options used to create the mesh
  28910. * @param scene defines the hosting scene
  28911. * @returns the plane polygonal mesh
  28912. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28913. */
  28914. static CreateDisc(name: string, options: {
  28915. radius?: number;
  28916. tessellation?: number;
  28917. arc?: number;
  28918. updatable?: boolean;
  28919. sideOrientation?: number;
  28920. frontUVs?: Vector4;
  28921. backUVs?: Vector4;
  28922. }, scene?: Nullable<Scene>): Mesh;
  28923. }
  28924. }
  28925. declare module BABYLON {
  28926. /**
  28927. * Options to be used when creating a FresnelParameters.
  28928. */
  28929. export type IFresnelParametersCreationOptions = {
  28930. /**
  28931. * Define the color used on edges (grazing angle)
  28932. */
  28933. leftColor?: Color3;
  28934. /**
  28935. * Define the color used on center
  28936. */
  28937. rightColor?: Color3;
  28938. /**
  28939. * Define bias applied to computed fresnel term
  28940. */
  28941. bias?: number;
  28942. /**
  28943. * Defined the power exponent applied to fresnel term
  28944. */
  28945. power?: number;
  28946. /**
  28947. * Define if the fresnel effect is enable or not.
  28948. */
  28949. isEnabled?: boolean;
  28950. };
  28951. /**
  28952. * Serialized format for FresnelParameters.
  28953. */
  28954. export type IFresnelParametersSerialized = {
  28955. /**
  28956. * Define the color used on edges (grazing angle) [as an array]
  28957. */
  28958. leftColor: number[];
  28959. /**
  28960. * Define the color used on center [as an array]
  28961. */
  28962. rightColor: number[];
  28963. /**
  28964. * Define bias applied to computed fresnel term
  28965. */
  28966. bias: number;
  28967. /**
  28968. * Defined the power exponent applied to fresnel term
  28969. */
  28970. power?: number;
  28971. /**
  28972. * Define if the fresnel effect is enable or not.
  28973. */
  28974. isEnabled: boolean;
  28975. };
  28976. /**
  28977. * This represents all the required information to add a fresnel effect on a material:
  28978. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28979. */
  28980. export class FresnelParameters {
  28981. private _isEnabled;
  28982. /**
  28983. * Define if the fresnel effect is enable or not.
  28984. */
  28985. get isEnabled(): boolean;
  28986. set isEnabled(value: boolean);
  28987. /**
  28988. * Define the color used on edges (grazing angle)
  28989. */
  28990. leftColor: Color3;
  28991. /**
  28992. * Define the color used on center
  28993. */
  28994. rightColor: Color3;
  28995. /**
  28996. * Define bias applied to computed fresnel term
  28997. */
  28998. bias: number;
  28999. /**
  29000. * Defined the power exponent applied to fresnel term
  29001. */
  29002. power: number;
  29003. /**
  29004. * Creates a new FresnelParameters object.
  29005. *
  29006. * @param options provide your own settings to optionally to override defaults
  29007. */
  29008. constructor(options?: IFresnelParametersCreationOptions);
  29009. /**
  29010. * Clones the current fresnel and its valuues
  29011. * @returns a clone fresnel configuration
  29012. */
  29013. clone(): FresnelParameters;
  29014. /**
  29015. * Determines equality between FresnelParameters objects
  29016. * @param otherFresnelParameters defines the second operand
  29017. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29018. */
  29019. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29020. /**
  29021. * Serializes the current fresnel parameters to a JSON representation.
  29022. * @return the JSON serialization
  29023. */
  29024. serialize(): IFresnelParametersSerialized;
  29025. /**
  29026. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29027. * @param parsedFresnelParameters Define the JSON representation
  29028. * @returns the parsed parameters
  29029. */
  29030. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29031. }
  29032. }
  29033. declare module BABYLON {
  29034. /**
  29035. * This groups all the flags used to control the materials channel.
  29036. */
  29037. export class MaterialFlags {
  29038. private static _DiffuseTextureEnabled;
  29039. /**
  29040. * Are diffuse textures enabled in the application.
  29041. */
  29042. static get DiffuseTextureEnabled(): boolean;
  29043. static set DiffuseTextureEnabled(value: boolean);
  29044. private static _AmbientTextureEnabled;
  29045. /**
  29046. * Are ambient textures enabled in the application.
  29047. */
  29048. static get AmbientTextureEnabled(): boolean;
  29049. static set AmbientTextureEnabled(value: boolean);
  29050. private static _OpacityTextureEnabled;
  29051. /**
  29052. * Are opacity textures enabled in the application.
  29053. */
  29054. static get OpacityTextureEnabled(): boolean;
  29055. static set OpacityTextureEnabled(value: boolean);
  29056. private static _ReflectionTextureEnabled;
  29057. /**
  29058. * Are reflection textures enabled in the application.
  29059. */
  29060. static get ReflectionTextureEnabled(): boolean;
  29061. static set ReflectionTextureEnabled(value: boolean);
  29062. private static _EmissiveTextureEnabled;
  29063. /**
  29064. * Are emissive textures enabled in the application.
  29065. */
  29066. static get EmissiveTextureEnabled(): boolean;
  29067. static set EmissiveTextureEnabled(value: boolean);
  29068. private static _SpecularTextureEnabled;
  29069. /**
  29070. * Are specular textures enabled in the application.
  29071. */
  29072. static get SpecularTextureEnabled(): boolean;
  29073. static set SpecularTextureEnabled(value: boolean);
  29074. private static _BumpTextureEnabled;
  29075. /**
  29076. * Are bump textures enabled in the application.
  29077. */
  29078. static get BumpTextureEnabled(): boolean;
  29079. static set BumpTextureEnabled(value: boolean);
  29080. private static _LightmapTextureEnabled;
  29081. /**
  29082. * Are lightmap textures enabled in the application.
  29083. */
  29084. static get LightmapTextureEnabled(): boolean;
  29085. static set LightmapTextureEnabled(value: boolean);
  29086. private static _RefractionTextureEnabled;
  29087. /**
  29088. * Are refraction textures enabled in the application.
  29089. */
  29090. static get RefractionTextureEnabled(): boolean;
  29091. static set RefractionTextureEnabled(value: boolean);
  29092. private static _ColorGradingTextureEnabled;
  29093. /**
  29094. * Are color grading textures enabled in the application.
  29095. */
  29096. static get ColorGradingTextureEnabled(): boolean;
  29097. static set ColorGradingTextureEnabled(value: boolean);
  29098. private static _FresnelEnabled;
  29099. /**
  29100. * Are fresnels enabled in the application.
  29101. */
  29102. static get FresnelEnabled(): boolean;
  29103. static set FresnelEnabled(value: boolean);
  29104. private static _ClearCoatTextureEnabled;
  29105. /**
  29106. * Are clear coat textures enabled in the application.
  29107. */
  29108. static get ClearCoatTextureEnabled(): boolean;
  29109. static set ClearCoatTextureEnabled(value: boolean);
  29110. private static _ClearCoatBumpTextureEnabled;
  29111. /**
  29112. * Are clear coat bump textures enabled in the application.
  29113. */
  29114. static get ClearCoatBumpTextureEnabled(): boolean;
  29115. static set ClearCoatBumpTextureEnabled(value: boolean);
  29116. private static _ClearCoatTintTextureEnabled;
  29117. /**
  29118. * Are clear coat tint textures enabled in the application.
  29119. */
  29120. static get ClearCoatTintTextureEnabled(): boolean;
  29121. static set ClearCoatTintTextureEnabled(value: boolean);
  29122. private static _SheenTextureEnabled;
  29123. /**
  29124. * Are sheen textures enabled in the application.
  29125. */
  29126. static get SheenTextureEnabled(): boolean;
  29127. static set SheenTextureEnabled(value: boolean);
  29128. private static _AnisotropicTextureEnabled;
  29129. /**
  29130. * Are anisotropic textures enabled in the application.
  29131. */
  29132. static get AnisotropicTextureEnabled(): boolean;
  29133. static set AnisotropicTextureEnabled(value: boolean);
  29134. private static _ThicknessTextureEnabled;
  29135. /**
  29136. * Are thickness textures enabled in the application.
  29137. */
  29138. static get ThicknessTextureEnabled(): boolean;
  29139. static set ThicknessTextureEnabled(value: boolean);
  29140. }
  29141. }
  29142. declare module BABYLON {
  29143. /** @hidden */
  29144. export var defaultFragmentDeclaration: {
  29145. name: string;
  29146. shader: string;
  29147. };
  29148. }
  29149. declare module BABYLON {
  29150. /** @hidden */
  29151. export var defaultUboDeclaration: {
  29152. name: string;
  29153. shader: string;
  29154. };
  29155. }
  29156. declare module BABYLON {
  29157. /** @hidden */
  29158. export var lightFragmentDeclaration: {
  29159. name: string;
  29160. shader: string;
  29161. };
  29162. }
  29163. declare module BABYLON {
  29164. /** @hidden */
  29165. export var lightUboDeclaration: {
  29166. name: string;
  29167. shader: string;
  29168. };
  29169. }
  29170. declare module BABYLON {
  29171. /** @hidden */
  29172. export var lightsFragmentFunctions: {
  29173. name: string;
  29174. shader: string;
  29175. };
  29176. }
  29177. declare module BABYLON {
  29178. /** @hidden */
  29179. export var shadowsFragmentFunctions: {
  29180. name: string;
  29181. shader: string;
  29182. };
  29183. }
  29184. declare module BABYLON {
  29185. /** @hidden */
  29186. export var fresnelFunction: {
  29187. name: string;
  29188. shader: string;
  29189. };
  29190. }
  29191. declare module BABYLON {
  29192. /** @hidden */
  29193. export var bumpFragmentMainFunctions: {
  29194. name: string;
  29195. shader: string;
  29196. };
  29197. }
  29198. declare module BABYLON {
  29199. /** @hidden */
  29200. export var bumpFragmentFunctions: {
  29201. name: string;
  29202. shader: string;
  29203. };
  29204. }
  29205. declare module BABYLON {
  29206. /** @hidden */
  29207. export var logDepthDeclaration: {
  29208. name: string;
  29209. shader: string;
  29210. };
  29211. }
  29212. declare module BABYLON {
  29213. /** @hidden */
  29214. export var bumpFragment: {
  29215. name: string;
  29216. shader: string;
  29217. };
  29218. }
  29219. declare module BABYLON {
  29220. /** @hidden */
  29221. export var depthPrePass: {
  29222. name: string;
  29223. shader: string;
  29224. };
  29225. }
  29226. declare module BABYLON {
  29227. /** @hidden */
  29228. export var lightFragment: {
  29229. name: string;
  29230. shader: string;
  29231. };
  29232. }
  29233. declare module BABYLON {
  29234. /** @hidden */
  29235. export var logDepthFragment: {
  29236. name: string;
  29237. shader: string;
  29238. };
  29239. }
  29240. declare module BABYLON {
  29241. /** @hidden */
  29242. export var defaultPixelShader: {
  29243. name: string;
  29244. shader: string;
  29245. };
  29246. }
  29247. declare module BABYLON {
  29248. /** @hidden */
  29249. export var defaultVertexDeclaration: {
  29250. name: string;
  29251. shader: string;
  29252. };
  29253. }
  29254. declare module BABYLON {
  29255. /** @hidden */
  29256. export var bumpVertexDeclaration: {
  29257. name: string;
  29258. shader: string;
  29259. };
  29260. }
  29261. declare module BABYLON {
  29262. /** @hidden */
  29263. export var bumpVertex: {
  29264. name: string;
  29265. shader: string;
  29266. };
  29267. }
  29268. declare module BABYLON {
  29269. /** @hidden */
  29270. export var fogVertex: {
  29271. name: string;
  29272. shader: string;
  29273. };
  29274. }
  29275. declare module BABYLON {
  29276. /** @hidden */
  29277. export var shadowsVertex: {
  29278. name: string;
  29279. shader: string;
  29280. };
  29281. }
  29282. declare module BABYLON {
  29283. /** @hidden */
  29284. export var pointCloudVertex: {
  29285. name: string;
  29286. shader: string;
  29287. };
  29288. }
  29289. declare module BABYLON {
  29290. /** @hidden */
  29291. export var logDepthVertex: {
  29292. name: string;
  29293. shader: string;
  29294. };
  29295. }
  29296. declare module BABYLON {
  29297. /** @hidden */
  29298. export var defaultVertexShader: {
  29299. name: string;
  29300. shader: string;
  29301. };
  29302. }
  29303. declare module BABYLON {
  29304. /** @hidden */
  29305. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29306. MAINUV1: boolean;
  29307. MAINUV2: boolean;
  29308. DIFFUSE: boolean;
  29309. DIFFUSEDIRECTUV: number;
  29310. AMBIENT: boolean;
  29311. AMBIENTDIRECTUV: number;
  29312. OPACITY: boolean;
  29313. OPACITYDIRECTUV: number;
  29314. OPACITYRGB: boolean;
  29315. REFLECTION: boolean;
  29316. EMISSIVE: boolean;
  29317. EMISSIVEDIRECTUV: number;
  29318. SPECULAR: boolean;
  29319. SPECULARDIRECTUV: number;
  29320. BUMP: boolean;
  29321. BUMPDIRECTUV: number;
  29322. PARALLAX: boolean;
  29323. PARALLAXOCCLUSION: boolean;
  29324. SPECULAROVERALPHA: boolean;
  29325. CLIPPLANE: boolean;
  29326. CLIPPLANE2: boolean;
  29327. CLIPPLANE3: boolean;
  29328. CLIPPLANE4: boolean;
  29329. CLIPPLANE5: boolean;
  29330. CLIPPLANE6: boolean;
  29331. ALPHATEST: boolean;
  29332. DEPTHPREPASS: boolean;
  29333. ALPHAFROMDIFFUSE: boolean;
  29334. POINTSIZE: boolean;
  29335. FOG: boolean;
  29336. SPECULARTERM: boolean;
  29337. DIFFUSEFRESNEL: boolean;
  29338. OPACITYFRESNEL: boolean;
  29339. REFLECTIONFRESNEL: boolean;
  29340. REFRACTIONFRESNEL: boolean;
  29341. EMISSIVEFRESNEL: boolean;
  29342. FRESNEL: boolean;
  29343. NORMAL: boolean;
  29344. UV1: boolean;
  29345. UV2: boolean;
  29346. VERTEXCOLOR: boolean;
  29347. VERTEXALPHA: boolean;
  29348. NUM_BONE_INFLUENCERS: number;
  29349. BonesPerMesh: number;
  29350. BONETEXTURE: boolean;
  29351. INSTANCES: boolean;
  29352. THIN_INSTANCES: boolean;
  29353. GLOSSINESS: boolean;
  29354. ROUGHNESS: boolean;
  29355. EMISSIVEASILLUMINATION: boolean;
  29356. LINKEMISSIVEWITHDIFFUSE: boolean;
  29357. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29358. LIGHTMAP: boolean;
  29359. LIGHTMAPDIRECTUV: number;
  29360. OBJECTSPACE_NORMALMAP: boolean;
  29361. USELIGHTMAPASSHADOWMAP: boolean;
  29362. REFLECTIONMAP_3D: boolean;
  29363. REFLECTIONMAP_SPHERICAL: boolean;
  29364. REFLECTIONMAP_PLANAR: boolean;
  29365. REFLECTIONMAP_CUBIC: boolean;
  29366. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29367. REFLECTIONMAP_PROJECTION: boolean;
  29368. REFLECTIONMAP_SKYBOX: boolean;
  29369. REFLECTIONMAP_EXPLICIT: boolean;
  29370. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29371. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29372. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29373. INVERTCUBICMAP: boolean;
  29374. LOGARITHMICDEPTH: boolean;
  29375. REFRACTION: boolean;
  29376. REFRACTIONMAP_3D: boolean;
  29377. REFLECTIONOVERALPHA: boolean;
  29378. TWOSIDEDLIGHTING: boolean;
  29379. SHADOWFLOAT: boolean;
  29380. MORPHTARGETS: boolean;
  29381. MORPHTARGETS_NORMAL: boolean;
  29382. MORPHTARGETS_TANGENT: boolean;
  29383. MORPHTARGETS_UV: boolean;
  29384. NUM_MORPH_INFLUENCERS: number;
  29385. NONUNIFORMSCALING: boolean;
  29386. PREMULTIPLYALPHA: boolean;
  29387. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29388. ALPHABLEND: boolean;
  29389. RGBDLIGHTMAP: boolean;
  29390. RGBDREFLECTION: boolean;
  29391. RGBDREFRACTION: boolean;
  29392. IMAGEPROCESSING: boolean;
  29393. VIGNETTE: boolean;
  29394. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29395. VIGNETTEBLENDMODEOPAQUE: boolean;
  29396. TONEMAPPING: boolean;
  29397. TONEMAPPING_ACES: boolean;
  29398. CONTRAST: boolean;
  29399. COLORCURVES: boolean;
  29400. COLORGRADING: boolean;
  29401. COLORGRADING3D: boolean;
  29402. SAMPLER3DGREENDEPTH: boolean;
  29403. SAMPLER3DBGRMAP: boolean;
  29404. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29405. MULTIVIEW: boolean;
  29406. /**
  29407. * If the reflection texture on this material is in linear color space
  29408. * @hidden
  29409. */
  29410. IS_REFLECTION_LINEAR: boolean;
  29411. /**
  29412. * If the refraction texture on this material is in linear color space
  29413. * @hidden
  29414. */
  29415. IS_REFRACTION_LINEAR: boolean;
  29416. EXPOSURE: boolean;
  29417. constructor();
  29418. setReflectionMode(modeToEnable: string): void;
  29419. }
  29420. /**
  29421. * This is the default material used in Babylon. It is the best trade off between quality
  29422. * and performances.
  29423. * @see http://doc.babylonjs.com/babylon101/materials
  29424. */
  29425. export class StandardMaterial extends PushMaterial {
  29426. private _diffuseTexture;
  29427. /**
  29428. * The basic texture of the material as viewed under a light.
  29429. */
  29430. diffuseTexture: Nullable<BaseTexture>;
  29431. private _ambientTexture;
  29432. /**
  29433. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29434. */
  29435. ambientTexture: Nullable<BaseTexture>;
  29436. private _opacityTexture;
  29437. /**
  29438. * Define the transparency of the material from a texture.
  29439. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29440. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29441. */
  29442. opacityTexture: Nullable<BaseTexture>;
  29443. private _reflectionTexture;
  29444. /**
  29445. * Define the texture used to display the reflection.
  29446. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29447. */
  29448. reflectionTexture: Nullable<BaseTexture>;
  29449. private _emissiveTexture;
  29450. /**
  29451. * Define texture of the material as if self lit.
  29452. * This will be mixed in the final result even in the absence of light.
  29453. */
  29454. emissiveTexture: Nullable<BaseTexture>;
  29455. private _specularTexture;
  29456. /**
  29457. * Define how the color and intensity of the highlight given by the light in the material.
  29458. */
  29459. specularTexture: Nullable<BaseTexture>;
  29460. private _bumpTexture;
  29461. /**
  29462. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29463. * 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.
  29464. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29465. */
  29466. bumpTexture: Nullable<BaseTexture>;
  29467. private _lightmapTexture;
  29468. /**
  29469. * Complex lighting can be computationally expensive to compute at runtime.
  29470. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29471. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29472. */
  29473. lightmapTexture: Nullable<BaseTexture>;
  29474. private _refractionTexture;
  29475. /**
  29476. * Define the texture used to display the refraction.
  29477. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29478. */
  29479. refractionTexture: Nullable<BaseTexture>;
  29480. /**
  29481. * The color of the material lit by the environmental background lighting.
  29482. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29483. */
  29484. ambientColor: Color3;
  29485. /**
  29486. * The basic color of the material as viewed under a light.
  29487. */
  29488. diffuseColor: Color3;
  29489. /**
  29490. * Define how the color and intensity of the highlight given by the light in the material.
  29491. */
  29492. specularColor: Color3;
  29493. /**
  29494. * Define the color of the material as if self lit.
  29495. * This will be mixed in the final result even in the absence of light.
  29496. */
  29497. emissiveColor: Color3;
  29498. /**
  29499. * Defines how sharp are the highlights in the material.
  29500. * The bigger the value the sharper giving a more glossy feeling to the result.
  29501. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29502. */
  29503. specularPower: number;
  29504. private _useAlphaFromDiffuseTexture;
  29505. /**
  29506. * Does the transparency come from the diffuse texture alpha channel.
  29507. */
  29508. useAlphaFromDiffuseTexture: boolean;
  29509. private _useEmissiveAsIllumination;
  29510. /**
  29511. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29512. */
  29513. useEmissiveAsIllumination: boolean;
  29514. private _linkEmissiveWithDiffuse;
  29515. /**
  29516. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29517. * the emissive level when the final color is close to one.
  29518. */
  29519. linkEmissiveWithDiffuse: boolean;
  29520. private _useSpecularOverAlpha;
  29521. /**
  29522. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29523. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29524. */
  29525. useSpecularOverAlpha: boolean;
  29526. private _useReflectionOverAlpha;
  29527. /**
  29528. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29529. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29530. */
  29531. useReflectionOverAlpha: boolean;
  29532. private _disableLighting;
  29533. /**
  29534. * Does lights from the scene impacts this material.
  29535. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29536. */
  29537. disableLighting: boolean;
  29538. private _useObjectSpaceNormalMap;
  29539. /**
  29540. * Allows using an object space normal map (instead of tangent space).
  29541. */
  29542. useObjectSpaceNormalMap: boolean;
  29543. private _useParallax;
  29544. /**
  29545. * Is parallax enabled or not.
  29546. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29547. */
  29548. useParallax: boolean;
  29549. private _useParallaxOcclusion;
  29550. /**
  29551. * Is parallax occlusion enabled or not.
  29552. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29553. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29554. */
  29555. useParallaxOcclusion: boolean;
  29556. /**
  29557. * 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.
  29558. */
  29559. parallaxScaleBias: number;
  29560. private _roughness;
  29561. /**
  29562. * Helps to define how blurry the reflections should appears in the material.
  29563. */
  29564. roughness: number;
  29565. /**
  29566. * In case of refraction, define the value of the index of refraction.
  29567. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29568. */
  29569. indexOfRefraction: number;
  29570. /**
  29571. * Invert the refraction texture alongside the y axis.
  29572. * It can be useful with procedural textures or probe for instance.
  29573. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29574. */
  29575. invertRefractionY: boolean;
  29576. /**
  29577. * Defines the alpha limits in alpha test mode.
  29578. */
  29579. alphaCutOff: number;
  29580. private _useLightmapAsShadowmap;
  29581. /**
  29582. * In case of light mapping, define whether the map contains light or shadow informations.
  29583. */
  29584. useLightmapAsShadowmap: boolean;
  29585. private _diffuseFresnelParameters;
  29586. /**
  29587. * Define the diffuse fresnel parameters of the material.
  29588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29589. */
  29590. diffuseFresnelParameters: FresnelParameters;
  29591. private _opacityFresnelParameters;
  29592. /**
  29593. * Define the opacity fresnel parameters of the material.
  29594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29595. */
  29596. opacityFresnelParameters: FresnelParameters;
  29597. private _reflectionFresnelParameters;
  29598. /**
  29599. * Define the reflection fresnel parameters of the material.
  29600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29601. */
  29602. reflectionFresnelParameters: FresnelParameters;
  29603. private _refractionFresnelParameters;
  29604. /**
  29605. * Define the refraction fresnel parameters of the material.
  29606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29607. */
  29608. refractionFresnelParameters: FresnelParameters;
  29609. private _emissiveFresnelParameters;
  29610. /**
  29611. * Define the emissive fresnel parameters of the material.
  29612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29613. */
  29614. emissiveFresnelParameters: FresnelParameters;
  29615. private _useReflectionFresnelFromSpecular;
  29616. /**
  29617. * If true automatically deducts the fresnels values from the material specularity.
  29618. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29619. */
  29620. useReflectionFresnelFromSpecular: boolean;
  29621. private _useGlossinessFromSpecularMapAlpha;
  29622. /**
  29623. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29624. */
  29625. useGlossinessFromSpecularMapAlpha: boolean;
  29626. private _maxSimultaneousLights;
  29627. /**
  29628. * Defines the maximum number of lights that can be used in the material
  29629. */
  29630. maxSimultaneousLights: number;
  29631. private _invertNormalMapX;
  29632. /**
  29633. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29634. */
  29635. invertNormalMapX: boolean;
  29636. private _invertNormalMapY;
  29637. /**
  29638. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29639. */
  29640. invertNormalMapY: boolean;
  29641. private _twoSidedLighting;
  29642. /**
  29643. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29644. */
  29645. twoSidedLighting: boolean;
  29646. /**
  29647. * Default configuration related to image processing available in the standard Material.
  29648. */
  29649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29650. /**
  29651. * Gets the image processing configuration used either in this material.
  29652. */
  29653. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29654. /**
  29655. * Sets the Default image processing configuration used either in the this material.
  29656. *
  29657. * If sets to null, the scene one is in use.
  29658. */
  29659. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29660. /**
  29661. * Keep track of the image processing observer to allow dispose and replace.
  29662. */
  29663. private _imageProcessingObserver;
  29664. /**
  29665. * Attaches a new image processing configuration to the Standard Material.
  29666. * @param configuration
  29667. */
  29668. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29669. /**
  29670. * Gets wether the color curves effect is enabled.
  29671. */
  29672. get cameraColorCurvesEnabled(): boolean;
  29673. /**
  29674. * Sets wether the color curves effect is enabled.
  29675. */
  29676. set cameraColorCurvesEnabled(value: boolean);
  29677. /**
  29678. * Gets wether the color grading effect is enabled.
  29679. */
  29680. get cameraColorGradingEnabled(): boolean;
  29681. /**
  29682. * Gets wether the color grading effect is enabled.
  29683. */
  29684. set cameraColorGradingEnabled(value: boolean);
  29685. /**
  29686. * Gets wether tonemapping is enabled or not.
  29687. */
  29688. get cameraToneMappingEnabled(): boolean;
  29689. /**
  29690. * Sets wether tonemapping is enabled or not
  29691. */
  29692. set cameraToneMappingEnabled(value: boolean);
  29693. /**
  29694. * The camera exposure used on this material.
  29695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29696. * This corresponds to a photographic exposure.
  29697. */
  29698. get cameraExposure(): number;
  29699. /**
  29700. * The camera exposure used on this material.
  29701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29702. * This corresponds to a photographic exposure.
  29703. */
  29704. set cameraExposure(value: number);
  29705. /**
  29706. * Gets The camera contrast used on this material.
  29707. */
  29708. get cameraContrast(): number;
  29709. /**
  29710. * Sets The camera contrast used on this material.
  29711. */
  29712. set cameraContrast(value: number);
  29713. /**
  29714. * Gets the Color Grading 2D Lookup Texture.
  29715. */
  29716. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29717. /**
  29718. * Sets the Color Grading 2D Lookup Texture.
  29719. */
  29720. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29721. /**
  29722. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29723. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29724. * 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;
  29725. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29726. */
  29727. get cameraColorCurves(): Nullable<ColorCurves>;
  29728. /**
  29729. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29731. * 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;
  29732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29733. */
  29734. set cameraColorCurves(value: Nullable<ColorCurves>);
  29735. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29736. protected _worldViewProjectionMatrix: Matrix;
  29737. protected _globalAmbientColor: Color3;
  29738. protected _useLogarithmicDepth: boolean;
  29739. protected _rebuildInParallel: boolean;
  29740. /**
  29741. * Instantiates a new standard material.
  29742. * This is the default material used in Babylon. It is the best trade off between quality
  29743. * and performances.
  29744. * @see http://doc.babylonjs.com/babylon101/materials
  29745. * @param name Define the name of the material in the scene
  29746. * @param scene Define the scene the material belong to
  29747. */
  29748. constructor(name: string, scene: Scene);
  29749. /**
  29750. * Gets a boolean indicating that current material needs to register RTT
  29751. */
  29752. get hasRenderTargetTextures(): boolean;
  29753. /**
  29754. * Gets the current class name of the material e.g. "StandardMaterial"
  29755. * Mainly use in serialization.
  29756. * @returns the class name
  29757. */
  29758. getClassName(): string;
  29759. /**
  29760. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29761. * You can try switching to logarithmic depth.
  29762. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29763. */
  29764. get useLogarithmicDepth(): boolean;
  29765. set useLogarithmicDepth(value: boolean);
  29766. /**
  29767. * Specifies if the material will require alpha blending
  29768. * @returns a boolean specifying if alpha blending is needed
  29769. */
  29770. needAlphaBlending(): boolean;
  29771. /**
  29772. * Specifies if this material should be rendered in alpha test mode
  29773. * @returns a boolean specifying if an alpha test is needed.
  29774. */
  29775. needAlphaTesting(): boolean;
  29776. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29777. /**
  29778. * Get the texture used for alpha test purpose.
  29779. * @returns the diffuse texture in case of the standard material.
  29780. */
  29781. getAlphaTestTexture(): Nullable<BaseTexture>;
  29782. /**
  29783. * Get if the submesh is ready to be used and all its information available.
  29784. * Child classes can use it to update shaders
  29785. * @param mesh defines the mesh to check
  29786. * @param subMesh defines which submesh to check
  29787. * @param useInstances specifies that instances should be used
  29788. * @returns a boolean indicating that the submesh is ready or not
  29789. */
  29790. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29791. /**
  29792. * Builds the material UBO layouts.
  29793. * Used internally during the effect preparation.
  29794. */
  29795. buildUniformLayout(): void;
  29796. /**
  29797. * Unbinds the material from the mesh
  29798. */
  29799. unbind(): void;
  29800. /**
  29801. * Binds the submesh to this material by preparing the effect and shader to draw
  29802. * @param world defines the world transformation matrix
  29803. * @param mesh defines the mesh containing the submesh
  29804. * @param subMesh defines the submesh to bind the material to
  29805. */
  29806. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29807. /**
  29808. * Get the list of animatables in the material.
  29809. * @returns the list of animatables object used in the material
  29810. */
  29811. getAnimatables(): IAnimatable[];
  29812. /**
  29813. * Gets the active textures from the material
  29814. * @returns an array of textures
  29815. */
  29816. getActiveTextures(): BaseTexture[];
  29817. /**
  29818. * Specifies if the material uses a texture
  29819. * @param texture defines the texture to check against the material
  29820. * @returns a boolean specifying if the material uses the texture
  29821. */
  29822. hasTexture(texture: BaseTexture): boolean;
  29823. /**
  29824. * Disposes the material
  29825. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29826. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29827. */
  29828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29829. /**
  29830. * Makes a duplicate of the material, and gives it a new name
  29831. * @param name defines the new name for the duplicated material
  29832. * @returns the cloned material
  29833. */
  29834. clone(name: string): StandardMaterial;
  29835. /**
  29836. * Serializes this material in a JSON representation
  29837. * @returns the serialized material object
  29838. */
  29839. serialize(): any;
  29840. /**
  29841. * Creates a standard material from parsed material data
  29842. * @param source defines the JSON representation of the material
  29843. * @param scene defines the hosting scene
  29844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29845. * @returns a new standard material
  29846. */
  29847. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29848. /**
  29849. * Are diffuse textures enabled in the application.
  29850. */
  29851. static get DiffuseTextureEnabled(): boolean;
  29852. static set DiffuseTextureEnabled(value: boolean);
  29853. /**
  29854. * Are ambient textures enabled in the application.
  29855. */
  29856. static get AmbientTextureEnabled(): boolean;
  29857. static set AmbientTextureEnabled(value: boolean);
  29858. /**
  29859. * Are opacity textures enabled in the application.
  29860. */
  29861. static get OpacityTextureEnabled(): boolean;
  29862. static set OpacityTextureEnabled(value: boolean);
  29863. /**
  29864. * Are reflection textures enabled in the application.
  29865. */
  29866. static get ReflectionTextureEnabled(): boolean;
  29867. static set ReflectionTextureEnabled(value: boolean);
  29868. /**
  29869. * Are emissive textures enabled in the application.
  29870. */
  29871. static get EmissiveTextureEnabled(): boolean;
  29872. static set EmissiveTextureEnabled(value: boolean);
  29873. /**
  29874. * Are specular textures enabled in the application.
  29875. */
  29876. static get SpecularTextureEnabled(): boolean;
  29877. static set SpecularTextureEnabled(value: boolean);
  29878. /**
  29879. * Are bump textures enabled in the application.
  29880. */
  29881. static get BumpTextureEnabled(): boolean;
  29882. static set BumpTextureEnabled(value: boolean);
  29883. /**
  29884. * Are lightmap textures enabled in the application.
  29885. */
  29886. static get LightmapTextureEnabled(): boolean;
  29887. static set LightmapTextureEnabled(value: boolean);
  29888. /**
  29889. * Are refraction textures enabled in the application.
  29890. */
  29891. static get RefractionTextureEnabled(): boolean;
  29892. static set RefractionTextureEnabled(value: boolean);
  29893. /**
  29894. * Are color grading textures enabled in the application.
  29895. */
  29896. static get ColorGradingTextureEnabled(): boolean;
  29897. static set ColorGradingTextureEnabled(value: boolean);
  29898. /**
  29899. * Are fresnels enabled in the application.
  29900. */
  29901. static get FresnelEnabled(): boolean;
  29902. static set FresnelEnabled(value: boolean);
  29903. }
  29904. }
  29905. declare module BABYLON {
  29906. /**
  29907. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29908. *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.
  29909. * The SPS is also a particle system. It provides some methods to manage the particles.
  29910. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29911. *
  29912. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29913. */
  29914. export class SolidParticleSystem implements IDisposable {
  29915. /**
  29916. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29917. * Example : var p = SPS.particles[i];
  29918. */
  29919. particles: SolidParticle[];
  29920. /**
  29921. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29922. */
  29923. nbParticles: number;
  29924. /**
  29925. * If the particles must ever face the camera (default false). Useful for planar particles.
  29926. */
  29927. billboard: boolean;
  29928. /**
  29929. * Recompute normals when adding a shape
  29930. */
  29931. recomputeNormals: boolean;
  29932. /**
  29933. * This a counter ofr your own usage. It's not set by any SPS functions.
  29934. */
  29935. counter: number;
  29936. /**
  29937. * The SPS name. This name is also given to the underlying mesh.
  29938. */
  29939. name: string;
  29940. /**
  29941. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29942. */
  29943. mesh: Mesh;
  29944. /**
  29945. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29946. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29947. */
  29948. vars: any;
  29949. /**
  29950. * This array is populated when the SPS is set as 'pickable'.
  29951. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29952. * Each element of this array is an object `{idx: int, faceId: int}`.
  29953. * `idx` is the picked particle index in the `SPS.particles` array
  29954. * `faceId` is the picked face index counted within this particle.
  29955. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29956. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29957. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29958. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29959. */
  29960. pickedParticles: {
  29961. idx: number;
  29962. faceId: number;
  29963. }[];
  29964. /**
  29965. * This array is populated when the SPS is set as 'pickable'
  29966. * Each key of this array is a submesh index.
  29967. * Each element of this array is a second array defined like this :
  29968. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29969. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29970. * `idx` is the picked particle index in the `SPS.particles` array
  29971. * `faceId` is the picked face index counted within this particle.
  29972. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29973. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29974. */
  29975. pickedBySubMesh: {
  29976. idx: number;
  29977. faceId: number;
  29978. }[][];
  29979. /**
  29980. * This array is populated when `enableDepthSort` is set to true.
  29981. * Each element of this array is an instance of the class DepthSortedParticle.
  29982. */
  29983. depthSortedParticles: DepthSortedParticle[];
  29984. /**
  29985. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29986. * @hidden
  29987. */
  29988. _bSphereOnly: boolean;
  29989. /**
  29990. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29991. * @hidden
  29992. */
  29993. _bSphereRadiusFactor: number;
  29994. private _scene;
  29995. private _positions;
  29996. private _indices;
  29997. private _normals;
  29998. private _colors;
  29999. private _uvs;
  30000. private _indices32;
  30001. private _positions32;
  30002. private _normals32;
  30003. private _fixedNormal32;
  30004. private _colors32;
  30005. private _uvs32;
  30006. private _index;
  30007. private _updatable;
  30008. private _pickable;
  30009. private _isVisibilityBoxLocked;
  30010. private _alwaysVisible;
  30011. private _depthSort;
  30012. private _expandable;
  30013. private _shapeCounter;
  30014. private _copy;
  30015. private _color;
  30016. private _computeParticleColor;
  30017. private _computeParticleTexture;
  30018. private _computeParticleRotation;
  30019. private _computeParticleVertex;
  30020. private _computeBoundingBox;
  30021. private _depthSortParticles;
  30022. private _camera;
  30023. private _mustUnrotateFixedNormals;
  30024. private _particlesIntersect;
  30025. private _needs32Bits;
  30026. private _isNotBuilt;
  30027. private _lastParticleId;
  30028. private _idxOfId;
  30029. private _multimaterialEnabled;
  30030. private _useModelMaterial;
  30031. private _indicesByMaterial;
  30032. private _materialIndexes;
  30033. private _depthSortFunction;
  30034. private _materialSortFunction;
  30035. private _materials;
  30036. private _multimaterial;
  30037. private _materialIndexesById;
  30038. private _defaultMaterial;
  30039. private _autoUpdateSubMeshes;
  30040. private _tmpVertex;
  30041. /**
  30042. * Creates a SPS (Solid Particle System) object.
  30043. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30044. * @param scene (Scene) is the scene in which the SPS is added.
  30045. * @param options defines the options of the sps e.g.
  30046. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30047. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30048. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30049. * * 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.
  30050. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30051. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30052. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30053. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30054. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30055. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30056. */
  30057. constructor(name: string, scene: Scene, options?: {
  30058. updatable?: boolean;
  30059. isPickable?: boolean;
  30060. enableDepthSort?: boolean;
  30061. particleIntersection?: boolean;
  30062. boundingSphereOnly?: boolean;
  30063. bSphereRadiusFactor?: number;
  30064. expandable?: boolean;
  30065. useModelMaterial?: boolean;
  30066. enableMultiMaterial?: boolean;
  30067. });
  30068. /**
  30069. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30070. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30071. * @returns the created mesh
  30072. */
  30073. buildMesh(): Mesh;
  30074. /**
  30075. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30076. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30077. * Thus the particles generated from `digest()` have their property `position` set yet.
  30078. * @param mesh ( Mesh ) is the mesh to be digested
  30079. * @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
  30080. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30081. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30082. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30083. * @returns the current SPS
  30084. */
  30085. digest(mesh: Mesh, options?: {
  30086. facetNb?: number;
  30087. number?: number;
  30088. delta?: number;
  30089. storage?: [];
  30090. }): SolidParticleSystem;
  30091. /**
  30092. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30093. * @hidden
  30094. */
  30095. private _unrotateFixedNormals;
  30096. /**
  30097. * Resets the temporary working copy particle
  30098. * @hidden
  30099. */
  30100. private _resetCopy;
  30101. /**
  30102. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30103. * @param p the current index in the positions array to be updated
  30104. * @param ind the current index in the indices array
  30105. * @param shape a Vector3 array, the shape geometry
  30106. * @param positions the positions array to be updated
  30107. * @param meshInd the shape indices array
  30108. * @param indices the indices array to be updated
  30109. * @param meshUV the shape uv array
  30110. * @param uvs the uv array to be updated
  30111. * @param meshCol the shape color array
  30112. * @param colors the color array to be updated
  30113. * @param meshNor the shape normals array
  30114. * @param normals the normals array to be updated
  30115. * @param idx the particle index
  30116. * @param idxInShape the particle index in its shape
  30117. * @param options the addShape() method passed options
  30118. * @model the particle model
  30119. * @hidden
  30120. */
  30121. private _meshBuilder;
  30122. /**
  30123. * Returns a shape Vector3 array from positions float array
  30124. * @param positions float array
  30125. * @returns a vector3 array
  30126. * @hidden
  30127. */
  30128. private _posToShape;
  30129. /**
  30130. * Returns a shapeUV array from a float uvs (array deep copy)
  30131. * @param uvs as a float array
  30132. * @returns a shapeUV array
  30133. * @hidden
  30134. */
  30135. private _uvsToShapeUV;
  30136. /**
  30137. * Adds a new particle object in the particles array
  30138. * @param idx particle index in particles array
  30139. * @param id particle id
  30140. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30141. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30142. * @param model particle ModelShape object
  30143. * @param shapeId model shape identifier
  30144. * @param idxInShape index of the particle in the current model
  30145. * @param bInfo model bounding info object
  30146. * @param storage target storage array, if any
  30147. * @hidden
  30148. */
  30149. private _addParticle;
  30150. /**
  30151. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30152. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30153. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30154. * @param nb (positive integer) the number of particles to be created from this model
  30155. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30156. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30157. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30158. * @returns the number of shapes in the system
  30159. */
  30160. addShape(mesh: Mesh, nb: number, options?: {
  30161. positionFunction?: any;
  30162. vertexFunction?: any;
  30163. storage?: [];
  30164. }): number;
  30165. /**
  30166. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30167. * @hidden
  30168. */
  30169. private _rebuildParticle;
  30170. /**
  30171. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30172. * @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.
  30173. * @returns the SPS.
  30174. */
  30175. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30176. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30177. * Returns an array with the removed particles.
  30178. * 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.
  30179. * The SPS can't be empty so at least one particle needs to remain in place.
  30180. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30181. * @param start index of the first particle to remove
  30182. * @param end index of the last particle to remove (included)
  30183. * @returns an array populated with the removed particles
  30184. */
  30185. removeParticles(start: number, end: number): SolidParticle[];
  30186. /**
  30187. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30188. * @param solidParticleArray an array populated with Solid Particles objects
  30189. * @returns the SPS
  30190. */
  30191. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30192. /**
  30193. * Creates a new particle and modifies the SPS mesh geometry :
  30194. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30195. * - calls _addParticle() to populate the particle array
  30196. * factorized code from addShape() and insertParticlesFromArray()
  30197. * @param idx particle index in the particles array
  30198. * @param i particle index in its shape
  30199. * @param modelShape particle ModelShape object
  30200. * @param shape shape vertex array
  30201. * @param meshInd shape indices array
  30202. * @param meshUV shape uv array
  30203. * @param meshCol shape color array
  30204. * @param meshNor shape normals array
  30205. * @param bbInfo shape bounding info
  30206. * @param storage target particle storage
  30207. * @options addShape() passed options
  30208. * @hidden
  30209. */
  30210. private _insertNewParticle;
  30211. /**
  30212. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30213. * This method calls `updateParticle()` for each particle of the SPS.
  30214. * For an animated SPS, it is usually called within the render loop.
  30215. * 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.
  30216. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30217. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30218. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30219. * @returns the SPS.
  30220. */
  30221. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30222. /**
  30223. * Disposes the SPS.
  30224. */
  30225. dispose(): void;
  30226. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30227. * idx is the particle index in the SPS
  30228. * faceId is the picked face index counted within this particle.
  30229. * Returns null if the pickInfo can't identify a picked particle.
  30230. * @param pickingInfo (PickingInfo object)
  30231. * @returns {idx: number, faceId: number} or null
  30232. */
  30233. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30234. idx: number;
  30235. faceId: number;
  30236. }>;
  30237. /**
  30238. * Returns a SolidParticle object from its identifier : particle.id
  30239. * @param id (integer) the particle Id
  30240. * @returns the searched particle or null if not found in the SPS.
  30241. */
  30242. getParticleById(id: number): Nullable<SolidParticle>;
  30243. /**
  30244. * Returns a new array populated with the particles having the passed shapeId.
  30245. * @param shapeId (integer) the shape identifier
  30246. * @returns a new solid particle array
  30247. */
  30248. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30249. /**
  30250. * Populates the passed array "ref" with the particles having the passed shapeId.
  30251. * @param shapeId the shape identifier
  30252. * @returns the SPS
  30253. * @param ref
  30254. */
  30255. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30256. /**
  30257. * Computes the required SubMeshes according the materials assigned to the particles.
  30258. * @returns the solid particle system.
  30259. * Does nothing if called before the SPS mesh is built.
  30260. */
  30261. computeSubMeshes(): SolidParticleSystem;
  30262. /**
  30263. * Sorts the solid particles by material when MultiMaterial is enabled.
  30264. * Updates the indices32 array.
  30265. * Updates the indicesByMaterial array.
  30266. * Updates the mesh indices array.
  30267. * @returns the SPS
  30268. * @hidden
  30269. */
  30270. private _sortParticlesByMaterial;
  30271. /**
  30272. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30273. * @hidden
  30274. */
  30275. private _setMaterialIndexesById;
  30276. /**
  30277. * Returns an array with unique values of Materials from the passed array
  30278. * @param array the material array to be checked and filtered
  30279. * @hidden
  30280. */
  30281. private _filterUniqueMaterialId;
  30282. /**
  30283. * Sets a new Standard Material as _defaultMaterial if not already set.
  30284. * @hidden
  30285. */
  30286. private _setDefaultMaterial;
  30287. /**
  30288. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30289. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30290. * @returns the SPS.
  30291. */
  30292. refreshVisibleSize(): SolidParticleSystem;
  30293. /**
  30294. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30295. * @param size the size (float) of the visibility box
  30296. * note : this doesn't lock the SPS mesh bounding box.
  30297. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30298. */
  30299. setVisibilityBox(size: number): void;
  30300. /**
  30301. * Gets whether the SPS as always visible or not
  30302. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30303. */
  30304. get isAlwaysVisible(): boolean;
  30305. /**
  30306. * Sets the SPS as always visible or not
  30307. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30308. */
  30309. set isAlwaysVisible(val: boolean);
  30310. /**
  30311. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30312. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30313. */
  30314. set isVisibilityBoxLocked(val: boolean);
  30315. /**
  30316. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30317. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30318. */
  30319. get isVisibilityBoxLocked(): boolean;
  30320. /**
  30321. * Tells to `setParticles()` to compute the particle rotations or not.
  30322. * Default value : true. The SPS is faster when it's set to false.
  30323. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30324. */
  30325. set computeParticleRotation(val: boolean);
  30326. /**
  30327. * Tells to `setParticles()` to compute the particle colors or not.
  30328. * Default value : true. The SPS is faster when it's set to false.
  30329. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30330. */
  30331. set computeParticleColor(val: boolean);
  30332. set computeParticleTexture(val: boolean);
  30333. /**
  30334. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30335. * Default value : false. The SPS is faster when it's set to false.
  30336. * Note : the particle custom vertex positions aren't stored values.
  30337. */
  30338. set computeParticleVertex(val: boolean);
  30339. /**
  30340. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30341. */
  30342. set computeBoundingBox(val: boolean);
  30343. /**
  30344. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30345. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30346. * Default : `true`
  30347. */
  30348. set depthSortParticles(val: boolean);
  30349. /**
  30350. * Gets if `setParticles()` computes the particle rotations or not.
  30351. * Default value : true. The SPS is faster when it's set to false.
  30352. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30353. */
  30354. get computeParticleRotation(): boolean;
  30355. /**
  30356. * Gets if `setParticles()` computes the particle colors or not.
  30357. * Default value : true. The SPS is faster when it's set to false.
  30358. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30359. */
  30360. get computeParticleColor(): boolean;
  30361. /**
  30362. * Gets if `setParticles()` computes the particle textures or not.
  30363. * Default value : true. The SPS is faster when it's set to false.
  30364. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30365. */
  30366. get computeParticleTexture(): boolean;
  30367. /**
  30368. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30369. * Default value : false. The SPS is faster when it's set to false.
  30370. * Note : the particle custom vertex positions aren't stored values.
  30371. */
  30372. get computeParticleVertex(): boolean;
  30373. /**
  30374. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30375. */
  30376. get computeBoundingBox(): boolean;
  30377. /**
  30378. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30379. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30380. * Default : `true`
  30381. */
  30382. get depthSortParticles(): boolean;
  30383. /**
  30384. * Gets if the SPS is created as expandable at construction time.
  30385. * Default : `false`
  30386. */
  30387. get expandable(): boolean;
  30388. /**
  30389. * Gets if the SPS supports the Multi Materials
  30390. */
  30391. get multimaterialEnabled(): boolean;
  30392. /**
  30393. * Gets if the SPS uses the model materials for its own multimaterial.
  30394. */
  30395. get useModelMaterial(): boolean;
  30396. /**
  30397. * The SPS used material array.
  30398. */
  30399. get materials(): Material[];
  30400. /**
  30401. * Sets the SPS MultiMaterial from the passed materials.
  30402. * Note : the passed array is internally copied and not used then by reference.
  30403. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30404. */
  30405. setMultiMaterial(materials: Material[]): void;
  30406. /**
  30407. * The SPS computed multimaterial object
  30408. */
  30409. get multimaterial(): MultiMaterial;
  30410. set multimaterial(mm: MultiMaterial);
  30411. /**
  30412. * If the subMeshes must be updated on the next call to setParticles()
  30413. */
  30414. get autoUpdateSubMeshes(): boolean;
  30415. set autoUpdateSubMeshes(val: boolean);
  30416. /**
  30417. * This function does nothing. It may be overwritten to set all the particle first values.
  30418. * The SPS doesn't call this function, you may have to call it by your own.
  30419. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30420. */
  30421. initParticles(): void;
  30422. /**
  30423. * This function does nothing. It may be overwritten to recycle a particle.
  30424. * The SPS doesn't call this function, you may have to call it by your own.
  30425. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30426. * @param particle The particle to recycle
  30427. * @returns the recycled particle
  30428. */
  30429. recycleParticle(particle: SolidParticle): SolidParticle;
  30430. /**
  30431. * Updates a particle : this function should be overwritten by the user.
  30432. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30433. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30434. * @example : just set a particle position or velocity and recycle conditions
  30435. * @param particle The particle to update
  30436. * @returns the updated particle
  30437. */
  30438. updateParticle(particle: SolidParticle): SolidParticle;
  30439. /**
  30440. * Updates a vertex of a particle : it can be overwritten by the user.
  30441. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30442. * @param particle the current particle
  30443. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30444. * @param pt the index of the current vertex in the particle shape
  30445. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30446. * @example : just set a vertex particle position or color
  30447. * @returns the sps
  30448. */
  30449. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30450. /**
  30451. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30452. * This does nothing and may be overwritten by the user.
  30453. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30454. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30455. * @param update the boolean update value actually passed to setParticles()
  30456. */
  30457. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30458. /**
  30459. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30460. * This will be passed three parameters.
  30461. * This does nothing and may be overwritten by the user.
  30462. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30463. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30464. * @param update the boolean update value actually passed to setParticles()
  30465. */
  30466. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30467. }
  30468. }
  30469. declare module BABYLON {
  30470. /**
  30471. * Represents one particle of a solid particle system.
  30472. */
  30473. export class SolidParticle {
  30474. /**
  30475. * particle global index
  30476. */
  30477. idx: number;
  30478. /**
  30479. * particle identifier
  30480. */
  30481. id: number;
  30482. /**
  30483. * The color of the particle
  30484. */
  30485. color: Nullable<Color4>;
  30486. /**
  30487. * The world space position of the particle.
  30488. */
  30489. position: Vector3;
  30490. /**
  30491. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30492. */
  30493. rotation: Vector3;
  30494. /**
  30495. * The world space rotation quaternion of the particle.
  30496. */
  30497. rotationQuaternion: Nullable<Quaternion>;
  30498. /**
  30499. * The scaling of the particle.
  30500. */
  30501. scaling: Vector3;
  30502. /**
  30503. * The uvs of the particle.
  30504. */
  30505. uvs: Vector4;
  30506. /**
  30507. * The current speed of the particle.
  30508. */
  30509. velocity: Vector3;
  30510. /**
  30511. * The pivot point in the particle local space.
  30512. */
  30513. pivot: Vector3;
  30514. /**
  30515. * Must the particle be translated from its pivot point in its local space ?
  30516. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30517. * Default : false
  30518. */
  30519. translateFromPivot: boolean;
  30520. /**
  30521. * Is the particle active or not ?
  30522. */
  30523. alive: boolean;
  30524. /**
  30525. * Is the particle visible or not ?
  30526. */
  30527. isVisible: boolean;
  30528. /**
  30529. * Index of this particle in the global "positions" array (Internal use)
  30530. * @hidden
  30531. */
  30532. _pos: number;
  30533. /**
  30534. * @hidden Index of this particle in the global "indices" array (Internal use)
  30535. */
  30536. _ind: number;
  30537. /**
  30538. * @hidden ModelShape of this particle (Internal use)
  30539. */
  30540. _model: ModelShape;
  30541. /**
  30542. * ModelShape id of this particle
  30543. */
  30544. shapeId: number;
  30545. /**
  30546. * Index of the particle in its shape id
  30547. */
  30548. idxInShape: number;
  30549. /**
  30550. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30551. */
  30552. _modelBoundingInfo: BoundingInfo;
  30553. /**
  30554. * @hidden Particle BoundingInfo object (Internal use)
  30555. */
  30556. _boundingInfo: BoundingInfo;
  30557. /**
  30558. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30559. */
  30560. _sps: SolidParticleSystem;
  30561. /**
  30562. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30563. */
  30564. _stillInvisible: boolean;
  30565. /**
  30566. * @hidden Last computed particle rotation matrix
  30567. */
  30568. _rotationMatrix: number[];
  30569. /**
  30570. * Parent particle Id, if any.
  30571. * Default null.
  30572. */
  30573. parentId: Nullable<number>;
  30574. /**
  30575. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30576. */
  30577. materialIndex: Nullable<number>;
  30578. /**
  30579. * Custom object or properties.
  30580. */
  30581. props: Nullable<any>;
  30582. /**
  30583. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30584. * The possible values are :
  30585. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30586. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30587. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30588. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30589. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30590. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30591. * */
  30592. cullingStrategy: number;
  30593. /**
  30594. * @hidden Internal global position in the SPS.
  30595. */
  30596. _globalPosition: Vector3;
  30597. /**
  30598. * Creates a Solid Particle object.
  30599. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30600. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30601. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30602. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30603. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30604. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30605. * @param shapeId (integer) is the model shape identifier in the SPS.
  30606. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30607. * @param sps defines the sps it is associated to
  30608. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30609. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30610. */
  30611. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30612. /**
  30613. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30614. * @param target the particle target
  30615. * @returns the current particle
  30616. */
  30617. copyToRef(target: SolidParticle): SolidParticle;
  30618. /**
  30619. * Legacy support, changed scale to scaling
  30620. */
  30621. get scale(): Vector3;
  30622. /**
  30623. * Legacy support, changed scale to scaling
  30624. */
  30625. set scale(scale: Vector3);
  30626. /**
  30627. * Legacy support, changed quaternion to rotationQuaternion
  30628. */
  30629. get quaternion(): Nullable<Quaternion>;
  30630. /**
  30631. * Legacy support, changed quaternion to rotationQuaternion
  30632. */
  30633. set quaternion(q: Nullable<Quaternion>);
  30634. /**
  30635. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30636. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30637. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30638. * @returns true if it intersects
  30639. */
  30640. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30641. /**
  30642. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30643. * A particle is in the frustum if its bounding box intersects the frustum
  30644. * @param frustumPlanes defines the frustum to test
  30645. * @returns true if the particle is in the frustum planes
  30646. */
  30647. isInFrustum(frustumPlanes: Plane[]): boolean;
  30648. /**
  30649. * get the rotation matrix of the particle
  30650. * @hidden
  30651. */
  30652. getRotationMatrix(m: Matrix): void;
  30653. }
  30654. /**
  30655. * Represents the shape of the model used by one particle of a solid particle system.
  30656. * SPS internal tool, don't use it manually.
  30657. */
  30658. export class ModelShape {
  30659. /**
  30660. * The shape id
  30661. * @hidden
  30662. */
  30663. shapeID: number;
  30664. /**
  30665. * flat array of model positions (internal use)
  30666. * @hidden
  30667. */
  30668. _shape: Vector3[];
  30669. /**
  30670. * flat array of model UVs (internal use)
  30671. * @hidden
  30672. */
  30673. _shapeUV: number[];
  30674. /**
  30675. * color array of the model
  30676. * @hidden
  30677. */
  30678. _shapeColors: number[];
  30679. /**
  30680. * indices array of the model
  30681. * @hidden
  30682. */
  30683. _indices: number[];
  30684. /**
  30685. * normals array of the model
  30686. * @hidden
  30687. */
  30688. _normals: number[];
  30689. /**
  30690. * length of the shape in the model indices array (internal use)
  30691. * @hidden
  30692. */
  30693. _indicesLength: number;
  30694. /**
  30695. * Custom position function (internal use)
  30696. * @hidden
  30697. */
  30698. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30699. /**
  30700. * Custom vertex function (internal use)
  30701. * @hidden
  30702. */
  30703. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30704. /**
  30705. * Model material (internal use)
  30706. * @hidden
  30707. */
  30708. _material: Nullable<Material>;
  30709. /**
  30710. * 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.
  30711. * SPS internal tool, don't use it manually.
  30712. * @hidden
  30713. */
  30714. 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>);
  30715. }
  30716. /**
  30717. * Represents a Depth Sorted Particle in the solid particle system.
  30718. * @hidden
  30719. */
  30720. export class DepthSortedParticle {
  30721. /**
  30722. * Particle index
  30723. */
  30724. idx: number;
  30725. /**
  30726. * Index of the particle in the "indices" array
  30727. */
  30728. ind: number;
  30729. /**
  30730. * Length of the particle shape in the "indices" array
  30731. */
  30732. indicesLength: number;
  30733. /**
  30734. * Squared distance from the particle to the camera
  30735. */
  30736. sqDistance: number;
  30737. /**
  30738. * Material index when used with MultiMaterials
  30739. */
  30740. materialIndex: number;
  30741. /**
  30742. * Creates a new sorted particle
  30743. * @param materialIndex
  30744. */
  30745. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30746. }
  30747. /**
  30748. * Represents a solid particle vertex
  30749. */
  30750. export class SolidParticleVertex {
  30751. /**
  30752. * Vertex position
  30753. */
  30754. position: Vector3;
  30755. /**
  30756. * Vertex color
  30757. */
  30758. color: Color4;
  30759. /**
  30760. * Vertex UV
  30761. */
  30762. uv: Vector2;
  30763. /**
  30764. * Creates a new solid particle vertex
  30765. */
  30766. constructor();
  30767. /** Vertex x coordinate */
  30768. get x(): number;
  30769. set x(val: number);
  30770. /** Vertex y coordinate */
  30771. get y(): number;
  30772. set y(val: number);
  30773. /** Vertex z coordinate */
  30774. get z(): number;
  30775. set z(val: number);
  30776. }
  30777. }
  30778. declare module BABYLON {
  30779. /**
  30780. * @hidden
  30781. */
  30782. export class _MeshCollisionData {
  30783. _checkCollisions: boolean;
  30784. _collisionMask: number;
  30785. _collisionGroup: number;
  30786. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30787. _collider: Nullable<Collider>;
  30788. _oldPositionForCollisions: Vector3;
  30789. _diffPositionForCollisions: Vector3;
  30790. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30791. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30792. }
  30793. }
  30794. declare module BABYLON {
  30795. /** @hidden */
  30796. class _FacetDataStorage {
  30797. facetPositions: Vector3[];
  30798. facetNormals: Vector3[];
  30799. facetPartitioning: number[][];
  30800. facetNb: number;
  30801. partitioningSubdivisions: number;
  30802. partitioningBBoxRatio: number;
  30803. facetDataEnabled: boolean;
  30804. facetParameters: any;
  30805. bbSize: Vector3;
  30806. subDiv: {
  30807. max: number;
  30808. X: number;
  30809. Y: number;
  30810. Z: number;
  30811. };
  30812. facetDepthSort: boolean;
  30813. facetDepthSortEnabled: boolean;
  30814. depthSortedIndices: IndicesArray;
  30815. depthSortedFacets: {
  30816. ind: number;
  30817. sqDistance: number;
  30818. }[];
  30819. facetDepthSortFunction: (f1: {
  30820. ind: number;
  30821. sqDistance: number;
  30822. }, f2: {
  30823. ind: number;
  30824. sqDistance: number;
  30825. }) => number;
  30826. facetDepthSortFrom: Vector3;
  30827. facetDepthSortOrigin: Vector3;
  30828. invertedMatrix: Matrix;
  30829. }
  30830. /**
  30831. * @hidden
  30832. **/
  30833. class _InternalAbstractMeshDataInfo {
  30834. _hasVertexAlpha: boolean;
  30835. _useVertexColors: boolean;
  30836. _numBoneInfluencers: number;
  30837. _applyFog: boolean;
  30838. _receiveShadows: boolean;
  30839. _facetData: _FacetDataStorage;
  30840. _visibility: number;
  30841. _skeleton: Nullable<Skeleton>;
  30842. _layerMask: number;
  30843. _computeBonesUsingShaders: boolean;
  30844. _isActive: boolean;
  30845. _onlyForInstances: boolean;
  30846. _isActiveIntermediate: boolean;
  30847. _onlyForInstancesIntermediate: boolean;
  30848. _actAsRegularMesh: boolean;
  30849. }
  30850. /**
  30851. * Class used to store all common mesh properties
  30852. */
  30853. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30854. /** No occlusion */
  30855. static OCCLUSION_TYPE_NONE: number;
  30856. /** Occlusion set to optimisitic */
  30857. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30858. /** Occlusion set to strict */
  30859. static OCCLUSION_TYPE_STRICT: number;
  30860. /** Use an accurante occlusion algorithm */
  30861. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30862. /** Use a conservative occlusion algorithm */
  30863. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30864. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30865. * Test order :
  30866. * Is the bounding sphere outside the frustum ?
  30867. * If not, are the bounding box vertices outside the frustum ?
  30868. * It not, then the cullable object is in the frustum.
  30869. */
  30870. static readonly CULLINGSTRATEGY_STANDARD: number;
  30871. /** Culling strategy : Bounding Sphere Only.
  30872. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30873. * It's also less accurate than the standard because some not visible objects can still be selected.
  30874. * Test : is the bounding sphere outside the frustum ?
  30875. * If not, then the cullable object is in the frustum.
  30876. */
  30877. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30878. /** Culling strategy : Optimistic Inclusion.
  30879. * This in an inclusion test first, then the standard exclusion test.
  30880. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30881. * 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.
  30882. * Anyway, it's as accurate as the standard strategy.
  30883. * Test :
  30884. * Is the cullable object bounding sphere center in the frustum ?
  30885. * If not, apply the default culling strategy.
  30886. */
  30887. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30888. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30889. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30890. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30891. * 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.
  30892. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30893. * Test :
  30894. * Is the cullable object bounding sphere center in the frustum ?
  30895. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30896. */
  30897. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30898. /**
  30899. * No billboard
  30900. */
  30901. static get BILLBOARDMODE_NONE(): number;
  30902. /** Billboard on X axis */
  30903. static get BILLBOARDMODE_X(): number;
  30904. /** Billboard on Y axis */
  30905. static get BILLBOARDMODE_Y(): number;
  30906. /** Billboard on Z axis */
  30907. static get BILLBOARDMODE_Z(): number;
  30908. /** Billboard on all axes */
  30909. static get BILLBOARDMODE_ALL(): number;
  30910. /** Billboard on using position instead of orientation */
  30911. static get BILLBOARDMODE_USE_POSITION(): number;
  30912. /** @hidden */
  30913. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30914. /**
  30915. * The culling strategy to use to check whether the mesh must be rendered or not.
  30916. * This value can be changed at any time and will be used on the next render mesh selection.
  30917. * The possible values are :
  30918. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30919. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30920. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30921. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30922. * Please read each static variable documentation to get details about the culling process.
  30923. * */
  30924. cullingStrategy: number;
  30925. /**
  30926. * Gets the number of facets in the mesh
  30927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30928. */
  30929. get facetNb(): number;
  30930. /**
  30931. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30933. */
  30934. get partitioningSubdivisions(): number;
  30935. set partitioningSubdivisions(nb: number);
  30936. /**
  30937. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30938. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30940. */
  30941. get partitioningBBoxRatio(): number;
  30942. set partitioningBBoxRatio(ratio: number);
  30943. /**
  30944. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30945. * Works only for updatable meshes.
  30946. * Doesn't work with multi-materials
  30947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30948. */
  30949. get mustDepthSortFacets(): boolean;
  30950. set mustDepthSortFacets(sort: boolean);
  30951. /**
  30952. * The location (Vector3) where the facet depth sort must be computed from.
  30953. * By default, the active camera position.
  30954. * Used only when facet depth sort is enabled
  30955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30956. */
  30957. get facetDepthSortFrom(): Vector3;
  30958. set facetDepthSortFrom(location: Vector3);
  30959. /**
  30960. * gets a boolean indicating if facetData is enabled
  30961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30962. */
  30963. get isFacetDataEnabled(): boolean;
  30964. /** @hidden */
  30965. _updateNonUniformScalingState(value: boolean): boolean;
  30966. /**
  30967. * An event triggered when this mesh collides with another one
  30968. */
  30969. onCollideObservable: Observable<AbstractMesh>;
  30970. /** Set a function to call when this mesh collides with another one */
  30971. set onCollide(callback: () => void);
  30972. /**
  30973. * An event triggered when the collision's position changes
  30974. */
  30975. onCollisionPositionChangeObservable: Observable<Vector3>;
  30976. /** Set a function to call when the collision's position changes */
  30977. set onCollisionPositionChange(callback: () => void);
  30978. /**
  30979. * An event triggered when material is changed
  30980. */
  30981. onMaterialChangedObservable: Observable<AbstractMesh>;
  30982. /**
  30983. * Gets or sets the orientation for POV movement & rotation
  30984. */
  30985. definedFacingForward: boolean;
  30986. /** @hidden */
  30987. _occlusionQuery: Nullable<WebGLQuery>;
  30988. /** @hidden */
  30989. _renderingGroup: Nullable<RenderingGroup>;
  30990. /**
  30991. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30992. */
  30993. get visibility(): number;
  30994. /**
  30995. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30996. */
  30997. set visibility(value: number);
  30998. /** Gets or sets the alpha index used to sort transparent meshes
  30999. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31000. */
  31001. alphaIndex: number;
  31002. /**
  31003. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31004. */
  31005. isVisible: boolean;
  31006. /**
  31007. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31008. */
  31009. isPickable: boolean;
  31010. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31011. showSubMeshesBoundingBox: boolean;
  31012. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31013. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31014. */
  31015. isBlocker: boolean;
  31016. /**
  31017. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31018. */
  31019. enablePointerMoveEvents: boolean;
  31020. /**
  31021. * Specifies the rendering group id for this mesh (0 by default)
  31022. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31023. */
  31024. renderingGroupId: number;
  31025. private _material;
  31026. /** Gets or sets current material */
  31027. get material(): Nullable<Material>;
  31028. set material(value: Nullable<Material>);
  31029. /**
  31030. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31031. * @see http://doc.babylonjs.com/babylon101/shadows
  31032. */
  31033. get receiveShadows(): boolean;
  31034. set receiveShadows(value: boolean);
  31035. /** Defines color to use when rendering outline */
  31036. outlineColor: Color3;
  31037. /** Define width to use when rendering outline */
  31038. outlineWidth: number;
  31039. /** Defines color to use when rendering overlay */
  31040. overlayColor: Color3;
  31041. /** Defines alpha to use when rendering overlay */
  31042. overlayAlpha: number;
  31043. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31044. get hasVertexAlpha(): boolean;
  31045. set hasVertexAlpha(value: boolean);
  31046. /** 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) */
  31047. get useVertexColors(): boolean;
  31048. set useVertexColors(value: boolean);
  31049. /**
  31050. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31051. */
  31052. get computeBonesUsingShaders(): boolean;
  31053. set computeBonesUsingShaders(value: boolean);
  31054. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31055. get numBoneInfluencers(): number;
  31056. set numBoneInfluencers(value: number);
  31057. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31058. get applyFog(): boolean;
  31059. set applyFog(value: boolean);
  31060. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31061. useOctreeForRenderingSelection: boolean;
  31062. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31063. useOctreeForPicking: boolean;
  31064. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31065. useOctreeForCollisions: boolean;
  31066. /**
  31067. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31068. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31069. */
  31070. get layerMask(): number;
  31071. set layerMask(value: number);
  31072. /**
  31073. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31074. */
  31075. alwaysSelectAsActiveMesh: boolean;
  31076. /**
  31077. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31078. */
  31079. doNotSyncBoundingInfo: boolean;
  31080. /**
  31081. * Gets or sets the current action manager
  31082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31083. */
  31084. actionManager: Nullable<AbstractActionManager>;
  31085. private _meshCollisionData;
  31086. /**
  31087. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31089. */
  31090. ellipsoid: Vector3;
  31091. /**
  31092. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31094. */
  31095. ellipsoidOffset: Vector3;
  31096. /**
  31097. * Gets or sets a collision mask used to mask collisions (default is -1).
  31098. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31099. */
  31100. get collisionMask(): number;
  31101. set collisionMask(mask: number);
  31102. /**
  31103. * Gets or sets the current collision group mask (-1 by default).
  31104. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31105. */
  31106. get collisionGroup(): number;
  31107. set collisionGroup(mask: number);
  31108. /**
  31109. * Gets or sets current surrounding meshes (null by default).
  31110. *
  31111. * By default collision detection is tested against every mesh in the scene.
  31112. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31113. * meshes will be tested for the collision.
  31114. *
  31115. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31116. */
  31117. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31118. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31119. /**
  31120. * Defines edge width used when edgesRenderer is enabled
  31121. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31122. */
  31123. edgesWidth: number;
  31124. /**
  31125. * Defines edge color used when edgesRenderer is enabled
  31126. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31127. */
  31128. edgesColor: Color4;
  31129. /** @hidden */
  31130. _edgesRenderer: Nullable<IEdgesRenderer>;
  31131. /** @hidden */
  31132. _masterMesh: Nullable<AbstractMesh>;
  31133. /** @hidden */
  31134. _boundingInfo: Nullable<BoundingInfo>;
  31135. /** @hidden */
  31136. _renderId: number;
  31137. /**
  31138. * Gets or sets the list of subMeshes
  31139. * @see http://doc.babylonjs.com/how_to/multi_materials
  31140. */
  31141. subMeshes: SubMesh[];
  31142. /** @hidden */
  31143. _intersectionsInProgress: AbstractMesh[];
  31144. /** @hidden */
  31145. _unIndexed: boolean;
  31146. /** @hidden */
  31147. _lightSources: Light[];
  31148. /** Gets the list of lights affecting that mesh */
  31149. get lightSources(): Light[];
  31150. /** @hidden */
  31151. get _positions(): Nullable<Vector3[]>;
  31152. /** @hidden */
  31153. _waitingData: {
  31154. lods: Nullable<any>;
  31155. actions: Nullable<any>;
  31156. freezeWorldMatrix: Nullable<boolean>;
  31157. };
  31158. /** @hidden */
  31159. _bonesTransformMatrices: Nullable<Float32Array>;
  31160. /** @hidden */
  31161. _transformMatrixTexture: Nullable<RawTexture>;
  31162. /**
  31163. * Gets or sets a skeleton to apply skining transformations
  31164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31165. */
  31166. set skeleton(value: Nullable<Skeleton>);
  31167. get skeleton(): Nullable<Skeleton>;
  31168. /**
  31169. * An event triggered when the mesh is rebuilt.
  31170. */
  31171. onRebuildObservable: Observable<AbstractMesh>;
  31172. /**
  31173. * Creates a new AbstractMesh
  31174. * @param name defines the name of the mesh
  31175. * @param scene defines the hosting scene
  31176. */
  31177. constructor(name: string, scene?: Nullable<Scene>);
  31178. /**
  31179. * Returns the string "AbstractMesh"
  31180. * @returns "AbstractMesh"
  31181. */
  31182. getClassName(): string;
  31183. /**
  31184. * Gets a string representation of the current mesh
  31185. * @param fullDetails defines a boolean indicating if full details must be included
  31186. * @returns a string representation of the current mesh
  31187. */
  31188. toString(fullDetails?: boolean): string;
  31189. /**
  31190. * @hidden
  31191. */
  31192. protected _getEffectiveParent(): Nullable<Node>;
  31193. /** @hidden */
  31194. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31195. /** @hidden */
  31196. _rebuild(): void;
  31197. /** @hidden */
  31198. _resyncLightSources(): void;
  31199. /** @hidden */
  31200. _resyncLightSource(light: Light): void;
  31201. /** @hidden */
  31202. _unBindEffect(): void;
  31203. /** @hidden */
  31204. _removeLightSource(light: Light, dispose: boolean): void;
  31205. private _markSubMeshesAsDirty;
  31206. /** @hidden */
  31207. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31208. /** @hidden */
  31209. _markSubMeshesAsAttributesDirty(): void;
  31210. /** @hidden */
  31211. _markSubMeshesAsMiscDirty(): void;
  31212. /**
  31213. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31214. */
  31215. get scaling(): Vector3;
  31216. set scaling(newScaling: Vector3);
  31217. /**
  31218. * Returns true if the mesh is blocked. Implemented by child classes
  31219. */
  31220. get isBlocked(): boolean;
  31221. /**
  31222. * Returns the mesh itself by default. Implemented by child classes
  31223. * @param camera defines the camera to use to pick the right LOD level
  31224. * @returns the currentAbstractMesh
  31225. */
  31226. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31227. /**
  31228. * Returns 0 by default. Implemented by child classes
  31229. * @returns an integer
  31230. */
  31231. getTotalVertices(): number;
  31232. /**
  31233. * Returns a positive integer : the total number of indices in this mesh geometry.
  31234. * @returns the numner of indices or zero if the mesh has no geometry.
  31235. */
  31236. getTotalIndices(): number;
  31237. /**
  31238. * Returns null by default. Implemented by child classes
  31239. * @returns null
  31240. */
  31241. getIndices(): Nullable<IndicesArray>;
  31242. /**
  31243. * Returns the array of the requested vertex data kind. Implemented by child classes
  31244. * @param kind defines the vertex data kind to use
  31245. * @returns null
  31246. */
  31247. getVerticesData(kind: string): Nullable<FloatArray>;
  31248. /**
  31249. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31250. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31251. * Note that a new underlying VertexBuffer object is created each call.
  31252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31253. * @param kind defines vertex data kind:
  31254. * * VertexBuffer.PositionKind
  31255. * * VertexBuffer.UVKind
  31256. * * VertexBuffer.UV2Kind
  31257. * * VertexBuffer.UV3Kind
  31258. * * VertexBuffer.UV4Kind
  31259. * * VertexBuffer.UV5Kind
  31260. * * VertexBuffer.UV6Kind
  31261. * * VertexBuffer.ColorKind
  31262. * * VertexBuffer.MatricesIndicesKind
  31263. * * VertexBuffer.MatricesIndicesExtraKind
  31264. * * VertexBuffer.MatricesWeightsKind
  31265. * * VertexBuffer.MatricesWeightsExtraKind
  31266. * @param data defines the data source
  31267. * @param updatable defines if the data must be flagged as updatable (or static)
  31268. * @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
  31269. * @returns the current mesh
  31270. */
  31271. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31272. /**
  31273. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31274. * If the mesh has no geometry, it is simply returned as it is.
  31275. * @param kind defines vertex data kind:
  31276. * * VertexBuffer.PositionKind
  31277. * * VertexBuffer.UVKind
  31278. * * VertexBuffer.UV2Kind
  31279. * * VertexBuffer.UV3Kind
  31280. * * VertexBuffer.UV4Kind
  31281. * * VertexBuffer.UV5Kind
  31282. * * VertexBuffer.UV6Kind
  31283. * * VertexBuffer.ColorKind
  31284. * * VertexBuffer.MatricesIndicesKind
  31285. * * VertexBuffer.MatricesIndicesExtraKind
  31286. * * VertexBuffer.MatricesWeightsKind
  31287. * * VertexBuffer.MatricesWeightsExtraKind
  31288. * @param data defines the data source
  31289. * @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
  31290. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31291. * @returns the current mesh
  31292. */
  31293. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31294. /**
  31295. * Sets the mesh indices,
  31296. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31297. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31298. * @param totalVertices Defines the total number of vertices
  31299. * @returns the current mesh
  31300. */
  31301. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31302. /**
  31303. * Gets a boolean indicating if specific vertex data is present
  31304. * @param kind defines the vertex data kind to use
  31305. * @returns true is data kind is present
  31306. */
  31307. isVerticesDataPresent(kind: string): boolean;
  31308. /**
  31309. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31310. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31311. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31312. * @returns a BoundingInfo
  31313. */
  31314. getBoundingInfo(): BoundingInfo;
  31315. /**
  31316. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31317. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31318. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31319. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31320. * @returns the current mesh
  31321. */
  31322. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31323. /**
  31324. * Overwrite the current bounding info
  31325. * @param boundingInfo defines the new bounding info
  31326. * @returns the current mesh
  31327. */
  31328. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31329. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31330. get useBones(): boolean;
  31331. /** @hidden */
  31332. _preActivate(): void;
  31333. /** @hidden */
  31334. _preActivateForIntermediateRendering(renderId: number): void;
  31335. /** @hidden */
  31336. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31337. /** @hidden */
  31338. _postActivate(): void;
  31339. /** @hidden */
  31340. _freeze(): void;
  31341. /** @hidden */
  31342. _unFreeze(): void;
  31343. /**
  31344. * Gets the current world matrix
  31345. * @returns a Matrix
  31346. */
  31347. getWorldMatrix(): Matrix;
  31348. /** @hidden */
  31349. _getWorldMatrixDeterminant(): number;
  31350. /**
  31351. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31352. */
  31353. get isAnInstance(): boolean;
  31354. /**
  31355. * Gets a boolean indicating if this mesh has instances
  31356. */
  31357. get hasInstances(): boolean;
  31358. /**
  31359. * Gets a boolean indicating if this mesh has thin instances
  31360. */
  31361. get hasThinInstances(): boolean;
  31362. /**
  31363. * Perform relative position change from the point of view of behind the front of the mesh.
  31364. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31365. * Supports definition of mesh facing forward or backward
  31366. * @param amountRight defines the distance on the right axis
  31367. * @param amountUp defines the distance on the up axis
  31368. * @param amountForward defines the distance on the forward axis
  31369. * @returns the current mesh
  31370. */
  31371. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31372. /**
  31373. * Calculate relative position change from the point of view of behind the front of the mesh.
  31374. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31375. * Supports definition of mesh facing forward or backward
  31376. * @param amountRight defines the distance on the right axis
  31377. * @param amountUp defines the distance on the up axis
  31378. * @param amountForward defines the distance on the forward axis
  31379. * @returns the new displacement vector
  31380. */
  31381. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31382. /**
  31383. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31384. * Supports definition of mesh facing forward or backward
  31385. * @param flipBack defines the flip
  31386. * @param twirlClockwise defines the twirl
  31387. * @param tiltRight defines the tilt
  31388. * @returns the current mesh
  31389. */
  31390. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31391. /**
  31392. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31393. * Supports definition of mesh facing forward or backward.
  31394. * @param flipBack defines the flip
  31395. * @param twirlClockwise defines the twirl
  31396. * @param tiltRight defines the tilt
  31397. * @returns the new rotation vector
  31398. */
  31399. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31400. /**
  31401. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31402. * This means the mesh underlying bounding box and sphere are recomputed.
  31403. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31404. * @returns the current mesh
  31405. */
  31406. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31407. /** @hidden */
  31408. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31409. /** @hidden */
  31410. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31411. /** @hidden */
  31412. _updateBoundingInfo(): AbstractMesh;
  31413. /** @hidden */
  31414. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31415. /** @hidden */
  31416. protected _afterComputeWorldMatrix(): void;
  31417. /** @hidden */
  31418. get _effectiveMesh(): AbstractMesh;
  31419. /**
  31420. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31421. * A mesh is in the frustum if its bounding box intersects the frustum
  31422. * @param frustumPlanes defines the frustum to test
  31423. * @returns true if the mesh is in the frustum planes
  31424. */
  31425. isInFrustum(frustumPlanes: Plane[]): boolean;
  31426. /**
  31427. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31428. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31429. * @param frustumPlanes defines the frustum to test
  31430. * @returns true if the mesh is completely in the frustum planes
  31431. */
  31432. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31433. /**
  31434. * True if the mesh intersects another mesh or a SolidParticle object
  31435. * @param mesh defines a target mesh or SolidParticle to test
  31436. * @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)
  31437. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31438. * @returns true if there is an intersection
  31439. */
  31440. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31441. /**
  31442. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31443. * @param point defines the point to test
  31444. * @returns true if there is an intersection
  31445. */
  31446. intersectsPoint(point: Vector3): boolean;
  31447. /**
  31448. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31450. */
  31451. get checkCollisions(): boolean;
  31452. set checkCollisions(collisionEnabled: boolean);
  31453. /**
  31454. * Gets Collider object used to compute collisions (not physics)
  31455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31456. */
  31457. get collider(): Nullable<Collider>;
  31458. /**
  31459. * Move the mesh using collision engine
  31460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31461. * @param displacement defines the requested displacement vector
  31462. * @returns the current mesh
  31463. */
  31464. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31465. private _onCollisionPositionChange;
  31466. /** @hidden */
  31467. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31468. /** @hidden */
  31469. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31470. /** @hidden */
  31471. _checkCollision(collider: Collider): AbstractMesh;
  31472. /** @hidden */
  31473. _generatePointsArray(): boolean;
  31474. /**
  31475. * Checks if the passed Ray intersects with the mesh
  31476. * @param ray defines the ray to use
  31477. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31479. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31480. * @returns the picking info
  31481. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31482. */
  31483. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31484. /**
  31485. * Clones the current mesh
  31486. * @param name defines the mesh name
  31487. * @param newParent defines the new mesh parent
  31488. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31489. * @returns the new mesh
  31490. */
  31491. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31492. /**
  31493. * Disposes all the submeshes of the current meshnp
  31494. * @returns the current mesh
  31495. */
  31496. releaseSubMeshes(): AbstractMesh;
  31497. /**
  31498. * Releases resources associated with this abstract mesh.
  31499. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31500. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31501. */
  31502. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31503. /**
  31504. * Adds the passed mesh as a child to the current mesh
  31505. * @param mesh defines the child mesh
  31506. * @returns the current mesh
  31507. */
  31508. addChild(mesh: AbstractMesh): AbstractMesh;
  31509. /**
  31510. * Removes the passed mesh from the current mesh children list
  31511. * @param mesh defines the child mesh
  31512. * @returns the current mesh
  31513. */
  31514. removeChild(mesh: AbstractMesh): AbstractMesh;
  31515. /** @hidden */
  31516. private _initFacetData;
  31517. /**
  31518. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31519. * This method can be called within the render loop.
  31520. * 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
  31521. * @returns the current mesh
  31522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31523. */
  31524. updateFacetData(): AbstractMesh;
  31525. /**
  31526. * Returns the facetLocalNormals array.
  31527. * The normals are expressed in the mesh local spac
  31528. * @returns an array of Vector3
  31529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31530. */
  31531. getFacetLocalNormals(): Vector3[];
  31532. /**
  31533. * Returns the facetLocalPositions array.
  31534. * The facet positions are expressed in the mesh local space
  31535. * @returns an array of Vector3
  31536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31537. */
  31538. getFacetLocalPositions(): Vector3[];
  31539. /**
  31540. * Returns the facetLocalPartioning array
  31541. * @returns an array of array of numbers
  31542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31543. */
  31544. getFacetLocalPartitioning(): number[][];
  31545. /**
  31546. * Returns the i-th facet position in the world system.
  31547. * This method allocates a new Vector3 per call
  31548. * @param i defines the facet index
  31549. * @returns a new Vector3
  31550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31551. */
  31552. getFacetPosition(i: number): Vector3;
  31553. /**
  31554. * Sets the reference Vector3 with the i-th facet position in the world system
  31555. * @param i defines the facet index
  31556. * @param ref defines the target vector
  31557. * @returns the current mesh
  31558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31559. */
  31560. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31561. /**
  31562. * Returns the i-th facet normal in the world system.
  31563. * This method allocates a new Vector3 per call
  31564. * @param i defines the facet index
  31565. * @returns a new Vector3
  31566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31567. */
  31568. getFacetNormal(i: number): Vector3;
  31569. /**
  31570. * Sets the reference Vector3 with the i-th facet normal in the world system
  31571. * @param i defines the facet index
  31572. * @param ref defines the target vector
  31573. * @returns the current mesh
  31574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31575. */
  31576. getFacetNormalToRef(i: number, ref: Vector3): this;
  31577. /**
  31578. * 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)
  31579. * @param x defines x coordinate
  31580. * @param y defines y coordinate
  31581. * @param z defines z coordinate
  31582. * @returns the array of facet indexes
  31583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31584. */
  31585. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31586. /**
  31587. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31588. * @param projected sets as the (x,y,z) world projection on the facet
  31589. * @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
  31590. * @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
  31591. * @param x defines x coordinate
  31592. * @param y defines y coordinate
  31593. * @param z defines z coordinate
  31594. * @returns the face index if found (or null instead)
  31595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31596. */
  31597. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31598. /**
  31599. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31600. * @param projected sets as the (x,y,z) local projection on the facet
  31601. * @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
  31602. * @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
  31603. * @param x defines x coordinate
  31604. * @param y defines y coordinate
  31605. * @param z defines z coordinate
  31606. * @returns the face index if found (or null instead)
  31607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31608. */
  31609. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31610. /**
  31611. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31612. * @returns the parameters
  31613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31614. */
  31615. getFacetDataParameters(): any;
  31616. /**
  31617. * Disables the feature FacetData and frees the related memory
  31618. * @returns the current mesh
  31619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31620. */
  31621. disableFacetData(): AbstractMesh;
  31622. /**
  31623. * Updates the AbstractMesh indices array
  31624. * @param indices defines the data source
  31625. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31626. * @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)
  31627. * @returns the current mesh
  31628. */
  31629. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31630. /**
  31631. * Creates new normals data for the mesh
  31632. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31633. * @returns the current mesh
  31634. */
  31635. createNormals(updatable: boolean): AbstractMesh;
  31636. /**
  31637. * Align the mesh with a normal
  31638. * @param normal defines the normal to use
  31639. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31640. * @returns the current mesh
  31641. */
  31642. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31643. /** @hidden */
  31644. _checkOcclusionQuery(): boolean;
  31645. /**
  31646. * Disables the mesh edge rendering mode
  31647. * @returns the currentAbstractMesh
  31648. */
  31649. disableEdgesRendering(): AbstractMesh;
  31650. /**
  31651. * Enables the edge rendering mode on the mesh.
  31652. * This mode makes the mesh edges visible
  31653. * @param epsilon defines the maximal distance between two angles to detect a face
  31654. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31655. * @returns the currentAbstractMesh
  31656. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31657. */
  31658. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31659. }
  31660. }
  31661. declare module BABYLON {
  31662. /**
  31663. * Interface used to define ActionEvent
  31664. */
  31665. export interface IActionEvent {
  31666. /** The mesh or sprite that triggered the action */
  31667. source: any;
  31668. /** The X mouse cursor position at the time of the event */
  31669. pointerX: number;
  31670. /** The Y mouse cursor position at the time of the event */
  31671. pointerY: number;
  31672. /** The mesh that is currently pointed at (can be null) */
  31673. meshUnderPointer: Nullable<AbstractMesh>;
  31674. /** the original (browser) event that triggered the ActionEvent */
  31675. sourceEvent?: any;
  31676. /** additional data for the event */
  31677. additionalData?: any;
  31678. }
  31679. /**
  31680. * ActionEvent is the event being sent when an action is triggered.
  31681. */
  31682. export class ActionEvent implements IActionEvent {
  31683. /** The mesh or sprite that triggered the action */
  31684. source: any;
  31685. /** The X mouse cursor position at the time of the event */
  31686. pointerX: number;
  31687. /** The Y mouse cursor position at the time of the event */
  31688. pointerY: number;
  31689. /** The mesh that is currently pointed at (can be null) */
  31690. meshUnderPointer: Nullable<AbstractMesh>;
  31691. /** the original (browser) event that triggered the ActionEvent */
  31692. sourceEvent?: any;
  31693. /** additional data for the event */
  31694. additionalData?: any;
  31695. /**
  31696. * Creates a new ActionEvent
  31697. * @param source The mesh or sprite that triggered the action
  31698. * @param pointerX The X mouse cursor position at the time of the event
  31699. * @param pointerY The Y mouse cursor position at the time of the event
  31700. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31701. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31702. * @param additionalData additional data for the event
  31703. */
  31704. constructor(
  31705. /** The mesh or sprite that triggered the action */
  31706. source: any,
  31707. /** The X mouse cursor position at the time of the event */
  31708. pointerX: number,
  31709. /** The Y mouse cursor position at the time of the event */
  31710. pointerY: number,
  31711. /** The mesh that is currently pointed at (can be null) */
  31712. meshUnderPointer: Nullable<AbstractMesh>,
  31713. /** the original (browser) event that triggered the ActionEvent */
  31714. sourceEvent?: any,
  31715. /** additional data for the event */
  31716. additionalData?: any);
  31717. /**
  31718. * Helper function to auto-create an ActionEvent from a source mesh.
  31719. * @param source The source mesh that triggered the event
  31720. * @param evt The original (browser) event
  31721. * @param additionalData additional data for the event
  31722. * @returns the new ActionEvent
  31723. */
  31724. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31725. /**
  31726. * Helper function to auto-create an ActionEvent from a source sprite
  31727. * @param source The source sprite that triggered the event
  31728. * @param scene Scene associated with the sprite
  31729. * @param evt The original (browser) event
  31730. * @param additionalData additional data for the event
  31731. * @returns the new ActionEvent
  31732. */
  31733. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31734. /**
  31735. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31736. * @param scene the scene where the event occurred
  31737. * @param evt The original (browser) event
  31738. * @returns the new ActionEvent
  31739. */
  31740. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31741. /**
  31742. * Helper function to auto-create an ActionEvent from a primitive
  31743. * @param prim defines the target primitive
  31744. * @param pointerPos defines the pointer position
  31745. * @param evt The original (browser) event
  31746. * @param additionalData additional data for the event
  31747. * @returns the new ActionEvent
  31748. */
  31749. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31750. }
  31751. }
  31752. declare module BABYLON {
  31753. /**
  31754. * Abstract class used to decouple action Manager from scene and meshes.
  31755. * Do not instantiate.
  31756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31757. */
  31758. export abstract class AbstractActionManager implements IDisposable {
  31759. /** Gets the list of active triggers */
  31760. static Triggers: {
  31761. [key: string]: number;
  31762. };
  31763. /** Gets the cursor to use when hovering items */
  31764. hoverCursor: string;
  31765. /** Gets the list of actions */
  31766. actions: IAction[];
  31767. /**
  31768. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31769. */
  31770. isRecursive: boolean;
  31771. /**
  31772. * Releases all associated resources
  31773. */
  31774. abstract dispose(): void;
  31775. /**
  31776. * Does this action manager has pointer triggers
  31777. */
  31778. abstract get hasPointerTriggers(): boolean;
  31779. /**
  31780. * Does this action manager has pick triggers
  31781. */
  31782. abstract get hasPickTriggers(): boolean;
  31783. /**
  31784. * Process a specific trigger
  31785. * @param trigger defines the trigger to process
  31786. * @param evt defines the event details to be processed
  31787. */
  31788. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31789. /**
  31790. * Does this action manager handles actions of any of the given triggers
  31791. * @param triggers defines the triggers to be tested
  31792. * @return a boolean indicating whether one (or more) of the triggers is handled
  31793. */
  31794. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31795. /**
  31796. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31797. * speed.
  31798. * @param triggerA defines the trigger to be tested
  31799. * @param triggerB defines the trigger to be tested
  31800. * @return a boolean indicating whether one (or more) of the triggers is handled
  31801. */
  31802. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31803. /**
  31804. * Does this action manager handles actions of a given trigger
  31805. * @param trigger defines the trigger to be tested
  31806. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31807. * @return whether the trigger is handled
  31808. */
  31809. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31810. /**
  31811. * Serialize this manager to a JSON object
  31812. * @param name defines the property name to store this manager
  31813. * @returns a JSON representation of this manager
  31814. */
  31815. abstract serialize(name: string): any;
  31816. /**
  31817. * Registers an action to this action manager
  31818. * @param action defines the action to be registered
  31819. * @return the action amended (prepared) after registration
  31820. */
  31821. abstract registerAction(action: IAction): Nullable<IAction>;
  31822. /**
  31823. * Unregisters an action to this action manager
  31824. * @param action defines the action to be unregistered
  31825. * @return a boolean indicating whether the action has been unregistered
  31826. */
  31827. abstract unregisterAction(action: IAction): Boolean;
  31828. /**
  31829. * Does exist one action manager with at least one trigger
  31830. **/
  31831. static get HasTriggers(): boolean;
  31832. /**
  31833. * Does exist one action manager with at least one pick trigger
  31834. **/
  31835. static get HasPickTriggers(): boolean;
  31836. /**
  31837. * Does exist one action manager that handles actions of a given trigger
  31838. * @param trigger defines the trigger to be tested
  31839. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31840. **/
  31841. static HasSpecificTrigger(trigger: number): boolean;
  31842. }
  31843. }
  31844. declare module BABYLON {
  31845. /**
  31846. * Defines how a node can be built from a string name.
  31847. */
  31848. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31849. /**
  31850. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31851. */
  31852. export class Node implements IBehaviorAware<Node> {
  31853. /** @hidden */
  31854. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31855. private static _NodeConstructors;
  31856. /**
  31857. * Add a new node constructor
  31858. * @param type defines the type name of the node to construct
  31859. * @param constructorFunc defines the constructor function
  31860. */
  31861. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31862. /**
  31863. * Returns a node constructor based on type name
  31864. * @param type defines the type name
  31865. * @param name defines the new node name
  31866. * @param scene defines the hosting scene
  31867. * @param options defines optional options to transmit to constructors
  31868. * @returns the new constructor or null
  31869. */
  31870. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31871. /**
  31872. * Gets or sets the name of the node
  31873. */
  31874. name: string;
  31875. /**
  31876. * Gets or sets the id of the node
  31877. */
  31878. id: string;
  31879. /**
  31880. * Gets or sets the unique id of the node
  31881. */
  31882. uniqueId: number;
  31883. /**
  31884. * Gets or sets a string used to store user defined state for the node
  31885. */
  31886. state: string;
  31887. /**
  31888. * Gets or sets an object used to store user defined information for the node
  31889. */
  31890. metadata: any;
  31891. /**
  31892. * For internal use only. Please do not use.
  31893. */
  31894. reservedDataStore: any;
  31895. /**
  31896. * List of inspectable custom properties (used by the Inspector)
  31897. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31898. */
  31899. inspectableCustomProperties: IInspectable[];
  31900. private _doNotSerialize;
  31901. /**
  31902. * Gets or sets a boolean used to define if the node must be serialized
  31903. */
  31904. get doNotSerialize(): boolean;
  31905. set doNotSerialize(value: boolean);
  31906. /** @hidden */
  31907. _isDisposed: boolean;
  31908. /**
  31909. * Gets a list of Animations associated with the node
  31910. */
  31911. animations: Animation[];
  31912. protected _ranges: {
  31913. [name: string]: Nullable<AnimationRange>;
  31914. };
  31915. /**
  31916. * Callback raised when the node is ready to be used
  31917. */
  31918. onReady: Nullable<(node: Node) => void>;
  31919. private _isEnabled;
  31920. private _isParentEnabled;
  31921. private _isReady;
  31922. /** @hidden */
  31923. _currentRenderId: number;
  31924. private _parentUpdateId;
  31925. /** @hidden */
  31926. _childUpdateId: number;
  31927. /** @hidden */
  31928. _waitingParentId: Nullable<string>;
  31929. /** @hidden */
  31930. _scene: Scene;
  31931. /** @hidden */
  31932. _cache: any;
  31933. private _parentNode;
  31934. private _children;
  31935. /** @hidden */
  31936. _worldMatrix: Matrix;
  31937. /** @hidden */
  31938. _worldMatrixDeterminant: number;
  31939. /** @hidden */
  31940. _worldMatrixDeterminantIsDirty: boolean;
  31941. /** @hidden */
  31942. private _sceneRootNodesIndex;
  31943. /**
  31944. * Gets a boolean indicating if the node has been disposed
  31945. * @returns true if the node was disposed
  31946. */
  31947. isDisposed(): boolean;
  31948. /**
  31949. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31950. * @see https://doc.babylonjs.com/how_to/parenting
  31951. */
  31952. set parent(parent: Nullable<Node>);
  31953. get parent(): Nullable<Node>;
  31954. /** @hidden */
  31955. _addToSceneRootNodes(): void;
  31956. /** @hidden */
  31957. _removeFromSceneRootNodes(): void;
  31958. private _animationPropertiesOverride;
  31959. /**
  31960. * Gets or sets the animation properties override
  31961. */
  31962. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31963. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31964. /**
  31965. * Gets a string idenfifying the name of the class
  31966. * @returns "Node" string
  31967. */
  31968. getClassName(): string;
  31969. /** @hidden */
  31970. readonly _isNode: boolean;
  31971. /**
  31972. * An event triggered when the mesh is disposed
  31973. */
  31974. onDisposeObservable: Observable<Node>;
  31975. private _onDisposeObserver;
  31976. /**
  31977. * Sets a callback that will be raised when the node will be disposed
  31978. */
  31979. set onDispose(callback: () => void);
  31980. /**
  31981. * Creates a new Node
  31982. * @param name the name and id to be given to this node
  31983. * @param scene the scene this node will be added to
  31984. */
  31985. constructor(name: string, scene?: Nullable<Scene>);
  31986. /**
  31987. * Gets the scene of the node
  31988. * @returns a scene
  31989. */
  31990. getScene(): Scene;
  31991. /**
  31992. * Gets the engine of the node
  31993. * @returns a Engine
  31994. */
  31995. getEngine(): Engine;
  31996. private _behaviors;
  31997. /**
  31998. * Attach a behavior to the node
  31999. * @see http://doc.babylonjs.com/features/behaviour
  32000. * @param behavior defines the behavior to attach
  32001. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32002. * @returns the current Node
  32003. */
  32004. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32005. /**
  32006. * Remove an attached behavior
  32007. * @see http://doc.babylonjs.com/features/behaviour
  32008. * @param behavior defines the behavior to attach
  32009. * @returns the current Node
  32010. */
  32011. removeBehavior(behavior: Behavior<Node>): Node;
  32012. /**
  32013. * Gets the list of attached behaviors
  32014. * @see http://doc.babylonjs.com/features/behaviour
  32015. */
  32016. get behaviors(): Behavior<Node>[];
  32017. /**
  32018. * Gets an attached behavior by name
  32019. * @param name defines the name of the behavior to look for
  32020. * @see http://doc.babylonjs.com/features/behaviour
  32021. * @returns null if behavior was not found else the requested behavior
  32022. */
  32023. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32024. /**
  32025. * Returns the latest update of the World matrix
  32026. * @returns a Matrix
  32027. */
  32028. getWorldMatrix(): Matrix;
  32029. /** @hidden */
  32030. _getWorldMatrixDeterminant(): number;
  32031. /**
  32032. * Returns directly the latest state of the mesh World matrix.
  32033. * A Matrix is returned.
  32034. */
  32035. get worldMatrixFromCache(): Matrix;
  32036. /** @hidden */
  32037. _initCache(): void;
  32038. /** @hidden */
  32039. updateCache(force?: boolean): void;
  32040. /** @hidden */
  32041. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32042. /** @hidden */
  32043. _updateCache(ignoreParentClass?: boolean): void;
  32044. /** @hidden */
  32045. _isSynchronized(): boolean;
  32046. /** @hidden */
  32047. _markSyncedWithParent(): void;
  32048. /** @hidden */
  32049. isSynchronizedWithParent(): boolean;
  32050. /** @hidden */
  32051. isSynchronized(): boolean;
  32052. /**
  32053. * Is this node ready to be used/rendered
  32054. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32055. * @return true if the node is ready
  32056. */
  32057. isReady(completeCheck?: boolean): boolean;
  32058. /**
  32059. * Is this node enabled?
  32060. * 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
  32061. * @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
  32062. * @return whether this node (and its parent) is enabled
  32063. */
  32064. isEnabled(checkAncestors?: boolean): boolean;
  32065. /** @hidden */
  32066. protected _syncParentEnabledState(): void;
  32067. /**
  32068. * Set the enabled state of this node
  32069. * @param value defines the new enabled state
  32070. */
  32071. setEnabled(value: boolean): void;
  32072. /**
  32073. * Is this node a descendant of the given node?
  32074. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32075. * @param ancestor defines the parent node to inspect
  32076. * @returns a boolean indicating if this node is a descendant of the given node
  32077. */
  32078. isDescendantOf(ancestor: Node): boolean;
  32079. /** @hidden */
  32080. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32081. /**
  32082. * Will return all nodes that have this node as ascendant
  32083. * @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
  32084. * @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
  32085. * @return all children nodes of all types
  32086. */
  32087. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32088. /**
  32089. * Get all child-meshes of this node
  32090. * @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)
  32091. * @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
  32092. * @returns an array of AbstractMesh
  32093. */
  32094. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32095. /**
  32096. * Get all direct children of this node
  32097. * @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
  32098. * @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)
  32099. * @returns an array of Node
  32100. */
  32101. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32102. /** @hidden */
  32103. _setReady(state: boolean): void;
  32104. /**
  32105. * Get an animation by name
  32106. * @param name defines the name of the animation to look for
  32107. * @returns null if not found else the requested animation
  32108. */
  32109. getAnimationByName(name: string): Nullable<Animation>;
  32110. /**
  32111. * Creates an animation range for this node
  32112. * @param name defines the name of the range
  32113. * @param from defines the starting key
  32114. * @param to defines the end key
  32115. */
  32116. createAnimationRange(name: string, from: number, to: number): void;
  32117. /**
  32118. * Delete a specific animation range
  32119. * @param name defines the name of the range to delete
  32120. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32121. */
  32122. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32123. /**
  32124. * Get an animation range by name
  32125. * @param name defines the name of the animation range to look for
  32126. * @returns null if not found else the requested animation range
  32127. */
  32128. getAnimationRange(name: string): Nullable<AnimationRange>;
  32129. /**
  32130. * Gets the list of all animation ranges defined on this node
  32131. * @returns an array
  32132. */
  32133. getAnimationRanges(): Nullable<AnimationRange>[];
  32134. /**
  32135. * Will start the animation sequence
  32136. * @param name defines the range frames for animation sequence
  32137. * @param loop defines if the animation should loop (false by default)
  32138. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32139. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32140. * @returns the object created for this animation. If range does not exist, it will return null
  32141. */
  32142. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32143. /**
  32144. * Serialize animation ranges into a JSON compatible object
  32145. * @returns serialization object
  32146. */
  32147. serializeAnimationRanges(): any;
  32148. /**
  32149. * Computes the world matrix of the node
  32150. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32151. * @returns the world matrix
  32152. */
  32153. computeWorldMatrix(force?: boolean): Matrix;
  32154. /**
  32155. * Releases resources associated with this node.
  32156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32158. */
  32159. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32160. /**
  32161. * Parse animation range data from a serialization object and store them into a given node
  32162. * @param node defines where to store the animation ranges
  32163. * @param parsedNode defines the serialization object to read data from
  32164. * @param scene defines the hosting scene
  32165. */
  32166. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32167. /**
  32168. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32169. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32170. * @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
  32171. * @returns the new bounding vectors
  32172. */
  32173. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32174. min: Vector3;
  32175. max: Vector3;
  32176. };
  32177. }
  32178. }
  32179. declare module BABYLON {
  32180. /**
  32181. * @hidden
  32182. */
  32183. export class _IAnimationState {
  32184. key: number;
  32185. repeatCount: number;
  32186. workValue?: any;
  32187. loopMode?: number;
  32188. offsetValue?: any;
  32189. highLimitValue?: any;
  32190. }
  32191. /**
  32192. * Class used to store any kind of animation
  32193. */
  32194. export class Animation {
  32195. /**Name of the animation */
  32196. name: string;
  32197. /**Property to animate */
  32198. targetProperty: string;
  32199. /**The frames per second of the animation */
  32200. framePerSecond: number;
  32201. /**The data type of the animation */
  32202. dataType: number;
  32203. /**The loop mode of the animation */
  32204. loopMode?: number | undefined;
  32205. /**Specifies if blending should be enabled */
  32206. enableBlending?: boolean | undefined;
  32207. /**
  32208. * Use matrix interpolation instead of using direct key value when animating matrices
  32209. */
  32210. static AllowMatricesInterpolation: boolean;
  32211. /**
  32212. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32213. */
  32214. static AllowMatrixDecomposeForInterpolation: boolean;
  32215. /**
  32216. * Stores the key frames of the animation
  32217. */
  32218. private _keys;
  32219. /**
  32220. * Stores the easing function of the animation
  32221. */
  32222. private _easingFunction;
  32223. /**
  32224. * @hidden Internal use only
  32225. */
  32226. _runtimeAnimations: RuntimeAnimation[];
  32227. /**
  32228. * The set of event that will be linked to this animation
  32229. */
  32230. private _events;
  32231. /**
  32232. * Stores an array of target property paths
  32233. */
  32234. targetPropertyPath: string[];
  32235. /**
  32236. * Stores the blending speed of the animation
  32237. */
  32238. blendingSpeed: number;
  32239. /**
  32240. * Stores the animation ranges for the animation
  32241. */
  32242. private _ranges;
  32243. /**
  32244. * @hidden Internal use
  32245. */
  32246. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32247. /**
  32248. * Sets up an animation
  32249. * @param property The property to animate
  32250. * @param animationType The animation type to apply
  32251. * @param framePerSecond The frames per second of the animation
  32252. * @param easingFunction The easing function used in the animation
  32253. * @returns The created animation
  32254. */
  32255. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32256. /**
  32257. * Create and start an animation on a node
  32258. * @param name defines the name of the global animation that will be run on all nodes
  32259. * @param node defines the root node where the animation will take place
  32260. * @param targetProperty defines property to animate
  32261. * @param framePerSecond defines the number of frame per second yo use
  32262. * @param totalFrame defines the number of frames in total
  32263. * @param from defines the initial value
  32264. * @param to defines the final value
  32265. * @param loopMode defines which loop mode you want to use (off by default)
  32266. * @param easingFunction defines the easing function to use (linear by default)
  32267. * @param onAnimationEnd defines the callback to call when animation end
  32268. * @returns the animatable created for this animation
  32269. */
  32270. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32271. /**
  32272. * Create and start an animation on a node and its descendants
  32273. * @param name defines the name of the global animation that will be run on all nodes
  32274. * @param node defines the root node where the animation will take place
  32275. * @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
  32276. * @param targetProperty defines property to animate
  32277. * @param framePerSecond defines the number of frame per second to use
  32278. * @param totalFrame defines the number of frames in total
  32279. * @param from defines the initial value
  32280. * @param to defines the final value
  32281. * @param loopMode defines which loop mode you want to use (off by default)
  32282. * @param easingFunction defines the easing function to use (linear by default)
  32283. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32284. * @returns the list of animatables created for all nodes
  32285. * @example https://www.babylonjs-playground.com/#MH0VLI
  32286. */
  32287. 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[]>;
  32288. /**
  32289. * Creates a new animation, merges it with the existing animations and starts it
  32290. * @param name Name of the animation
  32291. * @param node Node which contains the scene that begins the animations
  32292. * @param targetProperty Specifies which property to animate
  32293. * @param framePerSecond The frames per second of the animation
  32294. * @param totalFrame The total number of frames
  32295. * @param from The frame at the beginning of the animation
  32296. * @param to The frame at the end of the animation
  32297. * @param loopMode Specifies the loop mode of the animation
  32298. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32299. * @param onAnimationEnd Callback to run once the animation is complete
  32300. * @returns Nullable animation
  32301. */
  32302. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32303. /**
  32304. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32305. * @param sourceAnimation defines the Animation containing keyframes to convert
  32306. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32307. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32308. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32309. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32310. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32311. */
  32312. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32313. /**
  32314. * Transition property of an host to the target Value
  32315. * @param property The property to transition
  32316. * @param targetValue The target Value of the property
  32317. * @param host The object where the property to animate belongs
  32318. * @param scene Scene used to run the animation
  32319. * @param frameRate Framerate (in frame/s) to use
  32320. * @param transition The transition type we want to use
  32321. * @param duration The duration of the animation, in milliseconds
  32322. * @param onAnimationEnd Callback trigger at the end of the animation
  32323. * @returns Nullable animation
  32324. */
  32325. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32326. /**
  32327. * Return the array of runtime animations currently using this animation
  32328. */
  32329. get runtimeAnimations(): RuntimeAnimation[];
  32330. /**
  32331. * Specifies if any of the runtime animations are currently running
  32332. */
  32333. get hasRunningRuntimeAnimations(): boolean;
  32334. /**
  32335. * Initializes the animation
  32336. * @param name Name of the animation
  32337. * @param targetProperty Property to animate
  32338. * @param framePerSecond The frames per second of the animation
  32339. * @param dataType The data type of the animation
  32340. * @param loopMode The loop mode of the animation
  32341. * @param enableBlending Specifies if blending should be enabled
  32342. */
  32343. constructor(
  32344. /**Name of the animation */
  32345. name: string,
  32346. /**Property to animate */
  32347. targetProperty: string,
  32348. /**The frames per second of the animation */
  32349. framePerSecond: number,
  32350. /**The data type of the animation */
  32351. dataType: number,
  32352. /**The loop mode of the animation */
  32353. loopMode?: number | undefined,
  32354. /**Specifies if blending should be enabled */
  32355. enableBlending?: boolean | undefined);
  32356. /**
  32357. * Converts the animation to a string
  32358. * @param fullDetails support for multiple levels of logging within scene loading
  32359. * @returns String form of the animation
  32360. */
  32361. toString(fullDetails?: boolean): string;
  32362. /**
  32363. * Add an event to this animation
  32364. * @param event Event to add
  32365. */
  32366. addEvent(event: AnimationEvent): void;
  32367. /**
  32368. * Remove all events found at the given frame
  32369. * @param frame The frame to remove events from
  32370. */
  32371. removeEvents(frame: number): void;
  32372. /**
  32373. * Retrieves all the events from the animation
  32374. * @returns Events from the animation
  32375. */
  32376. getEvents(): AnimationEvent[];
  32377. /**
  32378. * Creates an animation range
  32379. * @param name Name of the animation range
  32380. * @param from Starting frame of the animation range
  32381. * @param to Ending frame of the animation
  32382. */
  32383. createRange(name: string, from: number, to: number): void;
  32384. /**
  32385. * Deletes an animation range by name
  32386. * @param name Name of the animation range to delete
  32387. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32388. */
  32389. deleteRange(name: string, deleteFrames?: boolean): void;
  32390. /**
  32391. * Gets the animation range by name, or null if not defined
  32392. * @param name Name of the animation range
  32393. * @returns Nullable animation range
  32394. */
  32395. getRange(name: string): Nullable<AnimationRange>;
  32396. /**
  32397. * Gets the key frames from the animation
  32398. * @returns The key frames of the animation
  32399. */
  32400. getKeys(): Array<IAnimationKey>;
  32401. /**
  32402. * Gets the highest frame rate of the animation
  32403. * @returns Highest frame rate of the animation
  32404. */
  32405. getHighestFrame(): number;
  32406. /**
  32407. * Gets the easing function of the animation
  32408. * @returns Easing function of the animation
  32409. */
  32410. getEasingFunction(): IEasingFunction;
  32411. /**
  32412. * Sets the easing function of the animation
  32413. * @param easingFunction A custom mathematical formula for animation
  32414. */
  32415. setEasingFunction(easingFunction: EasingFunction): void;
  32416. /**
  32417. * Interpolates a scalar linearly
  32418. * @param startValue Start value of the animation curve
  32419. * @param endValue End value of the animation curve
  32420. * @param gradient Scalar amount to interpolate
  32421. * @returns Interpolated scalar value
  32422. */
  32423. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32424. /**
  32425. * Interpolates a scalar cubically
  32426. * @param startValue Start value of the animation curve
  32427. * @param outTangent End tangent of the animation
  32428. * @param endValue End value of the animation curve
  32429. * @param inTangent Start tangent of the animation curve
  32430. * @param gradient Scalar amount to interpolate
  32431. * @returns Interpolated scalar value
  32432. */
  32433. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32434. /**
  32435. * Interpolates a quaternion using a spherical linear interpolation
  32436. * @param startValue Start value of the animation curve
  32437. * @param endValue End value of the animation curve
  32438. * @param gradient Scalar amount to interpolate
  32439. * @returns Interpolated quaternion value
  32440. */
  32441. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32442. /**
  32443. * Interpolates a quaternion cubically
  32444. * @param startValue Start value of the animation curve
  32445. * @param outTangent End tangent of the animation curve
  32446. * @param endValue End value of the animation curve
  32447. * @param inTangent Start tangent of the animation curve
  32448. * @param gradient Scalar amount to interpolate
  32449. * @returns Interpolated quaternion value
  32450. */
  32451. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32452. /**
  32453. * Interpolates a Vector3 linearl
  32454. * @param startValue Start value of the animation curve
  32455. * @param endValue End value of the animation curve
  32456. * @param gradient Scalar amount to interpolate
  32457. * @returns Interpolated scalar value
  32458. */
  32459. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32460. /**
  32461. * Interpolates a Vector3 cubically
  32462. * @param startValue Start value of the animation curve
  32463. * @param outTangent End tangent of the animation
  32464. * @param endValue End value of the animation curve
  32465. * @param inTangent Start tangent of the animation curve
  32466. * @param gradient Scalar amount to interpolate
  32467. * @returns InterpolatedVector3 value
  32468. */
  32469. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32470. /**
  32471. * Interpolates a Vector2 linearly
  32472. * @param startValue Start value of the animation curve
  32473. * @param endValue End value of the animation curve
  32474. * @param gradient Scalar amount to interpolate
  32475. * @returns Interpolated Vector2 value
  32476. */
  32477. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32478. /**
  32479. * Interpolates a Vector2 cubically
  32480. * @param startValue Start value of the animation curve
  32481. * @param outTangent End tangent of the animation
  32482. * @param endValue End value of the animation curve
  32483. * @param inTangent Start tangent of the animation curve
  32484. * @param gradient Scalar amount to interpolate
  32485. * @returns Interpolated Vector2 value
  32486. */
  32487. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32488. /**
  32489. * Interpolates a size linearly
  32490. * @param startValue Start value of the animation curve
  32491. * @param endValue End value of the animation curve
  32492. * @param gradient Scalar amount to interpolate
  32493. * @returns Interpolated Size value
  32494. */
  32495. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32496. /**
  32497. * Interpolates a Color3 linearly
  32498. * @param startValue Start value of the animation curve
  32499. * @param endValue End value of the animation curve
  32500. * @param gradient Scalar amount to interpolate
  32501. * @returns Interpolated Color3 value
  32502. */
  32503. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32504. /**
  32505. * Interpolates a Color4 linearly
  32506. * @param startValue Start value of the animation curve
  32507. * @param endValue End value of the animation curve
  32508. * @param gradient Scalar amount to interpolate
  32509. * @returns Interpolated Color3 value
  32510. */
  32511. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32512. /**
  32513. * @hidden Internal use only
  32514. */
  32515. _getKeyValue(value: any): any;
  32516. /**
  32517. * @hidden Internal use only
  32518. */
  32519. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32520. /**
  32521. * Defines the function to use to interpolate matrices
  32522. * @param startValue defines the start matrix
  32523. * @param endValue defines the end matrix
  32524. * @param gradient defines the gradient between both matrices
  32525. * @param result defines an optional target matrix where to store the interpolation
  32526. * @returns the interpolated matrix
  32527. */
  32528. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32529. /**
  32530. * Makes a copy of the animation
  32531. * @returns Cloned animation
  32532. */
  32533. clone(): Animation;
  32534. /**
  32535. * Sets the key frames of the animation
  32536. * @param values The animation key frames to set
  32537. */
  32538. setKeys(values: Array<IAnimationKey>): void;
  32539. /**
  32540. * Serializes the animation to an object
  32541. * @returns Serialized object
  32542. */
  32543. serialize(): any;
  32544. /**
  32545. * Float animation type
  32546. */
  32547. static readonly ANIMATIONTYPE_FLOAT: number;
  32548. /**
  32549. * Vector3 animation type
  32550. */
  32551. static readonly ANIMATIONTYPE_VECTOR3: number;
  32552. /**
  32553. * Quaternion animation type
  32554. */
  32555. static readonly ANIMATIONTYPE_QUATERNION: number;
  32556. /**
  32557. * Matrix animation type
  32558. */
  32559. static readonly ANIMATIONTYPE_MATRIX: number;
  32560. /**
  32561. * Color3 animation type
  32562. */
  32563. static readonly ANIMATIONTYPE_COLOR3: number;
  32564. /**
  32565. * Color3 animation type
  32566. */
  32567. static readonly ANIMATIONTYPE_COLOR4: number;
  32568. /**
  32569. * Vector2 animation type
  32570. */
  32571. static readonly ANIMATIONTYPE_VECTOR2: number;
  32572. /**
  32573. * Size animation type
  32574. */
  32575. static readonly ANIMATIONTYPE_SIZE: number;
  32576. /**
  32577. * Relative Loop Mode
  32578. */
  32579. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32580. /**
  32581. * Cycle Loop Mode
  32582. */
  32583. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32584. /**
  32585. * Constant Loop Mode
  32586. */
  32587. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32588. /** @hidden */
  32589. static _UniversalLerp(left: any, right: any, amount: number): any;
  32590. /**
  32591. * Parses an animation object and creates an animation
  32592. * @param parsedAnimation Parsed animation object
  32593. * @returns Animation object
  32594. */
  32595. static Parse(parsedAnimation: any): Animation;
  32596. /**
  32597. * Appends the serialized animations from the source animations
  32598. * @param source Source containing the animations
  32599. * @param destination Target to store the animations
  32600. */
  32601. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32602. }
  32603. }
  32604. declare module BABYLON {
  32605. /**
  32606. * Interface containing an array of animations
  32607. */
  32608. export interface IAnimatable {
  32609. /**
  32610. * Array of animations
  32611. */
  32612. animations: Nullable<Array<Animation>>;
  32613. }
  32614. }
  32615. declare module BABYLON {
  32616. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32617. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32618. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32619. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32620. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32621. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32622. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32623. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32624. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32625. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32626. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32627. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32628. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32629. /**
  32630. * Decorator used to define property that can be serialized as reference to a camera
  32631. * @param sourceName defines the name of the property to decorate
  32632. */
  32633. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32634. /**
  32635. * Class used to help serialization objects
  32636. */
  32637. export class SerializationHelper {
  32638. /** @hidden */
  32639. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32640. /** @hidden */
  32641. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32642. /** @hidden */
  32643. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32644. /** @hidden */
  32645. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32646. /**
  32647. * Appends the serialized animations from the source animations
  32648. * @param source Source containing the animations
  32649. * @param destination Target to store the animations
  32650. */
  32651. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32652. /**
  32653. * Static function used to serialized a specific entity
  32654. * @param entity defines the entity to serialize
  32655. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32656. * @returns a JSON compatible object representing the serialization of the entity
  32657. */
  32658. static Serialize<T>(entity: T, serializationObject?: any): any;
  32659. /**
  32660. * Creates a new entity from a serialization data object
  32661. * @param creationFunction defines a function used to instanciated the new entity
  32662. * @param source defines the source serialization data
  32663. * @param scene defines the hosting scene
  32664. * @param rootUrl defines the root url for resources
  32665. * @returns a new entity
  32666. */
  32667. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32668. /**
  32669. * Clones an object
  32670. * @param creationFunction defines the function used to instanciate the new object
  32671. * @param source defines the source object
  32672. * @returns the cloned object
  32673. */
  32674. static Clone<T>(creationFunction: () => T, source: T): T;
  32675. /**
  32676. * Instanciates a new object based on a source one (some data will be shared between both object)
  32677. * @param creationFunction defines the function used to instanciate the new object
  32678. * @param source defines the source object
  32679. * @returns the new object
  32680. */
  32681. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32682. }
  32683. }
  32684. declare module BABYLON {
  32685. /**
  32686. * Base class of all the textures in babylon.
  32687. * It groups all the common properties the materials, post process, lights... might need
  32688. * in order to make a correct use of the texture.
  32689. */
  32690. export class BaseTexture implements IAnimatable {
  32691. /**
  32692. * Default anisotropic filtering level for the application.
  32693. * It is set to 4 as a good tradeoff between perf and quality.
  32694. */
  32695. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32696. /**
  32697. * Gets or sets the unique id of the texture
  32698. */
  32699. uniqueId: number;
  32700. /**
  32701. * Define the name of the texture.
  32702. */
  32703. name: string;
  32704. /**
  32705. * Gets or sets an object used to store user defined information.
  32706. */
  32707. metadata: any;
  32708. /**
  32709. * For internal use only. Please do not use.
  32710. */
  32711. reservedDataStore: any;
  32712. private _hasAlpha;
  32713. /**
  32714. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32715. */
  32716. set hasAlpha(value: boolean);
  32717. get hasAlpha(): boolean;
  32718. /**
  32719. * Defines if the alpha value should be determined via the rgb values.
  32720. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32721. */
  32722. getAlphaFromRGB: boolean;
  32723. /**
  32724. * Intensity or strength of the texture.
  32725. * It is commonly used by materials to fine tune the intensity of the texture
  32726. */
  32727. level: number;
  32728. /**
  32729. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32730. * This is part of the texture as textures usually maps to one uv set.
  32731. */
  32732. coordinatesIndex: number;
  32733. private _coordinatesMode;
  32734. /**
  32735. * How a texture is mapped.
  32736. *
  32737. * | Value | Type | Description |
  32738. * | ----- | ----------------------------------- | ----------- |
  32739. * | 0 | EXPLICIT_MODE | |
  32740. * | 1 | SPHERICAL_MODE | |
  32741. * | 2 | PLANAR_MODE | |
  32742. * | 3 | CUBIC_MODE | |
  32743. * | 4 | PROJECTION_MODE | |
  32744. * | 5 | SKYBOX_MODE | |
  32745. * | 6 | INVCUBIC_MODE | |
  32746. * | 7 | EQUIRECTANGULAR_MODE | |
  32747. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32748. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32749. */
  32750. set coordinatesMode(value: number);
  32751. get coordinatesMode(): number;
  32752. /**
  32753. * | Value | Type | Description |
  32754. * | ----- | ------------------ | ----------- |
  32755. * | 0 | CLAMP_ADDRESSMODE | |
  32756. * | 1 | WRAP_ADDRESSMODE | |
  32757. * | 2 | MIRROR_ADDRESSMODE | |
  32758. */
  32759. wrapU: number;
  32760. /**
  32761. * | Value | Type | Description |
  32762. * | ----- | ------------------ | ----------- |
  32763. * | 0 | CLAMP_ADDRESSMODE | |
  32764. * | 1 | WRAP_ADDRESSMODE | |
  32765. * | 2 | MIRROR_ADDRESSMODE | |
  32766. */
  32767. wrapV: number;
  32768. /**
  32769. * | Value | Type | Description |
  32770. * | ----- | ------------------ | ----------- |
  32771. * | 0 | CLAMP_ADDRESSMODE | |
  32772. * | 1 | WRAP_ADDRESSMODE | |
  32773. * | 2 | MIRROR_ADDRESSMODE | |
  32774. */
  32775. wrapR: number;
  32776. /**
  32777. * With compliant hardware and browser (supporting anisotropic filtering)
  32778. * this defines the level of anisotropic filtering in the texture.
  32779. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32780. */
  32781. anisotropicFilteringLevel: number;
  32782. /**
  32783. * Define if the texture is a cube texture or if false a 2d texture.
  32784. */
  32785. get isCube(): boolean;
  32786. set isCube(value: boolean);
  32787. /**
  32788. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32789. */
  32790. get is3D(): boolean;
  32791. set is3D(value: boolean);
  32792. /**
  32793. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32794. */
  32795. get is2DArray(): boolean;
  32796. set is2DArray(value: boolean);
  32797. /**
  32798. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32799. * HDR texture are usually stored in linear space.
  32800. * This only impacts the PBR and Background materials
  32801. */
  32802. gammaSpace: boolean;
  32803. /**
  32804. * Gets or sets whether or not the texture contains RGBD data.
  32805. */
  32806. get isRGBD(): boolean;
  32807. set isRGBD(value: boolean);
  32808. /**
  32809. * Is Z inverted in the texture (useful in a cube texture).
  32810. */
  32811. invertZ: boolean;
  32812. /**
  32813. * Are mip maps generated for this texture or not.
  32814. */
  32815. get noMipmap(): boolean;
  32816. /**
  32817. * @hidden
  32818. */
  32819. lodLevelInAlpha: boolean;
  32820. /**
  32821. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32822. */
  32823. get lodGenerationOffset(): number;
  32824. set lodGenerationOffset(value: number);
  32825. /**
  32826. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32827. */
  32828. get lodGenerationScale(): number;
  32829. set lodGenerationScale(value: number);
  32830. /**
  32831. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32832. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32833. * average roughness values.
  32834. */
  32835. get linearSpecularLOD(): boolean;
  32836. set linearSpecularLOD(value: boolean);
  32837. /**
  32838. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32839. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32840. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32841. */
  32842. get irradianceTexture(): Nullable<BaseTexture>;
  32843. set irradianceTexture(value: Nullable<BaseTexture>);
  32844. /**
  32845. * Define if the texture is a render target.
  32846. */
  32847. isRenderTarget: boolean;
  32848. /**
  32849. * Define the unique id of the texture in the scene.
  32850. */
  32851. get uid(): string;
  32852. /** @hidden */
  32853. _prefiltered: boolean;
  32854. /**
  32855. * Return a string representation of the texture.
  32856. * @returns the texture as a string
  32857. */
  32858. toString(): string;
  32859. /**
  32860. * Get the class name of the texture.
  32861. * @returns "BaseTexture"
  32862. */
  32863. getClassName(): string;
  32864. /**
  32865. * Define the list of animation attached to the texture.
  32866. */
  32867. animations: Animation[];
  32868. /**
  32869. * An event triggered when the texture is disposed.
  32870. */
  32871. onDisposeObservable: Observable<BaseTexture>;
  32872. private _onDisposeObserver;
  32873. /**
  32874. * Callback triggered when the texture has been disposed.
  32875. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32876. */
  32877. set onDispose(callback: () => void);
  32878. /**
  32879. * Define the current state of the loading sequence when in delayed load mode.
  32880. */
  32881. delayLoadState: number;
  32882. private _scene;
  32883. private _engine;
  32884. /** @hidden */
  32885. _texture: Nullable<InternalTexture>;
  32886. private _uid;
  32887. /**
  32888. * Define if the texture is preventinga material to render or not.
  32889. * If not and the texture is not ready, the engine will use a default black texture instead.
  32890. */
  32891. get isBlocking(): boolean;
  32892. /**
  32893. * Instantiates a new BaseTexture.
  32894. * Base class of all the textures in babylon.
  32895. * It groups all the common properties the materials, post process, lights... might need
  32896. * in order to make a correct use of the texture.
  32897. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32898. */
  32899. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32900. /**
  32901. * Get the scene the texture belongs to.
  32902. * @returns the scene or null if undefined
  32903. */
  32904. getScene(): Nullable<Scene>;
  32905. /** @hidden */
  32906. protected _getEngine(): Nullable<ThinEngine>;
  32907. /**
  32908. * Get the texture transform matrix used to offset tile the texture for istance.
  32909. * @returns the transformation matrix
  32910. */
  32911. getTextureMatrix(): Matrix;
  32912. /**
  32913. * Get the texture reflection matrix used to rotate/transform the reflection.
  32914. * @returns the reflection matrix
  32915. */
  32916. getReflectionTextureMatrix(): Matrix;
  32917. /**
  32918. * Get the underlying lower level texture from Babylon.
  32919. * @returns the insternal texture
  32920. */
  32921. getInternalTexture(): Nullable<InternalTexture>;
  32922. /**
  32923. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32924. * @returns true if ready or not blocking
  32925. */
  32926. isReadyOrNotBlocking(): boolean;
  32927. /**
  32928. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32929. * @returns true if fully ready
  32930. */
  32931. isReady(): boolean;
  32932. private _cachedSize;
  32933. /**
  32934. * Get the size of the texture.
  32935. * @returns the texture size.
  32936. */
  32937. getSize(): ISize;
  32938. /**
  32939. * Get the base size of the texture.
  32940. * It can be different from the size if the texture has been resized for POT for instance
  32941. * @returns the base size
  32942. */
  32943. getBaseSize(): ISize;
  32944. /**
  32945. * Update the sampling mode of the texture.
  32946. * Default is Trilinear mode.
  32947. *
  32948. * | Value | Type | Description |
  32949. * | ----- | ------------------ | ----------- |
  32950. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32951. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32952. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32953. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32954. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32955. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32956. * | 7 | NEAREST_LINEAR | |
  32957. * | 8 | NEAREST_NEAREST | |
  32958. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32959. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32960. * | 11 | LINEAR_LINEAR | |
  32961. * | 12 | LINEAR_NEAREST | |
  32962. *
  32963. * > _mag_: magnification filter (close to the viewer)
  32964. * > _min_: minification filter (far from the viewer)
  32965. * > _mip_: filter used between mip map levels
  32966. *@param samplingMode Define the new sampling mode of the texture
  32967. */
  32968. updateSamplingMode(samplingMode: number): void;
  32969. /**
  32970. * Scales the texture if is `canRescale()`
  32971. * @param ratio the resize factor we want to use to rescale
  32972. */
  32973. scale(ratio: number): void;
  32974. /**
  32975. * Get if the texture can rescale.
  32976. */
  32977. get canRescale(): boolean;
  32978. /** @hidden */
  32979. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32980. /** @hidden */
  32981. _rebuild(): void;
  32982. /**
  32983. * Triggers the load sequence in delayed load mode.
  32984. */
  32985. delayLoad(): void;
  32986. /**
  32987. * Clones the texture.
  32988. * @returns the cloned texture
  32989. */
  32990. clone(): Nullable<BaseTexture>;
  32991. /**
  32992. * Get the texture underlying type (INT, FLOAT...)
  32993. */
  32994. get textureType(): number;
  32995. /**
  32996. * Get the texture underlying format (RGB, RGBA...)
  32997. */
  32998. get textureFormat(): number;
  32999. /**
  33000. * Indicates that textures need to be re-calculated for all materials
  33001. */
  33002. protected _markAllSubMeshesAsTexturesDirty(): void;
  33003. /**
  33004. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33005. * This will returns an RGBA array buffer containing either in values (0-255) or
  33006. * float values (0-1) depending of the underlying buffer type.
  33007. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33008. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33009. * @param buffer defines a user defined buffer to fill with data (can be null)
  33010. * @returns The Array buffer containing the pixels data.
  33011. */
  33012. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33013. /**
  33014. * Release and destroy the underlying lower level texture aka internalTexture.
  33015. */
  33016. releaseInternalTexture(): void;
  33017. /** @hidden */
  33018. get _lodTextureHigh(): Nullable<BaseTexture>;
  33019. /** @hidden */
  33020. get _lodTextureMid(): Nullable<BaseTexture>;
  33021. /** @hidden */
  33022. get _lodTextureLow(): Nullable<BaseTexture>;
  33023. /**
  33024. * Dispose the texture and release its associated resources.
  33025. */
  33026. dispose(): void;
  33027. /**
  33028. * Serialize the texture into a JSON representation that can be parsed later on.
  33029. * @returns the JSON representation of the texture
  33030. */
  33031. serialize(): any;
  33032. /**
  33033. * Helper function to be called back once a list of texture contains only ready textures.
  33034. * @param textures Define the list of textures to wait for
  33035. * @param callback Define the callback triggered once the entire list will be ready
  33036. */
  33037. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33038. private static _isScene;
  33039. }
  33040. }
  33041. declare module BABYLON {
  33042. /**
  33043. * Options to be used when creating an effect.
  33044. */
  33045. export interface IEffectCreationOptions {
  33046. /**
  33047. * Atrributes that will be used in the shader.
  33048. */
  33049. attributes: string[];
  33050. /**
  33051. * Uniform varible names that will be set in the shader.
  33052. */
  33053. uniformsNames: string[];
  33054. /**
  33055. * Uniform buffer variable names that will be set in the shader.
  33056. */
  33057. uniformBuffersNames: string[];
  33058. /**
  33059. * Sampler texture variable names that will be set in the shader.
  33060. */
  33061. samplers: string[];
  33062. /**
  33063. * Define statements that will be set in the shader.
  33064. */
  33065. defines: any;
  33066. /**
  33067. * Possible fallbacks for this effect to improve performance when needed.
  33068. */
  33069. fallbacks: Nullable<IEffectFallbacks>;
  33070. /**
  33071. * Callback that will be called when the shader is compiled.
  33072. */
  33073. onCompiled: Nullable<(effect: Effect) => void>;
  33074. /**
  33075. * Callback that will be called if an error occurs during shader compilation.
  33076. */
  33077. onError: Nullable<(effect: Effect, errors: string) => void>;
  33078. /**
  33079. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33080. */
  33081. indexParameters?: any;
  33082. /**
  33083. * Max number of lights that can be used in the shader.
  33084. */
  33085. maxSimultaneousLights?: number;
  33086. /**
  33087. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33088. */
  33089. transformFeedbackVaryings?: Nullable<string[]>;
  33090. /**
  33091. * 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
  33092. */
  33093. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33094. }
  33095. /**
  33096. * Effect containing vertex and fragment shader that can be executed on an object.
  33097. */
  33098. export class Effect implements IDisposable {
  33099. /**
  33100. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33101. */
  33102. static ShadersRepository: string;
  33103. /**
  33104. * Enable logging of the shader code when a compilation error occurs
  33105. */
  33106. static LogShaderCodeOnCompilationError: boolean;
  33107. /**
  33108. * Name of the effect.
  33109. */
  33110. name: any;
  33111. /**
  33112. * String container all the define statements that should be set on the shader.
  33113. */
  33114. defines: string;
  33115. /**
  33116. * Callback that will be called when the shader is compiled.
  33117. */
  33118. onCompiled: Nullable<(effect: Effect) => void>;
  33119. /**
  33120. * Callback that will be called if an error occurs during shader compilation.
  33121. */
  33122. onError: Nullable<(effect: Effect, errors: string) => void>;
  33123. /**
  33124. * Callback that will be called when effect is bound.
  33125. */
  33126. onBind: Nullable<(effect: Effect) => void>;
  33127. /**
  33128. * Unique ID of the effect.
  33129. */
  33130. uniqueId: number;
  33131. /**
  33132. * Observable that will be called when the shader is compiled.
  33133. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33134. */
  33135. onCompileObservable: Observable<Effect>;
  33136. /**
  33137. * Observable that will be called if an error occurs during shader compilation.
  33138. */
  33139. onErrorObservable: Observable<Effect>;
  33140. /** @hidden */
  33141. _onBindObservable: Nullable<Observable<Effect>>;
  33142. /**
  33143. * @hidden
  33144. * Specifies if the effect was previously ready
  33145. */
  33146. _wasPreviouslyReady: boolean;
  33147. /**
  33148. * Observable that will be called when effect is bound.
  33149. */
  33150. get onBindObservable(): Observable<Effect>;
  33151. /** @hidden */
  33152. _bonesComputationForcedToCPU: boolean;
  33153. private static _uniqueIdSeed;
  33154. private _engine;
  33155. private _uniformBuffersNames;
  33156. private _uniformBuffersNamesList;
  33157. private _uniformsNames;
  33158. private _samplerList;
  33159. private _samplers;
  33160. private _isReady;
  33161. private _compilationError;
  33162. private _allFallbacksProcessed;
  33163. private _attributesNames;
  33164. private _attributes;
  33165. private _attributeLocationByName;
  33166. private _uniforms;
  33167. /**
  33168. * Key for the effect.
  33169. * @hidden
  33170. */
  33171. _key: string;
  33172. private _indexParameters;
  33173. private _fallbacks;
  33174. private _vertexSourceCode;
  33175. private _fragmentSourceCode;
  33176. private _vertexSourceCodeOverride;
  33177. private _fragmentSourceCodeOverride;
  33178. private _transformFeedbackVaryings;
  33179. /**
  33180. * Compiled shader to webGL program.
  33181. * @hidden
  33182. */
  33183. _pipelineContext: Nullable<IPipelineContext>;
  33184. private _valueCache;
  33185. private static _baseCache;
  33186. /**
  33187. * Instantiates an effect.
  33188. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33189. * @param baseName Name of the effect.
  33190. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33191. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33192. * @param samplers List of sampler variables that will be passed to the shader.
  33193. * @param engine Engine to be used to render the effect
  33194. * @param defines Define statements to be added to the shader.
  33195. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33196. * @param onCompiled Callback that will be called when the shader is compiled.
  33197. * @param onError Callback that will be called if an error occurs during shader compilation.
  33198. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33199. */
  33200. 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);
  33201. private _useFinalCode;
  33202. /**
  33203. * Unique key for this effect
  33204. */
  33205. get key(): string;
  33206. /**
  33207. * If the effect has been compiled and prepared.
  33208. * @returns if the effect is compiled and prepared.
  33209. */
  33210. isReady(): boolean;
  33211. private _isReadyInternal;
  33212. /**
  33213. * The engine the effect was initialized with.
  33214. * @returns the engine.
  33215. */
  33216. getEngine(): Engine;
  33217. /**
  33218. * The pipeline context for this effect
  33219. * @returns the associated pipeline context
  33220. */
  33221. getPipelineContext(): Nullable<IPipelineContext>;
  33222. /**
  33223. * The set of names of attribute variables for the shader.
  33224. * @returns An array of attribute names.
  33225. */
  33226. getAttributesNames(): string[];
  33227. /**
  33228. * Returns the attribute at the given index.
  33229. * @param index The index of the attribute.
  33230. * @returns The location of the attribute.
  33231. */
  33232. getAttributeLocation(index: number): number;
  33233. /**
  33234. * Returns the attribute based on the name of the variable.
  33235. * @param name of the attribute to look up.
  33236. * @returns the attribute location.
  33237. */
  33238. getAttributeLocationByName(name: string): number;
  33239. /**
  33240. * The number of attributes.
  33241. * @returns the numnber of attributes.
  33242. */
  33243. getAttributesCount(): number;
  33244. /**
  33245. * Gets the index of a uniform variable.
  33246. * @param uniformName of the uniform to look up.
  33247. * @returns the index.
  33248. */
  33249. getUniformIndex(uniformName: string): number;
  33250. /**
  33251. * Returns the attribute based on the name of the variable.
  33252. * @param uniformName of the uniform to look up.
  33253. * @returns the location of the uniform.
  33254. */
  33255. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33256. /**
  33257. * Returns an array of sampler variable names
  33258. * @returns The array of sampler variable names.
  33259. */
  33260. getSamplers(): string[];
  33261. /**
  33262. * Returns an array of uniform variable names
  33263. * @returns The array of uniform variable names.
  33264. */
  33265. getUniformNames(): string[];
  33266. /**
  33267. * Returns an array of uniform buffer variable names
  33268. * @returns The array of uniform buffer variable names.
  33269. */
  33270. getUniformBuffersNames(): string[];
  33271. /**
  33272. * Returns the index parameters used to create the effect
  33273. * @returns The index parameters object
  33274. */
  33275. getIndexParameters(): any;
  33276. /**
  33277. * The error from the last compilation.
  33278. * @returns the error string.
  33279. */
  33280. getCompilationError(): string;
  33281. /**
  33282. * Gets a boolean indicating that all fallbacks were used during compilation
  33283. * @returns true if all fallbacks were used
  33284. */
  33285. allFallbacksProcessed(): boolean;
  33286. /**
  33287. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33288. * @param func The callback to be used.
  33289. */
  33290. executeWhenCompiled(func: (effect: Effect) => void): void;
  33291. private _checkIsReady;
  33292. private _loadShader;
  33293. /**
  33294. * Gets the vertex shader source code of this effect
  33295. */
  33296. get vertexSourceCode(): string;
  33297. /**
  33298. * Gets the fragment shader source code of this effect
  33299. */
  33300. get fragmentSourceCode(): string;
  33301. /**
  33302. * Recompiles the webGL program
  33303. * @param vertexSourceCode The source code for the vertex shader.
  33304. * @param fragmentSourceCode The source code for the fragment shader.
  33305. * @param onCompiled Callback called when completed.
  33306. * @param onError Callback called on error.
  33307. * @hidden
  33308. */
  33309. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33310. /**
  33311. * Prepares the effect
  33312. * @hidden
  33313. */
  33314. _prepareEffect(): void;
  33315. private _getShaderCodeAndErrorLine;
  33316. private _processCompilationErrors;
  33317. /**
  33318. * Checks if the effect is supported. (Must be called after compilation)
  33319. */
  33320. get isSupported(): boolean;
  33321. /**
  33322. * Binds a texture to the engine to be used as output of the shader.
  33323. * @param channel Name of the output variable.
  33324. * @param texture Texture to bind.
  33325. * @hidden
  33326. */
  33327. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33328. /**
  33329. * Sets a texture on the engine to be used in the shader.
  33330. * @param channel Name of the sampler variable.
  33331. * @param texture Texture to set.
  33332. */
  33333. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33334. /**
  33335. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33336. * @param channel Name of the sampler variable.
  33337. * @param texture Texture to set.
  33338. */
  33339. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33340. /**
  33341. * Sets an array of textures on the engine to be used in the shader.
  33342. * @param channel Name of the variable.
  33343. * @param textures Textures to set.
  33344. */
  33345. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33346. /**
  33347. * 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)
  33348. * @param channel Name of the sampler variable.
  33349. * @param postProcess Post process to get the input texture from.
  33350. */
  33351. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33352. /**
  33353. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33354. * 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)
  33355. * @param channel Name of the sampler variable.
  33356. * @param postProcess Post process to get the output texture from.
  33357. */
  33358. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33359. /** @hidden */
  33360. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33361. /** @hidden */
  33362. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33363. /** @hidden */
  33364. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33365. /** @hidden */
  33366. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33367. /**
  33368. * Binds a buffer to a uniform.
  33369. * @param buffer Buffer to bind.
  33370. * @param name Name of the uniform variable to bind to.
  33371. */
  33372. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33373. /**
  33374. * Binds block to a uniform.
  33375. * @param blockName Name of the block to bind.
  33376. * @param index Index to bind.
  33377. */
  33378. bindUniformBlock(blockName: string, index: number): void;
  33379. /**
  33380. * Sets an interger value on a uniform variable.
  33381. * @param uniformName Name of the variable.
  33382. * @param value Value to be set.
  33383. * @returns this effect.
  33384. */
  33385. setInt(uniformName: string, value: number): Effect;
  33386. /**
  33387. * Sets an int array on a uniform variable.
  33388. * @param uniformName Name of the variable.
  33389. * @param array array to be set.
  33390. * @returns this effect.
  33391. */
  33392. setIntArray(uniformName: string, array: Int32Array): Effect;
  33393. /**
  33394. * 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)
  33395. * @param uniformName Name of the variable.
  33396. * @param array array to be set.
  33397. * @returns this effect.
  33398. */
  33399. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33400. /**
  33401. * 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)
  33402. * @param uniformName Name of the variable.
  33403. * @param array array to be set.
  33404. * @returns this effect.
  33405. */
  33406. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33407. /**
  33408. * 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)
  33409. * @param uniformName Name of the variable.
  33410. * @param array array to be set.
  33411. * @returns this effect.
  33412. */
  33413. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33414. /**
  33415. * Sets an float array on a uniform variable.
  33416. * @param uniformName Name of the variable.
  33417. * @param array array to be set.
  33418. * @returns this effect.
  33419. */
  33420. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33421. /**
  33422. * 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)
  33423. * @param uniformName Name of the variable.
  33424. * @param array array to be set.
  33425. * @returns this effect.
  33426. */
  33427. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33428. /**
  33429. * 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)
  33430. * @param uniformName Name of the variable.
  33431. * @param array array to be set.
  33432. * @returns this effect.
  33433. */
  33434. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33435. /**
  33436. * 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)
  33437. * @param uniformName Name of the variable.
  33438. * @param array array to be set.
  33439. * @returns this effect.
  33440. */
  33441. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33442. /**
  33443. * Sets an array on a uniform variable.
  33444. * @param uniformName Name of the variable.
  33445. * @param array array to be set.
  33446. * @returns this effect.
  33447. */
  33448. setArray(uniformName: string, array: number[]): Effect;
  33449. /**
  33450. * 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)
  33451. * @param uniformName Name of the variable.
  33452. * @param array array to be set.
  33453. * @returns this effect.
  33454. */
  33455. setArray2(uniformName: string, array: number[]): Effect;
  33456. /**
  33457. * 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)
  33458. * @param uniformName Name of the variable.
  33459. * @param array array to be set.
  33460. * @returns this effect.
  33461. */
  33462. setArray3(uniformName: string, array: number[]): Effect;
  33463. /**
  33464. * 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)
  33465. * @param uniformName Name of the variable.
  33466. * @param array array to be set.
  33467. * @returns this effect.
  33468. */
  33469. setArray4(uniformName: string, array: number[]): Effect;
  33470. /**
  33471. * Sets matrices on a uniform variable.
  33472. * @param uniformName Name of the variable.
  33473. * @param matrices matrices to be set.
  33474. * @returns this effect.
  33475. */
  33476. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33477. /**
  33478. * Sets matrix on a uniform variable.
  33479. * @param uniformName Name of the variable.
  33480. * @param matrix matrix to be set.
  33481. * @returns this effect.
  33482. */
  33483. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33484. /**
  33485. * 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)
  33486. * @param uniformName Name of the variable.
  33487. * @param matrix matrix to be set.
  33488. * @returns this effect.
  33489. */
  33490. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33491. /**
  33492. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33493. * @param uniformName Name of the variable.
  33494. * @param matrix matrix to be set.
  33495. * @returns this effect.
  33496. */
  33497. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33498. /**
  33499. * Sets a float on a uniform variable.
  33500. * @param uniformName Name of the variable.
  33501. * @param value value to be set.
  33502. * @returns this effect.
  33503. */
  33504. setFloat(uniformName: string, value: number): Effect;
  33505. /**
  33506. * Sets a boolean on a uniform variable.
  33507. * @param uniformName Name of the variable.
  33508. * @param bool value to be set.
  33509. * @returns this effect.
  33510. */
  33511. setBool(uniformName: string, bool: boolean): Effect;
  33512. /**
  33513. * Sets a Vector2 on a uniform variable.
  33514. * @param uniformName Name of the variable.
  33515. * @param vector2 vector2 to be set.
  33516. * @returns this effect.
  33517. */
  33518. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33519. /**
  33520. * Sets a float2 on a uniform variable.
  33521. * @param uniformName Name of the variable.
  33522. * @param x First float in float2.
  33523. * @param y Second float in float2.
  33524. * @returns this effect.
  33525. */
  33526. setFloat2(uniformName: string, x: number, y: number): Effect;
  33527. /**
  33528. * Sets a Vector3 on a uniform variable.
  33529. * @param uniformName Name of the variable.
  33530. * @param vector3 Value to be set.
  33531. * @returns this effect.
  33532. */
  33533. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33534. /**
  33535. * Sets a float3 on a uniform variable.
  33536. * @param uniformName Name of the variable.
  33537. * @param x First float in float3.
  33538. * @param y Second float in float3.
  33539. * @param z Third float in float3.
  33540. * @returns this effect.
  33541. */
  33542. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33543. /**
  33544. * Sets a Vector4 on a uniform variable.
  33545. * @param uniformName Name of the variable.
  33546. * @param vector4 Value to be set.
  33547. * @returns this effect.
  33548. */
  33549. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33550. /**
  33551. * Sets a float4 on a uniform variable.
  33552. * @param uniformName Name of the variable.
  33553. * @param x First float in float4.
  33554. * @param y Second float in float4.
  33555. * @param z Third float in float4.
  33556. * @param w Fourth float in float4.
  33557. * @returns this effect.
  33558. */
  33559. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33560. /**
  33561. * Sets a Color3 on a uniform variable.
  33562. * @param uniformName Name of the variable.
  33563. * @param color3 Value to be set.
  33564. * @returns this effect.
  33565. */
  33566. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33567. /**
  33568. * Sets a Color4 on a uniform variable.
  33569. * @param uniformName Name of the variable.
  33570. * @param color3 Value to be set.
  33571. * @param alpha Alpha value to be set.
  33572. * @returns this effect.
  33573. */
  33574. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33575. /**
  33576. * Sets a Color4 on a uniform variable
  33577. * @param uniformName defines the name of the variable
  33578. * @param color4 defines the value to be set
  33579. * @returns this effect.
  33580. */
  33581. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33582. /** Release all associated resources */
  33583. dispose(): void;
  33584. /**
  33585. * This function will add a new shader to the shader store
  33586. * @param name the name of the shader
  33587. * @param pixelShader optional pixel shader content
  33588. * @param vertexShader optional vertex shader content
  33589. */
  33590. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33591. /**
  33592. * Store of each shader (The can be looked up using effect.key)
  33593. */
  33594. static ShadersStore: {
  33595. [key: string]: string;
  33596. };
  33597. /**
  33598. * Store of each included file for a shader (The can be looked up using effect.key)
  33599. */
  33600. static IncludesShadersStore: {
  33601. [key: string]: string;
  33602. };
  33603. /**
  33604. * Resets the cache of effects.
  33605. */
  33606. static ResetCache(): void;
  33607. }
  33608. }
  33609. declare module BABYLON {
  33610. /**
  33611. * Interface used to describe the capabilities of the engine relatively to the current browser
  33612. */
  33613. export interface EngineCapabilities {
  33614. /** Maximum textures units per fragment shader */
  33615. maxTexturesImageUnits: number;
  33616. /** Maximum texture units per vertex shader */
  33617. maxVertexTextureImageUnits: number;
  33618. /** Maximum textures units in the entire pipeline */
  33619. maxCombinedTexturesImageUnits: number;
  33620. /** Maximum texture size */
  33621. maxTextureSize: number;
  33622. /** Maximum texture samples */
  33623. maxSamples?: number;
  33624. /** Maximum cube texture size */
  33625. maxCubemapTextureSize: number;
  33626. /** Maximum render texture size */
  33627. maxRenderTextureSize: number;
  33628. /** Maximum number of vertex attributes */
  33629. maxVertexAttribs: number;
  33630. /** Maximum number of varyings */
  33631. maxVaryingVectors: number;
  33632. /** Maximum number of uniforms per vertex shader */
  33633. maxVertexUniformVectors: number;
  33634. /** Maximum number of uniforms per fragment shader */
  33635. maxFragmentUniformVectors: number;
  33636. /** Defines if standard derivates (dx/dy) are supported */
  33637. standardDerivatives: boolean;
  33638. /** Defines if s3tc texture compression is supported */
  33639. s3tc?: WEBGL_compressed_texture_s3tc;
  33640. /** Defines if pvrtc texture compression is supported */
  33641. pvrtc: any;
  33642. /** Defines if etc1 texture compression is supported */
  33643. etc1: any;
  33644. /** Defines if etc2 texture compression is supported */
  33645. etc2: any;
  33646. /** Defines if astc texture compression is supported */
  33647. astc: any;
  33648. /** Defines if float textures are supported */
  33649. textureFloat: boolean;
  33650. /** Defines if vertex array objects are supported */
  33651. vertexArrayObject: boolean;
  33652. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33653. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33654. /** Gets the maximum level of anisotropy supported */
  33655. maxAnisotropy: number;
  33656. /** Defines if instancing is supported */
  33657. instancedArrays: boolean;
  33658. /** Defines if 32 bits indices are supported */
  33659. uintIndices: boolean;
  33660. /** Defines if high precision shaders are supported */
  33661. highPrecisionShaderSupported: boolean;
  33662. /** Defines if depth reading in the fragment shader is supported */
  33663. fragmentDepthSupported: boolean;
  33664. /** Defines if float texture linear filtering is supported*/
  33665. textureFloatLinearFiltering: boolean;
  33666. /** Defines if rendering to float textures is supported */
  33667. textureFloatRender: boolean;
  33668. /** Defines if half float textures are supported*/
  33669. textureHalfFloat: boolean;
  33670. /** Defines if half float texture linear filtering is supported*/
  33671. textureHalfFloatLinearFiltering: boolean;
  33672. /** Defines if rendering to half float textures is supported */
  33673. textureHalfFloatRender: boolean;
  33674. /** Defines if textureLOD shader command is supported */
  33675. textureLOD: boolean;
  33676. /** Defines if draw buffers extension is supported */
  33677. drawBuffersExtension: boolean;
  33678. /** Defines if depth textures are supported */
  33679. depthTextureExtension: boolean;
  33680. /** Defines if float color buffer are supported */
  33681. colorBufferFloat: boolean;
  33682. /** Gets disjoint timer query extension (null if not supported) */
  33683. timerQuery?: EXT_disjoint_timer_query;
  33684. /** Defines if timestamp can be used with timer query */
  33685. canUseTimestampForTimerQuery: boolean;
  33686. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33687. multiview?: any;
  33688. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33689. oculusMultiview?: any;
  33690. /** Function used to let the system compiles shaders in background */
  33691. parallelShaderCompile?: {
  33692. COMPLETION_STATUS_KHR: number;
  33693. };
  33694. /** Max number of texture samples for MSAA */
  33695. maxMSAASamples: number;
  33696. /** Defines if the blend min max extension is supported */
  33697. blendMinMax: boolean;
  33698. }
  33699. }
  33700. declare module BABYLON {
  33701. /**
  33702. * @hidden
  33703. **/
  33704. export class DepthCullingState {
  33705. private _isDepthTestDirty;
  33706. private _isDepthMaskDirty;
  33707. private _isDepthFuncDirty;
  33708. private _isCullFaceDirty;
  33709. private _isCullDirty;
  33710. private _isZOffsetDirty;
  33711. private _isFrontFaceDirty;
  33712. private _depthTest;
  33713. private _depthMask;
  33714. private _depthFunc;
  33715. private _cull;
  33716. private _cullFace;
  33717. private _zOffset;
  33718. private _frontFace;
  33719. /**
  33720. * Initializes the state.
  33721. */
  33722. constructor();
  33723. get isDirty(): boolean;
  33724. get zOffset(): number;
  33725. set zOffset(value: number);
  33726. get cullFace(): Nullable<number>;
  33727. set cullFace(value: Nullable<number>);
  33728. get cull(): Nullable<boolean>;
  33729. set cull(value: Nullable<boolean>);
  33730. get depthFunc(): Nullable<number>;
  33731. set depthFunc(value: Nullable<number>);
  33732. get depthMask(): boolean;
  33733. set depthMask(value: boolean);
  33734. get depthTest(): boolean;
  33735. set depthTest(value: boolean);
  33736. get frontFace(): Nullable<number>;
  33737. set frontFace(value: Nullable<number>);
  33738. reset(): void;
  33739. apply(gl: WebGLRenderingContext): void;
  33740. }
  33741. }
  33742. declare module BABYLON {
  33743. /**
  33744. * @hidden
  33745. **/
  33746. export class StencilState {
  33747. /** 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 */
  33748. static readonly ALWAYS: number;
  33749. /** Passed to stencilOperation to specify that stencil value must be kept */
  33750. static readonly KEEP: number;
  33751. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33752. static readonly REPLACE: number;
  33753. private _isStencilTestDirty;
  33754. private _isStencilMaskDirty;
  33755. private _isStencilFuncDirty;
  33756. private _isStencilOpDirty;
  33757. private _stencilTest;
  33758. private _stencilMask;
  33759. private _stencilFunc;
  33760. private _stencilFuncRef;
  33761. private _stencilFuncMask;
  33762. private _stencilOpStencilFail;
  33763. private _stencilOpDepthFail;
  33764. private _stencilOpStencilDepthPass;
  33765. get isDirty(): boolean;
  33766. get stencilFunc(): number;
  33767. set stencilFunc(value: number);
  33768. get stencilFuncRef(): number;
  33769. set stencilFuncRef(value: number);
  33770. get stencilFuncMask(): number;
  33771. set stencilFuncMask(value: number);
  33772. get stencilOpStencilFail(): number;
  33773. set stencilOpStencilFail(value: number);
  33774. get stencilOpDepthFail(): number;
  33775. set stencilOpDepthFail(value: number);
  33776. get stencilOpStencilDepthPass(): number;
  33777. set stencilOpStencilDepthPass(value: number);
  33778. get stencilMask(): number;
  33779. set stencilMask(value: number);
  33780. get stencilTest(): boolean;
  33781. set stencilTest(value: boolean);
  33782. constructor();
  33783. reset(): void;
  33784. apply(gl: WebGLRenderingContext): void;
  33785. }
  33786. }
  33787. declare module BABYLON {
  33788. /**
  33789. * @hidden
  33790. **/
  33791. export class AlphaState {
  33792. private _isAlphaBlendDirty;
  33793. private _isBlendFunctionParametersDirty;
  33794. private _isBlendEquationParametersDirty;
  33795. private _isBlendConstantsDirty;
  33796. private _alphaBlend;
  33797. private _blendFunctionParameters;
  33798. private _blendEquationParameters;
  33799. private _blendConstants;
  33800. /**
  33801. * Initializes the state.
  33802. */
  33803. constructor();
  33804. get isDirty(): boolean;
  33805. get alphaBlend(): boolean;
  33806. set alphaBlend(value: boolean);
  33807. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33808. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33809. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33810. reset(): void;
  33811. apply(gl: WebGLRenderingContext): void;
  33812. }
  33813. }
  33814. declare module BABYLON {
  33815. /** @hidden */
  33816. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33817. attributeProcessor(attribute: string): string;
  33818. varyingProcessor(varying: string, isFragment: boolean): string;
  33819. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33820. }
  33821. }
  33822. declare module BABYLON {
  33823. /**
  33824. * Interface for attribute information associated with buffer instanciation
  33825. */
  33826. export interface InstancingAttributeInfo {
  33827. /**
  33828. * Name of the GLSL attribute
  33829. * if attribute index is not specified, this is used to retrieve the index from the effect
  33830. */
  33831. attributeName: string;
  33832. /**
  33833. * Index/offset of the attribute in the vertex shader
  33834. * if not specified, this will be computes from the name.
  33835. */
  33836. index?: number;
  33837. /**
  33838. * size of the attribute, 1, 2, 3 or 4
  33839. */
  33840. attributeSize: number;
  33841. /**
  33842. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33843. */
  33844. offset: number;
  33845. /**
  33846. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33847. * default to 1
  33848. */
  33849. divisor?: number;
  33850. /**
  33851. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33852. * default is FLOAT
  33853. */
  33854. attributeType?: number;
  33855. /**
  33856. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33857. */
  33858. normalized?: boolean;
  33859. }
  33860. }
  33861. declare module BABYLON {
  33862. interface ThinEngine {
  33863. /**
  33864. * Update a video texture
  33865. * @param texture defines the texture to update
  33866. * @param video defines the video element to use
  33867. * @param invertY defines if data must be stored with Y axis inverted
  33868. */
  33869. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33870. }
  33871. }
  33872. declare module BABYLON {
  33873. /**
  33874. * Settings for finer control over video usage
  33875. */
  33876. export interface VideoTextureSettings {
  33877. /**
  33878. * Applies `autoplay` to video, if specified
  33879. */
  33880. autoPlay?: boolean;
  33881. /**
  33882. * Applies `loop` to video, if specified
  33883. */
  33884. loop?: boolean;
  33885. /**
  33886. * Automatically updates internal texture from video at every frame in the render loop
  33887. */
  33888. autoUpdateTexture: boolean;
  33889. /**
  33890. * Image src displayed during the video loading or until the user interacts with the video.
  33891. */
  33892. poster?: string;
  33893. }
  33894. /**
  33895. * If you want to display a video in your scene, this is the special texture for that.
  33896. * This special texture works similar to other textures, with the exception of a few parameters.
  33897. * @see https://doc.babylonjs.com/how_to/video_texture
  33898. */
  33899. export class VideoTexture extends Texture {
  33900. /**
  33901. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33902. */
  33903. readonly autoUpdateTexture: boolean;
  33904. /**
  33905. * The video instance used by the texture internally
  33906. */
  33907. readonly video: HTMLVideoElement;
  33908. private _onUserActionRequestedObservable;
  33909. /**
  33910. * Event triggerd when a dom action is required by the user to play the video.
  33911. * This happens due to recent changes in browser policies preventing video to auto start.
  33912. */
  33913. get onUserActionRequestedObservable(): Observable<Texture>;
  33914. private _generateMipMaps;
  33915. private _stillImageCaptured;
  33916. private _displayingPosterTexture;
  33917. private _settings;
  33918. private _createInternalTextureOnEvent;
  33919. private _frameId;
  33920. private _currentSrc;
  33921. /**
  33922. * Creates a video texture.
  33923. * If you want to display a video in your scene, this is the special texture for that.
  33924. * This special texture works similar to other textures, with the exception of a few parameters.
  33925. * @see https://doc.babylonjs.com/how_to/video_texture
  33926. * @param name optional name, will detect from video source, if not defined
  33927. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33928. * @param scene is obviously the current scene.
  33929. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33930. * @param invertY is false by default but can be used to invert video on Y axis
  33931. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33932. * @param settings allows finer control over video usage
  33933. */
  33934. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33935. private _getName;
  33936. private _getVideo;
  33937. private _createInternalTexture;
  33938. private reset;
  33939. /**
  33940. * @hidden Internal method to initiate `update`.
  33941. */
  33942. _rebuild(): void;
  33943. /**
  33944. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33945. */
  33946. update(): void;
  33947. /**
  33948. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33949. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33950. */
  33951. updateTexture(isVisible: boolean): void;
  33952. protected _updateInternalTexture: () => void;
  33953. /**
  33954. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33955. * @param url New url.
  33956. */
  33957. updateURL(url: string): void;
  33958. /**
  33959. * Clones the texture.
  33960. * @returns the cloned texture
  33961. */
  33962. clone(): VideoTexture;
  33963. /**
  33964. * Dispose the texture and release its associated resources.
  33965. */
  33966. dispose(): void;
  33967. /**
  33968. * Creates a video texture straight from a stream.
  33969. * @param scene Define the scene the texture should be created in
  33970. * @param stream Define the stream the texture should be created from
  33971. * @returns The created video texture as a promise
  33972. */
  33973. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33974. /**
  33975. * Creates a video texture straight from your WebCam video feed.
  33976. * @param scene Define the scene the texture should be created in
  33977. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33978. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33979. * @returns The created video texture as a promise
  33980. */
  33981. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33982. minWidth: number;
  33983. maxWidth: number;
  33984. minHeight: number;
  33985. maxHeight: number;
  33986. deviceId: string;
  33987. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33988. /**
  33989. * Creates a video texture straight from your WebCam video feed.
  33990. * @param scene Define the scene the texture should be created in
  33991. * @param onReady Define a callback to triggered once the texture will be ready
  33992. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33993. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33994. */
  33995. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33996. minWidth: number;
  33997. maxWidth: number;
  33998. minHeight: number;
  33999. maxHeight: number;
  34000. deviceId: string;
  34001. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34002. }
  34003. }
  34004. declare module BABYLON {
  34005. /**
  34006. * Defines the interface used by objects working like Scene
  34007. * @hidden
  34008. */
  34009. export interface ISceneLike {
  34010. _addPendingData(data: any): void;
  34011. _removePendingData(data: any): void;
  34012. offlineProvider: IOfflineProvider;
  34013. }
  34014. /** Interface defining initialization parameters for Engine class */
  34015. export interface EngineOptions extends WebGLContextAttributes {
  34016. /**
  34017. * Defines if the engine should no exceed a specified device ratio
  34018. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34019. */
  34020. limitDeviceRatio?: number;
  34021. /**
  34022. * Defines if webvr should be enabled automatically
  34023. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34024. */
  34025. autoEnableWebVR?: boolean;
  34026. /**
  34027. * Defines if webgl2 should be turned off even if supported
  34028. * @see http://doc.babylonjs.com/features/webgl2
  34029. */
  34030. disableWebGL2Support?: boolean;
  34031. /**
  34032. * Defines if webaudio should be initialized as well
  34033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34034. */
  34035. audioEngine?: boolean;
  34036. /**
  34037. * Defines if animations should run using a deterministic lock step
  34038. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34039. */
  34040. deterministicLockstep?: boolean;
  34041. /** Defines the maximum steps to use with deterministic lock step mode */
  34042. lockstepMaxSteps?: number;
  34043. /** Defines the seconds between each deterministic lock step */
  34044. timeStep?: number;
  34045. /**
  34046. * Defines that engine should ignore context lost events
  34047. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34048. */
  34049. doNotHandleContextLost?: boolean;
  34050. /**
  34051. * Defines that engine should ignore modifying touch action attribute and style
  34052. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34053. */
  34054. doNotHandleTouchAction?: boolean;
  34055. /**
  34056. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34057. */
  34058. useHighPrecisionFloats?: boolean;
  34059. }
  34060. /**
  34061. * The base engine class (root of all engines)
  34062. */
  34063. export class ThinEngine {
  34064. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34065. static ExceptionList: ({
  34066. key: string;
  34067. capture: string;
  34068. captureConstraint: number;
  34069. targets: string[];
  34070. } | {
  34071. key: string;
  34072. capture: null;
  34073. captureConstraint: null;
  34074. targets: string[];
  34075. })[];
  34076. /** @hidden */
  34077. static _TextureLoaders: IInternalTextureLoader[];
  34078. /**
  34079. * Returns the current npm package of the sdk
  34080. */
  34081. static get NpmPackage(): string;
  34082. /**
  34083. * Returns the current version of the framework
  34084. */
  34085. static get Version(): string;
  34086. /**
  34087. * Returns a string describing the current engine
  34088. */
  34089. get description(): string;
  34090. /**
  34091. * Gets or sets the epsilon value used by collision engine
  34092. */
  34093. static CollisionsEpsilon: number;
  34094. /**
  34095. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34096. */
  34097. static get ShadersRepository(): string;
  34098. static set ShadersRepository(value: string);
  34099. /** @hidden */
  34100. _shaderProcessor: IShaderProcessor;
  34101. /**
  34102. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34103. */
  34104. forcePOTTextures: boolean;
  34105. /**
  34106. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34107. */
  34108. isFullscreen: boolean;
  34109. /**
  34110. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34111. */
  34112. cullBackFaces: boolean;
  34113. /**
  34114. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34115. */
  34116. renderEvenInBackground: boolean;
  34117. /**
  34118. * Gets or sets a boolean indicating that cache can be kept between frames
  34119. */
  34120. preventCacheWipeBetweenFrames: boolean;
  34121. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34122. validateShaderPrograms: boolean;
  34123. /**
  34124. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34125. * This can provide greater z depth for distant objects.
  34126. */
  34127. useReverseDepthBuffer: boolean;
  34128. /**
  34129. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34130. */
  34131. disableUniformBuffers: boolean;
  34132. /** @hidden */
  34133. _uniformBuffers: UniformBuffer[];
  34134. /**
  34135. * Gets a boolean indicating that the engine supports uniform buffers
  34136. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34137. */
  34138. get supportsUniformBuffers(): boolean;
  34139. /** @hidden */
  34140. _gl: WebGLRenderingContext;
  34141. /** @hidden */
  34142. _webGLVersion: number;
  34143. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34144. protected _windowIsBackground: boolean;
  34145. protected _creationOptions: EngineOptions;
  34146. protected _highPrecisionShadersAllowed: boolean;
  34147. /** @hidden */
  34148. get _shouldUseHighPrecisionShader(): boolean;
  34149. /**
  34150. * Gets a boolean indicating that only power of 2 textures are supported
  34151. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34152. */
  34153. get needPOTTextures(): boolean;
  34154. /** @hidden */
  34155. _badOS: boolean;
  34156. /** @hidden */
  34157. _badDesktopOS: boolean;
  34158. private _hardwareScalingLevel;
  34159. /** @hidden */
  34160. _caps: EngineCapabilities;
  34161. private _isStencilEnable;
  34162. private _glVersion;
  34163. private _glRenderer;
  34164. private _glVendor;
  34165. /** @hidden */
  34166. _videoTextureSupported: boolean;
  34167. protected _renderingQueueLaunched: boolean;
  34168. protected _activeRenderLoops: (() => void)[];
  34169. /**
  34170. * Observable signaled when a context lost event is raised
  34171. */
  34172. onContextLostObservable: Observable<ThinEngine>;
  34173. /**
  34174. * Observable signaled when a context restored event is raised
  34175. */
  34176. onContextRestoredObservable: Observable<ThinEngine>;
  34177. private _onContextLost;
  34178. private _onContextRestored;
  34179. protected _contextWasLost: boolean;
  34180. /** @hidden */
  34181. _doNotHandleContextLost: boolean;
  34182. /**
  34183. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34185. */
  34186. get doNotHandleContextLost(): boolean;
  34187. set doNotHandleContextLost(value: boolean);
  34188. /**
  34189. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34190. */
  34191. disableVertexArrayObjects: boolean;
  34192. /** @hidden */
  34193. protected _colorWrite: boolean;
  34194. /** @hidden */
  34195. protected _colorWriteChanged: boolean;
  34196. /** @hidden */
  34197. protected _depthCullingState: DepthCullingState;
  34198. /** @hidden */
  34199. protected _stencilState: StencilState;
  34200. /** @hidden */
  34201. _alphaState: AlphaState;
  34202. /** @hidden */
  34203. _alphaMode: number;
  34204. /** @hidden */
  34205. _alphaEquation: number;
  34206. /** @hidden */
  34207. _internalTexturesCache: InternalTexture[];
  34208. /** @hidden */
  34209. protected _activeChannel: number;
  34210. private _currentTextureChannel;
  34211. /** @hidden */
  34212. protected _boundTexturesCache: {
  34213. [key: string]: Nullable<InternalTexture>;
  34214. };
  34215. /** @hidden */
  34216. protected _currentEffect: Nullable<Effect>;
  34217. /** @hidden */
  34218. protected _currentProgram: Nullable<WebGLProgram>;
  34219. private _compiledEffects;
  34220. private _vertexAttribArraysEnabled;
  34221. /** @hidden */
  34222. protected _cachedViewport: Nullable<IViewportLike>;
  34223. private _cachedVertexArrayObject;
  34224. /** @hidden */
  34225. protected _cachedVertexBuffers: any;
  34226. /** @hidden */
  34227. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34228. /** @hidden */
  34229. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34230. /** @hidden */
  34231. _currentRenderTarget: Nullable<InternalTexture>;
  34232. private _uintIndicesCurrentlySet;
  34233. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34234. /** @hidden */
  34235. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34236. /** @hidden */
  34237. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34238. private _currentBufferPointers;
  34239. private _currentInstanceLocations;
  34240. private _currentInstanceBuffers;
  34241. private _textureUnits;
  34242. /** @hidden */
  34243. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34244. /** @hidden */
  34245. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34246. /** @hidden */
  34247. _boundRenderFunction: any;
  34248. private _vaoRecordInProgress;
  34249. private _mustWipeVertexAttributes;
  34250. private _emptyTexture;
  34251. private _emptyCubeTexture;
  34252. private _emptyTexture3D;
  34253. private _emptyTexture2DArray;
  34254. /** @hidden */
  34255. _frameHandler: number;
  34256. private _nextFreeTextureSlots;
  34257. private _maxSimultaneousTextures;
  34258. private _activeRequests;
  34259. /** @hidden */
  34260. _transformTextureUrl: Nullable<(url: string) => string>;
  34261. protected get _supportsHardwareTextureRescaling(): boolean;
  34262. private _framebufferDimensionsObject;
  34263. /**
  34264. * sets the object from which width and height will be taken from when getting render width and height
  34265. * Will fallback to the gl object
  34266. * @param dimensions the framebuffer width and height that will be used.
  34267. */
  34268. set framebufferDimensionsObject(dimensions: Nullable<{
  34269. framebufferWidth: number;
  34270. framebufferHeight: number;
  34271. }>);
  34272. /**
  34273. * Gets the current viewport
  34274. */
  34275. get currentViewport(): Nullable<IViewportLike>;
  34276. /**
  34277. * Gets the default empty texture
  34278. */
  34279. get emptyTexture(): InternalTexture;
  34280. /**
  34281. * Gets the default empty 3D texture
  34282. */
  34283. get emptyTexture3D(): InternalTexture;
  34284. /**
  34285. * Gets the default empty 2D array texture
  34286. */
  34287. get emptyTexture2DArray(): InternalTexture;
  34288. /**
  34289. * Gets the default empty cube texture
  34290. */
  34291. get emptyCubeTexture(): InternalTexture;
  34292. /**
  34293. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34294. */
  34295. readonly premultipliedAlpha: boolean;
  34296. /**
  34297. * Observable event triggered before each texture is initialized
  34298. */
  34299. onBeforeTextureInitObservable: Observable<Texture>;
  34300. /**
  34301. * Creates a new engine
  34302. * @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
  34303. * @param antialias defines enable antialiasing (default: false)
  34304. * @param options defines further options to be sent to the getContext() function
  34305. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34306. */
  34307. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34308. private _rebuildInternalTextures;
  34309. private _rebuildEffects;
  34310. /**
  34311. * Gets a boolean indicating if all created effects are ready
  34312. * @returns true if all effects are ready
  34313. */
  34314. areAllEffectsReady(): boolean;
  34315. protected _rebuildBuffers(): void;
  34316. protected _initGLContext(): void;
  34317. /**
  34318. * Gets version of the current webGL context
  34319. */
  34320. get webGLVersion(): number;
  34321. /**
  34322. * Gets a string idenfifying the name of the class
  34323. * @returns "Engine" string
  34324. */
  34325. getClassName(): string;
  34326. /**
  34327. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34328. */
  34329. get isStencilEnable(): boolean;
  34330. /** @hidden */
  34331. _prepareWorkingCanvas(): void;
  34332. /**
  34333. * Reset the texture cache to empty state
  34334. */
  34335. resetTextureCache(): void;
  34336. /**
  34337. * Gets an object containing information about the current webGL context
  34338. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34339. */
  34340. getGlInfo(): {
  34341. vendor: string;
  34342. renderer: string;
  34343. version: string;
  34344. };
  34345. /**
  34346. * Defines the hardware scaling level.
  34347. * By default the hardware scaling level is computed from the window device ratio.
  34348. * 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.
  34349. * @param level defines the level to use
  34350. */
  34351. setHardwareScalingLevel(level: number): void;
  34352. /**
  34353. * Gets the current hardware scaling level.
  34354. * By default the hardware scaling level is computed from the window device ratio.
  34355. * 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.
  34356. * @returns a number indicating the current hardware scaling level
  34357. */
  34358. getHardwareScalingLevel(): number;
  34359. /**
  34360. * Gets the list of loaded textures
  34361. * @returns an array containing all loaded textures
  34362. */
  34363. getLoadedTexturesCache(): InternalTexture[];
  34364. /**
  34365. * Gets the object containing all engine capabilities
  34366. * @returns the EngineCapabilities object
  34367. */
  34368. getCaps(): EngineCapabilities;
  34369. /**
  34370. * stop executing a render loop function and remove it from the execution array
  34371. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34372. */
  34373. stopRenderLoop(renderFunction?: () => void): void;
  34374. /** @hidden */
  34375. _renderLoop(): void;
  34376. /**
  34377. * Gets the HTML canvas attached with the current webGL context
  34378. * @returns a HTML canvas
  34379. */
  34380. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34381. /**
  34382. * Gets host window
  34383. * @returns the host window object
  34384. */
  34385. getHostWindow(): Nullable<Window>;
  34386. /**
  34387. * Gets the current render width
  34388. * @param useScreen defines if screen size must be used (or the current render target if any)
  34389. * @returns a number defining the current render width
  34390. */
  34391. getRenderWidth(useScreen?: boolean): number;
  34392. /**
  34393. * Gets the current render height
  34394. * @param useScreen defines if screen size must be used (or the current render target if any)
  34395. * @returns a number defining the current render height
  34396. */
  34397. getRenderHeight(useScreen?: boolean): number;
  34398. /**
  34399. * Can be used to override the current requestAnimationFrame requester.
  34400. * @hidden
  34401. */
  34402. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34403. /**
  34404. * Register and execute a render loop. The engine can have more than one render function
  34405. * @param renderFunction defines the function to continuously execute
  34406. */
  34407. runRenderLoop(renderFunction: () => void): void;
  34408. /**
  34409. * Clear the current render buffer or the current render target (if any is set up)
  34410. * @param color defines the color to use
  34411. * @param backBuffer defines if the back buffer must be cleared
  34412. * @param depth defines if the depth buffer must be cleared
  34413. * @param stencil defines if the stencil buffer must be cleared
  34414. */
  34415. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34416. private _viewportCached;
  34417. /** @hidden */
  34418. _viewport(x: number, y: number, width: number, height: number): void;
  34419. /**
  34420. * Set the WebGL's viewport
  34421. * @param viewport defines the viewport element to be used
  34422. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34423. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34424. */
  34425. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34426. /**
  34427. * Begin a new frame
  34428. */
  34429. beginFrame(): void;
  34430. /**
  34431. * Enf the current frame
  34432. */
  34433. endFrame(): void;
  34434. /**
  34435. * Resize the view according to the canvas' size
  34436. */
  34437. resize(): void;
  34438. /**
  34439. * Force a specific size of the canvas
  34440. * @param width defines the new canvas' width
  34441. * @param height defines the new canvas' height
  34442. */
  34443. setSize(width: number, height: number): void;
  34444. /**
  34445. * Binds the frame buffer to the specified texture.
  34446. * @param texture The texture to render to or null for the default canvas
  34447. * @param faceIndex The face of the texture to render to in case of cube texture
  34448. * @param requiredWidth The width of the target to render to
  34449. * @param requiredHeight The height of the target to render to
  34450. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34451. * @param lodLevel defines the lod level to bind to the frame buffer
  34452. * @param layer defines the 2d array index to bind to frame buffer to
  34453. */
  34454. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34455. /** @hidden */
  34456. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34457. /**
  34458. * Unbind the current render target texture from the webGL context
  34459. * @param texture defines the render target texture to unbind
  34460. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34461. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34462. */
  34463. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34464. /**
  34465. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34466. */
  34467. flushFramebuffer(): void;
  34468. /**
  34469. * Unbind the current render target and bind the default framebuffer
  34470. */
  34471. restoreDefaultFramebuffer(): void;
  34472. /** @hidden */
  34473. protected _resetVertexBufferBinding(): void;
  34474. /**
  34475. * Creates a vertex buffer
  34476. * @param data the data for the vertex buffer
  34477. * @returns the new WebGL static buffer
  34478. */
  34479. createVertexBuffer(data: DataArray): DataBuffer;
  34480. private _createVertexBuffer;
  34481. /**
  34482. * Creates a dynamic vertex buffer
  34483. * @param data the data for the dynamic vertex buffer
  34484. * @returns the new WebGL dynamic buffer
  34485. */
  34486. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34487. protected _resetIndexBufferBinding(): void;
  34488. /**
  34489. * Creates a new index buffer
  34490. * @param indices defines the content of the index buffer
  34491. * @param updatable defines if the index buffer must be updatable
  34492. * @returns a new webGL buffer
  34493. */
  34494. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34495. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34496. /**
  34497. * Bind a webGL buffer to the webGL context
  34498. * @param buffer defines the buffer to bind
  34499. */
  34500. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34501. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34502. private bindBuffer;
  34503. /**
  34504. * update the bound buffer with the given data
  34505. * @param data defines the data to update
  34506. */
  34507. updateArrayBuffer(data: Float32Array): void;
  34508. private _vertexAttribPointer;
  34509. /** @hidden */
  34510. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34511. private _bindVertexBuffersAttributes;
  34512. /**
  34513. * Records a vertex array object
  34514. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34515. * @param vertexBuffers defines the list of vertex buffers to store
  34516. * @param indexBuffer defines the index buffer to store
  34517. * @param effect defines the effect to store
  34518. * @returns the new vertex array object
  34519. */
  34520. recordVertexArrayObject(vertexBuffers: {
  34521. [key: string]: VertexBuffer;
  34522. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34523. /**
  34524. * Bind a specific vertex array object
  34525. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34526. * @param vertexArrayObject defines the vertex array object to bind
  34527. * @param indexBuffer defines the index buffer to bind
  34528. */
  34529. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34530. /**
  34531. * Bind webGl buffers directly to the webGL context
  34532. * @param vertexBuffer defines the vertex buffer to bind
  34533. * @param indexBuffer defines the index buffer to bind
  34534. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34535. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34536. * @param effect defines the effect associated with the vertex buffer
  34537. */
  34538. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34539. private _unbindVertexArrayObject;
  34540. /**
  34541. * Bind a list of vertex buffers to the webGL context
  34542. * @param vertexBuffers defines the list of vertex buffers to bind
  34543. * @param indexBuffer defines the index buffer to bind
  34544. * @param effect defines the effect associated with the vertex buffers
  34545. */
  34546. bindBuffers(vertexBuffers: {
  34547. [key: string]: Nullable<VertexBuffer>;
  34548. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34549. /**
  34550. * Unbind all instance attributes
  34551. */
  34552. unbindInstanceAttributes(): void;
  34553. /**
  34554. * Release and free the memory of a vertex array object
  34555. * @param vao defines the vertex array object to delete
  34556. */
  34557. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34558. /** @hidden */
  34559. _releaseBuffer(buffer: DataBuffer): boolean;
  34560. protected _deleteBuffer(buffer: DataBuffer): void;
  34561. /**
  34562. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34563. * @param instancesBuffer defines the webGL buffer to update and bind
  34564. * @param data defines the data to store in the buffer
  34565. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34566. */
  34567. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34568. /**
  34569. * Bind the content of a webGL buffer used with instantiation
  34570. * @param instancesBuffer defines the webGL buffer to bind
  34571. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34572. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34573. */
  34574. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34575. /**
  34576. * Disable the instance attribute corresponding to the name in parameter
  34577. * @param name defines the name of the attribute to disable
  34578. */
  34579. disableInstanceAttributeByName(name: string): void;
  34580. /**
  34581. * Disable the instance attribute corresponding to the location in parameter
  34582. * @param attributeLocation defines the attribute location of the attribute to disable
  34583. */
  34584. disableInstanceAttribute(attributeLocation: number): void;
  34585. /**
  34586. * Disable the attribute corresponding to the location in parameter
  34587. * @param attributeLocation defines the attribute location of the attribute to disable
  34588. */
  34589. disableAttributeByIndex(attributeLocation: number): void;
  34590. /**
  34591. * Send a draw order
  34592. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34593. * @param indexStart defines the starting index
  34594. * @param indexCount defines the number of index to draw
  34595. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34596. */
  34597. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34598. /**
  34599. * Draw a list of points
  34600. * @param verticesStart defines the index of first vertex to draw
  34601. * @param verticesCount defines the count of vertices to draw
  34602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34603. */
  34604. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34605. /**
  34606. * Draw a list of unindexed primitives
  34607. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34608. * @param verticesStart defines the index of first vertex to draw
  34609. * @param verticesCount defines the count of vertices to draw
  34610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34611. */
  34612. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34613. /**
  34614. * Draw a list of indexed primitives
  34615. * @param fillMode defines the primitive to use
  34616. * @param indexStart defines the starting index
  34617. * @param indexCount defines the number of index to draw
  34618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34619. */
  34620. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34621. /**
  34622. * Draw a list of unindexed primitives
  34623. * @param fillMode defines the primitive to use
  34624. * @param verticesStart defines the index of first vertex to draw
  34625. * @param verticesCount defines the count of vertices to draw
  34626. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34627. */
  34628. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34629. private _drawMode;
  34630. /** @hidden */
  34631. protected _reportDrawCall(): void;
  34632. /** @hidden */
  34633. _releaseEffect(effect: Effect): void;
  34634. /** @hidden */
  34635. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34636. /**
  34637. * Create a new effect (used to store vertex/fragment shaders)
  34638. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34639. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34640. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34641. * @param samplers defines an array of string used to represent textures
  34642. * @param defines defines the string containing the defines to use to compile the shaders
  34643. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34644. * @param onCompiled defines a function to call when the effect creation is successful
  34645. * @param onError defines a function to call when the effect creation has failed
  34646. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34647. * @returns the new Effect
  34648. */
  34649. 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;
  34650. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34651. private _compileShader;
  34652. private _compileRawShader;
  34653. /** @hidden */
  34654. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34655. /**
  34656. * Directly creates a webGL program
  34657. * @param pipelineContext defines the pipeline context to attach to
  34658. * @param vertexCode defines the vertex shader code to use
  34659. * @param fragmentCode defines the fragment shader code to use
  34660. * @param context defines the webGL context to use (if not set, the current one will be used)
  34661. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34662. * @returns the new webGL program
  34663. */
  34664. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34665. /**
  34666. * Creates a webGL program
  34667. * @param pipelineContext defines the pipeline context to attach to
  34668. * @param vertexCode defines the vertex shader code to use
  34669. * @param fragmentCode defines the fragment shader code to use
  34670. * @param defines defines the string containing the defines to use to compile the shaders
  34671. * @param context defines the webGL context to use (if not set, the current one will be used)
  34672. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34673. * @returns the new webGL program
  34674. */
  34675. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34676. /**
  34677. * Creates a new pipeline context
  34678. * @returns the new pipeline
  34679. */
  34680. createPipelineContext(): IPipelineContext;
  34681. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34682. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34683. /** @hidden */
  34684. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34685. /** @hidden */
  34686. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34687. /** @hidden */
  34688. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34689. /**
  34690. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34691. * @param pipelineContext defines the pipeline context to use
  34692. * @param uniformsNames defines the list of uniform names
  34693. * @returns an array of webGL uniform locations
  34694. */
  34695. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34696. /**
  34697. * Gets the lsit of active attributes for a given webGL program
  34698. * @param pipelineContext defines the pipeline context to use
  34699. * @param attributesNames defines the list of attribute names to get
  34700. * @returns an array of indices indicating the offset of each attribute
  34701. */
  34702. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34703. /**
  34704. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34705. * @param effect defines the effect to activate
  34706. */
  34707. enableEffect(effect: Nullable<Effect>): void;
  34708. /**
  34709. * Set the value of an uniform to a number (int)
  34710. * @param uniform defines the webGL uniform location where to store the value
  34711. * @param value defines the int number to store
  34712. */
  34713. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34714. /**
  34715. * Set the value of an uniform to an array of int32
  34716. * @param uniform defines the webGL uniform location where to store the value
  34717. * @param array defines the array of int32 to store
  34718. */
  34719. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34720. /**
  34721. * Set the value of an uniform to an array of int32 (stored as vec2)
  34722. * @param uniform defines the webGL uniform location where to store the value
  34723. * @param array defines the array of int32 to store
  34724. */
  34725. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34726. /**
  34727. * Set the value of an uniform to an array of int32 (stored as vec3)
  34728. * @param uniform defines the webGL uniform location where to store the value
  34729. * @param array defines the array of int32 to store
  34730. */
  34731. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34732. /**
  34733. * Set the value of an uniform to an array of int32 (stored as vec4)
  34734. * @param uniform defines the webGL uniform location where to store the value
  34735. * @param array defines the array of int32 to store
  34736. */
  34737. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34738. /**
  34739. * Set the value of an uniform to an array of number
  34740. * @param uniform defines the webGL uniform location where to store the value
  34741. * @param array defines the array of number to store
  34742. */
  34743. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34744. /**
  34745. * Set the value of an uniform to an array of number (stored as vec2)
  34746. * @param uniform defines the webGL uniform location where to store the value
  34747. * @param array defines the array of number to store
  34748. */
  34749. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34750. /**
  34751. * Set the value of an uniform to an array of number (stored as vec3)
  34752. * @param uniform defines the webGL uniform location where to store the value
  34753. * @param array defines the array of number to store
  34754. */
  34755. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34756. /**
  34757. * Set the value of an uniform to an array of number (stored as vec4)
  34758. * @param uniform defines the webGL uniform location where to store the value
  34759. * @param array defines the array of number to store
  34760. */
  34761. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34762. /**
  34763. * Set the value of an uniform to an array of float32 (stored as matrices)
  34764. * @param uniform defines the webGL uniform location where to store the value
  34765. * @param matrices defines the array of float32 to store
  34766. */
  34767. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34768. /**
  34769. * Set the value of an uniform to a matrix (3x3)
  34770. * @param uniform defines the webGL uniform location where to store the value
  34771. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34772. */
  34773. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34774. /**
  34775. * Set the value of an uniform to a matrix (2x2)
  34776. * @param uniform defines the webGL uniform location where to store the value
  34777. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34778. */
  34779. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34780. /**
  34781. * Set the value of an uniform to a number (float)
  34782. * @param uniform defines the webGL uniform location where to store the value
  34783. * @param value defines the float number to store
  34784. */
  34785. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34786. /**
  34787. * Set the value of an uniform to a vec2
  34788. * @param uniform defines the webGL uniform location where to store the value
  34789. * @param x defines the 1st component of the value
  34790. * @param y defines the 2nd component of the value
  34791. */
  34792. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34793. /**
  34794. * Set the value of an uniform to a vec3
  34795. * @param uniform defines the webGL uniform location where to store the value
  34796. * @param x defines the 1st component of the value
  34797. * @param y defines the 2nd component of the value
  34798. * @param z defines the 3rd component of the value
  34799. */
  34800. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34801. /**
  34802. * Set the value of an uniform to a vec4
  34803. * @param uniform defines the webGL uniform location where to store the value
  34804. * @param x defines the 1st component of the value
  34805. * @param y defines the 2nd component of the value
  34806. * @param z defines the 3rd component of the value
  34807. * @param w defines the 4th component of the value
  34808. */
  34809. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34810. /**
  34811. * Apply all cached states (depth, culling, stencil and alpha)
  34812. */
  34813. applyStates(): void;
  34814. /**
  34815. * Enable or disable color writing
  34816. * @param enable defines the state to set
  34817. */
  34818. setColorWrite(enable: boolean): void;
  34819. /**
  34820. * Gets a boolean indicating if color writing is enabled
  34821. * @returns the current color writing state
  34822. */
  34823. getColorWrite(): boolean;
  34824. /**
  34825. * Gets the depth culling state manager
  34826. */
  34827. get depthCullingState(): DepthCullingState;
  34828. /**
  34829. * Gets the alpha state manager
  34830. */
  34831. get alphaState(): AlphaState;
  34832. /**
  34833. * Gets the stencil state manager
  34834. */
  34835. get stencilState(): StencilState;
  34836. /**
  34837. * Clears the list of texture accessible through engine.
  34838. * This can help preventing texture load conflict due to name collision.
  34839. */
  34840. clearInternalTexturesCache(): void;
  34841. /**
  34842. * Force the entire cache to be cleared
  34843. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34844. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34845. */
  34846. wipeCaches(bruteForce?: boolean): void;
  34847. /** @hidden */
  34848. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34849. min: number;
  34850. mag: number;
  34851. };
  34852. /** @hidden */
  34853. _createTexture(): WebGLTexture;
  34854. /**
  34855. * Usually called from Texture.ts.
  34856. * Passed information to create a WebGLTexture
  34857. * @param url defines a value which contains one of the following:
  34858. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34859. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34860. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34861. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34862. * @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)
  34863. * @param scene needed for loading to the correct scene
  34864. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34865. * @param onLoad optional callback to be called upon successful completion
  34866. * @param onError optional callback to be called upon failure
  34867. * @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
  34868. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34869. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34870. * @param forcedExtension defines the extension to use to pick the right loader
  34871. * @param mimeType defines an optional mime type
  34872. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34873. */
  34874. 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;
  34875. /**
  34876. * Loads an image as an HTMLImageElement.
  34877. * @param input url string, ArrayBuffer, or Blob to load
  34878. * @param onLoad callback called when the image successfully loads
  34879. * @param onError callback called when the image fails to load
  34880. * @param offlineProvider offline provider for caching
  34881. * @param mimeType optional mime type
  34882. * @returns the HTMLImageElement of the loaded image
  34883. * @hidden
  34884. */
  34885. 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>;
  34886. /**
  34887. * @hidden
  34888. */
  34889. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34890. private _unpackFlipYCached;
  34891. /**
  34892. * In case you are sharing the context with other applications, it might
  34893. * be interested to not cache the unpack flip y state to ensure a consistent
  34894. * value would be set.
  34895. */
  34896. enableUnpackFlipYCached: boolean;
  34897. /** @hidden */
  34898. _unpackFlipY(value: boolean): void;
  34899. /** @hidden */
  34900. _getUnpackAlignement(): number;
  34901. private _getTextureTarget;
  34902. /**
  34903. * Update the sampling mode of a given texture
  34904. * @param samplingMode defines the required sampling mode
  34905. * @param texture defines the texture to update
  34906. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34907. */
  34908. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34909. /**
  34910. * Update the sampling mode of a given texture
  34911. * @param texture defines the texture to update
  34912. * @param wrapU defines the texture wrap mode of the u coordinates
  34913. * @param wrapV defines the texture wrap mode of the v coordinates
  34914. * @param wrapR defines the texture wrap mode of the r coordinates
  34915. */
  34916. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34917. /** @hidden */
  34918. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34919. width: number;
  34920. height: number;
  34921. layers?: number;
  34922. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34923. /** @hidden */
  34924. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34925. /** @hidden */
  34926. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34927. /**
  34928. * Update a portion of an internal texture
  34929. * @param texture defines the texture to update
  34930. * @param imageData defines the data to store into the texture
  34931. * @param xOffset defines the x coordinates of the update rectangle
  34932. * @param yOffset defines the y coordinates of the update rectangle
  34933. * @param width defines the width of the update rectangle
  34934. * @param height defines the height of the update rectangle
  34935. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34936. * @param lod defines the lod level to update (0 by default)
  34937. */
  34938. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34939. /** @hidden */
  34940. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34941. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34942. private _prepareWebGLTexture;
  34943. /** @hidden */
  34944. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34945. private _getDepthStencilBuffer;
  34946. /** @hidden */
  34947. _releaseFramebufferObjects(texture: InternalTexture): void;
  34948. /** @hidden */
  34949. _releaseTexture(texture: InternalTexture): void;
  34950. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34951. protected _setProgram(program: WebGLProgram): void;
  34952. protected _boundUniforms: {
  34953. [key: number]: WebGLUniformLocation;
  34954. };
  34955. /**
  34956. * Binds an effect to the webGL context
  34957. * @param effect defines the effect to bind
  34958. */
  34959. bindSamplers(effect: Effect): void;
  34960. private _activateCurrentTexture;
  34961. /** @hidden */
  34962. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34963. /** @hidden */
  34964. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34965. /**
  34966. * Unbind all textures from the webGL context
  34967. */
  34968. unbindAllTextures(): void;
  34969. /**
  34970. * Sets a texture to the according uniform.
  34971. * @param channel The texture channel
  34972. * @param uniform The uniform to set
  34973. * @param texture The texture to apply
  34974. */
  34975. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34976. private _bindSamplerUniformToChannel;
  34977. private _getTextureWrapMode;
  34978. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34979. /**
  34980. * Sets an array of texture to the webGL context
  34981. * @param channel defines the channel where the texture array must be set
  34982. * @param uniform defines the associated uniform location
  34983. * @param textures defines the array of textures to bind
  34984. */
  34985. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34986. /** @hidden */
  34987. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34988. private _setTextureParameterFloat;
  34989. private _setTextureParameterInteger;
  34990. /**
  34991. * Unbind all vertex attributes from the webGL context
  34992. */
  34993. unbindAllAttributes(): void;
  34994. /**
  34995. * 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
  34996. */
  34997. releaseEffects(): void;
  34998. /**
  34999. * Dispose and release all associated resources
  35000. */
  35001. dispose(): void;
  35002. /**
  35003. * Attach a new callback raised when context lost event is fired
  35004. * @param callback defines the callback to call
  35005. */
  35006. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35007. /**
  35008. * Attach a new callback raised when context restored event is fired
  35009. * @param callback defines the callback to call
  35010. */
  35011. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35012. /**
  35013. * Get the current error code of the webGL context
  35014. * @returns the error code
  35015. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35016. */
  35017. getError(): number;
  35018. private _canRenderToFloatFramebuffer;
  35019. private _canRenderToHalfFloatFramebuffer;
  35020. private _canRenderToFramebuffer;
  35021. /** @hidden */
  35022. _getWebGLTextureType(type: number): number;
  35023. /** @hidden */
  35024. _getInternalFormat(format: number): number;
  35025. /** @hidden */
  35026. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35027. /** @hidden */
  35028. _getRGBAMultiSampleBufferFormat(type: number): number;
  35029. /** @hidden */
  35030. _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;
  35031. /**
  35032. * Loads a file from a url
  35033. * @param url url to load
  35034. * @param onSuccess callback called when the file successfully loads
  35035. * @param onProgress callback called while file is loading (if the server supports this mode)
  35036. * @param offlineProvider defines the offline provider for caching
  35037. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35038. * @param onError callback called when the file fails to load
  35039. * @returns a file request object
  35040. * @hidden
  35041. */
  35042. 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;
  35043. /**
  35044. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35045. * @param x defines the x coordinate of the rectangle where pixels must be read
  35046. * @param y defines the y coordinate of the rectangle where pixels must be read
  35047. * @param width defines the width of the rectangle where pixels must be read
  35048. * @param height defines the height of the rectangle where pixels must be read
  35049. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35050. * @returns a Uint8Array containing RGBA colors
  35051. */
  35052. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35053. private static _isSupported;
  35054. /**
  35055. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35056. * @returns true if the engine can be created
  35057. * @ignorenaming
  35058. */
  35059. static isSupported(): boolean;
  35060. /**
  35061. * Find the next highest power of two.
  35062. * @param x Number to start search from.
  35063. * @return Next highest power of two.
  35064. */
  35065. static CeilingPOT(x: number): number;
  35066. /**
  35067. * Find the next lowest power of two.
  35068. * @param x Number to start search from.
  35069. * @return Next lowest power of two.
  35070. */
  35071. static FloorPOT(x: number): number;
  35072. /**
  35073. * Find the nearest power of two.
  35074. * @param x Number to start search from.
  35075. * @return Next nearest power of two.
  35076. */
  35077. static NearestPOT(x: number): number;
  35078. /**
  35079. * Get the closest exponent of two
  35080. * @param value defines the value to approximate
  35081. * @param max defines the maximum value to return
  35082. * @param mode defines how to define the closest value
  35083. * @returns closest exponent of two of the given value
  35084. */
  35085. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35086. /**
  35087. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35088. * @param func - the function to be called
  35089. * @param requester - the object that will request the next frame. Falls back to window.
  35090. * @returns frame number
  35091. */
  35092. static QueueNewFrame(func: () => void, requester?: any): number;
  35093. /**
  35094. * Gets host document
  35095. * @returns the host document object
  35096. */
  35097. getHostDocument(): Nullable<Document>;
  35098. }
  35099. }
  35100. declare module BABYLON {
  35101. /**
  35102. * Class representing spherical harmonics coefficients to the 3rd degree
  35103. */
  35104. export class SphericalHarmonics {
  35105. /**
  35106. * Defines whether or not the harmonics have been prescaled for rendering.
  35107. */
  35108. preScaled: boolean;
  35109. /**
  35110. * The l0,0 coefficients of the spherical harmonics
  35111. */
  35112. l00: Vector3;
  35113. /**
  35114. * The l1,-1 coefficients of the spherical harmonics
  35115. */
  35116. l1_1: Vector3;
  35117. /**
  35118. * The l1,0 coefficients of the spherical harmonics
  35119. */
  35120. l10: Vector3;
  35121. /**
  35122. * The l1,1 coefficients of the spherical harmonics
  35123. */
  35124. l11: Vector3;
  35125. /**
  35126. * The l2,-2 coefficients of the spherical harmonics
  35127. */
  35128. l2_2: Vector3;
  35129. /**
  35130. * The l2,-1 coefficients of the spherical harmonics
  35131. */
  35132. l2_1: Vector3;
  35133. /**
  35134. * The l2,0 coefficients of the spherical harmonics
  35135. */
  35136. l20: Vector3;
  35137. /**
  35138. * The l2,1 coefficients of the spherical harmonics
  35139. */
  35140. l21: Vector3;
  35141. /**
  35142. * The l2,2 coefficients of the spherical harmonics
  35143. */
  35144. l22: Vector3;
  35145. /**
  35146. * Adds a light to the spherical harmonics
  35147. * @param direction the direction of the light
  35148. * @param color the color of the light
  35149. * @param deltaSolidAngle the delta solid angle of the light
  35150. */
  35151. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35152. /**
  35153. * Scales the spherical harmonics by the given amount
  35154. * @param scale the amount to scale
  35155. */
  35156. scaleInPlace(scale: number): void;
  35157. /**
  35158. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35159. *
  35160. * ```
  35161. * E_lm = A_l * L_lm
  35162. * ```
  35163. *
  35164. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35165. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35166. * the scaling factors are given in equation 9.
  35167. */
  35168. convertIncidentRadianceToIrradiance(): void;
  35169. /**
  35170. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35171. *
  35172. * ```
  35173. * L = (1/pi) * E * rho
  35174. * ```
  35175. *
  35176. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35177. */
  35178. convertIrradianceToLambertianRadiance(): void;
  35179. /**
  35180. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35181. * required operations at run time.
  35182. *
  35183. * This is simply done by scaling back the SH with Ylm constants parameter.
  35184. * The trigonometric part being applied by the shader at run time.
  35185. */
  35186. preScaleForRendering(): void;
  35187. /**
  35188. * Constructs a spherical harmonics from an array.
  35189. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35190. * @returns the spherical harmonics
  35191. */
  35192. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35193. /**
  35194. * Gets the spherical harmonics from polynomial
  35195. * @param polynomial the spherical polynomial
  35196. * @returns the spherical harmonics
  35197. */
  35198. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35199. }
  35200. /**
  35201. * Class representing spherical polynomial coefficients to the 3rd degree
  35202. */
  35203. export class SphericalPolynomial {
  35204. private _harmonics;
  35205. /**
  35206. * The spherical harmonics used to create the polynomials.
  35207. */
  35208. get preScaledHarmonics(): SphericalHarmonics;
  35209. /**
  35210. * The x coefficients of the spherical polynomial
  35211. */
  35212. x: Vector3;
  35213. /**
  35214. * The y coefficients of the spherical polynomial
  35215. */
  35216. y: Vector3;
  35217. /**
  35218. * The z coefficients of the spherical polynomial
  35219. */
  35220. z: Vector3;
  35221. /**
  35222. * The xx coefficients of the spherical polynomial
  35223. */
  35224. xx: Vector3;
  35225. /**
  35226. * The yy coefficients of the spherical polynomial
  35227. */
  35228. yy: Vector3;
  35229. /**
  35230. * The zz coefficients of the spherical polynomial
  35231. */
  35232. zz: Vector3;
  35233. /**
  35234. * The xy coefficients of the spherical polynomial
  35235. */
  35236. xy: Vector3;
  35237. /**
  35238. * The yz coefficients of the spherical polynomial
  35239. */
  35240. yz: Vector3;
  35241. /**
  35242. * The zx coefficients of the spherical polynomial
  35243. */
  35244. zx: Vector3;
  35245. /**
  35246. * Adds an ambient color to the spherical polynomial
  35247. * @param color the color to add
  35248. */
  35249. addAmbient(color: Color3): void;
  35250. /**
  35251. * Scales the spherical polynomial by the given amount
  35252. * @param scale the amount to scale
  35253. */
  35254. scaleInPlace(scale: number): void;
  35255. /**
  35256. * Gets the spherical polynomial from harmonics
  35257. * @param harmonics the spherical harmonics
  35258. * @returns the spherical polynomial
  35259. */
  35260. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35261. /**
  35262. * Constructs a spherical polynomial from an array.
  35263. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35264. * @returns the spherical polynomial
  35265. */
  35266. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35267. }
  35268. }
  35269. declare module BABYLON {
  35270. /**
  35271. * Defines the source of the internal texture
  35272. */
  35273. export enum InternalTextureSource {
  35274. /**
  35275. * The source of the texture data is unknown
  35276. */
  35277. Unknown = 0,
  35278. /**
  35279. * Texture data comes from an URL
  35280. */
  35281. Url = 1,
  35282. /**
  35283. * Texture data is only used for temporary storage
  35284. */
  35285. Temp = 2,
  35286. /**
  35287. * Texture data comes from raw data (ArrayBuffer)
  35288. */
  35289. Raw = 3,
  35290. /**
  35291. * Texture content is dynamic (video or dynamic texture)
  35292. */
  35293. Dynamic = 4,
  35294. /**
  35295. * Texture content is generated by rendering to it
  35296. */
  35297. RenderTarget = 5,
  35298. /**
  35299. * Texture content is part of a multi render target process
  35300. */
  35301. MultiRenderTarget = 6,
  35302. /**
  35303. * Texture data comes from a cube data file
  35304. */
  35305. Cube = 7,
  35306. /**
  35307. * Texture data comes from a raw cube data
  35308. */
  35309. CubeRaw = 8,
  35310. /**
  35311. * Texture data come from a prefiltered cube data file
  35312. */
  35313. CubePrefiltered = 9,
  35314. /**
  35315. * Texture content is raw 3D data
  35316. */
  35317. Raw3D = 10,
  35318. /**
  35319. * Texture content is raw 2D array data
  35320. */
  35321. Raw2DArray = 11,
  35322. /**
  35323. * Texture content is a depth texture
  35324. */
  35325. Depth = 12,
  35326. /**
  35327. * Texture data comes from a raw cube data encoded with RGBD
  35328. */
  35329. CubeRawRGBD = 13
  35330. }
  35331. /**
  35332. * Class used to store data associated with WebGL texture data for the engine
  35333. * This class should not be used directly
  35334. */
  35335. export class InternalTexture {
  35336. /** @hidden */
  35337. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35338. /**
  35339. * Defines if the texture is ready
  35340. */
  35341. isReady: boolean;
  35342. /**
  35343. * Defines if the texture is a cube texture
  35344. */
  35345. isCube: boolean;
  35346. /**
  35347. * Defines if the texture contains 3D data
  35348. */
  35349. is3D: boolean;
  35350. /**
  35351. * Defines if the texture contains 2D array data
  35352. */
  35353. is2DArray: boolean;
  35354. /**
  35355. * Defines if the texture contains multiview data
  35356. */
  35357. isMultiview: boolean;
  35358. /**
  35359. * Gets the URL used to load this texture
  35360. */
  35361. url: string;
  35362. /**
  35363. * Gets the sampling mode of the texture
  35364. */
  35365. samplingMode: number;
  35366. /**
  35367. * Gets a boolean indicating if the texture needs mipmaps generation
  35368. */
  35369. generateMipMaps: boolean;
  35370. /**
  35371. * Gets the number of samples used by the texture (WebGL2+ only)
  35372. */
  35373. samples: number;
  35374. /**
  35375. * Gets the type of the texture (int, float...)
  35376. */
  35377. type: number;
  35378. /**
  35379. * Gets the format of the texture (RGB, RGBA...)
  35380. */
  35381. format: number;
  35382. /**
  35383. * Observable called when the texture is loaded
  35384. */
  35385. onLoadedObservable: Observable<InternalTexture>;
  35386. /**
  35387. * Gets the width of the texture
  35388. */
  35389. width: number;
  35390. /**
  35391. * Gets the height of the texture
  35392. */
  35393. height: number;
  35394. /**
  35395. * Gets the depth of the texture
  35396. */
  35397. depth: number;
  35398. /**
  35399. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35400. */
  35401. baseWidth: number;
  35402. /**
  35403. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35404. */
  35405. baseHeight: number;
  35406. /**
  35407. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35408. */
  35409. baseDepth: number;
  35410. /**
  35411. * Gets a boolean indicating if the texture is inverted on Y axis
  35412. */
  35413. invertY: boolean;
  35414. /** @hidden */
  35415. _invertVScale: boolean;
  35416. /** @hidden */
  35417. _associatedChannel: number;
  35418. /** @hidden */
  35419. _source: InternalTextureSource;
  35420. /** @hidden */
  35421. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35422. /** @hidden */
  35423. _bufferView: Nullable<ArrayBufferView>;
  35424. /** @hidden */
  35425. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35426. /** @hidden */
  35427. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35428. /** @hidden */
  35429. _size: number;
  35430. /** @hidden */
  35431. _extension: string;
  35432. /** @hidden */
  35433. _files: Nullable<string[]>;
  35434. /** @hidden */
  35435. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35436. /** @hidden */
  35437. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35438. /** @hidden */
  35439. _framebuffer: Nullable<WebGLFramebuffer>;
  35440. /** @hidden */
  35441. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35442. /** @hidden */
  35443. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35444. /** @hidden */
  35445. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35446. /** @hidden */
  35447. _attachments: Nullable<number[]>;
  35448. /** @hidden */
  35449. _cachedCoordinatesMode: Nullable<number>;
  35450. /** @hidden */
  35451. _cachedWrapU: Nullable<number>;
  35452. /** @hidden */
  35453. _cachedWrapV: Nullable<number>;
  35454. /** @hidden */
  35455. _cachedWrapR: Nullable<number>;
  35456. /** @hidden */
  35457. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35458. /** @hidden */
  35459. _isDisabled: boolean;
  35460. /** @hidden */
  35461. _compression: Nullable<string>;
  35462. /** @hidden */
  35463. _generateStencilBuffer: boolean;
  35464. /** @hidden */
  35465. _generateDepthBuffer: boolean;
  35466. /** @hidden */
  35467. _comparisonFunction: number;
  35468. /** @hidden */
  35469. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35470. /** @hidden */
  35471. _lodGenerationScale: number;
  35472. /** @hidden */
  35473. _lodGenerationOffset: number;
  35474. /** @hidden */
  35475. _depthStencilTexture: Nullable<InternalTexture>;
  35476. /** @hidden */
  35477. _colorTextureArray: Nullable<WebGLTexture>;
  35478. /** @hidden */
  35479. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35480. /** @hidden */
  35481. _lodTextureHigh: Nullable<BaseTexture>;
  35482. /** @hidden */
  35483. _lodTextureMid: Nullable<BaseTexture>;
  35484. /** @hidden */
  35485. _lodTextureLow: Nullable<BaseTexture>;
  35486. /** @hidden */
  35487. _isRGBD: boolean;
  35488. /** @hidden */
  35489. _linearSpecularLOD: boolean;
  35490. /** @hidden */
  35491. _irradianceTexture: Nullable<BaseTexture>;
  35492. /** @hidden */
  35493. _webGLTexture: Nullable<WebGLTexture>;
  35494. /** @hidden */
  35495. _references: number;
  35496. private _engine;
  35497. /**
  35498. * Gets the Engine the texture belongs to.
  35499. * @returns The babylon engine
  35500. */
  35501. getEngine(): ThinEngine;
  35502. /**
  35503. * Gets the data source type of the texture
  35504. */
  35505. get source(): InternalTextureSource;
  35506. /**
  35507. * Creates a new InternalTexture
  35508. * @param engine defines the engine to use
  35509. * @param source defines the type of data that will be used
  35510. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35511. */
  35512. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35513. /**
  35514. * Increments the number of references (ie. the number of Texture that point to it)
  35515. */
  35516. incrementReferences(): void;
  35517. /**
  35518. * Change the size of the texture (not the size of the content)
  35519. * @param width defines the new width
  35520. * @param height defines the new height
  35521. * @param depth defines the new depth (1 by default)
  35522. */
  35523. updateSize(width: int, height: int, depth?: int): void;
  35524. /** @hidden */
  35525. _rebuild(): void;
  35526. /** @hidden */
  35527. _swapAndDie(target: InternalTexture): void;
  35528. /**
  35529. * Dispose the current allocated resources
  35530. */
  35531. dispose(): void;
  35532. }
  35533. }
  35534. declare module BABYLON {
  35535. /**
  35536. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35538. */
  35539. export class Analyser {
  35540. /**
  35541. * Gets or sets the smoothing
  35542. * @ignorenaming
  35543. */
  35544. SMOOTHING: number;
  35545. /**
  35546. * Gets or sets the FFT table size
  35547. * @ignorenaming
  35548. */
  35549. FFT_SIZE: number;
  35550. /**
  35551. * Gets or sets the bar graph amplitude
  35552. * @ignorenaming
  35553. */
  35554. BARGRAPHAMPLITUDE: number;
  35555. /**
  35556. * Gets or sets the position of the debug canvas
  35557. * @ignorenaming
  35558. */
  35559. DEBUGCANVASPOS: {
  35560. x: number;
  35561. y: number;
  35562. };
  35563. /**
  35564. * Gets or sets the debug canvas size
  35565. * @ignorenaming
  35566. */
  35567. DEBUGCANVASSIZE: {
  35568. width: number;
  35569. height: number;
  35570. };
  35571. private _byteFreqs;
  35572. private _byteTime;
  35573. private _floatFreqs;
  35574. private _webAudioAnalyser;
  35575. private _debugCanvas;
  35576. private _debugCanvasContext;
  35577. private _scene;
  35578. private _registerFunc;
  35579. private _audioEngine;
  35580. /**
  35581. * Creates a new analyser
  35582. * @param scene defines hosting scene
  35583. */
  35584. constructor(scene: Scene);
  35585. /**
  35586. * Get the number of data values you will have to play with for the visualization
  35587. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35588. * @returns a number
  35589. */
  35590. getFrequencyBinCount(): number;
  35591. /**
  35592. * Gets the current frequency data as a byte array
  35593. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35594. * @returns a Uint8Array
  35595. */
  35596. getByteFrequencyData(): Uint8Array;
  35597. /**
  35598. * Gets the current waveform as a byte array
  35599. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35600. * @returns a Uint8Array
  35601. */
  35602. getByteTimeDomainData(): Uint8Array;
  35603. /**
  35604. * Gets the current frequency data as a float array
  35605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35606. * @returns a Float32Array
  35607. */
  35608. getFloatFrequencyData(): Float32Array;
  35609. /**
  35610. * Renders the debug canvas
  35611. */
  35612. drawDebugCanvas(): void;
  35613. /**
  35614. * Stops rendering the debug canvas and removes it
  35615. */
  35616. stopDebugCanvas(): void;
  35617. /**
  35618. * Connects two audio nodes
  35619. * @param inputAudioNode defines first node to connect
  35620. * @param outputAudioNode defines second node to connect
  35621. */
  35622. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35623. /**
  35624. * Releases all associated resources
  35625. */
  35626. dispose(): void;
  35627. }
  35628. }
  35629. declare module BABYLON {
  35630. /**
  35631. * This represents an audio engine and it is responsible
  35632. * to play, synchronize and analyse sounds throughout the application.
  35633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35634. */
  35635. export interface IAudioEngine extends IDisposable {
  35636. /**
  35637. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35638. */
  35639. readonly canUseWebAudio: boolean;
  35640. /**
  35641. * Gets the current AudioContext if available.
  35642. */
  35643. readonly audioContext: Nullable<AudioContext>;
  35644. /**
  35645. * The master gain node defines the global audio volume of your audio engine.
  35646. */
  35647. readonly masterGain: GainNode;
  35648. /**
  35649. * Gets whether or not mp3 are supported by your browser.
  35650. */
  35651. readonly isMP3supported: boolean;
  35652. /**
  35653. * Gets whether or not ogg are supported by your browser.
  35654. */
  35655. readonly isOGGsupported: boolean;
  35656. /**
  35657. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35658. * @ignoreNaming
  35659. */
  35660. WarnedWebAudioUnsupported: boolean;
  35661. /**
  35662. * Defines if the audio engine relies on a custom unlocked button.
  35663. * In this case, the embedded button will not be displayed.
  35664. */
  35665. useCustomUnlockedButton: boolean;
  35666. /**
  35667. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35668. */
  35669. readonly unlocked: boolean;
  35670. /**
  35671. * Event raised when audio has been unlocked on the browser.
  35672. */
  35673. onAudioUnlockedObservable: Observable<AudioEngine>;
  35674. /**
  35675. * Event raised when audio has been locked on the browser.
  35676. */
  35677. onAudioLockedObservable: Observable<AudioEngine>;
  35678. /**
  35679. * Flags the audio engine in Locked state.
  35680. * This happens due to new browser policies preventing audio to autoplay.
  35681. */
  35682. lock(): void;
  35683. /**
  35684. * Unlocks the audio engine once a user action has been done on the dom.
  35685. * This is helpful to resume play once browser policies have been satisfied.
  35686. */
  35687. unlock(): void;
  35688. /**
  35689. * Gets the global volume sets on the master gain.
  35690. * @returns the global volume if set or -1 otherwise
  35691. */
  35692. getGlobalVolume(): number;
  35693. /**
  35694. * Sets the global volume of your experience (sets on the master gain).
  35695. * @param newVolume Defines the new global volume of the application
  35696. */
  35697. setGlobalVolume(newVolume: number): void;
  35698. /**
  35699. * Connect the audio engine to an audio analyser allowing some amazing
  35700. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35702. * @param analyser The analyser to connect to the engine
  35703. */
  35704. connectToAnalyser(analyser: Analyser): void;
  35705. }
  35706. /**
  35707. * This represents the default audio engine used in babylon.
  35708. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35710. */
  35711. export class AudioEngine implements IAudioEngine {
  35712. private _audioContext;
  35713. private _audioContextInitialized;
  35714. private _muteButton;
  35715. private _hostElement;
  35716. /**
  35717. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35718. */
  35719. canUseWebAudio: boolean;
  35720. /**
  35721. * The master gain node defines the global audio volume of your audio engine.
  35722. */
  35723. masterGain: GainNode;
  35724. /**
  35725. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35726. * @ignoreNaming
  35727. */
  35728. WarnedWebAudioUnsupported: boolean;
  35729. /**
  35730. * Gets whether or not mp3 are supported by your browser.
  35731. */
  35732. isMP3supported: boolean;
  35733. /**
  35734. * Gets whether or not ogg are supported by your browser.
  35735. */
  35736. isOGGsupported: boolean;
  35737. /**
  35738. * Gets whether audio has been unlocked on the device.
  35739. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35740. * a user interaction has happened.
  35741. */
  35742. unlocked: boolean;
  35743. /**
  35744. * Defines if the audio engine relies on a custom unlocked button.
  35745. * In this case, the embedded button will not be displayed.
  35746. */
  35747. useCustomUnlockedButton: boolean;
  35748. /**
  35749. * Event raised when audio has been unlocked on the browser.
  35750. */
  35751. onAudioUnlockedObservable: Observable<AudioEngine>;
  35752. /**
  35753. * Event raised when audio has been locked on the browser.
  35754. */
  35755. onAudioLockedObservable: Observable<AudioEngine>;
  35756. /**
  35757. * Gets the current AudioContext if available.
  35758. */
  35759. get audioContext(): Nullable<AudioContext>;
  35760. private _connectedAnalyser;
  35761. /**
  35762. * Instantiates a new audio engine.
  35763. *
  35764. * There should be only one per page as some browsers restrict the number
  35765. * of audio contexts you can create.
  35766. * @param hostElement defines the host element where to display the mute icon if necessary
  35767. */
  35768. constructor(hostElement?: Nullable<HTMLElement>);
  35769. /**
  35770. * Flags the audio engine in Locked state.
  35771. * This happens due to new browser policies preventing audio to autoplay.
  35772. */
  35773. lock(): void;
  35774. /**
  35775. * Unlocks the audio engine once a user action has been done on the dom.
  35776. * This is helpful to resume play once browser policies have been satisfied.
  35777. */
  35778. unlock(): void;
  35779. private _resumeAudioContext;
  35780. private _initializeAudioContext;
  35781. private _tryToRun;
  35782. private _triggerRunningState;
  35783. private _triggerSuspendedState;
  35784. private _displayMuteButton;
  35785. private _moveButtonToTopLeft;
  35786. private _onResize;
  35787. private _hideMuteButton;
  35788. /**
  35789. * Destroy and release the resources associated with the audio ccontext.
  35790. */
  35791. dispose(): void;
  35792. /**
  35793. * Gets the global volume sets on the master gain.
  35794. * @returns the global volume if set or -1 otherwise
  35795. */
  35796. getGlobalVolume(): number;
  35797. /**
  35798. * Sets the global volume of your experience (sets on the master gain).
  35799. * @param newVolume Defines the new global volume of the application
  35800. */
  35801. setGlobalVolume(newVolume: number): void;
  35802. /**
  35803. * Connect the audio engine to an audio analyser allowing some amazing
  35804. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35806. * @param analyser The analyser to connect to the engine
  35807. */
  35808. connectToAnalyser(analyser: Analyser): void;
  35809. }
  35810. }
  35811. declare module BABYLON {
  35812. /**
  35813. * Interface used to present a loading screen while loading a scene
  35814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35815. */
  35816. export interface ILoadingScreen {
  35817. /**
  35818. * Function called to display the loading screen
  35819. */
  35820. displayLoadingUI: () => void;
  35821. /**
  35822. * Function called to hide the loading screen
  35823. */
  35824. hideLoadingUI: () => void;
  35825. /**
  35826. * Gets or sets the color to use for the background
  35827. */
  35828. loadingUIBackgroundColor: string;
  35829. /**
  35830. * Gets or sets the text to display while loading
  35831. */
  35832. loadingUIText: string;
  35833. }
  35834. /**
  35835. * Class used for the default loading screen
  35836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35837. */
  35838. export class DefaultLoadingScreen implements ILoadingScreen {
  35839. private _renderingCanvas;
  35840. private _loadingText;
  35841. private _loadingDivBackgroundColor;
  35842. private _loadingDiv;
  35843. private _loadingTextDiv;
  35844. /** Gets or sets the logo url to use for the default loading screen */
  35845. static DefaultLogoUrl: string;
  35846. /** Gets or sets the spinner url to use for the default loading screen */
  35847. static DefaultSpinnerUrl: string;
  35848. /**
  35849. * Creates a new default loading screen
  35850. * @param _renderingCanvas defines the canvas used to render the scene
  35851. * @param _loadingText defines the default text to display
  35852. * @param _loadingDivBackgroundColor defines the default background color
  35853. */
  35854. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35855. /**
  35856. * Function called to display the loading screen
  35857. */
  35858. displayLoadingUI(): void;
  35859. /**
  35860. * Function called to hide the loading screen
  35861. */
  35862. hideLoadingUI(): void;
  35863. /**
  35864. * Gets or sets the text to display while loading
  35865. */
  35866. set loadingUIText(text: string);
  35867. get loadingUIText(): string;
  35868. /**
  35869. * Gets or sets the color to use for the background
  35870. */
  35871. get loadingUIBackgroundColor(): string;
  35872. set loadingUIBackgroundColor(color: string);
  35873. private _resizeLoadingUI;
  35874. }
  35875. }
  35876. declare module BABYLON {
  35877. /**
  35878. * Interface for any object that can request an animation frame
  35879. */
  35880. export interface ICustomAnimationFrameRequester {
  35881. /**
  35882. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35883. */
  35884. renderFunction?: Function;
  35885. /**
  35886. * Called to request the next frame to render to
  35887. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35888. */
  35889. requestAnimationFrame: Function;
  35890. /**
  35891. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35892. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35893. */
  35894. requestID?: number;
  35895. }
  35896. }
  35897. declare module BABYLON {
  35898. /**
  35899. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35900. */
  35901. export class PerformanceMonitor {
  35902. private _enabled;
  35903. private _rollingFrameTime;
  35904. private _lastFrameTimeMs;
  35905. /**
  35906. * constructor
  35907. * @param frameSampleSize The number of samples required to saturate the sliding window
  35908. */
  35909. constructor(frameSampleSize?: number);
  35910. /**
  35911. * Samples current frame
  35912. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35913. */
  35914. sampleFrame(timeMs?: number): void;
  35915. /**
  35916. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35917. */
  35918. get averageFrameTime(): number;
  35919. /**
  35920. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35921. */
  35922. get averageFrameTimeVariance(): number;
  35923. /**
  35924. * Returns the frame time of the most recent frame
  35925. */
  35926. get instantaneousFrameTime(): number;
  35927. /**
  35928. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35929. */
  35930. get averageFPS(): number;
  35931. /**
  35932. * Returns the average framerate in frames per second using the most recent frame time
  35933. */
  35934. get instantaneousFPS(): number;
  35935. /**
  35936. * Returns true if enough samples have been taken to completely fill the sliding window
  35937. */
  35938. get isSaturated(): boolean;
  35939. /**
  35940. * Enables contributions to the sliding window sample set
  35941. */
  35942. enable(): void;
  35943. /**
  35944. * Disables contributions to the sliding window sample set
  35945. * Samples will not be interpolated over the disabled period
  35946. */
  35947. disable(): void;
  35948. /**
  35949. * Returns true if sampling is enabled
  35950. */
  35951. get isEnabled(): boolean;
  35952. /**
  35953. * Resets performance monitor
  35954. */
  35955. reset(): void;
  35956. }
  35957. /**
  35958. * RollingAverage
  35959. *
  35960. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35961. */
  35962. export class RollingAverage {
  35963. /**
  35964. * Current average
  35965. */
  35966. average: number;
  35967. /**
  35968. * Current variance
  35969. */
  35970. variance: number;
  35971. protected _samples: Array<number>;
  35972. protected _sampleCount: number;
  35973. protected _pos: number;
  35974. protected _m2: number;
  35975. /**
  35976. * constructor
  35977. * @param length The number of samples required to saturate the sliding window
  35978. */
  35979. constructor(length: number);
  35980. /**
  35981. * Adds a sample to the sample set
  35982. * @param v The sample value
  35983. */
  35984. add(v: number): void;
  35985. /**
  35986. * Returns previously added values or null if outside of history or outside the sliding window domain
  35987. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35988. * @return Value previously recorded with add() or null if outside of range
  35989. */
  35990. history(i: number): number;
  35991. /**
  35992. * Returns true if enough samples have been taken to completely fill the sliding window
  35993. * @return true if sample-set saturated
  35994. */
  35995. isSaturated(): boolean;
  35996. /**
  35997. * Resets the rolling average (equivalent to 0 samples taken so far)
  35998. */
  35999. reset(): void;
  36000. /**
  36001. * Wraps a value around the sample range boundaries
  36002. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36003. * @return Wrapped position in sample range
  36004. */
  36005. protected _wrapPosition(i: number): number;
  36006. }
  36007. }
  36008. declare module BABYLON {
  36009. /**
  36010. * This class is used to track a performance counter which is number based.
  36011. * The user has access to many properties which give statistics of different nature.
  36012. *
  36013. * The implementer can track two kinds of Performance Counter: time and count.
  36014. * 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.
  36015. * 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.
  36016. */
  36017. export class PerfCounter {
  36018. /**
  36019. * Gets or sets a global boolean to turn on and off all the counters
  36020. */
  36021. static Enabled: boolean;
  36022. /**
  36023. * Returns the smallest value ever
  36024. */
  36025. get min(): number;
  36026. /**
  36027. * Returns the biggest value ever
  36028. */
  36029. get max(): number;
  36030. /**
  36031. * Returns the average value since the performance counter is running
  36032. */
  36033. get average(): number;
  36034. /**
  36035. * Returns the average value of the last second the counter was monitored
  36036. */
  36037. get lastSecAverage(): number;
  36038. /**
  36039. * Returns the current value
  36040. */
  36041. get current(): number;
  36042. /**
  36043. * Gets the accumulated total
  36044. */
  36045. get total(): number;
  36046. /**
  36047. * Gets the total value count
  36048. */
  36049. get count(): number;
  36050. /**
  36051. * Creates a new counter
  36052. */
  36053. constructor();
  36054. /**
  36055. * Call this method to start monitoring a new frame.
  36056. * 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.
  36057. */
  36058. fetchNewFrame(): void;
  36059. /**
  36060. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36061. * @param newCount the count value to add to the monitored count
  36062. * @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.
  36063. */
  36064. addCount(newCount: number, fetchResult: boolean): void;
  36065. /**
  36066. * Start monitoring this performance counter
  36067. */
  36068. beginMonitoring(): void;
  36069. /**
  36070. * Compute the time lapsed since the previous beginMonitoring() call.
  36071. * @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
  36072. */
  36073. endMonitoring(newFrame?: boolean): void;
  36074. private _fetchResult;
  36075. private _startMonitoringTime;
  36076. private _min;
  36077. private _max;
  36078. private _average;
  36079. private _current;
  36080. private _totalValueCount;
  36081. private _totalAccumulated;
  36082. private _lastSecAverage;
  36083. private _lastSecAccumulated;
  36084. private _lastSecTime;
  36085. private _lastSecValueCount;
  36086. }
  36087. }
  36088. declare module BABYLON {
  36089. interface ThinEngine {
  36090. /**
  36091. * Sets alpha constants used by some alpha blending modes
  36092. * @param r defines the red component
  36093. * @param g defines the green component
  36094. * @param b defines the blue component
  36095. * @param a defines the alpha component
  36096. */
  36097. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36098. /**
  36099. * Sets the current alpha mode
  36100. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36101. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36102. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36103. */
  36104. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36105. /**
  36106. * Gets the current alpha mode
  36107. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36108. * @returns the current alpha mode
  36109. */
  36110. getAlphaMode(): number;
  36111. /**
  36112. * Sets the current alpha equation
  36113. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36114. */
  36115. setAlphaEquation(equation: number): void;
  36116. /**
  36117. * Gets the current alpha equation.
  36118. * @returns the current alpha equation
  36119. */
  36120. getAlphaEquation(): number;
  36121. }
  36122. }
  36123. declare module BABYLON {
  36124. interface ThinEngine {
  36125. /** @hidden */
  36126. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36127. }
  36128. }
  36129. declare module BABYLON {
  36130. /**
  36131. * Defines the interface used by display changed events
  36132. */
  36133. export interface IDisplayChangedEventArgs {
  36134. /** Gets the vrDisplay object (if any) */
  36135. vrDisplay: Nullable<any>;
  36136. /** Gets a boolean indicating if webVR is supported */
  36137. vrSupported: boolean;
  36138. }
  36139. /**
  36140. * Defines the interface used by objects containing a viewport (like a camera)
  36141. */
  36142. interface IViewportOwnerLike {
  36143. /**
  36144. * Gets or sets the viewport
  36145. */
  36146. viewport: IViewportLike;
  36147. }
  36148. /**
  36149. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36150. */
  36151. export class Engine extends ThinEngine {
  36152. /** Defines that alpha blending is disabled */
  36153. static readonly ALPHA_DISABLE: number;
  36154. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36155. static readonly ALPHA_ADD: number;
  36156. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36157. static readonly ALPHA_COMBINE: number;
  36158. /** Defines that alpha blending to DEST - SRC * DEST */
  36159. static readonly ALPHA_SUBTRACT: number;
  36160. /** Defines that alpha blending to SRC * DEST */
  36161. static readonly ALPHA_MULTIPLY: number;
  36162. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36163. static readonly ALPHA_MAXIMIZED: number;
  36164. /** Defines that alpha blending to SRC + DEST */
  36165. static readonly ALPHA_ONEONE: number;
  36166. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36167. static readonly ALPHA_PREMULTIPLIED: number;
  36168. /**
  36169. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36170. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36171. */
  36172. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36173. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36174. static readonly ALPHA_INTERPOLATE: number;
  36175. /**
  36176. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36177. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36178. */
  36179. static readonly ALPHA_SCREENMODE: number;
  36180. /** Defines that the ressource is not delayed*/
  36181. static readonly DELAYLOADSTATE_NONE: number;
  36182. /** Defines that the ressource was successfully delay loaded */
  36183. static readonly DELAYLOADSTATE_LOADED: number;
  36184. /** Defines that the ressource is currently delay loading */
  36185. static readonly DELAYLOADSTATE_LOADING: number;
  36186. /** Defines that the ressource is delayed and has not started loading */
  36187. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36188. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36189. static readonly NEVER: number;
  36190. /** 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 */
  36191. static readonly ALWAYS: number;
  36192. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36193. static readonly LESS: number;
  36194. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36195. static readonly EQUAL: number;
  36196. /** 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 */
  36197. static readonly LEQUAL: number;
  36198. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36199. static readonly GREATER: number;
  36200. /** 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 */
  36201. static readonly GEQUAL: number;
  36202. /** 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 */
  36203. static readonly NOTEQUAL: number;
  36204. /** Passed to stencilOperation to specify that stencil value must be kept */
  36205. static readonly KEEP: number;
  36206. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36207. static readonly REPLACE: number;
  36208. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36209. static readonly INCR: number;
  36210. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36211. static readonly DECR: number;
  36212. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36213. static readonly INVERT: number;
  36214. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36215. static readonly INCR_WRAP: number;
  36216. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36217. static readonly DECR_WRAP: number;
  36218. /** Texture is not repeating outside of 0..1 UVs */
  36219. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36220. /** Texture is repeating outside of 0..1 UVs */
  36221. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36222. /** Texture is repeating and mirrored */
  36223. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36224. /** ALPHA */
  36225. static readonly TEXTUREFORMAT_ALPHA: number;
  36226. /** LUMINANCE */
  36227. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36228. /** LUMINANCE_ALPHA */
  36229. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36230. /** RGB */
  36231. static readonly TEXTUREFORMAT_RGB: number;
  36232. /** RGBA */
  36233. static readonly TEXTUREFORMAT_RGBA: number;
  36234. /** RED */
  36235. static readonly TEXTUREFORMAT_RED: number;
  36236. /** RED (2nd reference) */
  36237. static readonly TEXTUREFORMAT_R: number;
  36238. /** RG */
  36239. static readonly TEXTUREFORMAT_RG: number;
  36240. /** RED_INTEGER */
  36241. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36242. /** RED_INTEGER (2nd reference) */
  36243. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36244. /** RG_INTEGER */
  36245. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36246. /** RGB_INTEGER */
  36247. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36248. /** RGBA_INTEGER */
  36249. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36250. /** UNSIGNED_BYTE */
  36251. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36252. /** UNSIGNED_BYTE (2nd reference) */
  36253. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36254. /** FLOAT */
  36255. static readonly TEXTURETYPE_FLOAT: number;
  36256. /** HALF_FLOAT */
  36257. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36258. /** BYTE */
  36259. static readonly TEXTURETYPE_BYTE: number;
  36260. /** SHORT */
  36261. static readonly TEXTURETYPE_SHORT: number;
  36262. /** UNSIGNED_SHORT */
  36263. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36264. /** INT */
  36265. static readonly TEXTURETYPE_INT: number;
  36266. /** UNSIGNED_INT */
  36267. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36268. /** UNSIGNED_SHORT_4_4_4_4 */
  36269. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36270. /** UNSIGNED_SHORT_5_5_5_1 */
  36271. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36272. /** UNSIGNED_SHORT_5_6_5 */
  36273. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36274. /** UNSIGNED_INT_2_10_10_10_REV */
  36275. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36276. /** UNSIGNED_INT_24_8 */
  36277. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36278. /** UNSIGNED_INT_10F_11F_11F_REV */
  36279. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36280. /** UNSIGNED_INT_5_9_9_9_REV */
  36281. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36282. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36283. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36284. /** nearest is mag = nearest and min = nearest and mip = linear */
  36285. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36286. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36287. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36288. /** Trilinear is mag = linear and min = linear and mip = linear */
  36289. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36290. /** nearest is mag = nearest and min = nearest and mip = linear */
  36291. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36292. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36293. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36294. /** Trilinear is mag = linear and min = linear and mip = linear */
  36295. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36296. /** mag = nearest and min = nearest and mip = nearest */
  36297. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36298. /** mag = nearest and min = linear and mip = nearest */
  36299. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36300. /** mag = nearest and min = linear and mip = linear */
  36301. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36302. /** mag = nearest and min = linear and mip = none */
  36303. static readonly TEXTURE_NEAREST_LINEAR: number;
  36304. /** mag = nearest and min = nearest and mip = none */
  36305. static readonly TEXTURE_NEAREST_NEAREST: number;
  36306. /** mag = linear and min = nearest and mip = nearest */
  36307. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36308. /** mag = linear and min = nearest and mip = linear */
  36309. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36310. /** mag = linear and min = linear and mip = none */
  36311. static readonly TEXTURE_LINEAR_LINEAR: number;
  36312. /** mag = linear and min = nearest and mip = none */
  36313. static readonly TEXTURE_LINEAR_NEAREST: number;
  36314. /** Explicit coordinates mode */
  36315. static readonly TEXTURE_EXPLICIT_MODE: number;
  36316. /** Spherical coordinates mode */
  36317. static readonly TEXTURE_SPHERICAL_MODE: number;
  36318. /** Planar coordinates mode */
  36319. static readonly TEXTURE_PLANAR_MODE: number;
  36320. /** Cubic coordinates mode */
  36321. static readonly TEXTURE_CUBIC_MODE: number;
  36322. /** Projection coordinates mode */
  36323. static readonly TEXTURE_PROJECTION_MODE: number;
  36324. /** Skybox coordinates mode */
  36325. static readonly TEXTURE_SKYBOX_MODE: number;
  36326. /** Inverse Cubic coordinates mode */
  36327. static readonly TEXTURE_INVCUBIC_MODE: number;
  36328. /** Equirectangular coordinates mode */
  36329. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36330. /** Equirectangular Fixed coordinates mode */
  36331. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36332. /** Equirectangular Fixed Mirrored coordinates mode */
  36333. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36334. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36335. static readonly SCALEMODE_FLOOR: number;
  36336. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36337. static readonly SCALEMODE_NEAREST: number;
  36338. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36339. static readonly SCALEMODE_CEILING: number;
  36340. /**
  36341. * Returns the current npm package of the sdk
  36342. */
  36343. static get NpmPackage(): string;
  36344. /**
  36345. * Returns the current version of the framework
  36346. */
  36347. static get Version(): string;
  36348. /** Gets the list of created engines */
  36349. static get Instances(): Engine[];
  36350. /**
  36351. * Gets the latest created engine
  36352. */
  36353. static get LastCreatedEngine(): Nullable<Engine>;
  36354. /**
  36355. * Gets the latest created scene
  36356. */
  36357. static get LastCreatedScene(): Nullable<Scene>;
  36358. /**
  36359. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36360. * @param flag defines which part of the materials must be marked as dirty
  36361. * @param predicate defines a predicate used to filter which materials should be affected
  36362. */
  36363. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36364. /**
  36365. * Method called to create the default loading screen.
  36366. * This can be overriden in your own app.
  36367. * @param canvas The rendering canvas element
  36368. * @returns The loading screen
  36369. */
  36370. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36371. /**
  36372. * Method called to create the default rescale post process on each engine.
  36373. */
  36374. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36375. /**
  36376. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36377. **/
  36378. enableOfflineSupport: boolean;
  36379. /**
  36380. * 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)
  36381. **/
  36382. disableManifestCheck: boolean;
  36383. /**
  36384. * Gets the list of created scenes
  36385. */
  36386. scenes: Scene[];
  36387. /**
  36388. * Event raised when a new scene is created
  36389. */
  36390. onNewSceneAddedObservable: Observable<Scene>;
  36391. /**
  36392. * Gets the list of created postprocesses
  36393. */
  36394. postProcesses: PostProcess[];
  36395. /**
  36396. * Gets a boolean indicating if the pointer is currently locked
  36397. */
  36398. isPointerLock: boolean;
  36399. /**
  36400. * Observable event triggered each time the rendering canvas is resized
  36401. */
  36402. onResizeObservable: Observable<Engine>;
  36403. /**
  36404. * Observable event triggered each time the canvas loses focus
  36405. */
  36406. onCanvasBlurObservable: Observable<Engine>;
  36407. /**
  36408. * Observable event triggered each time the canvas gains focus
  36409. */
  36410. onCanvasFocusObservable: Observable<Engine>;
  36411. /**
  36412. * Observable event triggered each time the canvas receives pointerout event
  36413. */
  36414. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36415. /**
  36416. * Observable raised when the engine begins a new frame
  36417. */
  36418. onBeginFrameObservable: Observable<Engine>;
  36419. /**
  36420. * If set, will be used to request the next animation frame for the render loop
  36421. */
  36422. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36423. /**
  36424. * Observable raised when the engine ends the current frame
  36425. */
  36426. onEndFrameObservable: Observable<Engine>;
  36427. /**
  36428. * Observable raised when the engine is about to compile a shader
  36429. */
  36430. onBeforeShaderCompilationObservable: Observable<Engine>;
  36431. /**
  36432. * Observable raised when the engine has jsut compiled a shader
  36433. */
  36434. onAfterShaderCompilationObservable: Observable<Engine>;
  36435. /**
  36436. * Gets the audio engine
  36437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36438. * @ignorenaming
  36439. */
  36440. static audioEngine: IAudioEngine;
  36441. /**
  36442. * Default AudioEngine factory responsible of creating the Audio Engine.
  36443. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36444. */
  36445. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36446. /**
  36447. * Default offline support factory responsible of creating a tool used to store data locally.
  36448. * By default, this will create a Database object if the workload has been embedded.
  36449. */
  36450. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36451. private _loadingScreen;
  36452. private _pointerLockRequested;
  36453. private _rescalePostProcess;
  36454. private _deterministicLockstep;
  36455. private _lockstepMaxSteps;
  36456. private _timeStep;
  36457. protected get _supportsHardwareTextureRescaling(): boolean;
  36458. private _fps;
  36459. private _deltaTime;
  36460. /** @hidden */
  36461. _drawCalls: PerfCounter;
  36462. /** 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 */
  36463. canvasTabIndex: number;
  36464. /**
  36465. * Turn this value on if you want to pause FPS computation when in background
  36466. */
  36467. disablePerformanceMonitorInBackground: boolean;
  36468. private _performanceMonitor;
  36469. /**
  36470. * Gets the performance monitor attached to this engine
  36471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36472. */
  36473. get performanceMonitor(): PerformanceMonitor;
  36474. private _onFocus;
  36475. private _onBlur;
  36476. private _onCanvasPointerOut;
  36477. private _onCanvasBlur;
  36478. private _onCanvasFocus;
  36479. private _onFullscreenChange;
  36480. private _onPointerLockChange;
  36481. /**
  36482. * Gets the HTML element used to attach event listeners
  36483. * @returns a HTML element
  36484. */
  36485. getInputElement(): Nullable<HTMLElement>;
  36486. /**
  36487. * Creates a new engine
  36488. * @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
  36489. * @param antialias defines enable antialiasing (default: false)
  36490. * @param options defines further options to be sent to the getContext() function
  36491. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36492. */
  36493. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36494. /**
  36495. * Gets current aspect ratio
  36496. * @param viewportOwner defines the camera to use to get the aspect ratio
  36497. * @param useScreen defines if screen size must be used (or the current render target if any)
  36498. * @returns a number defining the aspect ratio
  36499. */
  36500. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36501. /**
  36502. * Gets current screen aspect ratio
  36503. * @returns a number defining the aspect ratio
  36504. */
  36505. getScreenAspectRatio(): number;
  36506. /**
  36507. * Gets the client rect of the HTML canvas attached with the current webGL context
  36508. * @returns a client rectanglee
  36509. */
  36510. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36511. /**
  36512. * Gets the client rect of the HTML element used for events
  36513. * @returns a client rectanglee
  36514. */
  36515. getInputElementClientRect(): Nullable<ClientRect>;
  36516. /**
  36517. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36518. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36519. * @returns true if engine is in deterministic lock step mode
  36520. */
  36521. isDeterministicLockStep(): boolean;
  36522. /**
  36523. * Gets the max steps when engine is running in deterministic lock step
  36524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36525. * @returns the max steps
  36526. */
  36527. getLockstepMaxSteps(): number;
  36528. /**
  36529. * Returns the time in ms between steps when using deterministic lock step.
  36530. * @returns time step in (ms)
  36531. */
  36532. getTimeStep(): number;
  36533. /**
  36534. * Force the mipmap generation for the given render target texture
  36535. * @param texture defines the render target texture to use
  36536. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36537. */
  36538. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36539. /** States */
  36540. /**
  36541. * Set various states to the webGL context
  36542. * @param culling defines backface culling state
  36543. * @param zOffset defines the value to apply to zOffset (0 by default)
  36544. * @param force defines if states must be applied even if cache is up to date
  36545. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36546. */
  36547. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36548. /**
  36549. * Set the z offset to apply to current rendering
  36550. * @param value defines the offset to apply
  36551. */
  36552. setZOffset(value: number): void;
  36553. /**
  36554. * Gets the current value of the zOffset
  36555. * @returns the current zOffset state
  36556. */
  36557. getZOffset(): number;
  36558. /**
  36559. * Enable or disable depth buffering
  36560. * @param enable defines the state to set
  36561. */
  36562. setDepthBuffer(enable: boolean): void;
  36563. /**
  36564. * Gets a boolean indicating if depth writing is enabled
  36565. * @returns the current depth writing state
  36566. */
  36567. getDepthWrite(): boolean;
  36568. /**
  36569. * Enable or disable depth writing
  36570. * @param enable defines the state to set
  36571. */
  36572. setDepthWrite(enable: boolean): void;
  36573. /**
  36574. * Gets a boolean indicating if stencil buffer is enabled
  36575. * @returns the current stencil buffer state
  36576. */
  36577. getStencilBuffer(): boolean;
  36578. /**
  36579. * Enable or disable the stencil buffer
  36580. * @param enable defines if the stencil buffer must be enabled or disabled
  36581. */
  36582. setStencilBuffer(enable: boolean): void;
  36583. /**
  36584. * Gets the current stencil mask
  36585. * @returns a number defining the new stencil mask to use
  36586. */
  36587. getStencilMask(): number;
  36588. /**
  36589. * Sets the current stencil mask
  36590. * @param mask defines the new stencil mask to use
  36591. */
  36592. setStencilMask(mask: number): void;
  36593. /**
  36594. * Gets the current stencil function
  36595. * @returns a number defining the stencil function to use
  36596. */
  36597. getStencilFunction(): number;
  36598. /**
  36599. * Gets the current stencil reference value
  36600. * @returns a number defining the stencil reference value to use
  36601. */
  36602. getStencilFunctionReference(): number;
  36603. /**
  36604. * Gets the current stencil mask
  36605. * @returns a number defining the stencil mask to use
  36606. */
  36607. getStencilFunctionMask(): number;
  36608. /**
  36609. * Sets the current stencil function
  36610. * @param stencilFunc defines the new stencil function to use
  36611. */
  36612. setStencilFunction(stencilFunc: number): void;
  36613. /**
  36614. * Sets the current stencil reference
  36615. * @param reference defines the new stencil reference to use
  36616. */
  36617. setStencilFunctionReference(reference: number): void;
  36618. /**
  36619. * Sets the current stencil mask
  36620. * @param mask defines the new stencil mask to use
  36621. */
  36622. setStencilFunctionMask(mask: number): void;
  36623. /**
  36624. * Gets the current stencil operation when stencil fails
  36625. * @returns a number defining stencil operation to use when stencil fails
  36626. */
  36627. getStencilOperationFail(): number;
  36628. /**
  36629. * Gets the current stencil operation when depth fails
  36630. * @returns a number defining stencil operation to use when depth fails
  36631. */
  36632. getStencilOperationDepthFail(): number;
  36633. /**
  36634. * Gets the current stencil operation when stencil passes
  36635. * @returns a number defining stencil operation to use when stencil passes
  36636. */
  36637. getStencilOperationPass(): number;
  36638. /**
  36639. * Sets the stencil operation to use when stencil fails
  36640. * @param operation defines the stencil operation to use when stencil fails
  36641. */
  36642. setStencilOperationFail(operation: number): void;
  36643. /**
  36644. * Sets the stencil operation to use when depth fails
  36645. * @param operation defines the stencil operation to use when depth fails
  36646. */
  36647. setStencilOperationDepthFail(operation: number): void;
  36648. /**
  36649. * Sets the stencil operation to use when stencil passes
  36650. * @param operation defines the stencil operation to use when stencil passes
  36651. */
  36652. setStencilOperationPass(operation: number): void;
  36653. /**
  36654. * Sets a boolean indicating if the dithering state is enabled or disabled
  36655. * @param value defines the dithering state
  36656. */
  36657. setDitheringState(value: boolean): void;
  36658. /**
  36659. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36660. * @param value defines the rasterizer state
  36661. */
  36662. setRasterizerState(value: boolean): void;
  36663. /**
  36664. * Gets the current depth function
  36665. * @returns a number defining the depth function
  36666. */
  36667. getDepthFunction(): Nullable<number>;
  36668. /**
  36669. * Sets the current depth function
  36670. * @param depthFunc defines the function to use
  36671. */
  36672. setDepthFunction(depthFunc: number): void;
  36673. /**
  36674. * Sets the current depth function to GREATER
  36675. */
  36676. setDepthFunctionToGreater(): void;
  36677. /**
  36678. * Sets the current depth function to GEQUAL
  36679. */
  36680. setDepthFunctionToGreaterOrEqual(): void;
  36681. /**
  36682. * Sets the current depth function to LESS
  36683. */
  36684. setDepthFunctionToLess(): void;
  36685. /**
  36686. * Sets the current depth function to LEQUAL
  36687. */
  36688. setDepthFunctionToLessOrEqual(): void;
  36689. private _cachedStencilBuffer;
  36690. private _cachedStencilFunction;
  36691. private _cachedStencilMask;
  36692. private _cachedStencilOperationPass;
  36693. private _cachedStencilOperationFail;
  36694. private _cachedStencilOperationDepthFail;
  36695. private _cachedStencilReference;
  36696. /**
  36697. * Caches the the state of the stencil buffer
  36698. */
  36699. cacheStencilState(): void;
  36700. /**
  36701. * Restores the state of the stencil buffer
  36702. */
  36703. restoreStencilState(): void;
  36704. /**
  36705. * Directly set the WebGL Viewport
  36706. * @param x defines the x coordinate of the viewport (in screen space)
  36707. * @param y defines the y coordinate of the viewport (in screen space)
  36708. * @param width defines the width of the viewport (in screen space)
  36709. * @param height defines the height of the viewport (in screen space)
  36710. * @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
  36711. */
  36712. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36713. /**
  36714. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36715. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36716. * @param y defines the y-coordinate of the corner of the clear rectangle
  36717. * @param width defines the width of the clear rectangle
  36718. * @param height defines the height of the clear rectangle
  36719. * @param clearColor defines the clear color
  36720. */
  36721. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36722. /**
  36723. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36724. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36725. * @param y defines the y-coordinate of the corner of the clear rectangle
  36726. * @param width defines the width of the clear rectangle
  36727. * @param height defines the height of the clear rectangle
  36728. */
  36729. enableScissor(x: number, y: number, width: number, height: number): void;
  36730. /**
  36731. * Disable previously set scissor test rectangle
  36732. */
  36733. disableScissor(): void;
  36734. protected _reportDrawCall(): void;
  36735. /**
  36736. * Initializes a webVR display and starts listening to display change events
  36737. * The onVRDisplayChangedObservable will be notified upon these changes
  36738. * @returns The onVRDisplayChangedObservable
  36739. */
  36740. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36741. /** @hidden */
  36742. _prepareVRComponent(): void;
  36743. /** @hidden */
  36744. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36745. /** @hidden */
  36746. _submitVRFrame(): void;
  36747. /**
  36748. * Call this function to leave webVR mode
  36749. * Will do nothing if webVR is not supported or if there is no webVR device
  36750. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36751. */
  36752. disableVR(): void;
  36753. /**
  36754. * Gets a boolean indicating that the system is in VR mode and is presenting
  36755. * @returns true if VR mode is engaged
  36756. */
  36757. isVRPresenting(): boolean;
  36758. /** @hidden */
  36759. _requestVRFrame(): void;
  36760. /** @hidden */
  36761. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36762. /**
  36763. * Gets the source code of the vertex shader associated with a specific webGL program
  36764. * @param program defines the program to use
  36765. * @returns a string containing the source code of the vertex shader associated with the program
  36766. */
  36767. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36768. /**
  36769. * Gets the source code of the fragment shader associated with a specific webGL program
  36770. * @param program defines the program to use
  36771. * @returns a string containing the source code of the fragment shader associated with the program
  36772. */
  36773. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36774. /**
  36775. * Sets a depth stencil texture from a render target to the according uniform.
  36776. * @param channel The texture channel
  36777. * @param uniform The uniform to set
  36778. * @param texture The render target texture containing the depth stencil texture to apply
  36779. */
  36780. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36781. /**
  36782. * Sets a texture to the webGL context from a postprocess
  36783. * @param channel defines the channel to use
  36784. * @param postProcess defines the source postprocess
  36785. */
  36786. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36787. /**
  36788. * Binds the output of the passed in post process to the texture channel specified
  36789. * @param channel The channel the texture should be bound to
  36790. * @param postProcess The post process which's output should be bound
  36791. */
  36792. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36793. protected _rebuildBuffers(): void;
  36794. /** @hidden */
  36795. _renderFrame(): void;
  36796. _renderLoop(): void;
  36797. /** @hidden */
  36798. _renderViews(): boolean;
  36799. /**
  36800. * Toggle full screen mode
  36801. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36802. */
  36803. switchFullscreen(requestPointerLock: boolean): void;
  36804. /**
  36805. * Enters full screen mode
  36806. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36807. */
  36808. enterFullscreen(requestPointerLock: boolean): void;
  36809. /**
  36810. * Exits full screen mode
  36811. */
  36812. exitFullscreen(): void;
  36813. /**
  36814. * Enters Pointerlock mode
  36815. */
  36816. enterPointerlock(): void;
  36817. /**
  36818. * Exits Pointerlock mode
  36819. */
  36820. exitPointerlock(): void;
  36821. /**
  36822. * Begin a new frame
  36823. */
  36824. beginFrame(): void;
  36825. /**
  36826. * Enf the current frame
  36827. */
  36828. endFrame(): void;
  36829. resize(): void;
  36830. /**
  36831. * Force a specific size of the canvas
  36832. * @param width defines the new canvas' width
  36833. * @param height defines the new canvas' height
  36834. */
  36835. setSize(width: number, height: number): void;
  36836. /**
  36837. * Updates a dynamic vertex buffer.
  36838. * @param vertexBuffer the vertex buffer to update
  36839. * @param data the data used to update the vertex buffer
  36840. * @param byteOffset the byte offset of the data
  36841. * @param byteLength the byte length of the data
  36842. */
  36843. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36844. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36845. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36846. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36847. _releaseTexture(texture: InternalTexture): void;
  36848. /**
  36849. * @hidden
  36850. * Rescales a texture
  36851. * @param source input texutre
  36852. * @param destination destination texture
  36853. * @param scene scene to use to render the resize
  36854. * @param internalFormat format to use when resizing
  36855. * @param onComplete callback to be called when resize has completed
  36856. */
  36857. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36858. /**
  36859. * Gets the current framerate
  36860. * @returns a number representing the framerate
  36861. */
  36862. getFps(): number;
  36863. /**
  36864. * Gets the time spent between current and previous frame
  36865. * @returns a number representing the delta time in ms
  36866. */
  36867. getDeltaTime(): number;
  36868. private _measureFps;
  36869. /** @hidden */
  36870. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36871. /**
  36872. * Update a dynamic index buffer
  36873. * @param indexBuffer defines the target index buffer
  36874. * @param indices defines the data to update
  36875. * @param offset defines the offset in the target index buffer where update should start
  36876. */
  36877. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36878. /**
  36879. * Updates the sample count of a render target texture
  36880. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36881. * @param texture defines the texture to update
  36882. * @param samples defines the sample count to set
  36883. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36884. */
  36885. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36886. /**
  36887. * Updates a depth texture Comparison Mode and Function.
  36888. * If the comparison Function is equal to 0, the mode will be set to none.
  36889. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36890. * @param texture The texture to set the comparison function for
  36891. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36892. */
  36893. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36894. /**
  36895. * Creates a webGL buffer to use with instanciation
  36896. * @param capacity defines the size of the buffer
  36897. * @returns the webGL buffer
  36898. */
  36899. createInstancesBuffer(capacity: number): DataBuffer;
  36900. /**
  36901. * Delete a webGL buffer used with instanciation
  36902. * @param buffer defines the webGL buffer to delete
  36903. */
  36904. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36905. private _clientWaitAsync;
  36906. /** @hidden */
  36907. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36908. dispose(): void;
  36909. private _disableTouchAction;
  36910. /**
  36911. * Display the loading screen
  36912. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36913. */
  36914. displayLoadingUI(): void;
  36915. /**
  36916. * Hide the loading screen
  36917. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36918. */
  36919. hideLoadingUI(): void;
  36920. /**
  36921. * Gets the current loading screen object
  36922. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36923. */
  36924. get loadingScreen(): ILoadingScreen;
  36925. /**
  36926. * Sets the current loading screen object
  36927. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36928. */
  36929. set loadingScreen(loadingScreen: ILoadingScreen);
  36930. /**
  36931. * Sets the current loading screen text
  36932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36933. */
  36934. set loadingUIText(text: string);
  36935. /**
  36936. * Sets the current loading screen background color
  36937. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36938. */
  36939. set loadingUIBackgroundColor(color: string);
  36940. /** Pointerlock and fullscreen */
  36941. /**
  36942. * Ask the browser to promote the current element to pointerlock mode
  36943. * @param element defines the DOM element to promote
  36944. */
  36945. static _RequestPointerlock(element: HTMLElement): void;
  36946. /**
  36947. * Asks the browser to exit pointerlock mode
  36948. */
  36949. static _ExitPointerlock(): void;
  36950. /**
  36951. * Ask the browser to promote the current element to fullscreen rendering mode
  36952. * @param element defines the DOM element to promote
  36953. */
  36954. static _RequestFullscreen(element: HTMLElement): void;
  36955. /**
  36956. * Asks the browser to exit fullscreen mode
  36957. */
  36958. static _ExitFullscreen(): void;
  36959. }
  36960. }
  36961. declare module BABYLON {
  36962. /**
  36963. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36964. * during the life time of the application.
  36965. */
  36966. export class EngineStore {
  36967. /** Gets the list of created engines */
  36968. static Instances: Engine[];
  36969. /** @hidden */
  36970. static _LastCreatedScene: Nullable<Scene>;
  36971. /**
  36972. * Gets the latest created engine
  36973. */
  36974. static get LastCreatedEngine(): Nullable<Engine>;
  36975. /**
  36976. * Gets the latest created scene
  36977. */
  36978. static get LastCreatedScene(): Nullable<Scene>;
  36979. /**
  36980. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36981. * @ignorenaming
  36982. */
  36983. static UseFallbackTexture: boolean;
  36984. /**
  36985. * Texture content used if a texture cannot loaded
  36986. * @ignorenaming
  36987. */
  36988. static FallbackTexture: string;
  36989. }
  36990. }
  36991. declare module BABYLON {
  36992. /**
  36993. * Helper class that provides a small promise polyfill
  36994. */
  36995. export class PromisePolyfill {
  36996. /**
  36997. * Static function used to check if the polyfill is required
  36998. * If this is the case then the function will inject the polyfill to window.Promise
  36999. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37000. */
  37001. static Apply(force?: boolean): void;
  37002. }
  37003. }
  37004. declare module BABYLON {
  37005. /**
  37006. * Interface for screenshot methods with describe argument called `size` as object with options
  37007. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37008. */
  37009. export interface IScreenshotSize {
  37010. /**
  37011. * number in pixels for canvas height
  37012. */
  37013. height?: number;
  37014. /**
  37015. * multiplier allowing render at a higher or lower resolution
  37016. * If value is defined then height and width will be ignored and taken from camera
  37017. */
  37018. precision?: number;
  37019. /**
  37020. * number in pixels for canvas width
  37021. */
  37022. width?: number;
  37023. }
  37024. }
  37025. declare module BABYLON {
  37026. interface IColor4Like {
  37027. r: float;
  37028. g: float;
  37029. b: float;
  37030. a: float;
  37031. }
  37032. /**
  37033. * Class containing a set of static utilities functions
  37034. */
  37035. export class Tools {
  37036. /**
  37037. * Gets or sets the base URL to use to load assets
  37038. */
  37039. static get BaseUrl(): string;
  37040. static set BaseUrl(value: string);
  37041. /**
  37042. * Enable/Disable Custom HTTP Request Headers globally.
  37043. * default = false
  37044. * @see CustomRequestHeaders
  37045. */
  37046. static UseCustomRequestHeaders: boolean;
  37047. /**
  37048. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37049. * i.e. when loading files, where the server/service expects an Authorization header
  37050. */
  37051. static CustomRequestHeaders: {
  37052. [key: string]: string;
  37053. };
  37054. /**
  37055. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37056. */
  37057. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37058. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37059. /**
  37060. * Default behaviour for cors in the application.
  37061. * It can be a string if the expected behavior is identical in the entire app.
  37062. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37063. */
  37064. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37065. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37066. /**
  37067. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37068. * @ignorenaming
  37069. */
  37070. static get UseFallbackTexture(): boolean;
  37071. static set UseFallbackTexture(value: boolean);
  37072. /**
  37073. * Use this object to register external classes like custom textures or material
  37074. * to allow the laoders to instantiate them
  37075. */
  37076. static get RegisteredExternalClasses(): {
  37077. [key: string]: Object;
  37078. };
  37079. static set RegisteredExternalClasses(classes: {
  37080. [key: string]: Object;
  37081. });
  37082. /**
  37083. * Texture content used if a texture cannot loaded
  37084. * @ignorenaming
  37085. */
  37086. static get fallbackTexture(): string;
  37087. static set fallbackTexture(value: string);
  37088. /**
  37089. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37090. * @param u defines the coordinate on X axis
  37091. * @param v defines the coordinate on Y axis
  37092. * @param width defines the width of the source data
  37093. * @param height defines the height of the source data
  37094. * @param pixels defines the source byte array
  37095. * @param color defines the output color
  37096. */
  37097. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37098. /**
  37099. * Interpolates between a and b via alpha
  37100. * @param a The lower value (returned when alpha = 0)
  37101. * @param b The upper value (returned when alpha = 1)
  37102. * @param alpha The interpolation-factor
  37103. * @return The mixed value
  37104. */
  37105. static Mix(a: number, b: number, alpha: number): number;
  37106. /**
  37107. * Tries to instantiate a new object from a given class name
  37108. * @param className defines the class name to instantiate
  37109. * @returns the new object or null if the system was not able to do the instantiation
  37110. */
  37111. static Instantiate(className: string): any;
  37112. /**
  37113. * Provides a slice function that will work even on IE
  37114. * @param data defines the array to slice
  37115. * @param start defines the start of the data (optional)
  37116. * @param end defines the end of the data (optional)
  37117. * @returns the new sliced array
  37118. */
  37119. static Slice<T>(data: T, start?: number, end?: number): T;
  37120. /**
  37121. * Polyfill for setImmediate
  37122. * @param action defines the action to execute after the current execution block
  37123. */
  37124. static SetImmediate(action: () => void): void;
  37125. /**
  37126. * Function indicating if a number is an exponent of 2
  37127. * @param value defines the value to test
  37128. * @returns true if the value is an exponent of 2
  37129. */
  37130. static IsExponentOfTwo(value: number): boolean;
  37131. private static _tmpFloatArray;
  37132. /**
  37133. * Returns the nearest 32-bit single precision float representation of a Number
  37134. * @param value A Number. If the parameter is of a different type, it will get converted
  37135. * to a number or to NaN if it cannot be converted
  37136. * @returns number
  37137. */
  37138. static FloatRound(value: number): number;
  37139. /**
  37140. * Extracts the filename from a path
  37141. * @param path defines the path to use
  37142. * @returns the filename
  37143. */
  37144. static GetFilename(path: string): string;
  37145. /**
  37146. * Extracts the "folder" part of a path (everything before the filename).
  37147. * @param uri The URI to extract the info from
  37148. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37149. * @returns The "folder" part of the path
  37150. */
  37151. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37152. /**
  37153. * Extracts text content from a DOM element hierarchy
  37154. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37155. */
  37156. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37157. /**
  37158. * Convert an angle in radians to degrees
  37159. * @param angle defines the angle to convert
  37160. * @returns the angle in degrees
  37161. */
  37162. static ToDegrees(angle: number): number;
  37163. /**
  37164. * Convert an angle in degrees to radians
  37165. * @param angle defines the angle to convert
  37166. * @returns the angle in radians
  37167. */
  37168. static ToRadians(angle: number): number;
  37169. /**
  37170. * Returns an array if obj is not an array
  37171. * @param obj defines the object to evaluate as an array
  37172. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37173. * @returns either obj directly if obj is an array or a new array containing obj
  37174. */
  37175. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37176. /**
  37177. * Gets the pointer prefix to use
  37178. * @param engine defines the engine we are finding the prefix for
  37179. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37180. */
  37181. static GetPointerPrefix(engine: Engine): string;
  37182. /**
  37183. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37184. * @param url define the url we are trying
  37185. * @param element define the dom element where to configure the cors policy
  37186. */
  37187. static SetCorsBehavior(url: string | string[], element: {
  37188. crossOrigin: string | null;
  37189. }): void;
  37190. /**
  37191. * Removes unwanted characters from an url
  37192. * @param url defines the url to clean
  37193. * @returns the cleaned url
  37194. */
  37195. static CleanUrl(url: string): string;
  37196. /**
  37197. * Gets or sets a function used to pre-process url before using them to load assets
  37198. */
  37199. static get PreprocessUrl(): (url: string) => string;
  37200. static set PreprocessUrl(processor: (url: string) => string);
  37201. /**
  37202. * Loads an image as an HTMLImageElement.
  37203. * @param input url string, ArrayBuffer, or Blob to load
  37204. * @param onLoad callback called when the image successfully loads
  37205. * @param onError callback called when the image fails to load
  37206. * @param offlineProvider offline provider for caching
  37207. * @param mimeType optional mime type
  37208. * @returns the HTMLImageElement of the loaded image
  37209. */
  37210. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37211. /**
  37212. * Loads a file from a url
  37213. * @param url url string, ArrayBuffer, or Blob to load
  37214. * @param onSuccess callback called when the file successfully loads
  37215. * @param onProgress callback called while file is loading (if the server supports this mode)
  37216. * @param offlineProvider defines the offline provider for caching
  37217. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37218. * @param onError callback called when the file fails to load
  37219. * @returns a file request object
  37220. */
  37221. 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;
  37222. /**
  37223. * Loads a file from a url
  37224. * @param url the file url to load
  37225. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37226. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37227. */
  37228. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37229. /**
  37230. * Load a script (identified by an url). When the url returns, the
  37231. * content of this file is added into a new script element, attached to the DOM (body element)
  37232. * @param scriptUrl defines the url of the script to laod
  37233. * @param onSuccess defines the callback called when the script is loaded
  37234. * @param onError defines the callback to call if an error occurs
  37235. * @param scriptId defines the id of the script element
  37236. */
  37237. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37238. /**
  37239. * Load an asynchronous script (identified by an url). When the url returns, the
  37240. * content of this file is added into a new script element, attached to the DOM (body element)
  37241. * @param scriptUrl defines the url of the script to laod
  37242. * @param scriptId defines the id of the script element
  37243. * @returns a promise request object
  37244. */
  37245. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37246. /**
  37247. * Loads a file from a blob
  37248. * @param fileToLoad defines the blob to use
  37249. * @param callback defines the callback to call when data is loaded
  37250. * @param progressCallback defines the callback to call during loading process
  37251. * @returns a file request object
  37252. */
  37253. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37254. /**
  37255. * Reads a file from a File object
  37256. * @param file defines the file to load
  37257. * @param onSuccess defines the callback to call when data is loaded
  37258. * @param onProgress defines the callback to call during loading process
  37259. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37260. * @param onError defines the callback to call when an error occurs
  37261. * @returns a file request object
  37262. */
  37263. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37264. /**
  37265. * Creates a data url from a given string content
  37266. * @param content defines the content to convert
  37267. * @returns the new data url link
  37268. */
  37269. static FileAsURL(content: string): string;
  37270. /**
  37271. * Format the given number to a specific decimal format
  37272. * @param value defines the number to format
  37273. * @param decimals defines the number of decimals to use
  37274. * @returns the formatted string
  37275. */
  37276. static Format(value: number, decimals?: number): string;
  37277. /**
  37278. * Tries to copy an object by duplicating every property
  37279. * @param source defines the source object
  37280. * @param destination defines the target object
  37281. * @param doNotCopyList defines a list of properties to avoid
  37282. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37283. */
  37284. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37285. /**
  37286. * Gets a boolean indicating if the given object has no own property
  37287. * @param obj defines the object to test
  37288. * @returns true if object has no own property
  37289. */
  37290. static IsEmpty(obj: any): boolean;
  37291. /**
  37292. * Function used to register events at window level
  37293. * @param windowElement defines the Window object to use
  37294. * @param events defines the events to register
  37295. */
  37296. static RegisterTopRootEvents(windowElement: Window, events: {
  37297. name: string;
  37298. handler: Nullable<(e: FocusEvent) => any>;
  37299. }[]): void;
  37300. /**
  37301. * Function used to unregister events from window level
  37302. * @param windowElement defines the Window object to use
  37303. * @param events defines the events to unregister
  37304. */
  37305. static UnregisterTopRootEvents(windowElement: Window, events: {
  37306. name: string;
  37307. handler: Nullable<(e: FocusEvent) => any>;
  37308. }[]): void;
  37309. /**
  37310. * @ignore
  37311. */
  37312. static _ScreenshotCanvas: HTMLCanvasElement;
  37313. /**
  37314. * Dumps the current bound framebuffer
  37315. * @param width defines the rendering width
  37316. * @param height defines the rendering height
  37317. * @param engine defines the hosting engine
  37318. * @param successCallback defines the callback triggered once the data are available
  37319. * @param mimeType defines the mime type of the result
  37320. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37321. */
  37322. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37323. /**
  37324. * Converts the canvas data to blob.
  37325. * This acts as a polyfill for browsers not supporting the to blob function.
  37326. * @param canvas Defines the canvas to extract the data from
  37327. * @param successCallback Defines the callback triggered once the data are available
  37328. * @param mimeType Defines the mime type of the result
  37329. */
  37330. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37331. /**
  37332. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37333. * @param successCallback defines the callback triggered once the data are available
  37334. * @param mimeType defines the mime type of the result
  37335. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37336. */
  37337. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37338. /**
  37339. * Downloads a blob in the browser
  37340. * @param blob defines the blob to download
  37341. * @param fileName defines the name of the downloaded file
  37342. */
  37343. static Download(blob: Blob, fileName: string): void;
  37344. /**
  37345. * Captures a screenshot of the current rendering
  37346. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37347. * @param engine defines the rendering engine
  37348. * @param camera defines the source camera
  37349. * @param size This parameter can be set to a single number or to an object with the
  37350. * following (optional) properties: precision, width, height. If a single number is passed,
  37351. * it will be used for both width and height. If an object is passed, the screenshot size
  37352. * will be derived from the parameters. The precision property is a multiplier allowing
  37353. * rendering at a higher or lower resolution
  37354. * @param successCallback defines the callback receives a single parameter which contains the
  37355. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37356. * src parameter of an <img> to display it
  37357. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37358. * Check your browser for supported MIME types
  37359. */
  37360. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37361. /**
  37362. * Captures a screenshot of the current rendering
  37363. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37364. * @param engine defines the rendering engine
  37365. * @param camera defines the source camera
  37366. * @param size This parameter can be set to a single number or to an object with the
  37367. * following (optional) properties: precision, width, height. If a single number is passed,
  37368. * it will be used for both width and height. If an object is passed, the screenshot size
  37369. * will be derived from the parameters. The precision property is a multiplier allowing
  37370. * rendering at a higher or lower resolution
  37371. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37372. * Check your browser for supported MIME types
  37373. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37374. * to the src parameter of an <img> to display it
  37375. */
  37376. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37377. /**
  37378. * Generates an image screenshot from the specified camera.
  37379. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37380. * @param engine The engine to use for rendering
  37381. * @param camera The camera to use for rendering
  37382. * @param size This parameter can be set to a single number or to an object with the
  37383. * following (optional) properties: precision, width, height. If a single number is passed,
  37384. * it will be used for both width and height. If an object is passed, the screenshot size
  37385. * will be derived from the parameters. The precision property is a multiplier allowing
  37386. * rendering at a higher or lower resolution
  37387. * @param successCallback The callback receives a single parameter which contains the
  37388. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37389. * src parameter of an <img> to display it
  37390. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37391. * Check your browser for supported MIME types
  37392. * @param samples Texture samples (default: 1)
  37393. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37394. * @param fileName A name for for the downloaded file.
  37395. */
  37396. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37397. /**
  37398. * Generates an image screenshot from the specified camera.
  37399. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37400. * @param engine The engine to use for rendering
  37401. * @param camera The camera to use for rendering
  37402. * @param size This parameter can be set to a single number or to an object with the
  37403. * following (optional) properties: precision, width, height. If a single number is passed,
  37404. * it will be used for both width and height. If an object is passed, the screenshot size
  37405. * will be derived from the parameters. The precision property is a multiplier allowing
  37406. * rendering at a higher or lower resolution
  37407. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37408. * Check your browser for supported MIME types
  37409. * @param samples Texture samples (default: 1)
  37410. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37411. * @param fileName A name for for the downloaded file.
  37412. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37413. * to the src parameter of an <img> to display it
  37414. */
  37415. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37416. /**
  37417. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37418. * Be aware Math.random() could cause collisions, but:
  37419. * "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"
  37420. * @returns a pseudo random id
  37421. */
  37422. static RandomId(): string;
  37423. /**
  37424. * Test if the given uri is a base64 string
  37425. * @param uri The uri to test
  37426. * @return True if the uri is a base64 string or false otherwise
  37427. */
  37428. static IsBase64(uri: string): boolean;
  37429. /**
  37430. * Decode the given base64 uri.
  37431. * @param uri The uri to decode
  37432. * @return The decoded base64 data.
  37433. */
  37434. static DecodeBase64(uri: string): ArrayBuffer;
  37435. /**
  37436. * Gets the absolute url.
  37437. * @param url the input url
  37438. * @return the absolute url
  37439. */
  37440. static GetAbsoluteUrl(url: string): string;
  37441. /**
  37442. * No log
  37443. */
  37444. static readonly NoneLogLevel: number;
  37445. /**
  37446. * Only message logs
  37447. */
  37448. static readonly MessageLogLevel: number;
  37449. /**
  37450. * Only warning logs
  37451. */
  37452. static readonly WarningLogLevel: number;
  37453. /**
  37454. * Only error logs
  37455. */
  37456. static readonly ErrorLogLevel: number;
  37457. /**
  37458. * All logs
  37459. */
  37460. static readonly AllLogLevel: number;
  37461. /**
  37462. * Gets a value indicating the number of loading errors
  37463. * @ignorenaming
  37464. */
  37465. static get errorsCount(): number;
  37466. /**
  37467. * Callback called when a new log is added
  37468. */
  37469. static OnNewCacheEntry: (entry: string) => void;
  37470. /**
  37471. * Log a message to the console
  37472. * @param message defines the message to log
  37473. */
  37474. static Log(message: string): void;
  37475. /**
  37476. * Write a warning message to the console
  37477. * @param message defines the message to log
  37478. */
  37479. static Warn(message: string): void;
  37480. /**
  37481. * Write an error message to the console
  37482. * @param message defines the message to log
  37483. */
  37484. static Error(message: string): void;
  37485. /**
  37486. * Gets current log cache (list of logs)
  37487. */
  37488. static get LogCache(): string;
  37489. /**
  37490. * Clears the log cache
  37491. */
  37492. static ClearLogCache(): void;
  37493. /**
  37494. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37495. */
  37496. static set LogLevels(level: number);
  37497. /**
  37498. * Checks if the window object exists
  37499. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37500. */
  37501. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37502. /**
  37503. * No performance log
  37504. */
  37505. static readonly PerformanceNoneLogLevel: number;
  37506. /**
  37507. * Use user marks to log performance
  37508. */
  37509. static readonly PerformanceUserMarkLogLevel: number;
  37510. /**
  37511. * Log performance to the console
  37512. */
  37513. static readonly PerformanceConsoleLogLevel: number;
  37514. private static _performance;
  37515. /**
  37516. * Sets the current performance log level
  37517. */
  37518. static set PerformanceLogLevel(level: number);
  37519. private static _StartPerformanceCounterDisabled;
  37520. private static _EndPerformanceCounterDisabled;
  37521. private static _StartUserMark;
  37522. private static _EndUserMark;
  37523. private static _StartPerformanceConsole;
  37524. private static _EndPerformanceConsole;
  37525. /**
  37526. * Starts a performance counter
  37527. */
  37528. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37529. /**
  37530. * Ends a specific performance coutner
  37531. */
  37532. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37533. /**
  37534. * Gets either window.performance.now() if supported or Date.now() else
  37535. */
  37536. static get Now(): number;
  37537. /**
  37538. * This method will return the name of the class used to create the instance of the given object.
  37539. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37540. * @param object the object to get the class name from
  37541. * @param isType defines if the object is actually a type
  37542. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37543. */
  37544. static GetClassName(object: any, isType?: boolean): string;
  37545. /**
  37546. * Gets the first element of an array satisfying a given predicate
  37547. * @param array defines the array to browse
  37548. * @param predicate defines the predicate to use
  37549. * @returns null if not found or the element
  37550. */
  37551. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37552. /**
  37553. * This method will return the name of the full name of the class, including its owning module (if any).
  37554. * 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).
  37555. * @param object the object to get the class name from
  37556. * @param isType defines if the object is actually a type
  37557. * @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.
  37558. * @ignorenaming
  37559. */
  37560. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37561. /**
  37562. * Returns a promise that resolves after the given amount of time.
  37563. * @param delay Number of milliseconds to delay
  37564. * @returns Promise that resolves after the given amount of time
  37565. */
  37566. static DelayAsync(delay: number): Promise<void>;
  37567. /**
  37568. * Utility function to detect if the current user agent is Safari
  37569. * @returns whether or not the current user agent is safari
  37570. */
  37571. static IsSafari(): boolean;
  37572. }
  37573. /**
  37574. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37575. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37576. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37577. * @param name The name of the class, case should be preserved
  37578. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37579. */
  37580. export function className(name: string, module?: string): (target: Object) => void;
  37581. /**
  37582. * An implementation of a loop for asynchronous functions.
  37583. */
  37584. export class AsyncLoop {
  37585. /**
  37586. * Defines the number of iterations for the loop
  37587. */
  37588. iterations: number;
  37589. /**
  37590. * Defines the current index of the loop.
  37591. */
  37592. index: number;
  37593. private _done;
  37594. private _fn;
  37595. private _successCallback;
  37596. /**
  37597. * Constructor.
  37598. * @param iterations the number of iterations.
  37599. * @param func the function to run each iteration
  37600. * @param successCallback the callback that will be called upon succesful execution
  37601. * @param offset starting offset.
  37602. */
  37603. constructor(
  37604. /**
  37605. * Defines the number of iterations for the loop
  37606. */
  37607. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37608. /**
  37609. * Execute the next iteration. Must be called after the last iteration was finished.
  37610. */
  37611. executeNext(): void;
  37612. /**
  37613. * Break the loop and run the success callback.
  37614. */
  37615. breakLoop(): void;
  37616. /**
  37617. * Create and run an async loop.
  37618. * @param iterations the number of iterations.
  37619. * @param fn the function to run each iteration
  37620. * @param successCallback the callback that will be called upon succesful execution
  37621. * @param offset starting offset.
  37622. * @returns the created async loop object
  37623. */
  37624. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37625. /**
  37626. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37627. * @param iterations total number of iterations
  37628. * @param syncedIterations number of synchronous iterations in each async iteration.
  37629. * @param fn the function to call each iteration.
  37630. * @param callback a success call back that will be called when iterating stops.
  37631. * @param breakFunction a break condition (optional)
  37632. * @param timeout timeout settings for the setTimeout function. default - 0.
  37633. * @returns the created async loop object
  37634. */
  37635. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37636. }
  37637. }
  37638. declare module BABYLON {
  37639. /**
  37640. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37641. * The underlying implementation relies on an associative array to ensure the best performances.
  37642. * The value can be anything including 'null' but except 'undefined'
  37643. */
  37644. export class StringDictionary<T> {
  37645. /**
  37646. * This will clear this dictionary and copy the content from the 'source' one.
  37647. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37648. * @param source the dictionary to take the content from and copy to this dictionary
  37649. */
  37650. copyFrom(source: StringDictionary<T>): void;
  37651. /**
  37652. * Get a value based from its key
  37653. * @param key the given key to get the matching value from
  37654. * @return the value if found, otherwise undefined is returned
  37655. */
  37656. get(key: string): T | undefined;
  37657. /**
  37658. * Get a value from its key or add it if it doesn't exist.
  37659. * This method will ensure you that a given key/data will be present in the dictionary.
  37660. * @param key the given key to get the matching value from
  37661. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37662. * The factory will only be invoked if there's no data for the given key.
  37663. * @return the value corresponding to the key.
  37664. */
  37665. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37666. /**
  37667. * Get a value from its key if present in the dictionary otherwise add it
  37668. * @param key the key to get the value from
  37669. * @param val if there's no such key/value pair in the dictionary add it with this value
  37670. * @return the value corresponding to the key
  37671. */
  37672. getOrAdd(key: string, val: T): T;
  37673. /**
  37674. * Check if there's a given key in the dictionary
  37675. * @param key the key to check for
  37676. * @return true if the key is present, false otherwise
  37677. */
  37678. contains(key: string): boolean;
  37679. /**
  37680. * Add a new key and its corresponding value
  37681. * @param key the key to add
  37682. * @param value the value corresponding to the key
  37683. * @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
  37684. */
  37685. add(key: string, value: T): boolean;
  37686. /**
  37687. * Update a specific value associated to a key
  37688. * @param key defines the key to use
  37689. * @param value defines the value to store
  37690. * @returns true if the value was updated (or false if the key was not found)
  37691. */
  37692. set(key: string, value: T): boolean;
  37693. /**
  37694. * Get the element of the given key and remove it from the dictionary
  37695. * @param key defines the key to search
  37696. * @returns the value associated with the key or null if not found
  37697. */
  37698. getAndRemove(key: string): Nullable<T>;
  37699. /**
  37700. * Remove a key/value from the dictionary.
  37701. * @param key the key to remove
  37702. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37703. */
  37704. remove(key: string): boolean;
  37705. /**
  37706. * Clear the whole content of the dictionary
  37707. */
  37708. clear(): void;
  37709. /**
  37710. * Gets the current count
  37711. */
  37712. get count(): number;
  37713. /**
  37714. * Execute a callback on each key/val of the dictionary.
  37715. * Note that you can remove any element in this dictionary in the callback implementation
  37716. * @param callback the callback to execute on a given key/value pair
  37717. */
  37718. forEach(callback: (key: string, val: T) => void): void;
  37719. /**
  37720. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37721. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37722. * Note that you can remove any element in this dictionary in the callback implementation
  37723. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37724. * @returns the first item
  37725. */
  37726. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37727. private _count;
  37728. private _data;
  37729. }
  37730. }
  37731. declare module BABYLON {
  37732. /** @hidden */
  37733. export interface ICollisionCoordinator {
  37734. createCollider(): Collider;
  37735. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37736. init(scene: Scene): void;
  37737. }
  37738. /** @hidden */
  37739. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37740. private _scene;
  37741. private _scaledPosition;
  37742. private _scaledVelocity;
  37743. private _finalPosition;
  37744. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37745. createCollider(): Collider;
  37746. init(scene: Scene): void;
  37747. private _collideWithWorld;
  37748. }
  37749. }
  37750. declare module BABYLON {
  37751. /**
  37752. * Class used to manage all inputs for the scene.
  37753. */
  37754. export class InputManager {
  37755. /** The distance in pixel that you have to move to prevent some events */
  37756. static DragMovementThreshold: number;
  37757. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37758. static LongPressDelay: number;
  37759. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37760. static DoubleClickDelay: number;
  37761. /** If you need to check double click without raising a single click at first click, enable this flag */
  37762. static ExclusiveDoubleClickMode: boolean;
  37763. private _wheelEventName;
  37764. private _onPointerMove;
  37765. private _onPointerDown;
  37766. private _onPointerUp;
  37767. private _initClickEvent;
  37768. private _initActionManager;
  37769. private _delayedSimpleClick;
  37770. private _delayedSimpleClickTimeout;
  37771. private _previousDelayedSimpleClickTimeout;
  37772. private _meshPickProceed;
  37773. private _previousButtonPressed;
  37774. private _currentPickResult;
  37775. private _previousPickResult;
  37776. private _totalPointersPressed;
  37777. private _doubleClickOccured;
  37778. private _pointerOverMesh;
  37779. private _pickedDownMesh;
  37780. private _pickedUpMesh;
  37781. private _pointerX;
  37782. private _pointerY;
  37783. private _unTranslatedPointerX;
  37784. private _unTranslatedPointerY;
  37785. private _startingPointerPosition;
  37786. private _previousStartingPointerPosition;
  37787. private _startingPointerTime;
  37788. private _previousStartingPointerTime;
  37789. private _pointerCaptures;
  37790. private _onKeyDown;
  37791. private _onKeyUp;
  37792. private _onCanvasFocusObserver;
  37793. private _onCanvasBlurObserver;
  37794. private _scene;
  37795. /**
  37796. * Creates a new InputManager
  37797. * @param scene defines the hosting scene
  37798. */
  37799. constructor(scene: Scene);
  37800. /**
  37801. * Gets the mesh that is currently under the pointer
  37802. */
  37803. get meshUnderPointer(): Nullable<AbstractMesh>;
  37804. /**
  37805. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37806. */
  37807. get unTranslatedPointer(): Vector2;
  37808. /**
  37809. * Gets or sets the current on-screen X position of the pointer
  37810. */
  37811. get pointerX(): number;
  37812. set pointerX(value: number);
  37813. /**
  37814. * Gets or sets the current on-screen Y position of the pointer
  37815. */
  37816. get pointerY(): number;
  37817. set pointerY(value: number);
  37818. private _updatePointerPosition;
  37819. private _processPointerMove;
  37820. private _setRayOnPointerInfo;
  37821. private _checkPrePointerObservable;
  37822. /**
  37823. * Use this method to simulate a pointer move on a mesh
  37824. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37825. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37826. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37827. */
  37828. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37829. /**
  37830. * Use this method to simulate a pointer down on a mesh
  37831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37834. */
  37835. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37836. private _processPointerDown;
  37837. /** @hidden */
  37838. _isPointerSwiping(): boolean;
  37839. /**
  37840. * Use this method to simulate a pointer up on a mesh
  37841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37844. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37845. */
  37846. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37847. private _processPointerUp;
  37848. /**
  37849. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37850. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37851. * @returns true if the pointer was captured
  37852. */
  37853. isPointerCaptured(pointerId?: number): boolean;
  37854. /**
  37855. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37856. * @param attachUp defines if you want to attach events to pointerup
  37857. * @param attachDown defines if you want to attach events to pointerdown
  37858. * @param attachMove defines if you want to attach events to pointermove
  37859. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37860. */
  37861. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37862. /**
  37863. * Detaches all event handlers
  37864. */
  37865. detachControl(): void;
  37866. /**
  37867. * Force the value of meshUnderPointer
  37868. * @param mesh defines the mesh to use
  37869. */
  37870. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37871. /**
  37872. * Gets the mesh under the pointer
  37873. * @returns a Mesh or null if no mesh is under the pointer
  37874. */
  37875. getPointerOverMesh(): Nullable<AbstractMesh>;
  37876. }
  37877. }
  37878. declare module BABYLON {
  37879. /**
  37880. * This class defines the direct association between an animation and a target
  37881. */
  37882. export class TargetedAnimation {
  37883. /**
  37884. * Animation to perform
  37885. */
  37886. animation: Animation;
  37887. /**
  37888. * Target to animate
  37889. */
  37890. target: any;
  37891. /**
  37892. * Returns the string "TargetedAnimation"
  37893. * @returns "TargetedAnimation"
  37894. */
  37895. getClassName(): string;
  37896. /**
  37897. * Serialize the object
  37898. * @returns the JSON object representing the current entity
  37899. */
  37900. serialize(): any;
  37901. }
  37902. /**
  37903. * Use this class to create coordinated animations on multiple targets
  37904. */
  37905. export class AnimationGroup implements IDisposable {
  37906. /** The name of the animation group */
  37907. name: string;
  37908. private _scene;
  37909. private _targetedAnimations;
  37910. private _animatables;
  37911. private _from;
  37912. private _to;
  37913. private _isStarted;
  37914. private _isPaused;
  37915. private _speedRatio;
  37916. private _loopAnimation;
  37917. private _isAdditive;
  37918. /**
  37919. * Gets or sets the unique id of the node
  37920. */
  37921. uniqueId: number;
  37922. /**
  37923. * This observable will notify when one animation have ended
  37924. */
  37925. onAnimationEndObservable: Observable<TargetedAnimation>;
  37926. /**
  37927. * Observer raised when one animation loops
  37928. */
  37929. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37930. /**
  37931. * Observer raised when all animations have looped
  37932. */
  37933. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37934. /**
  37935. * This observable will notify when all animations have ended.
  37936. */
  37937. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37938. /**
  37939. * This observable will notify when all animations have paused.
  37940. */
  37941. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37942. /**
  37943. * This observable will notify when all animations are playing.
  37944. */
  37945. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37946. /**
  37947. * Gets the first frame
  37948. */
  37949. get from(): number;
  37950. /**
  37951. * Gets the last frame
  37952. */
  37953. get to(): number;
  37954. /**
  37955. * Define if the animations are started
  37956. */
  37957. get isStarted(): boolean;
  37958. /**
  37959. * Gets a value indicating that the current group is playing
  37960. */
  37961. get isPlaying(): boolean;
  37962. /**
  37963. * Gets or sets the speed ratio to use for all animations
  37964. */
  37965. get speedRatio(): number;
  37966. /**
  37967. * Gets or sets the speed ratio to use for all animations
  37968. */
  37969. set speedRatio(value: number);
  37970. /**
  37971. * Gets or sets if all animations should loop or not
  37972. */
  37973. get loopAnimation(): boolean;
  37974. set loopAnimation(value: boolean);
  37975. /**
  37976. * Gets or sets if all animations should be evaluated additively
  37977. */
  37978. get isAdditive(): boolean;
  37979. set isAdditive(value: boolean);
  37980. /**
  37981. * Gets the targeted animations for this animation group
  37982. */
  37983. get targetedAnimations(): Array<TargetedAnimation>;
  37984. /**
  37985. * returning the list of animatables controlled by this animation group.
  37986. */
  37987. get animatables(): Array<Animatable>;
  37988. /**
  37989. * Gets the list of target animations
  37990. */
  37991. get children(): TargetedAnimation[];
  37992. /**
  37993. * Instantiates a new Animation Group.
  37994. * This helps managing several animations at once.
  37995. * @see http://doc.babylonjs.com/how_to/group
  37996. * @param name Defines the name of the group
  37997. * @param scene Defines the scene the group belongs to
  37998. */
  37999. constructor(
  38000. /** The name of the animation group */
  38001. name: string, scene?: Nullable<Scene>);
  38002. /**
  38003. * Add an animation (with its target) in the group
  38004. * @param animation defines the animation we want to add
  38005. * @param target defines the target of the animation
  38006. * @returns the TargetedAnimation object
  38007. */
  38008. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38009. /**
  38010. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38011. * It can add constant keys at begin or end
  38012. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38013. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38014. * @returns the animation group
  38015. */
  38016. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38017. private _animationLoopCount;
  38018. private _animationLoopFlags;
  38019. private _processLoop;
  38020. /**
  38021. * Start all animations on given targets
  38022. * @param loop defines if animations must loop
  38023. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38024. * @param from defines the from key (optional)
  38025. * @param to defines the to key (optional)
  38026. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38027. * @returns the current animation group
  38028. */
  38029. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38030. /**
  38031. * Pause all animations
  38032. * @returns the animation group
  38033. */
  38034. pause(): AnimationGroup;
  38035. /**
  38036. * Play all animations to initial state
  38037. * This function will start() the animations if they were not started or will restart() them if they were paused
  38038. * @param loop defines if animations must loop
  38039. * @returns the animation group
  38040. */
  38041. play(loop?: boolean): AnimationGroup;
  38042. /**
  38043. * Reset all animations to initial state
  38044. * @returns the animation group
  38045. */
  38046. reset(): AnimationGroup;
  38047. /**
  38048. * Restart animations from key 0
  38049. * @returns the animation group
  38050. */
  38051. restart(): AnimationGroup;
  38052. /**
  38053. * Stop all animations
  38054. * @returns the animation group
  38055. */
  38056. stop(): AnimationGroup;
  38057. /**
  38058. * Set animation weight for all animatables
  38059. * @param weight defines the weight to use
  38060. * @return the animationGroup
  38061. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38062. */
  38063. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38064. /**
  38065. * Synchronize and normalize all animatables with a source animatable
  38066. * @param root defines the root animatable to synchronize with
  38067. * @return the animationGroup
  38068. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38069. */
  38070. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38071. /**
  38072. * Goes to a specific frame in this animation group
  38073. * @param frame the frame number to go to
  38074. * @return the animationGroup
  38075. */
  38076. goToFrame(frame: number): AnimationGroup;
  38077. /**
  38078. * Dispose all associated resources
  38079. */
  38080. dispose(): void;
  38081. private _checkAnimationGroupEnded;
  38082. /**
  38083. * Clone the current animation group and returns a copy
  38084. * @param newName defines the name of the new group
  38085. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38086. * @returns the new aniamtion group
  38087. */
  38088. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38089. /**
  38090. * Serializes the animationGroup to an object
  38091. * @returns Serialized object
  38092. */
  38093. serialize(): any;
  38094. /**
  38095. * Returns a new AnimationGroup object parsed from the source provided.
  38096. * @param parsedAnimationGroup defines the source
  38097. * @param scene defines the scene that will receive the animationGroup
  38098. * @returns a new AnimationGroup
  38099. */
  38100. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38101. /**
  38102. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38103. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38104. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38105. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38106. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38107. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38108. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38109. */
  38110. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38111. /**
  38112. * Returns the string "AnimationGroup"
  38113. * @returns "AnimationGroup"
  38114. */
  38115. getClassName(): string;
  38116. /**
  38117. * Creates a detailled string about the object
  38118. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38119. * @returns a string representing the object
  38120. */
  38121. toString(fullDetails?: boolean): string;
  38122. }
  38123. }
  38124. declare module BABYLON {
  38125. /**
  38126. * Define an interface for all classes that will hold resources
  38127. */
  38128. export interface IDisposable {
  38129. /**
  38130. * Releases all held resources
  38131. */
  38132. dispose(): void;
  38133. }
  38134. /** Interface defining initialization parameters for Scene class */
  38135. export interface SceneOptions {
  38136. /**
  38137. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38138. * It will improve performance when the number of geometries becomes important.
  38139. */
  38140. useGeometryUniqueIdsMap?: boolean;
  38141. /**
  38142. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38143. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38144. */
  38145. useMaterialMeshMap?: boolean;
  38146. /**
  38147. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38148. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38149. */
  38150. useClonedMeshMap?: boolean;
  38151. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38152. virtual?: boolean;
  38153. }
  38154. /**
  38155. * Represents a scene to be rendered by the engine.
  38156. * @see http://doc.babylonjs.com/features/scene
  38157. */
  38158. export class Scene extends AbstractScene implements IAnimatable {
  38159. /** The fog is deactivated */
  38160. static readonly FOGMODE_NONE: number;
  38161. /** The fog density is following an exponential function */
  38162. static readonly FOGMODE_EXP: number;
  38163. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38164. static readonly FOGMODE_EXP2: number;
  38165. /** The fog density is following a linear function. */
  38166. static readonly FOGMODE_LINEAR: number;
  38167. /**
  38168. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38170. */
  38171. static MinDeltaTime: number;
  38172. /**
  38173. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38175. */
  38176. static MaxDeltaTime: number;
  38177. /**
  38178. * Factory used to create the default material.
  38179. * @param name The name of the material to create
  38180. * @param scene The scene to create the material for
  38181. * @returns The default material
  38182. */
  38183. static DefaultMaterialFactory(scene: Scene): Material;
  38184. /**
  38185. * Factory used to create the a collision coordinator.
  38186. * @returns The collision coordinator
  38187. */
  38188. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38189. /** @hidden */
  38190. _inputManager: InputManager;
  38191. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38192. cameraToUseForPointers: Nullable<Camera>;
  38193. /** @hidden */
  38194. readonly _isScene: boolean;
  38195. /** @hidden */
  38196. _blockEntityCollection: boolean;
  38197. /**
  38198. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38199. */
  38200. autoClear: boolean;
  38201. /**
  38202. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38203. */
  38204. autoClearDepthAndStencil: boolean;
  38205. /**
  38206. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38207. */
  38208. clearColor: Color4;
  38209. /**
  38210. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38211. */
  38212. ambientColor: Color3;
  38213. /**
  38214. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38215. * It should only be one of the following (if not the default embedded one):
  38216. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38217. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38218. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38219. * The material properties need to be setup according to the type of texture in use.
  38220. */
  38221. environmentBRDFTexture: BaseTexture;
  38222. /** @hidden */
  38223. protected _environmentTexture: Nullable<BaseTexture>;
  38224. /**
  38225. * Texture used in all pbr material as the reflection texture.
  38226. * As in the majority of the scene they are the same (exception for multi room and so on),
  38227. * this is easier to reference from here than from all the materials.
  38228. */
  38229. get environmentTexture(): Nullable<BaseTexture>;
  38230. /**
  38231. * Texture used in all pbr material as the reflection texture.
  38232. * As in the majority of the scene they are the same (exception for multi room and so on),
  38233. * this is easier to set here than in all the materials.
  38234. */
  38235. set environmentTexture(value: Nullable<BaseTexture>);
  38236. /** @hidden */
  38237. protected _environmentIntensity: number;
  38238. /**
  38239. * Intensity of the environment in all pbr material.
  38240. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38241. * As in the majority of the scene they are the same (exception for multi room and so on),
  38242. * this is easier to reference from here than from all the materials.
  38243. */
  38244. get environmentIntensity(): number;
  38245. /**
  38246. * Intensity of the environment in all pbr material.
  38247. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38248. * As in the majority of the scene they are the same (exception for multi room and so on),
  38249. * this is easier to set here than in all the materials.
  38250. */
  38251. set environmentIntensity(value: number);
  38252. /** @hidden */
  38253. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38254. /**
  38255. * Default image processing configuration used either in the rendering
  38256. * Forward main pass or through the imageProcessingPostProcess if present.
  38257. * As in the majority of the scene they are the same (exception for multi camera),
  38258. * this is easier to reference from here than from all the materials and post process.
  38259. *
  38260. * No setter as we it is a shared configuration, you can set the values instead.
  38261. */
  38262. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38263. private _forceWireframe;
  38264. /**
  38265. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38266. */
  38267. set forceWireframe(value: boolean);
  38268. get forceWireframe(): boolean;
  38269. private _skipFrustumClipping;
  38270. /**
  38271. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38272. */
  38273. set skipFrustumClipping(value: boolean);
  38274. get skipFrustumClipping(): boolean;
  38275. private _forcePointsCloud;
  38276. /**
  38277. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38278. */
  38279. set forcePointsCloud(value: boolean);
  38280. get forcePointsCloud(): boolean;
  38281. /**
  38282. * Gets or sets the active clipplane 1
  38283. */
  38284. clipPlane: Nullable<Plane>;
  38285. /**
  38286. * Gets or sets the active clipplane 2
  38287. */
  38288. clipPlane2: Nullable<Plane>;
  38289. /**
  38290. * Gets or sets the active clipplane 3
  38291. */
  38292. clipPlane3: Nullable<Plane>;
  38293. /**
  38294. * Gets or sets the active clipplane 4
  38295. */
  38296. clipPlane4: Nullable<Plane>;
  38297. /**
  38298. * Gets or sets the active clipplane 5
  38299. */
  38300. clipPlane5: Nullable<Plane>;
  38301. /**
  38302. * Gets or sets the active clipplane 6
  38303. */
  38304. clipPlane6: Nullable<Plane>;
  38305. /**
  38306. * Gets or sets a boolean indicating if animations are enabled
  38307. */
  38308. animationsEnabled: boolean;
  38309. private _animationPropertiesOverride;
  38310. /**
  38311. * Gets or sets the animation properties override
  38312. */
  38313. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38314. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38315. /**
  38316. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38317. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38318. */
  38319. useConstantAnimationDeltaTime: boolean;
  38320. /**
  38321. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38322. * Please note that it requires to run a ray cast through the scene on every frame
  38323. */
  38324. constantlyUpdateMeshUnderPointer: boolean;
  38325. /**
  38326. * Defines the HTML cursor to use when hovering over interactive elements
  38327. */
  38328. hoverCursor: string;
  38329. /**
  38330. * Defines the HTML default cursor to use (empty by default)
  38331. */
  38332. defaultCursor: string;
  38333. /**
  38334. * Defines whether cursors are handled by the scene.
  38335. */
  38336. doNotHandleCursors: boolean;
  38337. /**
  38338. * This is used to call preventDefault() on pointer down
  38339. * in order to block unwanted artifacts like system double clicks
  38340. */
  38341. preventDefaultOnPointerDown: boolean;
  38342. /**
  38343. * This is used to call preventDefault() on pointer up
  38344. * in order to block unwanted artifacts like system double clicks
  38345. */
  38346. preventDefaultOnPointerUp: boolean;
  38347. /**
  38348. * Gets or sets user defined metadata
  38349. */
  38350. metadata: any;
  38351. /**
  38352. * For internal use only. Please do not use.
  38353. */
  38354. reservedDataStore: any;
  38355. /**
  38356. * Gets the name of the plugin used to load this scene (null by default)
  38357. */
  38358. loadingPluginName: string;
  38359. /**
  38360. * Use this array to add regular expressions used to disable offline support for specific urls
  38361. */
  38362. disableOfflineSupportExceptionRules: RegExp[];
  38363. /**
  38364. * An event triggered when the scene is disposed.
  38365. */
  38366. onDisposeObservable: Observable<Scene>;
  38367. private _onDisposeObserver;
  38368. /** Sets a function to be executed when this scene is disposed. */
  38369. set onDispose(callback: () => void);
  38370. /**
  38371. * An event triggered before rendering the scene (right after animations and physics)
  38372. */
  38373. onBeforeRenderObservable: Observable<Scene>;
  38374. private _onBeforeRenderObserver;
  38375. /** Sets a function to be executed before rendering this scene */
  38376. set beforeRender(callback: Nullable<() => void>);
  38377. /**
  38378. * An event triggered after rendering the scene
  38379. */
  38380. onAfterRenderObservable: Observable<Scene>;
  38381. /**
  38382. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38383. */
  38384. onAfterRenderCameraObservable: Observable<Camera>;
  38385. private _onAfterRenderObserver;
  38386. /** Sets a function to be executed after rendering this scene */
  38387. set afterRender(callback: Nullable<() => void>);
  38388. /**
  38389. * An event triggered before animating the scene
  38390. */
  38391. onBeforeAnimationsObservable: Observable<Scene>;
  38392. /**
  38393. * An event triggered after animations processing
  38394. */
  38395. onAfterAnimationsObservable: Observable<Scene>;
  38396. /**
  38397. * An event triggered before draw calls are ready to be sent
  38398. */
  38399. onBeforeDrawPhaseObservable: Observable<Scene>;
  38400. /**
  38401. * An event triggered after draw calls have been sent
  38402. */
  38403. onAfterDrawPhaseObservable: Observable<Scene>;
  38404. /**
  38405. * An event triggered when the scene is ready
  38406. */
  38407. onReadyObservable: Observable<Scene>;
  38408. /**
  38409. * An event triggered before rendering a camera
  38410. */
  38411. onBeforeCameraRenderObservable: Observable<Camera>;
  38412. private _onBeforeCameraRenderObserver;
  38413. /** Sets a function to be executed before rendering a camera*/
  38414. set beforeCameraRender(callback: () => void);
  38415. /**
  38416. * An event triggered after rendering a camera
  38417. */
  38418. onAfterCameraRenderObservable: Observable<Camera>;
  38419. private _onAfterCameraRenderObserver;
  38420. /** Sets a function to be executed after rendering a camera*/
  38421. set afterCameraRender(callback: () => void);
  38422. /**
  38423. * An event triggered when active meshes evaluation is about to start
  38424. */
  38425. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38426. /**
  38427. * An event triggered when active meshes evaluation is done
  38428. */
  38429. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38430. /**
  38431. * An event triggered when particles rendering is about to start
  38432. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38433. */
  38434. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38435. /**
  38436. * An event triggered when particles rendering is done
  38437. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38438. */
  38439. onAfterParticlesRenderingObservable: Observable<Scene>;
  38440. /**
  38441. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38442. */
  38443. onDataLoadedObservable: Observable<Scene>;
  38444. /**
  38445. * An event triggered when a camera is created
  38446. */
  38447. onNewCameraAddedObservable: Observable<Camera>;
  38448. /**
  38449. * An event triggered when a camera is removed
  38450. */
  38451. onCameraRemovedObservable: Observable<Camera>;
  38452. /**
  38453. * An event triggered when a light is created
  38454. */
  38455. onNewLightAddedObservable: Observable<Light>;
  38456. /**
  38457. * An event triggered when a light is removed
  38458. */
  38459. onLightRemovedObservable: Observable<Light>;
  38460. /**
  38461. * An event triggered when a geometry is created
  38462. */
  38463. onNewGeometryAddedObservable: Observable<Geometry>;
  38464. /**
  38465. * An event triggered when a geometry is removed
  38466. */
  38467. onGeometryRemovedObservable: Observable<Geometry>;
  38468. /**
  38469. * An event triggered when a transform node is created
  38470. */
  38471. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38472. /**
  38473. * An event triggered when a transform node is removed
  38474. */
  38475. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38476. /**
  38477. * An event triggered when a mesh is created
  38478. */
  38479. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38480. /**
  38481. * An event triggered when a mesh is removed
  38482. */
  38483. onMeshRemovedObservable: Observable<AbstractMesh>;
  38484. /**
  38485. * An event triggered when a skeleton is created
  38486. */
  38487. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38488. /**
  38489. * An event triggered when a skeleton is removed
  38490. */
  38491. onSkeletonRemovedObservable: Observable<Skeleton>;
  38492. /**
  38493. * An event triggered when a material is created
  38494. */
  38495. onNewMaterialAddedObservable: Observable<Material>;
  38496. /**
  38497. * An event triggered when a material is removed
  38498. */
  38499. onMaterialRemovedObservable: Observable<Material>;
  38500. /**
  38501. * An event triggered when a texture is created
  38502. */
  38503. onNewTextureAddedObservable: Observable<BaseTexture>;
  38504. /**
  38505. * An event triggered when a texture is removed
  38506. */
  38507. onTextureRemovedObservable: Observable<BaseTexture>;
  38508. /**
  38509. * An event triggered when render targets are about to be rendered
  38510. * Can happen multiple times per frame.
  38511. */
  38512. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38513. /**
  38514. * An event triggered when render targets were rendered.
  38515. * Can happen multiple times per frame.
  38516. */
  38517. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38518. /**
  38519. * An event triggered before calculating deterministic simulation step
  38520. */
  38521. onBeforeStepObservable: Observable<Scene>;
  38522. /**
  38523. * An event triggered after calculating deterministic simulation step
  38524. */
  38525. onAfterStepObservable: Observable<Scene>;
  38526. /**
  38527. * An event triggered when the activeCamera property is updated
  38528. */
  38529. onActiveCameraChanged: Observable<Scene>;
  38530. /**
  38531. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38532. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38533. * 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)
  38534. */
  38535. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38536. /**
  38537. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38538. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38539. * 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)
  38540. */
  38541. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38542. /**
  38543. * This Observable will when a mesh has been imported into the scene.
  38544. */
  38545. onMeshImportedObservable: Observable<AbstractMesh>;
  38546. /**
  38547. * This Observable will when an animation file has been imported into the scene.
  38548. */
  38549. onAnimationFileImportedObservable: Observable<Scene>;
  38550. /**
  38551. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38552. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38553. */
  38554. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38555. /** @hidden */
  38556. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38557. /**
  38558. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38559. */
  38560. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38561. /**
  38562. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38563. */
  38564. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38565. /**
  38566. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38567. */
  38568. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38569. /** Callback called when a pointer move is detected */
  38570. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38571. /** Callback called when a pointer down is detected */
  38572. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38573. /** Callback called when a pointer up is detected */
  38574. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38575. /** Callback called when a pointer pick is detected */
  38576. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38577. /**
  38578. * 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).
  38579. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38580. */
  38581. onPrePointerObservable: Observable<PointerInfoPre>;
  38582. /**
  38583. * Observable event triggered each time an input event is received from the rendering canvas
  38584. */
  38585. onPointerObservable: Observable<PointerInfo>;
  38586. /**
  38587. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38588. */
  38589. get unTranslatedPointer(): Vector2;
  38590. /**
  38591. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38592. */
  38593. static get DragMovementThreshold(): number;
  38594. static set DragMovementThreshold(value: number);
  38595. /**
  38596. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38597. */
  38598. static get LongPressDelay(): number;
  38599. static set LongPressDelay(value: number);
  38600. /**
  38601. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38602. */
  38603. static get DoubleClickDelay(): number;
  38604. static set DoubleClickDelay(value: number);
  38605. /** If you need to check double click without raising a single click at first click, enable this flag */
  38606. static get ExclusiveDoubleClickMode(): boolean;
  38607. static set ExclusiveDoubleClickMode(value: boolean);
  38608. /** @hidden */
  38609. _mirroredCameraPosition: Nullable<Vector3>;
  38610. /**
  38611. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38612. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38613. */
  38614. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38615. /**
  38616. * Observable event triggered each time an keyboard event is received from the hosting window
  38617. */
  38618. onKeyboardObservable: Observable<KeyboardInfo>;
  38619. private _useRightHandedSystem;
  38620. /**
  38621. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38622. */
  38623. set useRightHandedSystem(value: boolean);
  38624. get useRightHandedSystem(): boolean;
  38625. private _timeAccumulator;
  38626. private _currentStepId;
  38627. private _currentInternalStep;
  38628. /**
  38629. * Sets the step Id used by deterministic lock step
  38630. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38631. * @param newStepId defines the step Id
  38632. */
  38633. setStepId(newStepId: number): void;
  38634. /**
  38635. * Gets the step Id used by deterministic lock step
  38636. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38637. * @returns the step Id
  38638. */
  38639. getStepId(): number;
  38640. /**
  38641. * Gets the internal step used by deterministic lock step
  38642. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38643. * @returns the internal step
  38644. */
  38645. getInternalStep(): number;
  38646. private _fogEnabled;
  38647. /**
  38648. * Gets or sets a boolean indicating if fog is enabled on this scene
  38649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38650. * (Default is true)
  38651. */
  38652. set fogEnabled(value: boolean);
  38653. get fogEnabled(): boolean;
  38654. private _fogMode;
  38655. /**
  38656. * Gets or sets the fog mode to use
  38657. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38658. * | mode | value |
  38659. * | --- | --- |
  38660. * | FOGMODE_NONE | 0 |
  38661. * | FOGMODE_EXP | 1 |
  38662. * | FOGMODE_EXP2 | 2 |
  38663. * | FOGMODE_LINEAR | 3 |
  38664. */
  38665. set fogMode(value: number);
  38666. get fogMode(): number;
  38667. /**
  38668. * Gets or sets the fog color to use
  38669. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38670. * (Default is Color3(0.2, 0.2, 0.3))
  38671. */
  38672. fogColor: Color3;
  38673. /**
  38674. * Gets or sets the fog density to use
  38675. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38676. * (Default is 0.1)
  38677. */
  38678. fogDensity: number;
  38679. /**
  38680. * Gets or sets the fog start distance to use
  38681. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38682. * (Default is 0)
  38683. */
  38684. fogStart: number;
  38685. /**
  38686. * Gets or sets the fog end distance to use
  38687. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38688. * (Default is 1000)
  38689. */
  38690. fogEnd: number;
  38691. private _shadowsEnabled;
  38692. /**
  38693. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38694. */
  38695. set shadowsEnabled(value: boolean);
  38696. get shadowsEnabled(): boolean;
  38697. private _lightsEnabled;
  38698. /**
  38699. * Gets or sets a boolean indicating if lights are enabled on this scene
  38700. */
  38701. set lightsEnabled(value: boolean);
  38702. get lightsEnabled(): boolean;
  38703. /** All of the active cameras added to this scene. */
  38704. activeCameras: Camera[];
  38705. /** @hidden */
  38706. _activeCamera: Nullable<Camera>;
  38707. /** Gets or sets the current active camera */
  38708. get activeCamera(): Nullable<Camera>;
  38709. set activeCamera(value: Nullable<Camera>);
  38710. private _defaultMaterial;
  38711. /** The default material used on meshes when no material is affected */
  38712. get defaultMaterial(): Material;
  38713. /** The default material used on meshes when no material is affected */
  38714. set defaultMaterial(value: Material);
  38715. private _texturesEnabled;
  38716. /**
  38717. * Gets or sets a boolean indicating if textures are enabled on this scene
  38718. */
  38719. set texturesEnabled(value: boolean);
  38720. get texturesEnabled(): boolean;
  38721. /**
  38722. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38723. */
  38724. physicsEnabled: boolean;
  38725. /**
  38726. * Gets or sets a boolean indicating if particles are enabled on this scene
  38727. */
  38728. particlesEnabled: boolean;
  38729. /**
  38730. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38731. */
  38732. spritesEnabled: boolean;
  38733. private _skeletonsEnabled;
  38734. /**
  38735. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38736. */
  38737. set skeletonsEnabled(value: boolean);
  38738. get skeletonsEnabled(): boolean;
  38739. /**
  38740. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38741. */
  38742. lensFlaresEnabled: boolean;
  38743. /**
  38744. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38746. */
  38747. collisionsEnabled: boolean;
  38748. private _collisionCoordinator;
  38749. /** @hidden */
  38750. get collisionCoordinator(): ICollisionCoordinator;
  38751. /**
  38752. * Defines the gravity applied to this scene (used only for collisions)
  38753. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38754. */
  38755. gravity: Vector3;
  38756. /**
  38757. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38758. */
  38759. postProcessesEnabled: boolean;
  38760. /**
  38761. * The list of postprocesses added to the scene
  38762. */
  38763. postProcesses: PostProcess[];
  38764. /**
  38765. * Gets the current postprocess manager
  38766. */
  38767. postProcessManager: PostProcessManager;
  38768. /**
  38769. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38770. */
  38771. renderTargetsEnabled: boolean;
  38772. /**
  38773. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38774. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38775. */
  38776. dumpNextRenderTargets: boolean;
  38777. /**
  38778. * The list of user defined render targets added to the scene
  38779. */
  38780. customRenderTargets: RenderTargetTexture[];
  38781. /**
  38782. * Defines if texture loading must be delayed
  38783. * If true, textures will only be loaded when they need to be rendered
  38784. */
  38785. useDelayedTextureLoading: boolean;
  38786. /**
  38787. * Gets the list of meshes imported to the scene through SceneLoader
  38788. */
  38789. importedMeshesFiles: String[];
  38790. /**
  38791. * Gets or sets a boolean indicating if probes are enabled on this scene
  38792. */
  38793. probesEnabled: boolean;
  38794. /**
  38795. * Gets or sets the current offline provider to use to store scene data
  38796. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38797. */
  38798. offlineProvider: IOfflineProvider;
  38799. /**
  38800. * Gets or sets the action manager associated with the scene
  38801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38802. */
  38803. actionManager: AbstractActionManager;
  38804. private _meshesForIntersections;
  38805. /**
  38806. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38807. */
  38808. proceduralTexturesEnabled: boolean;
  38809. private _engine;
  38810. private _totalVertices;
  38811. /** @hidden */
  38812. _activeIndices: PerfCounter;
  38813. /** @hidden */
  38814. _activeParticles: PerfCounter;
  38815. /** @hidden */
  38816. _activeBones: PerfCounter;
  38817. private _animationRatio;
  38818. /** @hidden */
  38819. _animationTimeLast: number;
  38820. /** @hidden */
  38821. _animationTime: number;
  38822. /**
  38823. * Gets or sets a general scale for animation speed
  38824. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38825. */
  38826. animationTimeScale: number;
  38827. /** @hidden */
  38828. _cachedMaterial: Nullable<Material>;
  38829. /** @hidden */
  38830. _cachedEffect: Nullable<Effect>;
  38831. /** @hidden */
  38832. _cachedVisibility: Nullable<number>;
  38833. private _renderId;
  38834. private _frameId;
  38835. private _executeWhenReadyTimeoutId;
  38836. private _intermediateRendering;
  38837. private _viewUpdateFlag;
  38838. private _projectionUpdateFlag;
  38839. /** @hidden */
  38840. _toBeDisposed: Nullable<IDisposable>[];
  38841. private _activeRequests;
  38842. /** @hidden */
  38843. _pendingData: any[];
  38844. private _isDisposed;
  38845. /**
  38846. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38847. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38848. */
  38849. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38850. private _activeMeshes;
  38851. private _processedMaterials;
  38852. private _renderTargets;
  38853. /** @hidden */
  38854. _activeParticleSystems: SmartArray<IParticleSystem>;
  38855. private _activeSkeletons;
  38856. private _softwareSkinnedMeshes;
  38857. private _renderingManager;
  38858. /** @hidden */
  38859. _activeAnimatables: Animatable[];
  38860. private _transformMatrix;
  38861. private _sceneUbo;
  38862. /** @hidden */
  38863. _viewMatrix: Matrix;
  38864. private _projectionMatrix;
  38865. /** @hidden */
  38866. _forcedViewPosition: Nullable<Vector3>;
  38867. /** @hidden */
  38868. _frustumPlanes: Plane[];
  38869. /**
  38870. * Gets the list of frustum planes (built from the active camera)
  38871. */
  38872. get frustumPlanes(): Plane[];
  38873. /**
  38874. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38875. * This is useful if there are more lights that the maximum simulteanous authorized
  38876. */
  38877. requireLightSorting: boolean;
  38878. /** @hidden */
  38879. readonly useMaterialMeshMap: boolean;
  38880. /** @hidden */
  38881. readonly useClonedMeshMap: boolean;
  38882. private _externalData;
  38883. private _uid;
  38884. /**
  38885. * @hidden
  38886. * Backing store of defined scene components.
  38887. */
  38888. _components: ISceneComponent[];
  38889. /**
  38890. * @hidden
  38891. * Backing store of defined scene components.
  38892. */
  38893. _serializableComponents: ISceneSerializableComponent[];
  38894. /**
  38895. * List of components to register on the next registration step.
  38896. */
  38897. private _transientComponents;
  38898. /**
  38899. * Registers the transient components if needed.
  38900. */
  38901. private _registerTransientComponents;
  38902. /**
  38903. * @hidden
  38904. * Add a component to the scene.
  38905. * Note that the ccomponent could be registered on th next frame if this is called after
  38906. * the register component stage.
  38907. * @param component Defines the component to add to the scene
  38908. */
  38909. _addComponent(component: ISceneComponent): void;
  38910. /**
  38911. * @hidden
  38912. * Gets a component from the scene.
  38913. * @param name defines the name of the component to retrieve
  38914. * @returns the component or null if not present
  38915. */
  38916. _getComponent(name: string): Nullable<ISceneComponent>;
  38917. /**
  38918. * @hidden
  38919. * Defines the actions happening before camera updates.
  38920. */
  38921. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38922. /**
  38923. * @hidden
  38924. * Defines the actions happening before clear the canvas.
  38925. */
  38926. _beforeClearStage: Stage<SimpleStageAction>;
  38927. /**
  38928. * @hidden
  38929. * Defines the actions when collecting render targets for the frame.
  38930. */
  38931. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38932. /**
  38933. * @hidden
  38934. * Defines the actions happening for one camera in the frame.
  38935. */
  38936. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38937. /**
  38938. * @hidden
  38939. * Defines the actions happening during the per mesh ready checks.
  38940. */
  38941. _isReadyForMeshStage: Stage<MeshStageAction>;
  38942. /**
  38943. * @hidden
  38944. * Defines the actions happening before evaluate active mesh checks.
  38945. */
  38946. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38947. /**
  38948. * @hidden
  38949. * Defines the actions happening during the evaluate sub mesh checks.
  38950. */
  38951. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38952. /**
  38953. * @hidden
  38954. * Defines the actions happening during the active mesh stage.
  38955. */
  38956. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38957. /**
  38958. * @hidden
  38959. * Defines the actions happening during the per camera render target step.
  38960. */
  38961. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38962. /**
  38963. * @hidden
  38964. * Defines the actions happening just before the active camera is drawing.
  38965. */
  38966. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38967. /**
  38968. * @hidden
  38969. * Defines the actions happening just before a render target is drawing.
  38970. */
  38971. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38972. /**
  38973. * @hidden
  38974. * Defines the actions happening just before a rendering group is drawing.
  38975. */
  38976. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38977. /**
  38978. * @hidden
  38979. * Defines the actions happening just before a mesh is drawing.
  38980. */
  38981. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38982. /**
  38983. * @hidden
  38984. * Defines the actions happening just after a mesh has been drawn.
  38985. */
  38986. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38987. /**
  38988. * @hidden
  38989. * Defines the actions happening just after a rendering group has been drawn.
  38990. */
  38991. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38992. /**
  38993. * @hidden
  38994. * Defines the actions happening just after the active camera has been drawn.
  38995. */
  38996. _afterCameraDrawStage: Stage<CameraStageAction>;
  38997. /**
  38998. * @hidden
  38999. * Defines the actions happening just after a render target has been drawn.
  39000. */
  39001. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39002. /**
  39003. * @hidden
  39004. * Defines the actions happening just after rendering all cameras and computing intersections.
  39005. */
  39006. _afterRenderStage: Stage<SimpleStageAction>;
  39007. /**
  39008. * @hidden
  39009. * Defines the actions happening when a pointer move event happens.
  39010. */
  39011. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39012. /**
  39013. * @hidden
  39014. * Defines the actions happening when a pointer down event happens.
  39015. */
  39016. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39017. /**
  39018. * @hidden
  39019. * Defines the actions happening when a pointer up event happens.
  39020. */
  39021. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39022. /**
  39023. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39024. */
  39025. private geometriesByUniqueId;
  39026. /**
  39027. * Creates a new Scene
  39028. * @param engine defines the engine to use to render this scene
  39029. * @param options defines the scene options
  39030. */
  39031. constructor(engine: Engine, options?: SceneOptions);
  39032. /**
  39033. * Gets a string idenfifying the name of the class
  39034. * @returns "Scene" string
  39035. */
  39036. getClassName(): string;
  39037. private _defaultMeshCandidates;
  39038. /**
  39039. * @hidden
  39040. */
  39041. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39042. private _defaultSubMeshCandidates;
  39043. /**
  39044. * @hidden
  39045. */
  39046. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39047. /**
  39048. * Sets the default candidate providers for the scene.
  39049. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39050. * and getCollidingSubMeshCandidates to their default function
  39051. */
  39052. setDefaultCandidateProviders(): void;
  39053. /**
  39054. * Gets the mesh that is currently under the pointer
  39055. */
  39056. get meshUnderPointer(): Nullable<AbstractMesh>;
  39057. /**
  39058. * Gets or sets the current on-screen X position of the pointer
  39059. */
  39060. get pointerX(): number;
  39061. set pointerX(value: number);
  39062. /**
  39063. * Gets or sets the current on-screen Y position of the pointer
  39064. */
  39065. get pointerY(): number;
  39066. set pointerY(value: number);
  39067. /**
  39068. * Gets the cached material (ie. the latest rendered one)
  39069. * @returns the cached material
  39070. */
  39071. getCachedMaterial(): Nullable<Material>;
  39072. /**
  39073. * Gets the cached effect (ie. the latest rendered one)
  39074. * @returns the cached effect
  39075. */
  39076. getCachedEffect(): Nullable<Effect>;
  39077. /**
  39078. * Gets the cached visibility state (ie. the latest rendered one)
  39079. * @returns the cached visibility state
  39080. */
  39081. getCachedVisibility(): Nullable<number>;
  39082. /**
  39083. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39084. * @param material defines the current material
  39085. * @param effect defines the current effect
  39086. * @param visibility defines the current visibility state
  39087. * @returns true if one parameter is not cached
  39088. */
  39089. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39090. /**
  39091. * Gets the engine associated with the scene
  39092. * @returns an Engine
  39093. */
  39094. getEngine(): Engine;
  39095. /**
  39096. * Gets the total number of vertices rendered per frame
  39097. * @returns the total number of vertices rendered per frame
  39098. */
  39099. getTotalVertices(): number;
  39100. /**
  39101. * Gets the performance counter for total vertices
  39102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39103. */
  39104. get totalVerticesPerfCounter(): PerfCounter;
  39105. /**
  39106. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39107. * @returns the total number of active indices rendered per frame
  39108. */
  39109. getActiveIndices(): number;
  39110. /**
  39111. * Gets the performance counter for active indices
  39112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39113. */
  39114. get totalActiveIndicesPerfCounter(): PerfCounter;
  39115. /**
  39116. * Gets the total number of active particles rendered per frame
  39117. * @returns the total number of active particles rendered per frame
  39118. */
  39119. getActiveParticles(): number;
  39120. /**
  39121. * Gets the performance counter for active particles
  39122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39123. */
  39124. get activeParticlesPerfCounter(): PerfCounter;
  39125. /**
  39126. * Gets the total number of active bones rendered per frame
  39127. * @returns the total number of active bones rendered per frame
  39128. */
  39129. getActiveBones(): number;
  39130. /**
  39131. * Gets the performance counter for active bones
  39132. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39133. */
  39134. get activeBonesPerfCounter(): PerfCounter;
  39135. /**
  39136. * Gets the array of active meshes
  39137. * @returns an array of AbstractMesh
  39138. */
  39139. getActiveMeshes(): SmartArray<AbstractMesh>;
  39140. /**
  39141. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39142. * @returns a number
  39143. */
  39144. getAnimationRatio(): number;
  39145. /**
  39146. * Gets an unique Id for the current render phase
  39147. * @returns a number
  39148. */
  39149. getRenderId(): number;
  39150. /**
  39151. * Gets an unique Id for the current frame
  39152. * @returns a number
  39153. */
  39154. getFrameId(): number;
  39155. /** Call this function if you want to manually increment the render Id*/
  39156. incrementRenderId(): void;
  39157. private _createUbo;
  39158. /**
  39159. * Use this method to simulate a pointer move on a mesh
  39160. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39161. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39162. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39163. * @returns the current scene
  39164. */
  39165. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39166. /**
  39167. * Use this method to simulate a pointer down on a mesh
  39168. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39169. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39170. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39171. * @returns the current scene
  39172. */
  39173. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39174. /**
  39175. * Use this method to simulate a pointer up on a mesh
  39176. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39177. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39178. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39179. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39180. * @returns the current scene
  39181. */
  39182. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39183. /**
  39184. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39185. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39186. * @returns true if the pointer was captured
  39187. */
  39188. isPointerCaptured(pointerId?: number): boolean;
  39189. /**
  39190. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39191. * @param attachUp defines if you want to attach events to pointerup
  39192. * @param attachDown defines if you want to attach events to pointerdown
  39193. * @param attachMove defines if you want to attach events to pointermove
  39194. */
  39195. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39196. /** Detaches all event handlers*/
  39197. detachControl(): void;
  39198. /**
  39199. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39200. * Delay loaded resources are not taking in account
  39201. * @return true if all required resources are ready
  39202. */
  39203. isReady(): boolean;
  39204. /** Resets all cached information relative to material (including effect and visibility) */
  39205. resetCachedMaterial(): void;
  39206. /**
  39207. * Registers a function to be called before every frame render
  39208. * @param func defines the function to register
  39209. */
  39210. registerBeforeRender(func: () => void): void;
  39211. /**
  39212. * Unregisters a function called before every frame render
  39213. * @param func defines the function to unregister
  39214. */
  39215. unregisterBeforeRender(func: () => void): void;
  39216. /**
  39217. * Registers a function to be called after every frame render
  39218. * @param func defines the function to register
  39219. */
  39220. registerAfterRender(func: () => void): void;
  39221. /**
  39222. * Unregisters a function called after every frame render
  39223. * @param func defines the function to unregister
  39224. */
  39225. unregisterAfterRender(func: () => void): void;
  39226. private _executeOnceBeforeRender;
  39227. /**
  39228. * The provided function will run before render once and will be disposed afterwards.
  39229. * A timeout delay can be provided so that the function will be executed in N ms.
  39230. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39231. * @param func The function to be executed.
  39232. * @param timeout optional delay in ms
  39233. */
  39234. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39235. /** @hidden */
  39236. _addPendingData(data: any): void;
  39237. /** @hidden */
  39238. _removePendingData(data: any): void;
  39239. /**
  39240. * Returns the number of items waiting to be loaded
  39241. * @returns the number of items waiting to be loaded
  39242. */
  39243. getWaitingItemsCount(): number;
  39244. /**
  39245. * Returns a boolean indicating if the scene is still loading data
  39246. */
  39247. get isLoading(): boolean;
  39248. /**
  39249. * Registers a function to be executed when the scene is ready
  39250. * @param {Function} func - the function to be executed
  39251. */
  39252. executeWhenReady(func: () => void): void;
  39253. /**
  39254. * Returns a promise that resolves when the scene is ready
  39255. * @returns A promise that resolves when the scene is ready
  39256. */
  39257. whenReadyAsync(): Promise<void>;
  39258. /** @hidden */
  39259. _checkIsReady(): void;
  39260. /**
  39261. * Gets all animatable attached to the scene
  39262. */
  39263. get animatables(): Animatable[];
  39264. /**
  39265. * Resets the last animation time frame.
  39266. * Useful to override when animations start running when loading a scene for the first time.
  39267. */
  39268. resetLastAnimationTimeFrame(): void;
  39269. /**
  39270. * Gets the current view matrix
  39271. * @returns a Matrix
  39272. */
  39273. getViewMatrix(): Matrix;
  39274. /**
  39275. * Gets the current projection matrix
  39276. * @returns a Matrix
  39277. */
  39278. getProjectionMatrix(): Matrix;
  39279. /**
  39280. * Gets the current transform matrix
  39281. * @returns a Matrix made of View * Projection
  39282. */
  39283. getTransformMatrix(): Matrix;
  39284. /**
  39285. * Sets the current transform matrix
  39286. * @param viewL defines the View matrix to use
  39287. * @param projectionL defines the Projection matrix to use
  39288. * @param viewR defines the right View matrix to use (if provided)
  39289. * @param projectionR defines the right Projection matrix to use (if provided)
  39290. */
  39291. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39292. /**
  39293. * Gets the uniform buffer used to store scene data
  39294. * @returns a UniformBuffer
  39295. */
  39296. getSceneUniformBuffer(): UniformBuffer;
  39297. /**
  39298. * Gets an unique (relatively to the current scene) Id
  39299. * @returns an unique number for the scene
  39300. */
  39301. getUniqueId(): number;
  39302. /**
  39303. * Add a mesh to the list of scene's meshes
  39304. * @param newMesh defines the mesh to add
  39305. * @param recursive if all child meshes should also be added to the scene
  39306. */
  39307. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39308. /**
  39309. * Remove a mesh for the list of scene's meshes
  39310. * @param toRemove defines the mesh to remove
  39311. * @param recursive if all child meshes should also be removed from the scene
  39312. * @returns the index where the mesh was in the mesh list
  39313. */
  39314. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39315. /**
  39316. * Add a transform node to the list of scene's transform nodes
  39317. * @param newTransformNode defines the transform node to add
  39318. */
  39319. addTransformNode(newTransformNode: TransformNode): void;
  39320. /**
  39321. * Remove a transform node for the list of scene's transform nodes
  39322. * @param toRemove defines the transform node to remove
  39323. * @returns the index where the transform node was in the transform node list
  39324. */
  39325. removeTransformNode(toRemove: TransformNode): number;
  39326. /**
  39327. * Remove a skeleton for the list of scene's skeletons
  39328. * @param toRemove defines the skeleton to remove
  39329. * @returns the index where the skeleton was in the skeleton list
  39330. */
  39331. removeSkeleton(toRemove: Skeleton): number;
  39332. /**
  39333. * Remove a morph target for the list of scene's morph targets
  39334. * @param toRemove defines the morph target to remove
  39335. * @returns the index where the morph target was in the morph target list
  39336. */
  39337. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39338. /**
  39339. * Remove a light for the list of scene's lights
  39340. * @param toRemove defines the light to remove
  39341. * @returns the index where the light was in the light list
  39342. */
  39343. removeLight(toRemove: Light): number;
  39344. /**
  39345. * Remove a camera for the list of scene's cameras
  39346. * @param toRemove defines the camera to remove
  39347. * @returns the index where the camera was in the camera list
  39348. */
  39349. removeCamera(toRemove: Camera): number;
  39350. /**
  39351. * Remove a particle system for the list of scene's particle systems
  39352. * @param toRemove defines the particle system to remove
  39353. * @returns the index where the particle system was in the particle system list
  39354. */
  39355. removeParticleSystem(toRemove: IParticleSystem): number;
  39356. /**
  39357. * Remove a animation for the list of scene's animations
  39358. * @param toRemove defines the animation to remove
  39359. * @returns the index where the animation was in the animation list
  39360. */
  39361. removeAnimation(toRemove: Animation): number;
  39362. /**
  39363. * Will stop the animation of the given target
  39364. * @param target - the target
  39365. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39366. * @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)
  39367. */
  39368. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39369. /**
  39370. * Removes the given animation group from this scene.
  39371. * @param toRemove The animation group to remove
  39372. * @returns The index of the removed animation group
  39373. */
  39374. removeAnimationGroup(toRemove: AnimationGroup): number;
  39375. /**
  39376. * Removes the given multi-material from this scene.
  39377. * @param toRemove The multi-material to remove
  39378. * @returns The index of the removed multi-material
  39379. */
  39380. removeMultiMaterial(toRemove: MultiMaterial): number;
  39381. /**
  39382. * Removes the given material from this scene.
  39383. * @param toRemove The material to remove
  39384. * @returns The index of the removed material
  39385. */
  39386. removeMaterial(toRemove: Material): number;
  39387. /**
  39388. * Removes the given action manager from this scene.
  39389. * @param toRemove The action manager to remove
  39390. * @returns The index of the removed action manager
  39391. */
  39392. removeActionManager(toRemove: AbstractActionManager): number;
  39393. /**
  39394. * Removes the given texture from this scene.
  39395. * @param toRemove The texture to remove
  39396. * @returns The index of the removed texture
  39397. */
  39398. removeTexture(toRemove: BaseTexture): number;
  39399. /**
  39400. * Adds the given light to this scene
  39401. * @param newLight The light to add
  39402. */
  39403. addLight(newLight: Light): void;
  39404. /**
  39405. * Sorts the list list based on light priorities
  39406. */
  39407. sortLightsByPriority(): void;
  39408. /**
  39409. * Adds the given camera to this scene
  39410. * @param newCamera The camera to add
  39411. */
  39412. addCamera(newCamera: Camera): void;
  39413. /**
  39414. * Adds the given skeleton to this scene
  39415. * @param newSkeleton The skeleton to add
  39416. */
  39417. addSkeleton(newSkeleton: Skeleton): void;
  39418. /**
  39419. * Adds the given particle system to this scene
  39420. * @param newParticleSystem The particle system to add
  39421. */
  39422. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39423. /**
  39424. * Adds the given animation to this scene
  39425. * @param newAnimation The animation to add
  39426. */
  39427. addAnimation(newAnimation: Animation): void;
  39428. /**
  39429. * Adds the given animation group to this scene.
  39430. * @param newAnimationGroup The animation group to add
  39431. */
  39432. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39433. /**
  39434. * Adds the given multi-material to this scene
  39435. * @param newMultiMaterial The multi-material to add
  39436. */
  39437. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39438. /**
  39439. * Adds the given material to this scene
  39440. * @param newMaterial The material to add
  39441. */
  39442. addMaterial(newMaterial: Material): void;
  39443. /**
  39444. * Adds the given morph target to this scene
  39445. * @param newMorphTargetManager The morph target to add
  39446. */
  39447. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39448. /**
  39449. * Adds the given geometry to this scene
  39450. * @param newGeometry The geometry to add
  39451. */
  39452. addGeometry(newGeometry: Geometry): void;
  39453. /**
  39454. * Adds the given action manager to this scene
  39455. * @param newActionManager The action manager to add
  39456. */
  39457. addActionManager(newActionManager: AbstractActionManager): void;
  39458. /**
  39459. * Adds the given texture to this scene.
  39460. * @param newTexture The texture to add
  39461. */
  39462. addTexture(newTexture: BaseTexture): void;
  39463. /**
  39464. * Switch active camera
  39465. * @param newCamera defines the new active camera
  39466. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39467. */
  39468. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39469. /**
  39470. * sets the active camera of the scene using its ID
  39471. * @param id defines the camera's ID
  39472. * @return the new active camera or null if none found.
  39473. */
  39474. setActiveCameraByID(id: string): Nullable<Camera>;
  39475. /**
  39476. * sets the active camera of the scene using its name
  39477. * @param name defines the camera's name
  39478. * @returns the new active camera or null if none found.
  39479. */
  39480. setActiveCameraByName(name: string): Nullable<Camera>;
  39481. /**
  39482. * get an animation group using its name
  39483. * @param name defines the material's name
  39484. * @return the animation group or null if none found.
  39485. */
  39486. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39487. /**
  39488. * Get a material using its unique id
  39489. * @param uniqueId defines the material's unique id
  39490. * @return the material or null if none found.
  39491. */
  39492. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39493. /**
  39494. * get a material using its id
  39495. * @param id defines the material's ID
  39496. * @return the material or null if none found.
  39497. */
  39498. getMaterialByID(id: string): Nullable<Material>;
  39499. /**
  39500. * Gets a the last added material using a given id
  39501. * @param id defines the material's ID
  39502. * @return the last material with the given id or null if none found.
  39503. */
  39504. getLastMaterialByID(id: string): Nullable<Material>;
  39505. /**
  39506. * Gets a material using its name
  39507. * @param name defines the material's name
  39508. * @return the material or null if none found.
  39509. */
  39510. getMaterialByName(name: string): Nullable<Material>;
  39511. /**
  39512. * Get a texture using its unique id
  39513. * @param uniqueId defines the texture's unique id
  39514. * @return the texture or null if none found.
  39515. */
  39516. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39517. /**
  39518. * Gets a camera using its id
  39519. * @param id defines the id to look for
  39520. * @returns the camera or null if not found
  39521. */
  39522. getCameraByID(id: string): Nullable<Camera>;
  39523. /**
  39524. * Gets a camera using its unique id
  39525. * @param uniqueId defines the unique id to look for
  39526. * @returns the camera or null if not found
  39527. */
  39528. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39529. /**
  39530. * Gets a camera using its name
  39531. * @param name defines the camera's name
  39532. * @return the camera or null if none found.
  39533. */
  39534. getCameraByName(name: string): Nullable<Camera>;
  39535. /**
  39536. * Gets a bone using its id
  39537. * @param id defines the bone's id
  39538. * @return the bone or null if not found
  39539. */
  39540. getBoneByID(id: string): Nullable<Bone>;
  39541. /**
  39542. * Gets a bone using its id
  39543. * @param name defines the bone's name
  39544. * @return the bone or null if not found
  39545. */
  39546. getBoneByName(name: string): Nullable<Bone>;
  39547. /**
  39548. * Gets a light node using its name
  39549. * @param name defines the the light's name
  39550. * @return the light or null if none found.
  39551. */
  39552. getLightByName(name: string): Nullable<Light>;
  39553. /**
  39554. * Gets a light node using its id
  39555. * @param id defines the light's id
  39556. * @return the light or null if none found.
  39557. */
  39558. getLightByID(id: string): Nullable<Light>;
  39559. /**
  39560. * Gets a light node using its scene-generated unique ID
  39561. * @param uniqueId defines the light's unique id
  39562. * @return the light or null if none found.
  39563. */
  39564. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39565. /**
  39566. * Gets a particle system by id
  39567. * @param id defines the particle system id
  39568. * @return the corresponding system or null if none found
  39569. */
  39570. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39571. /**
  39572. * Gets a geometry using its ID
  39573. * @param id defines the geometry's id
  39574. * @return the geometry or null if none found.
  39575. */
  39576. getGeometryByID(id: string): Nullable<Geometry>;
  39577. private _getGeometryByUniqueID;
  39578. /**
  39579. * Add a new geometry to this scene
  39580. * @param geometry defines the geometry to be added to the scene.
  39581. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39582. * @return a boolean defining if the geometry was added or not
  39583. */
  39584. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39585. /**
  39586. * Removes an existing geometry
  39587. * @param geometry defines the geometry to be removed from the scene
  39588. * @return a boolean defining if the geometry was removed or not
  39589. */
  39590. removeGeometry(geometry: Geometry): boolean;
  39591. /**
  39592. * Gets the list of geometries attached to the scene
  39593. * @returns an array of Geometry
  39594. */
  39595. getGeometries(): Geometry[];
  39596. /**
  39597. * Gets the first added mesh found of a given ID
  39598. * @param id defines the id to search for
  39599. * @return the mesh found or null if not found at all
  39600. */
  39601. getMeshByID(id: string): Nullable<AbstractMesh>;
  39602. /**
  39603. * Gets a list of meshes using their id
  39604. * @param id defines the id to search for
  39605. * @returns a list of meshes
  39606. */
  39607. getMeshesByID(id: string): Array<AbstractMesh>;
  39608. /**
  39609. * Gets the first added transform node found of a given ID
  39610. * @param id defines the id to search for
  39611. * @return the found transform node or null if not found at all.
  39612. */
  39613. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39614. /**
  39615. * Gets a transform node with its auto-generated unique id
  39616. * @param uniqueId efines the unique id to search for
  39617. * @return the found transform node or null if not found at all.
  39618. */
  39619. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39620. /**
  39621. * Gets a list of transform nodes using their id
  39622. * @param id defines the id to search for
  39623. * @returns a list of transform nodes
  39624. */
  39625. getTransformNodesByID(id: string): Array<TransformNode>;
  39626. /**
  39627. * Gets a mesh with its auto-generated unique id
  39628. * @param uniqueId defines the unique id to search for
  39629. * @return the found mesh or null if not found at all.
  39630. */
  39631. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39632. /**
  39633. * Gets a the last added mesh using a given id
  39634. * @param id defines the id to search for
  39635. * @return the found mesh or null if not found at all.
  39636. */
  39637. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39638. /**
  39639. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39640. * @param id defines the id to search for
  39641. * @return the found node or null if not found at all
  39642. */
  39643. getLastEntryByID(id: string): Nullable<Node>;
  39644. /**
  39645. * Gets a node (Mesh, Camera, Light) using a given id
  39646. * @param id defines the id to search for
  39647. * @return the found node or null if not found at all
  39648. */
  39649. getNodeByID(id: string): Nullable<Node>;
  39650. /**
  39651. * Gets a node (Mesh, Camera, Light) using a given name
  39652. * @param name defines the name to search for
  39653. * @return the found node or null if not found at all.
  39654. */
  39655. getNodeByName(name: string): Nullable<Node>;
  39656. /**
  39657. * Gets a mesh using a given name
  39658. * @param name defines the name to search for
  39659. * @return the found mesh or null if not found at all.
  39660. */
  39661. getMeshByName(name: string): Nullable<AbstractMesh>;
  39662. /**
  39663. * Gets a transform node using a given name
  39664. * @param name defines the name to search for
  39665. * @return the found transform node or null if not found at all.
  39666. */
  39667. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39668. /**
  39669. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39670. * @param id defines the id to search for
  39671. * @return the found skeleton or null if not found at all.
  39672. */
  39673. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39674. /**
  39675. * Gets a skeleton using a given auto generated unique id
  39676. * @param uniqueId defines the unique id to search for
  39677. * @return the found skeleton or null if not found at all.
  39678. */
  39679. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39680. /**
  39681. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39682. * @param id defines the id to search for
  39683. * @return the found skeleton or null if not found at all.
  39684. */
  39685. getSkeletonById(id: string): Nullable<Skeleton>;
  39686. /**
  39687. * Gets a skeleton using a given name
  39688. * @param name defines the name to search for
  39689. * @return the found skeleton or null if not found at all.
  39690. */
  39691. getSkeletonByName(name: string): Nullable<Skeleton>;
  39692. /**
  39693. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39694. * @param id defines the id to search for
  39695. * @return the found morph target manager or null if not found at all.
  39696. */
  39697. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39698. /**
  39699. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39700. * @param id defines the id to search for
  39701. * @return the found morph target or null if not found at all.
  39702. */
  39703. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39704. /**
  39705. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39706. * @param name defines the name to search for
  39707. * @return the found morph target or null if not found at all.
  39708. */
  39709. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39710. /**
  39711. * Gets a boolean indicating if the given mesh is active
  39712. * @param mesh defines the mesh to look for
  39713. * @returns true if the mesh is in the active list
  39714. */
  39715. isActiveMesh(mesh: AbstractMesh): boolean;
  39716. /**
  39717. * Return a unique id as a string which can serve as an identifier for the scene
  39718. */
  39719. get uid(): string;
  39720. /**
  39721. * Add an externaly attached data from its key.
  39722. * This method call will fail and return false, if such key already exists.
  39723. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39724. * @param key the unique key that identifies the data
  39725. * @param data the data object to associate to the key for this Engine instance
  39726. * @return true if no such key were already present and the data was added successfully, false otherwise
  39727. */
  39728. addExternalData<T>(key: string, data: T): boolean;
  39729. /**
  39730. * Get an externaly attached data from its key
  39731. * @param key the unique key that identifies the data
  39732. * @return the associated data, if present (can be null), or undefined if not present
  39733. */
  39734. getExternalData<T>(key: string): Nullable<T>;
  39735. /**
  39736. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39737. * @param key the unique key that identifies the data
  39738. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39739. * @return the associated data, can be null if the factory returned null.
  39740. */
  39741. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39742. /**
  39743. * Remove an externaly attached data from the Engine instance
  39744. * @param key the unique key that identifies the data
  39745. * @return true if the data was successfully removed, false if it doesn't exist
  39746. */
  39747. removeExternalData(key: string): boolean;
  39748. private _evaluateSubMesh;
  39749. /**
  39750. * Clear the processed materials smart array preventing retention point in material dispose.
  39751. */
  39752. freeProcessedMaterials(): void;
  39753. private _preventFreeActiveMeshesAndRenderingGroups;
  39754. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39755. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39756. * when disposing several meshes in a row or a hierarchy of meshes.
  39757. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39758. */
  39759. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39760. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39761. /**
  39762. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39763. */
  39764. freeActiveMeshes(): void;
  39765. /**
  39766. * Clear the info related to rendering groups preventing retention points during dispose.
  39767. */
  39768. freeRenderingGroups(): void;
  39769. /** @hidden */
  39770. _isInIntermediateRendering(): boolean;
  39771. /**
  39772. * Lambda returning the list of potentially active meshes.
  39773. */
  39774. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39775. /**
  39776. * Lambda returning the list of potentially active sub meshes.
  39777. */
  39778. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39779. /**
  39780. * Lambda returning the list of potentially intersecting sub meshes.
  39781. */
  39782. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39783. /**
  39784. * Lambda returning the list of potentially colliding sub meshes.
  39785. */
  39786. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39787. private _activeMeshesFrozen;
  39788. private _skipEvaluateActiveMeshesCompletely;
  39789. /**
  39790. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39791. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39792. * @returns the current scene
  39793. */
  39794. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39795. /**
  39796. * Use this function to restart evaluating active meshes on every frame
  39797. * @returns the current scene
  39798. */
  39799. unfreezeActiveMeshes(): Scene;
  39800. private _evaluateActiveMeshes;
  39801. private _activeMesh;
  39802. /**
  39803. * Update the transform matrix to update from the current active camera
  39804. * @param force defines a boolean used to force the update even if cache is up to date
  39805. */
  39806. updateTransformMatrix(force?: boolean): void;
  39807. private _bindFrameBuffer;
  39808. /** @hidden */
  39809. _allowPostProcessClearColor: boolean;
  39810. /** @hidden */
  39811. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39812. private _processSubCameras;
  39813. private _checkIntersections;
  39814. /** @hidden */
  39815. _advancePhysicsEngineStep(step: number): void;
  39816. /**
  39817. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39818. */
  39819. getDeterministicFrameTime: () => number;
  39820. /** @hidden */
  39821. _animate(): void;
  39822. /** Execute all animations (for a frame) */
  39823. animate(): void;
  39824. /**
  39825. * Render the scene
  39826. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39827. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39828. */
  39829. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39830. /**
  39831. * Freeze all materials
  39832. * A frozen material will not be updatable but should be faster to render
  39833. */
  39834. freezeMaterials(): void;
  39835. /**
  39836. * Unfreeze all materials
  39837. * A frozen material will not be updatable but should be faster to render
  39838. */
  39839. unfreezeMaterials(): void;
  39840. /**
  39841. * Releases all held ressources
  39842. */
  39843. dispose(): void;
  39844. /**
  39845. * Gets if the scene is already disposed
  39846. */
  39847. get isDisposed(): boolean;
  39848. /**
  39849. * Call this function to reduce memory footprint of the scene.
  39850. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39851. */
  39852. clearCachedVertexData(): void;
  39853. /**
  39854. * This function will remove the local cached buffer data from texture.
  39855. * It will save memory but will prevent the texture from being rebuilt
  39856. */
  39857. cleanCachedTextureBuffer(): void;
  39858. /**
  39859. * Get the world extend vectors with an optional filter
  39860. *
  39861. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39862. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39863. */
  39864. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39865. min: Vector3;
  39866. max: Vector3;
  39867. };
  39868. /**
  39869. * Creates a ray that can be used to pick in the scene
  39870. * @param x defines the x coordinate of the origin (on-screen)
  39871. * @param y defines the y coordinate of the origin (on-screen)
  39872. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39873. * @param camera defines the camera to use for the picking
  39874. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39875. * @returns a Ray
  39876. */
  39877. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39878. /**
  39879. * Creates a ray that can be used to pick in the scene
  39880. * @param x defines the x coordinate of the origin (on-screen)
  39881. * @param y defines the y coordinate of the origin (on-screen)
  39882. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39883. * @param result defines the ray where to store the picking ray
  39884. * @param camera defines the camera to use for the picking
  39885. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39886. * @returns the current scene
  39887. */
  39888. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39889. /**
  39890. * Creates a ray that can be used to pick in the scene
  39891. * @param x defines the x coordinate of the origin (on-screen)
  39892. * @param y defines the y coordinate of the origin (on-screen)
  39893. * @param camera defines the camera to use for the picking
  39894. * @returns a Ray
  39895. */
  39896. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39897. /**
  39898. * Creates a ray that can be used to pick in the scene
  39899. * @param x defines the x coordinate of the origin (on-screen)
  39900. * @param y defines the y coordinate of the origin (on-screen)
  39901. * @param result defines the ray where to store the picking ray
  39902. * @param camera defines the camera to use for the picking
  39903. * @returns the current scene
  39904. */
  39905. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39906. /** Launch a ray to try to pick a mesh in the scene
  39907. * @param x position on screen
  39908. * @param y position on screen
  39909. * @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
  39910. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39911. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39912. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39913. * @returns a PickingInfo
  39914. */
  39915. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39916. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39917. * @param x position on screen
  39918. * @param y position on screen
  39919. * @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
  39920. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39921. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39922. * @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)
  39923. */
  39924. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39925. /** Use the given ray to pick a mesh in the scene
  39926. * @param ray The ray to use to pick meshes
  39927. * @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
  39928. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39929. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39930. * @returns a PickingInfo
  39931. */
  39932. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39933. /**
  39934. * Launch a ray to try to pick a mesh in the scene
  39935. * @param x X position on screen
  39936. * @param y Y position on screen
  39937. * @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
  39938. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39939. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39940. * @returns an array of PickingInfo
  39941. */
  39942. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39943. /**
  39944. * Launch a ray to try to pick a mesh in the scene
  39945. * @param ray Ray to use
  39946. * @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
  39947. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39948. * @returns an array of PickingInfo
  39949. */
  39950. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39951. /**
  39952. * Force the value of meshUnderPointer
  39953. * @param mesh defines the mesh to use
  39954. */
  39955. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39956. /**
  39957. * Gets the mesh under the pointer
  39958. * @returns a Mesh or null if no mesh is under the pointer
  39959. */
  39960. getPointerOverMesh(): Nullable<AbstractMesh>;
  39961. /** @hidden */
  39962. _rebuildGeometries(): void;
  39963. /** @hidden */
  39964. _rebuildTextures(): void;
  39965. private _getByTags;
  39966. /**
  39967. * Get a list of meshes by tags
  39968. * @param tagsQuery defines the tags query to use
  39969. * @param forEach defines a predicate used to filter results
  39970. * @returns an array of Mesh
  39971. */
  39972. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39973. /**
  39974. * Get a list of cameras by tags
  39975. * @param tagsQuery defines the tags query to use
  39976. * @param forEach defines a predicate used to filter results
  39977. * @returns an array of Camera
  39978. */
  39979. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39980. /**
  39981. * Get a list of lights by tags
  39982. * @param tagsQuery defines the tags query to use
  39983. * @param forEach defines a predicate used to filter results
  39984. * @returns an array of Light
  39985. */
  39986. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39987. /**
  39988. * Get a list of materials by tags
  39989. * @param tagsQuery defines the tags query to use
  39990. * @param forEach defines a predicate used to filter results
  39991. * @returns an array of Material
  39992. */
  39993. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39994. /**
  39995. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39996. * This allowed control for front to back rendering or reversly depending of the special needs.
  39997. *
  39998. * @param renderingGroupId The rendering group id corresponding to its index
  39999. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40000. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40001. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40002. */
  40003. 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;
  40004. /**
  40005. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40006. *
  40007. * @param renderingGroupId The rendering group id corresponding to its index
  40008. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40009. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40010. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40011. */
  40012. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40013. /**
  40014. * Gets the current auto clear configuration for one rendering group of the rendering
  40015. * manager.
  40016. * @param index the rendering group index to get the information for
  40017. * @returns The auto clear setup for the requested rendering group
  40018. */
  40019. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40020. private _blockMaterialDirtyMechanism;
  40021. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40022. get blockMaterialDirtyMechanism(): boolean;
  40023. set blockMaterialDirtyMechanism(value: boolean);
  40024. /**
  40025. * Will flag all materials as dirty to trigger new shader compilation
  40026. * @param flag defines the flag used to specify which material part must be marked as dirty
  40027. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40028. */
  40029. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40030. /** @hidden */
  40031. _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;
  40032. /** @hidden */
  40033. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40034. /** @hidden */
  40035. _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;
  40036. /** @hidden */
  40037. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40038. /** @hidden */
  40039. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40040. /** @hidden */
  40041. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40042. }
  40043. }
  40044. declare module BABYLON {
  40045. /**
  40046. * Set of assets to keep when moving a scene into an asset container.
  40047. */
  40048. export class KeepAssets extends AbstractScene {
  40049. }
  40050. /**
  40051. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40052. */
  40053. export class InstantiatedEntries {
  40054. /**
  40055. * List of new root nodes (eg. nodes with no parent)
  40056. */
  40057. rootNodes: TransformNode[];
  40058. /**
  40059. * List of new skeletons
  40060. */
  40061. skeletons: Skeleton[];
  40062. /**
  40063. * List of new animation groups
  40064. */
  40065. animationGroups: AnimationGroup[];
  40066. }
  40067. /**
  40068. * Container with a set of assets that can be added or removed from a scene.
  40069. */
  40070. export class AssetContainer extends AbstractScene {
  40071. private _wasAddedToScene;
  40072. /**
  40073. * The scene the AssetContainer belongs to.
  40074. */
  40075. scene: Scene;
  40076. /**
  40077. * Instantiates an AssetContainer.
  40078. * @param scene The scene the AssetContainer belongs to.
  40079. */
  40080. constructor(scene: Scene);
  40081. /**
  40082. * Instantiate or clone all meshes and add the new ones to the scene.
  40083. * Skeletons and animation groups will all be cloned
  40084. * @param nameFunction defines an optional function used to get new names for clones
  40085. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40086. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40087. */
  40088. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40089. /**
  40090. * Adds all the assets from the container to the scene.
  40091. */
  40092. addAllToScene(): void;
  40093. /**
  40094. * Removes all the assets in the container from the scene
  40095. */
  40096. removeAllFromScene(): void;
  40097. /**
  40098. * Disposes all the assets in the container
  40099. */
  40100. dispose(): void;
  40101. private _moveAssets;
  40102. /**
  40103. * Removes all the assets contained in the scene and adds them to the container.
  40104. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40105. */
  40106. moveAllFromScene(keepAssets?: KeepAssets): void;
  40107. /**
  40108. * 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.
  40109. * @returns the root mesh
  40110. */
  40111. createRootMesh(): Mesh;
  40112. /**
  40113. * Merge animations (direct and animation groups) from this asset container into a scene
  40114. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40115. * @param animatables set of animatables to retarget to a node from the scene
  40116. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40117. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40118. */
  40119. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40120. }
  40121. }
  40122. declare module BABYLON {
  40123. /**
  40124. * Defines how the parser contract is defined.
  40125. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40126. */
  40127. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40128. /**
  40129. * Defines how the individual parser contract is defined.
  40130. * These parser can parse an individual asset
  40131. */
  40132. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40133. /**
  40134. * Base class of the scene acting as a container for the different elements composing a scene.
  40135. * This class is dynamically extended by the different components of the scene increasing
  40136. * flexibility and reducing coupling
  40137. */
  40138. export abstract class AbstractScene {
  40139. /**
  40140. * Stores the list of available parsers in the application.
  40141. */
  40142. private static _BabylonFileParsers;
  40143. /**
  40144. * Stores the list of available individual parsers in the application.
  40145. */
  40146. private static _IndividualBabylonFileParsers;
  40147. /**
  40148. * Adds a parser in the list of available ones
  40149. * @param name Defines the name of the parser
  40150. * @param parser Defines the parser to add
  40151. */
  40152. static AddParser(name: string, parser: BabylonFileParser): void;
  40153. /**
  40154. * Gets a general parser from the list of avaialble ones
  40155. * @param name Defines the name of the parser
  40156. * @returns the requested parser or null
  40157. */
  40158. static GetParser(name: string): Nullable<BabylonFileParser>;
  40159. /**
  40160. * Adds n individual parser in the list of available ones
  40161. * @param name Defines the name of the parser
  40162. * @param parser Defines the parser to add
  40163. */
  40164. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40165. /**
  40166. * Gets an individual parser from the list of avaialble ones
  40167. * @param name Defines the name of the parser
  40168. * @returns the requested parser or null
  40169. */
  40170. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40171. /**
  40172. * Parser json data and populate both a scene and its associated container object
  40173. * @param jsonData Defines the data to parse
  40174. * @param scene Defines the scene to parse the data for
  40175. * @param container Defines the container attached to the parsing sequence
  40176. * @param rootUrl Defines the root url of the data
  40177. */
  40178. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40179. /**
  40180. * Gets the list of root nodes (ie. nodes with no parent)
  40181. */
  40182. rootNodes: Node[];
  40183. /** All of the cameras added to this scene
  40184. * @see http://doc.babylonjs.com/babylon101/cameras
  40185. */
  40186. cameras: Camera[];
  40187. /**
  40188. * All of the lights added to this scene
  40189. * @see http://doc.babylonjs.com/babylon101/lights
  40190. */
  40191. lights: Light[];
  40192. /**
  40193. * All of the (abstract) meshes added to this scene
  40194. */
  40195. meshes: AbstractMesh[];
  40196. /**
  40197. * The list of skeletons added to the scene
  40198. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40199. */
  40200. skeletons: Skeleton[];
  40201. /**
  40202. * All of the particle systems added to this scene
  40203. * @see http://doc.babylonjs.com/babylon101/particles
  40204. */
  40205. particleSystems: IParticleSystem[];
  40206. /**
  40207. * Gets a list of Animations associated with the scene
  40208. */
  40209. animations: Animation[];
  40210. /**
  40211. * All of the animation groups added to this scene
  40212. * @see http://doc.babylonjs.com/how_to/group
  40213. */
  40214. animationGroups: AnimationGroup[];
  40215. /**
  40216. * All of the multi-materials added to this scene
  40217. * @see http://doc.babylonjs.com/how_to/multi_materials
  40218. */
  40219. multiMaterials: MultiMaterial[];
  40220. /**
  40221. * All of the materials added to this scene
  40222. * In the context of a Scene, it is not supposed to be modified manually.
  40223. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40224. * Note also that the order of the Material within the array is not significant and might change.
  40225. * @see http://doc.babylonjs.com/babylon101/materials
  40226. */
  40227. materials: Material[];
  40228. /**
  40229. * The list of morph target managers added to the scene
  40230. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40231. */
  40232. morphTargetManagers: MorphTargetManager[];
  40233. /**
  40234. * The list of geometries used in the scene.
  40235. */
  40236. geometries: Geometry[];
  40237. /**
  40238. * All of the tranform nodes added to this scene
  40239. * In the context of a Scene, it is not supposed to be modified manually.
  40240. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40241. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40242. * @see http://doc.babylonjs.com/how_to/transformnode
  40243. */
  40244. transformNodes: TransformNode[];
  40245. /**
  40246. * ActionManagers available on the scene.
  40247. */
  40248. actionManagers: AbstractActionManager[];
  40249. /**
  40250. * Textures to keep.
  40251. */
  40252. textures: BaseTexture[];
  40253. /**
  40254. * Environment texture for the scene
  40255. */
  40256. environmentTexture: Nullable<BaseTexture>;
  40257. /**
  40258. * @returns all meshes, lights, cameras, transformNodes and bones
  40259. */
  40260. getNodes(): Array<Node>;
  40261. }
  40262. }
  40263. declare module BABYLON {
  40264. /**
  40265. * Interface used to define options for Sound class
  40266. */
  40267. export interface ISoundOptions {
  40268. /**
  40269. * Does the sound autoplay once loaded.
  40270. */
  40271. autoplay?: boolean;
  40272. /**
  40273. * Does the sound loop after it finishes playing once.
  40274. */
  40275. loop?: boolean;
  40276. /**
  40277. * Sound's volume
  40278. */
  40279. volume?: number;
  40280. /**
  40281. * Is it a spatial sound?
  40282. */
  40283. spatialSound?: boolean;
  40284. /**
  40285. * Maximum distance to hear that sound
  40286. */
  40287. maxDistance?: number;
  40288. /**
  40289. * Uses user defined attenuation function
  40290. */
  40291. useCustomAttenuation?: boolean;
  40292. /**
  40293. * Define the roll off factor of spatial sounds.
  40294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40295. */
  40296. rolloffFactor?: number;
  40297. /**
  40298. * Define the reference distance the sound should be heard perfectly.
  40299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40300. */
  40301. refDistance?: number;
  40302. /**
  40303. * Define the distance attenuation model the sound will follow.
  40304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40305. */
  40306. distanceModel?: string;
  40307. /**
  40308. * Defines the playback speed (1 by default)
  40309. */
  40310. playbackRate?: number;
  40311. /**
  40312. * Defines if the sound is from a streaming source
  40313. */
  40314. streaming?: boolean;
  40315. /**
  40316. * Defines an optional length (in seconds) inside the sound file
  40317. */
  40318. length?: number;
  40319. /**
  40320. * Defines an optional offset (in seconds) inside the sound file
  40321. */
  40322. offset?: number;
  40323. /**
  40324. * If true, URLs will not be required to state the audio file codec to use.
  40325. */
  40326. skipCodecCheck?: boolean;
  40327. }
  40328. /**
  40329. * Defines a sound that can be played in the application.
  40330. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40332. */
  40333. export class Sound {
  40334. /**
  40335. * The name of the sound in the scene.
  40336. */
  40337. name: string;
  40338. /**
  40339. * Does the sound autoplay once loaded.
  40340. */
  40341. autoplay: boolean;
  40342. /**
  40343. * Does the sound loop after it finishes playing once.
  40344. */
  40345. loop: boolean;
  40346. /**
  40347. * Does the sound use a custom attenuation curve to simulate the falloff
  40348. * happening when the source gets further away from the camera.
  40349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40350. */
  40351. useCustomAttenuation: boolean;
  40352. /**
  40353. * The sound track id this sound belongs to.
  40354. */
  40355. soundTrackId: number;
  40356. /**
  40357. * Is this sound currently played.
  40358. */
  40359. isPlaying: boolean;
  40360. /**
  40361. * Is this sound currently paused.
  40362. */
  40363. isPaused: boolean;
  40364. /**
  40365. * Does this sound enables spatial sound.
  40366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40367. */
  40368. spatialSound: boolean;
  40369. /**
  40370. * Define the reference distance the sound should be heard perfectly.
  40371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40372. */
  40373. refDistance: number;
  40374. /**
  40375. * Define the roll off factor of spatial sounds.
  40376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40377. */
  40378. rolloffFactor: number;
  40379. /**
  40380. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40382. */
  40383. maxDistance: number;
  40384. /**
  40385. * Define the distance attenuation model the sound will follow.
  40386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40387. */
  40388. distanceModel: string;
  40389. /**
  40390. * @hidden
  40391. * Back Compat
  40392. **/
  40393. onended: () => any;
  40394. /**
  40395. * Gets or sets an object used to store user defined information for the sound.
  40396. */
  40397. metadata: any;
  40398. /**
  40399. * Observable event when the current playing sound finishes.
  40400. */
  40401. onEndedObservable: Observable<Sound>;
  40402. private _panningModel;
  40403. private _playbackRate;
  40404. private _streaming;
  40405. private _startTime;
  40406. private _startOffset;
  40407. private _position;
  40408. /** @hidden */
  40409. _positionInEmitterSpace: boolean;
  40410. private _localDirection;
  40411. private _volume;
  40412. private _isReadyToPlay;
  40413. private _isDirectional;
  40414. private _readyToPlayCallback;
  40415. private _audioBuffer;
  40416. private _soundSource;
  40417. private _streamingSource;
  40418. private _soundPanner;
  40419. private _soundGain;
  40420. private _inputAudioNode;
  40421. private _outputAudioNode;
  40422. private _coneInnerAngle;
  40423. private _coneOuterAngle;
  40424. private _coneOuterGain;
  40425. private _scene;
  40426. private _connectedTransformNode;
  40427. private _customAttenuationFunction;
  40428. private _registerFunc;
  40429. private _isOutputConnected;
  40430. private _htmlAudioElement;
  40431. private _urlType;
  40432. private _length?;
  40433. private _offset?;
  40434. /** @hidden */
  40435. static _SceneComponentInitialization: (scene: Scene) => void;
  40436. /**
  40437. * Create a sound and attach it to a scene
  40438. * @param name Name of your sound
  40439. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40440. * @param scene defines the scene the sound belongs to
  40441. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40442. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40443. */
  40444. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40445. /**
  40446. * Release the sound and its associated resources
  40447. */
  40448. dispose(): void;
  40449. /**
  40450. * Gets if the sounds is ready to be played or not.
  40451. * @returns true if ready, otherwise false
  40452. */
  40453. isReady(): boolean;
  40454. private _soundLoaded;
  40455. /**
  40456. * Sets the data of the sound from an audiobuffer
  40457. * @param audioBuffer The audioBuffer containing the data
  40458. */
  40459. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40460. /**
  40461. * Updates the current sounds options such as maxdistance, loop...
  40462. * @param options A JSON object containing values named as the object properties
  40463. */
  40464. updateOptions(options: ISoundOptions): void;
  40465. private _createSpatialParameters;
  40466. private _updateSpatialParameters;
  40467. /**
  40468. * Switch the panning model to HRTF:
  40469. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40471. */
  40472. switchPanningModelToHRTF(): void;
  40473. /**
  40474. * Switch the panning model to Equal Power:
  40475. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40477. */
  40478. switchPanningModelToEqualPower(): void;
  40479. private _switchPanningModel;
  40480. /**
  40481. * Connect this sound to a sound track audio node like gain...
  40482. * @param soundTrackAudioNode the sound track audio node to connect to
  40483. */
  40484. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40485. /**
  40486. * Transform this sound into a directional source
  40487. * @param coneInnerAngle Size of the inner cone in degree
  40488. * @param coneOuterAngle Size of the outer cone in degree
  40489. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40490. */
  40491. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40492. /**
  40493. * Gets or sets the inner angle for the directional cone.
  40494. */
  40495. get directionalConeInnerAngle(): number;
  40496. /**
  40497. * Gets or sets the inner angle for the directional cone.
  40498. */
  40499. set directionalConeInnerAngle(value: number);
  40500. /**
  40501. * Gets or sets the outer angle for the directional cone.
  40502. */
  40503. get directionalConeOuterAngle(): number;
  40504. /**
  40505. * Gets or sets the outer angle for the directional cone.
  40506. */
  40507. set directionalConeOuterAngle(value: number);
  40508. /**
  40509. * Sets the position of the emitter if spatial sound is enabled
  40510. * @param newPosition Defines the new posisiton
  40511. */
  40512. setPosition(newPosition: Vector3): void;
  40513. /**
  40514. * Sets the local direction of the emitter if spatial sound is enabled
  40515. * @param newLocalDirection Defines the new local direction
  40516. */
  40517. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40518. private _updateDirection;
  40519. /** @hidden */
  40520. updateDistanceFromListener(): void;
  40521. /**
  40522. * Sets a new custom attenuation function for the sound.
  40523. * @param callback Defines the function used for the attenuation
  40524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40525. */
  40526. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40527. /**
  40528. * Play the sound
  40529. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40530. * @param offset (optional) Start the sound at a specific time in seconds
  40531. * @param length (optional) Sound duration (in seconds)
  40532. */
  40533. play(time?: number, offset?: number, length?: number): void;
  40534. private _onended;
  40535. /**
  40536. * Stop the sound
  40537. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40538. */
  40539. stop(time?: number): void;
  40540. /**
  40541. * Put the sound in pause
  40542. */
  40543. pause(): void;
  40544. /**
  40545. * Sets a dedicated volume for this sounds
  40546. * @param newVolume Define the new volume of the sound
  40547. * @param time Define time for gradual change to new volume
  40548. */
  40549. setVolume(newVolume: number, time?: number): void;
  40550. /**
  40551. * Set the sound play back rate
  40552. * @param newPlaybackRate Define the playback rate the sound should be played at
  40553. */
  40554. setPlaybackRate(newPlaybackRate: number): void;
  40555. /**
  40556. * Gets the volume of the sound.
  40557. * @returns the volume of the sound
  40558. */
  40559. getVolume(): number;
  40560. /**
  40561. * Attach the sound to a dedicated mesh
  40562. * @param transformNode The transform node to connect the sound with
  40563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40564. */
  40565. attachToMesh(transformNode: TransformNode): void;
  40566. /**
  40567. * Detach the sound from the previously attached mesh
  40568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40569. */
  40570. detachFromMesh(): void;
  40571. private _onRegisterAfterWorldMatrixUpdate;
  40572. /**
  40573. * Clone the current sound in the scene.
  40574. * @returns the new sound clone
  40575. */
  40576. clone(): Nullable<Sound>;
  40577. /**
  40578. * Gets the current underlying audio buffer containing the data
  40579. * @returns the audio buffer
  40580. */
  40581. getAudioBuffer(): Nullable<AudioBuffer>;
  40582. /**
  40583. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40584. * @returns the source node
  40585. */
  40586. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40587. /**
  40588. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40589. * @returns the gain node
  40590. */
  40591. getSoundGain(): Nullable<GainNode>;
  40592. /**
  40593. * Serializes the Sound in a JSON representation
  40594. * @returns the JSON representation of the sound
  40595. */
  40596. serialize(): any;
  40597. /**
  40598. * Parse a JSON representation of a sound to innstantiate in a given scene
  40599. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40600. * @param scene Define the scene the new parsed sound should be created in
  40601. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40602. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40603. * @returns the newly parsed sound
  40604. */
  40605. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40606. }
  40607. }
  40608. declare module BABYLON {
  40609. /**
  40610. * This defines an action helpful to play a defined sound on a triggered action.
  40611. */
  40612. export class PlaySoundAction extends Action {
  40613. private _sound;
  40614. /**
  40615. * Instantiate the action
  40616. * @param triggerOptions defines the trigger options
  40617. * @param sound defines the sound to play
  40618. * @param condition defines the trigger related conditions
  40619. */
  40620. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40621. /** @hidden */
  40622. _prepare(): void;
  40623. /**
  40624. * Execute the action and play the sound.
  40625. */
  40626. execute(): void;
  40627. /**
  40628. * Serializes the actions and its related information.
  40629. * @param parent defines the object to serialize in
  40630. * @returns the serialized object
  40631. */
  40632. serialize(parent: any): any;
  40633. }
  40634. /**
  40635. * This defines an action helpful to stop a defined sound on a triggered action.
  40636. */
  40637. export class StopSoundAction extends Action {
  40638. private _sound;
  40639. /**
  40640. * Instantiate the action
  40641. * @param triggerOptions defines the trigger options
  40642. * @param sound defines the sound to stop
  40643. * @param condition defines the trigger related conditions
  40644. */
  40645. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40646. /** @hidden */
  40647. _prepare(): void;
  40648. /**
  40649. * Execute the action and stop the sound.
  40650. */
  40651. execute(): void;
  40652. /**
  40653. * Serializes the actions and its related information.
  40654. * @param parent defines the object to serialize in
  40655. * @returns the serialized object
  40656. */
  40657. serialize(parent: any): any;
  40658. }
  40659. }
  40660. declare module BABYLON {
  40661. /**
  40662. * This defines an action responsible to change the value of a property
  40663. * by interpolating between its current value and the newly set one once triggered.
  40664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40665. */
  40666. export class InterpolateValueAction extends Action {
  40667. /**
  40668. * Defines the path of the property where the value should be interpolated
  40669. */
  40670. propertyPath: string;
  40671. /**
  40672. * Defines the target value at the end of the interpolation.
  40673. */
  40674. value: any;
  40675. /**
  40676. * Defines the time it will take for the property to interpolate to the value.
  40677. */
  40678. duration: number;
  40679. /**
  40680. * Defines if the other scene animations should be stopped when the action has been triggered
  40681. */
  40682. stopOtherAnimations?: boolean;
  40683. /**
  40684. * Defines a callback raised once the interpolation animation has been done.
  40685. */
  40686. onInterpolationDone?: () => void;
  40687. /**
  40688. * Observable triggered once the interpolation animation has been done.
  40689. */
  40690. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40691. private _target;
  40692. private _effectiveTarget;
  40693. private _property;
  40694. /**
  40695. * Instantiate the action
  40696. * @param triggerOptions defines the trigger options
  40697. * @param target defines the object containing the value to interpolate
  40698. * @param propertyPath defines the path to the property in the target object
  40699. * @param value defines the target value at the end of the interpolation
  40700. * @param duration deines the time it will take for the property to interpolate to the value.
  40701. * @param condition defines the trigger related conditions
  40702. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40703. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40704. */
  40705. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40706. /** @hidden */
  40707. _prepare(): void;
  40708. /**
  40709. * Execute the action starts the value interpolation.
  40710. */
  40711. execute(): void;
  40712. /**
  40713. * Serializes the actions and its related information.
  40714. * @param parent defines the object to serialize in
  40715. * @returns the serialized object
  40716. */
  40717. serialize(parent: any): any;
  40718. }
  40719. }
  40720. declare module BABYLON {
  40721. /**
  40722. * Options allowed during the creation of a sound track.
  40723. */
  40724. export interface ISoundTrackOptions {
  40725. /**
  40726. * The volume the sound track should take during creation
  40727. */
  40728. volume?: number;
  40729. /**
  40730. * Define if the sound track is the main sound track of the scene
  40731. */
  40732. mainTrack?: boolean;
  40733. }
  40734. /**
  40735. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40736. * It will be also used in a future release to apply effects on a specific track.
  40737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40738. */
  40739. export class SoundTrack {
  40740. /**
  40741. * The unique identifier of the sound track in the scene.
  40742. */
  40743. id: number;
  40744. /**
  40745. * The list of sounds included in the sound track.
  40746. */
  40747. soundCollection: Array<Sound>;
  40748. private _outputAudioNode;
  40749. private _scene;
  40750. private _connectedAnalyser;
  40751. private _options;
  40752. private _isInitialized;
  40753. /**
  40754. * Creates a new sound track.
  40755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40756. * @param scene Define the scene the sound track belongs to
  40757. * @param options
  40758. */
  40759. constructor(scene: Scene, options?: ISoundTrackOptions);
  40760. private _initializeSoundTrackAudioGraph;
  40761. /**
  40762. * Release the sound track and its associated resources
  40763. */
  40764. dispose(): void;
  40765. /**
  40766. * Adds a sound to this sound track
  40767. * @param sound define the cound to add
  40768. * @ignoreNaming
  40769. */
  40770. AddSound(sound: Sound): void;
  40771. /**
  40772. * Removes a sound to this sound track
  40773. * @param sound define the cound to remove
  40774. * @ignoreNaming
  40775. */
  40776. RemoveSound(sound: Sound): void;
  40777. /**
  40778. * Set a global volume for the full sound track.
  40779. * @param newVolume Define the new volume of the sound track
  40780. */
  40781. setVolume(newVolume: number): void;
  40782. /**
  40783. * Switch the panning model to HRTF:
  40784. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40786. */
  40787. switchPanningModelToHRTF(): void;
  40788. /**
  40789. * Switch the panning model to Equal Power:
  40790. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40792. */
  40793. switchPanningModelToEqualPower(): void;
  40794. /**
  40795. * Connect the sound track to an audio analyser allowing some amazing
  40796. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40798. * @param analyser The analyser to connect to the engine
  40799. */
  40800. connectToAnalyser(analyser: Analyser): void;
  40801. }
  40802. }
  40803. declare module BABYLON {
  40804. interface AbstractScene {
  40805. /**
  40806. * The list of sounds used in the scene.
  40807. */
  40808. sounds: Nullable<Array<Sound>>;
  40809. }
  40810. interface Scene {
  40811. /**
  40812. * @hidden
  40813. * Backing field
  40814. */
  40815. _mainSoundTrack: SoundTrack;
  40816. /**
  40817. * The main sound track played by the scene.
  40818. * It cotains your primary collection of sounds.
  40819. */
  40820. mainSoundTrack: SoundTrack;
  40821. /**
  40822. * The list of sound tracks added to the scene
  40823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40824. */
  40825. soundTracks: Nullable<Array<SoundTrack>>;
  40826. /**
  40827. * Gets a sound using a given name
  40828. * @param name defines the name to search for
  40829. * @return the found sound or null if not found at all.
  40830. */
  40831. getSoundByName(name: string): Nullable<Sound>;
  40832. /**
  40833. * Gets or sets if audio support is enabled
  40834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40835. */
  40836. audioEnabled: boolean;
  40837. /**
  40838. * Gets or sets if audio will be output to headphones
  40839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40840. */
  40841. headphone: boolean;
  40842. /**
  40843. * Gets or sets custom audio listener position provider
  40844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40845. */
  40846. audioListenerPositionProvider: Nullable<() => Vector3>;
  40847. /**
  40848. * Gets or sets a refresh rate when using 3D audio positioning
  40849. */
  40850. audioPositioningRefreshRate: number;
  40851. }
  40852. /**
  40853. * Defines the sound scene component responsible to manage any sounds
  40854. * in a given scene.
  40855. */
  40856. export class AudioSceneComponent implements ISceneSerializableComponent {
  40857. /**
  40858. * The component name helpfull to identify the component in the list of scene components.
  40859. */
  40860. readonly name: string;
  40861. /**
  40862. * The scene the component belongs to.
  40863. */
  40864. scene: Scene;
  40865. private _audioEnabled;
  40866. /**
  40867. * Gets whether audio is enabled or not.
  40868. * Please use related enable/disable method to switch state.
  40869. */
  40870. get audioEnabled(): boolean;
  40871. private _headphone;
  40872. /**
  40873. * Gets whether audio is outputing to headphone or not.
  40874. * Please use the according Switch methods to change output.
  40875. */
  40876. get headphone(): boolean;
  40877. /**
  40878. * Gets or sets a refresh rate when using 3D audio positioning
  40879. */
  40880. audioPositioningRefreshRate: number;
  40881. private _audioListenerPositionProvider;
  40882. /**
  40883. * Gets the current audio listener position provider
  40884. */
  40885. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40886. /**
  40887. * Sets a custom listener position for all sounds in the scene
  40888. * By default, this is the position of the first active camera
  40889. */
  40890. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40891. /**
  40892. * Creates a new instance of the component for the given scene
  40893. * @param scene Defines the scene to register the component in
  40894. */
  40895. constructor(scene: Scene);
  40896. /**
  40897. * Registers the component in a given scene
  40898. */
  40899. register(): void;
  40900. /**
  40901. * Rebuilds the elements related to this component in case of
  40902. * context lost for instance.
  40903. */
  40904. rebuild(): void;
  40905. /**
  40906. * Serializes the component data to the specified json object
  40907. * @param serializationObject The object to serialize to
  40908. */
  40909. serialize(serializationObject: any): void;
  40910. /**
  40911. * Adds all the elements from the container to the scene
  40912. * @param container the container holding the elements
  40913. */
  40914. addFromContainer(container: AbstractScene): void;
  40915. /**
  40916. * Removes all the elements in the container from the scene
  40917. * @param container contains the elements to remove
  40918. * @param dispose if the removed element should be disposed (default: false)
  40919. */
  40920. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40921. /**
  40922. * Disposes the component and the associated ressources.
  40923. */
  40924. dispose(): void;
  40925. /**
  40926. * Disables audio in the associated scene.
  40927. */
  40928. disableAudio(): void;
  40929. /**
  40930. * Enables audio in the associated scene.
  40931. */
  40932. enableAudio(): void;
  40933. /**
  40934. * Switch audio to headphone output.
  40935. */
  40936. switchAudioModeForHeadphones(): void;
  40937. /**
  40938. * Switch audio to normal speakers.
  40939. */
  40940. switchAudioModeForNormalSpeakers(): void;
  40941. private _cachedCameraDirection;
  40942. private _cachedCameraPosition;
  40943. private _lastCheck;
  40944. private _afterRender;
  40945. }
  40946. }
  40947. declare module BABYLON {
  40948. /**
  40949. * Wraps one or more Sound objects and selects one with random weight for playback.
  40950. */
  40951. export class WeightedSound {
  40952. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40953. loop: boolean;
  40954. private _coneInnerAngle;
  40955. private _coneOuterAngle;
  40956. private _volume;
  40957. /** A Sound is currently playing. */
  40958. isPlaying: boolean;
  40959. /** A Sound is currently paused. */
  40960. isPaused: boolean;
  40961. private _sounds;
  40962. private _weights;
  40963. private _currentIndex?;
  40964. /**
  40965. * Creates a new WeightedSound from the list of sounds given.
  40966. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40967. * @param sounds Array of Sounds that will be selected from.
  40968. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40969. */
  40970. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40971. /**
  40972. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40973. */
  40974. get directionalConeInnerAngle(): number;
  40975. /**
  40976. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40977. */
  40978. set directionalConeInnerAngle(value: number);
  40979. /**
  40980. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40981. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40982. */
  40983. get directionalConeOuterAngle(): number;
  40984. /**
  40985. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40986. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40987. */
  40988. set directionalConeOuterAngle(value: number);
  40989. /**
  40990. * Playback volume.
  40991. */
  40992. get volume(): number;
  40993. /**
  40994. * Playback volume.
  40995. */
  40996. set volume(value: number);
  40997. private _onended;
  40998. /**
  40999. * Suspend playback
  41000. */
  41001. pause(): void;
  41002. /**
  41003. * Stop playback
  41004. */
  41005. stop(): void;
  41006. /**
  41007. * Start playback.
  41008. * @param startOffset Position the clip head at a specific time in seconds.
  41009. */
  41010. play(startOffset?: number): void;
  41011. }
  41012. }
  41013. declare module BABYLON {
  41014. /**
  41015. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41016. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41017. */
  41018. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41019. /**
  41020. * Gets the name of the behavior.
  41021. */
  41022. get name(): string;
  41023. /**
  41024. * The easing function used by animations
  41025. */
  41026. static EasingFunction: BackEase;
  41027. /**
  41028. * The easing mode used by animations
  41029. */
  41030. static EasingMode: number;
  41031. /**
  41032. * The duration of the animation, in milliseconds
  41033. */
  41034. transitionDuration: number;
  41035. /**
  41036. * Length of the distance animated by the transition when lower radius is reached
  41037. */
  41038. lowerRadiusTransitionRange: number;
  41039. /**
  41040. * Length of the distance animated by the transition when upper radius is reached
  41041. */
  41042. upperRadiusTransitionRange: number;
  41043. private _autoTransitionRange;
  41044. /**
  41045. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41046. */
  41047. get autoTransitionRange(): boolean;
  41048. /**
  41049. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41050. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41051. */
  41052. set autoTransitionRange(value: boolean);
  41053. private _attachedCamera;
  41054. private _onAfterCheckInputsObserver;
  41055. private _onMeshTargetChangedObserver;
  41056. /**
  41057. * Initializes the behavior.
  41058. */
  41059. init(): void;
  41060. /**
  41061. * Attaches the behavior to its arc rotate camera.
  41062. * @param camera Defines the camera to attach the behavior to
  41063. */
  41064. attach(camera: ArcRotateCamera): void;
  41065. /**
  41066. * Detaches the behavior from its current arc rotate camera.
  41067. */
  41068. detach(): void;
  41069. private _radiusIsAnimating;
  41070. private _radiusBounceTransition;
  41071. private _animatables;
  41072. private _cachedWheelPrecision;
  41073. /**
  41074. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41075. * @param radiusLimit The limit to check against.
  41076. * @return Bool to indicate if at limit.
  41077. */
  41078. private _isRadiusAtLimit;
  41079. /**
  41080. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41081. * @param radiusDelta The delta by which to animate to. Can be negative.
  41082. */
  41083. private _applyBoundRadiusAnimation;
  41084. /**
  41085. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41086. */
  41087. protected _clearAnimationLocks(): void;
  41088. /**
  41089. * Stops and removes all animations that have been applied to the camera
  41090. */
  41091. stopAllAnimations(): void;
  41092. }
  41093. }
  41094. declare module BABYLON {
  41095. /**
  41096. * 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.
  41097. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41098. */
  41099. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41100. /**
  41101. * Gets the name of the behavior.
  41102. */
  41103. get name(): string;
  41104. private _mode;
  41105. private _radiusScale;
  41106. private _positionScale;
  41107. private _defaultElevation;
  41108. private _elevationReturnTime;
  41109. private _elevationReturnWaitTime;
  41110. private _zoomStopsAnimation;
  41111. private _framingTime;
  41112. /**
  41113. * The easing function used by animations
  41114. */
  41115. static EasingFunction: ExponentialEase;
  41116. /**
  41117. * The easing mode used by animations
  41118. */
  41119. static EasingMode: number;
  41120. /**
  41121. * Sets the current mode used by the behavior
  41122. */
  41123. set mode(mode: number);
  41124. /**
  41125. * Gets current mode used by the behavior.
  41126. */
  41127. get mode(): number;
  41128. /**
  41129. * Sets the scale applied to the radius (1 by default)
  41130. */
  41131. set radiusScale(radius: number);
  41132. /**
  41133. * Gets the scale applied to the radius
  41134. */
  41135. get radiusScale(): number;
  41136. /**
  41137. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41138. */
  41139. set positionScale(scale: number);
  41140. /**
  41141. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41142. */
  41143. get positionScale(): number;
  41144. /**
  41145. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41146. * behaviour is triggered, in radians.
  41147. */
  41148. set defaultElevation(elevation: number);
  41149. /**
  41150. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41151. * behaviour is triggered, in radians.
  41152. */
  41153. get defaultElevation(): number;
  41154. /**
  41155. * Sets the time (in milliseconds) taken to return to the default beta position.
  41156. * Negative value indicates camera should not return to default.
  41157. */
  41158. set elevationReturnTime(speed: number);
  41159. /**
  41160. * Gets the time (in milliseconds) taken to return to the default beta position.
  41161. * Negative value indicates camera should not return to default.
  41162. */
  41163. get elevationReturnTime(): number;
  41164. /**
  41165. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41166. */
  41167. set elevationReturnWaitTime(time: number);
  41168. /**
  41169. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41170. */
  41171. get elevationReturnWaitTime(): number;
  41172. /**
  41173. * Sets the flag that indicates if user zooming should stop animation.
  41174. */
  41175. set zoomStopsAnimation(flag: boolean);
  41176. /**
  41177. * Gets the flag that indicates if user zooming should stop animation.
  41178. */
  41179. get zoomStopsAnimation(): boolean;
  41180. /**
  41181. * Sets the transition time when framing the mesh, in milliseconds
  41182. */
  41183. set framingTime(time: number);
  41184. /**
  41185. * Gets the transition time when framing the mesh, in milliseconds
  41186. */
  41187. get framingTime(): number;
  41188. /**
  41189. * Define if the behavior should automatically change the configured
  41190. * camera limits and sensibilities.
  41191. */
  41192. autoCorrectCameraLimitsAndSensibility: boolean;
  41193. private _onPrePointerObservableObserver;
  41194. private _onAfterCheckInputsObserver;
  41195. private _onMeshTargetChangedObserver;
  41196. private _attachedCamera;
  41197. private _isPointerDown;
  41198. private _lastInteractionTime;
  41199. /**
  41200. * Initializes the behavior.
  41201. */
  41202. init(): void;
  41203. /**
  41204. * Attaches the behavior to its arc rotate camera.
  41205. * @param camera Defines the camera to attach the behavior to
  41206. */
  41207. attach(camera: ArcRotateCamera): void;
  41208. /**
  41209. * Detaches the behavior from its current arc rotate camera.
  41210. */
  41211. detach(): void;
  41212. private _animatables;
  41213. private _betaIsAnimating;
  41214. private _betaTransition;
  41215. private _radiusTransition;
  41216. private _vectorTransition;
  41217. /**
  41218. * Targets the given mesh and updates zoom level accordingly.
  41219. * @param mesh The mesh to target.
  41220. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41221. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41222. */
  41223. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41224. /**
  41225. * Targets the given mesh with its children and updates zoom level accordingly.
  41226. * @param mesh The mesh to target.
  41227. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41228. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41229. */
  41230. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41231. /**
  41232. * Targets the given meshes with their children and updates zoom level accordingly.
  41233. * @param meshes The mesh to target.
  41234. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41235. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41236. */
  41237. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41238. /**
  41239. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41240. * @param minimumWorld Determines the smaller position of the bounding box extend
  41241. * @param maximumWorld Determines the bigger position of the bounding box extend
  41242. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41243. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41244. */
  41245. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41246. /**
  41247. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41248. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41249. * frustum width.
  41250. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41251. * to fully enclose the mesh in the viewing frustum.
  41252. */
  41253. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41254. /**
  41255. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41256. * is automatically returned to its default position (expected to be above ground plane).
  41257. */
  41258. private _maintainCameraAboveGround;
  41259. /**
  41260. * Returns the frustum slope based on the canvas ratio and camera FOV
  41261. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41262. */
  41263. private _getFrustumSlope;
  41264. /**
  41265. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41266. */
  41267. private _clearAnimationLocks;
  41268. /**
  41269. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41270. */
  41271. private _applyUserInteraction;
  41272. /**
  41273. * Stops and removes all animations that have been applied to the camera
  41274. */
  41275. stopAllAnimations(): void;
  41276. /**
  41277. * Gets a value indicating if the user is moving the camera
  41278. */
  41279. get isUserIsMoving(): boolean;
  41280. /**
  41281. * The camera can move all the way towards the mesh.
  41282. */
  41283. static IgnoreBoundsSizeMode: number;
  41284. /**
  41285. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41286. */
  41287. static FitFrustumSidesMode: number;
  41288. }
  41289. }
  41290. declare module BABYLON {
  41291. /**
  41292. * Base class for Camera Pointer Inputs.
  41293. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41294. * for example usage.
  41295. */
  41296. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41297. /**
  41298. * Defines the camera the input is attached to.
  41299. */
  41300. abstract camera: Camera;
  41301. /**
  41302. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41303. */
  41304. protected _altKey: boolean;
  41305. protected _ctrlKey: boolean;
  41306. protected _metaKey: boolean;
  41307. protected _shiftKey: boolean;
  41308. /**
  41309. * Which mouse buttons were pressed at time of last mouse event.
  41310. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41311. */
  41312. protected _buttonsPressed: number;
  41313. /**
  41314. * Defines the buttons associated with the input to handle camera move.
  41315. */
  41316. buttons: number[];
  41317. /**
  41318. * Attach the input controls to a specific dom element to get the input from.
  41319. * @param element Defines the element the controls should be listened from
  41320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41321. */
  41322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41323. /**
  41324. * Detach the current controls from the specified dom element.
  41325. * @param element Defines the element to stop listening the inputs from
  41326. */
  41327. detachControl(element: Nullable<HTMLElement>): void;
  41328. /**
  41329. * Gets the class name of the current input.
  41330. * @returns the class name
  41331. */
  41332. getClassName(): string;
  41333. /**
  41334. * Get the friendly name associated with the input class.
  41335. * @returns the input friendly name
  41336. */
  41337. getSimpleName(): string;
  41338. /**
  41339. * Called on pointer POINTERDOUBLETAP event.
  41340. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41341. */
  41342. protected onDoubleTap(type: string): void;
  41343. /**
  41344. * Called on pointer POINTERMOVE event if only a single touch is active.
  41345. * Override this method to provide functionality.
  41346. */
  41347. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41348. /**
  41349. * Called on pointer POINTERMOVE event if multiple touches are active.
  41350. * Override this method to provide functionality.
  41351. */
  41352. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41353. /**
  41354. * Called on JS contextmenu event.
  41355. * Override this method to provide functionality.
  41356. */
  41357. protected onContextMenu(evt: PointerEvent): void;
  41358. /**
  41359. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41360. * press.
  41361. * Override this method to provide functionality.
  41362. */
  41363. protected onButtonDown(evt: PointerEvent): void;
  41364. /**
  41365. * Called each time a new POINTERUP event occurs. Ie, for each button
  41366. * release.
  41367. * Override this method to provide functionality.
  41368. */
  41369. protected onButtonUp(evt: PointerEvent): void;
  41370. /**
  41371. * Called when window becomes inactive.
  41372. * Override this method to provide functionality.
  41373. */
  41374. protected onLostFocus(): void;
  41375. private _pointerInput;
  41376. private _observer;
  41377. private _onLostFocus;
  41378. private pointA;
  41379. private pointB;
  41380. }
  41381. }
  41382. declare module BABYLON {
  41383. /**
  41384. * Manage the pointers inputs to control an arc rotate camera.
  41385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41386. */
  41387. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41388. /**
  41389. * Defines the camera the input is attached to.
  41390. */
  41391. camera: ArcRotateCamera;
  41392. /**
  41393. * Gets the class name of the current input.
  41394. * @returns the class name
  41395. */
  41396. getClassName(): string;
  41397. /**
  41398. * Defines the buttons associated with the input to handle camera move.
  41399. */
  41400. buttons: number[];
  41401. /**
  41402. * Defines the pointer angular sensibility along the X axis or how fast is
  41403. * the camera rotating.
  41404. */
  41405. angularSensibilityX: number;
  41406. /**
  41407. * Defines the pointer angular sensibility along the Y axis or how fast is
  41408. * the camera rotating.
  41409. */
  41410. angularSensibilityY: number;
  41411. /**
  41412. * Defines the pointer pinch precision or how fast is the camera zooming.
  41413. */
  41414. pinchPrecision: number;
  41415. /**
  41416. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41417. * from 0.
  41418. * It defines the percentage of current camera.radius to use as delta when
  41419. * pinch zoom is used.
  41420. */
  41421. pinchDeltaPercentage: number;
  41422. /**
  41423. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41424. * that any object in the plane at the camera's target point will scale
  41425. * perfectly with finger motion.
  41426. * Overrides pinchDeltaPercentage and pinchPrecision.
  41427. */
  41428. useNaturalPinchZoom: boolean;
  41429. /**
  41430. * Defines the pointer panning sensibility or how fast is the camera moving.
  41431. */
  41432. panningSensibility: number;
  41433. /**
  41434. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41435. */
  41436. multiTouchPanning: boolean;
  41437. /**
  41438. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41439. * zoom (pinch) through multitouch.
  41440. */
  41441. multiTouchPanAndZoom: boolean;
  41442. /**
  41443. * Revers pinch action direction.
  41444. */
  41445. pinchInwards: boolean;
  41446. private _isPanClick;
  41447. private _twoFingerActivityCount;
  41448. private _isPinching;
  41449. /**
  41450. * Called on pointer POINTERMOVE event if only a single touch is active.
  41451. */
  41452. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41453. /**
  41454. * Called on pointer POINTERDOUBLETAP event.
  41455. */
  41456. protected onDoubleTap(type: string): void;
  41457. /**
  41458. * Called on pointer POINTERMOVE event if multiple touches are active.
  41459. */
  41460. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41461. /**
  41462. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41463. * press.
  41464. */
  41465. protected onButtonDown(evt: PointerEvent): void;
  41466. /**
  41467. * Called each time a new POINTERUP event occurs. Ie, for each button
  41468. * release.
  41469. */
  41470. protected onButtonUp(evt: PointerEvent): void;
  41471. /**
  41472. * Called when window becomes inactive.
  41473. */
  41474. protected onLostFocus(): void;
  41475. }
  41476. }
  41477. declare module BABYLON {
  41478. /**
  41479. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41481. */
  41482. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41483. /**
  41484. * Defines the camera the input is attached to.
  41485. */
  41486. camera: ArcRotateCamera;
  41487. /**
  41488. * Defines the list of key codes associated with the up action (increase alpha)
  41489. */
  41490. keysUp: number[];
  41491. /**
  41492. * Defines the list of key codes associated with the down action (decrease alpha)
  41493. */
  41494. keysDown: number[];
  41495. /**
  41496. * Defines the list of key codes associated with the left action (increase beta)
  41497. */
  41498. keysLeft: number[];
  41499. /**
  41500. * Defines the list of key codes associated with the right action (decrease beta)
  41501. */
  41502. keysRight: number[];
  41503. /**
  41504. * Defines the list of key codes associated with the reset action.
  41505. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41506. */
  41507. keysReset: number[];
  41508. /**
  41509. * Defines the panning sensibility of the inputs.
  41510. * (How fast is the camera panning)
  41511. */
  41512. panningSensibility: number;
  41513. /**
  41514. * Defines the zooming sensibility of the inputs.
  41515. * (How fast is the camera zooming)
  41516. */
  41517. zoomingSensibility: number;
  41518. /**
  41519. * Defines whether maintaining the alt key down switch the movement mode from
  41520. * orientation to zoom.
  41521. */
  41522. useAltToZoom: boolean;
  41523. /**
  41524. * Rotation speed of the camera
  41525. */
  41526. angularSpeed: number;
  41527. private _keys;
  41528. private _ctrlPressed;
  41529. private _altPressed;
  41530. private _onCanvasBlurObserver;
  41531. private _onKeyboardObserver;
  41532. private _engine;
  41533. private _scene;
  41534. /**
  41535. * Attach the input controls to a specific dom element to get the input from.
  41536. * @param element Defines the element the controls should be listened from
  41537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41538. */
  41539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41540. /**
  41541. * Detach the current controls from the specified dom element.
  41542. * @param element Defines the element to stop listening the inputs from
  41543. */
  41544. detachControl(element: Nullable<HTMLElement>): void;
  41545. /**
  41546. * Update the current camera state depending on the inputs that have been used this frame.
  41547. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41548. */
  41549. checkInputs(): void;
  41550. /**
  41551. * Gets the class name of the current intput.
  41552. * @returns the class name
  41553. */
  41554. getClassName(): string;
  41555. /**
  41556. * Get the friendly name associated with the input class.
  41557. * @returns the input friendly name
  41558. */
  41559. getSimpleName(): string;
  41560. }
  41561. }
  41562. declare module BABYLON {
  41563. /**
  41564. * Manage the mouse wheel inputs to control an arc rotate camera.
  41565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41566. */
  41567. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41568. /**
  41569. * Defines the camera the input is attached to.
  41570. */
  41571. camera: ArcRotateCamera;
  41572. /**
  41573. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41574. */
  41575. wheelPrecision: number;
  41576. /**
  41577. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41578. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41579. */
  41580. wheelDeltaPercentage: number;
  41581. private _wheel;
  41582. private _observer;
  41583. private computeDeltaFromMouseWheelLegacyEvent;
  41584. /**
  41585. * Attach the input controls to a specific dom element to get the input from.
  41586. * @param element Defines the element the controls should be listened from
  41587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41588. */
  41589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41590. /**
  41591. * Detach the current controls from the specified dom element.
  41592. * @param element Defines the element to stop listening the inputs from
  41593. */
  41594. detachControl(element: Nullable<HTMLElement>): void;
  41595. /**
  41596. * Gets the class name of the current intput.
  41597. * @returns the class name
  41598. */
  41599. getClassName(): string;
  41600. /**
  41601. * Get the friendly name associated with the input class.
  41602. * @returns the input friendly name
  41603. */
  41604. getSimpleName(): string;
  41605. }
  41606. }
  41607. declare module BABYLON {
  41608. /**
  41609. * Default Inputs manager for the ArcRotateCamera.
  41610. * It groups all the default supported inputs for ease of use.
  41611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41612. */
  41613. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41614. /**
  41615. * Instantiates a new ArcRotateCameraInputsManager.
  41616. * @param camera Defines the camera the inputs belong to
  41617. */
  41618. constructor(camera: ArcRotateCamera);
  41619. /**
  41620. * Add mouse wheel input support to the input manager.
  41621. * @returns the current input manager
  41622. */
  41623. addMouseWheel(): ArcRotateCameraInputsManager;
  41624. /**
  41625. * Add pointers input support to the input manager.
  41626. * @returns the current input manager
  41627. */
  41628. addPointers(): ArcRotateCameraInputsManager;
  41629. /**
  41630. * Add keyboard input support to the input manager.
  41631. * @returns the current input manager
  41632. */
  41633. addKeyboard(): ArcRotateCameraInputsManager;
  41634. }
  41635. }
  41636. declare module BABYLON {
  41637. /**
  41638. * This represents an orbital type of camera.
  41639. *
  41640. * 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.
  41641. * 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.
  41642. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41643. */
  41644. export class ArcRotateCamera extends TargetCamera {
  41645. /**
  41646. * Defines the rotation angle of the camera along the longitudinal axis.
  41647. */
  41648. alpha: number;
  41649. /**
  41650. * Defines the rotation angle of the camera along the latitudinal axis.
  41651. */
  41652. beta: number;
  41653. /**
  41654. * Defines the radius of the camera from it s target point.
  41655. */
  41656. radius: number;
  41657. protected _target: Vector3;
  41658. protected _targetHost: Nullable<AbstractMesh>;
  41659. /**
  41660. * Defines the target point of the camera.
  41661. * The camera looks towards it form the radius distance.
  41662. */
  41663. get target(): Vector3;
  41664. set target(value: Vector3);
  41665. /**
  41666. * Define the current local position of the camera in the scene
  41667. */
  41668. get position(): Vector3;
  41669. set position(newPosition: Vector3);
  41670. protected _upVector: Vector3;
  41671. protected _upToYMatrix: Matrix;
  41672. protected _YToUpMatrix: Matrix;
  41673. /**
  41674. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41675. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41676. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41677. */
  41678. set upVector(vec: Vector3);
  41679. get upVector(): Vector3;
  41680. /**
  41681. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41682. */
  41683. setMatUp(): void;
  41684. /**
  41685. * Current inertia value on the longitudinal axis.
  41686. * The bigger this number the longer it will take for the camera to stop.
  41687. */
  41688. inertialAlphaOffset: number;
  41689. /**
  41690. * Current inertia value on the latitudinal axis.
  41691. * The bigger this number the longer it will take for the camera to stop.
  41692. */
  41693. inertialBetaOffset: number;
  41694. /**
  41695. * Current inertia value on the radius axis.
  41696. * The bigger this number the longer it will take for the camera to stop.
  41697. */
  41698. inertialRadiusOffset: number;
  41699. /**
  41700. * Minimum allowed angle on the longitudinal axis.
  41701. * This can help limiting how the Camera is able to move in the scene.
  41702. */
  41703. lowerAlphaLimit: Nullable<number>;
  41704. /**
  41705. * Maximum allowed angle on the longitudinal axis.
  41706. * This can help limiting how the Camera is able to move in the scene.
  41707. */
  41708. upperAlphaLimit: Nullable<number>;
  41709. /**
  41710. * Minimum allowed angle on the latitudinal axis.
  41711. * This can help limiting how the Camera is able to move in the scene.
  41712. */
  41713. lowerBetaLimit: number;
  41714. /**
  41715. * Maximum allowed angle on the latitudinal axis.
  41716. * This can help limiting how the Camera is able to move in the scene.
  41717. */
  41718. upperBetaLimit: number;
  41719. /**
  41720. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41721. * This can help limiting how the Camera is able to move in the scene.
  41722. */
  41723. lowerRadiusLimit: Nullable<number>;
  41724. /**
  41725. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41726. * This can help limiting how the Camera is able to move in the scene.
  41727. */
  41728. upperRadiusLimit: Nullable<number>;
  41729. /**
  41730. * Defines the current inertia value used during panning of the camera along the X axis.
  41731. */
  41732. inertialPanningX: number;
  41733. /**
  41734. * Defines the current inertia value used during panning of the camera along the Y axis.
  41735. */
  41736. inertialPanningY: number;
  41737. /**
  41738. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41739. * Basically if your fingers moves away from more than this distance you will be considered
  41740. * in pinch mode.
  41741. */
  41742. pinchToPanMaxDistance: number;
  41743. /**
  41744. * Defines the maximum distance the camera can pan.
  41745. * This could help keeping the cammera always in your scene.
  41746. */
  41747. panningDistanceLimit: Nullable<number>;
  41748. /**
  41749. * Defines the target of the camera before paning.
  41750. */
  41751. panningOriginTarget: Vector3;
  41752. /**
  41753. * Defines the value of the inertia used during panning.
  41754. * 0 would mean stop inertia and one would mean no decelleration at all.
  41755. */
  41756. panningInertia: number;
  41757. /**
  41758. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41759. */
  41760. get angularSensibilityX(): number;
  41761. set angularSensibilityX(value: number);
  41762. /**
  41763. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41764. */
  41765. get angularSensibilityY(): number;
  41766. set angularSensibilityY(value: number);
  41767. /**
  41768. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41769. */
  41770. get pinchPrecision(): number;
  41771. set pinchPrecision(value: number);
  41772. /**
  41773. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41774. * It will be used instead of pinchDeltaPrecision if different from 0.
  41775. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41776. */
  41777. get pinchDeltaPercentage(): number;
  41778. set pinchDeltaPercentage(value: number);
  41779. /**
  41780. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41781. * and pinch delta percentage.
  41782. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41783. * that any object in the plane at the camera's target point will scale
  41784. * perfectly with finger motion.
  41785. */
  41786. get useNaturalPinchZoom(): boolean;
  41787. set useNaturalPinchZoom(value: boolean);
  41788. /**
  41789. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41790. */
  41791. get panningSensibility(): number;
  41792. set panningSensibility(value: number);
  41793. /**
  41794. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41795. */
  41796. get keysUp(): number[];
  41797. set keysUp(value: number[]);
  41798. /**
  41799. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41800. */
  41801. get keysDown(): number[];
  41802. set keysDown(value: number[]);
  41803. /**
  41804. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41805. */
  41806. get keysLeft(): number[];
  41807. set keysLeft(value: number[]);
  41808. /**
  41809. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41810. */
  41811. get keysRight(): number[];
  41812. set keysRight(value: number[]);
  41813. /**
  41814. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41815. */
  41816. get wheelPrecision(): number;
  41817. set wheelPrecision(value: number);
  41818. /**
  41819. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41820. * It will be used instead of pinchDeltaPrecision if different from 0.
  41821. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41822. */
  41823. get wheelDeltaPercentage(): number;
  41824. set wheelDeltaPercentage(value: number);
  41825. /**
  41826. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41827. */
  41828. zoomOnFactor: number;
  41829. /**
  41830. * Defines a screen offset for the camera position.
  41831. */
  41832. targetScreenOffset: Vector2;
  41833. /**
  41834. * Allows the camera to be completely reversed.
  41835. * If false the camera can not arrive upside down.
  41836. */
  41837. allowUpsideDown: boolean;
  41838. /**
  41839. * Define if double tap/click is used to restore the previously saved state of the camera.
  41840. */
  41841. useInputToRestoreState: boolean;
  41842. /** @hidden */
  41843. _viewMatrix: Matrix;
  41844. /** @hidden */
  41845. _useCtrlForPanning: boolean;
  41846. /** @hidden */
  41847. _panningMouseButton: number;
  41848. /**
  41849. * Defines the input associated to the camera.
  41850. */
  41851. inputs: ArcRotateCameraInputsManager;
  41852. /** @hidden */
  41853. _reset: () => void;
  41854. /**
  41855. * Defines the allowed panning axis.
  41856. */
  41857. panningAxis: Vector3;
  41858. protected _localDirection: Vector3;
  41859. protected _transformedDirection: Vector3;
  41860. private _bouncingBehavior;
  41861. /**
  41862. * Gets the bouncing behavior of the camera if it has been enabled.
  41863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41864. */
  41865. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41866. /**
  41867. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41868. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41869. */
  41870. get useBouncingBehavior(): boolean;
  41871. set useBouncingBehavior(value: boolean);
  41872. private _framingBehavior;
  41873. /**
  41874. * Gets the framing behavior of the camera if it has been enabled.
  41875. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41876. */
  41877. get framingBehavior(): Nullable<FramingBehavior>;
  41878. /**
  41879. * Defines if the framing behavior of the camera is enabled on the camera.
  41880. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41881. */
  41882. get useFramingBehavior(): boolean;
  41883. set useFramingBehavior(value: boolean);
  41884. private _autoRotationBehavior;
  41885. /**
  41886. * Gets the auto rotation behavior of the camera if it has been enabled.
  41887. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41888. */
  41889. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41890. /**
  41891. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41892. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41893. */
  41894. get useAutoRotationBehavior(): boolean;
  41895. set useAutoRotationBehavior(value: boolean);
  41896. /**
  41897. * Observable triggered when the mesh target has been changed on the camera.
  41898. */
  41899. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41900. /**
  41901. * Event raised when the camera is colliding with a mesh.
  41902. */
  41903. onCollide: (collidedMesh: AbstractMesh) => void;
  41904. /**
  41905. * Defines whether the camera should check collision with the objects oh the scene.
  41906. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41907. */
  41908. checkCollisions: boolean;
  41909. /**
  41910. * Defines the collision radius of the camera.
  41911. * This simulates a sphere around the camera.
  41912. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41913. */
  41914. collisionRadius: Vector3;
  41915. protected _collider: Collider;
  41916. protected _previousPosition: Vector3;
  41917. protected _collisionVelocity: Vector3;
  41918. protected _newPosition: Vector3;
  41919. protected _previousAlpha: number;
  41920. protected _previousBeta: number;
  41921. protected _previousRadius: number;
  41922. protected _collisionTriggered: boolean;
  41923. protected _targetBoundingCenter: Nullable<Vector3>;
  41924. private _computationVector;
  41925. /**
  41926. * Instantiates a new ArcRotateCamera in a given scene
  41927. * @param name Defines the name of the camera
  41928. * @param alpha Defines the camera rotation along the logitudinal axis
  41929. * @param beta Defines the camera rotation along the latitudinal axis
  41930. * @param radius Defines the camera distance from its target
  41931. * @param target Defines the camera target
  41932. * @param scene Defines the scene the camera belongs to
  41933. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41934. */
  41935. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41936. /** @hidden */
  41937. _initCache(): void;
  41938. /** @hidden */
  41939. _updateCache(ignoreParentClass?: boolean): void;
  41940. protected _getTargetPosition(): Vector3;
  41941. private _storedAlpha;
  41942. private _storedBeta;
  41943. private _storedRadius;
  41944. private _storedTarget;
  41945. private _storedTargetScreenOffset;
  41946. /**
  41947. * Stores the current state of the camera (alpha, beta, radius and target)
  41948. * @returns the camera itself
  41949. */
  41950. storeState(): Camera;
  41951. /**
  41952. * @hidden
  41953. * Restored camera state. You must call storeState() first
  41954. */
  41955. _restoreStateValues(): boolean;
  41956. /** @hidden */
  41957. _isSynchronizedViewMatrix(): boolean;
  41958. /**
  41959. * Attached controls to the current camera.
  41960. * @param element Defines the element the controls should be listened from
  41961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41962. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41963. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41964. */
  41965. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41966. /**
  41967. * Detach the current controls from the camera.
  41968. * The camera will stop reacting to inputs.
  41969. * @param element Defines the element to stop listening the inputs from
  41970. */
  41971. detachControl(element: HTMLElement): void;
  41972. /** @hidden */
  41973. _checkInputs(): void;
  41974. protected _checkLimits(): void;
  41975. /**
  41976. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41977. */
  41978. rebuildAnglesAndRadius(): void;
  41979. /**
  41980. * Use a position to define the current camera related information like alpha, beta and radius
  41981. * @param position Defines the position to set the camera at
  41982. */
  41983. setPosition(position: Vector3): void;
  41984. /**
  41985. * Defines the target the camera should look at.
  41986. * This will automatically adapt alpha beta and radius to fit within the new target.
  41987. * @param target Defines the new target as a Vector or a mesh
  41988. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41989. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41990. */
  41991. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41992. /** @hidden */
  41993. _getViewMatrix(): Matrix;
  41994. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41995. /**
  41996. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41997. * @param meshes Defines the mesh to zoom on
  41998. * @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)
  41999. */
  42000. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42001. /**
  42002. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42003. * The target will be changed but the radius
  42004. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42005. * @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)
  42006. */
  42007. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42008. min: Vector3;
  42009. max: Vector3;
  42010. distance: number;
  42011. }, doNotUpdateMaxZ?: boolean): void;
  42012. /**
  42013. * @override
  42014. * Override Camera.createRigCamera
  42015. */
  42016. createRigCamera(name: string, cameraIndex: number): Camera;
  42017. /**
  42018. * @hidden
  42019. * @override
  42020. * Override Camera._updateRigCameras
  42021. */
  42022. _updateRigCameras(): void;
  42023. /**
  42024. * Destroy the camera and release the current resources hold by it.
  42025. */
  42026. dispose(): void;
  42027. /**
  42028. * Gets the current object class name.
  42029. * @return the class name
  42030. */
  42031. getClassName(): string;
  42032. }
  42033. }
  42034. declare module BABYLON {
  42035. /**
  42036. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42037. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42038. */
  42039. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42040. /**
  42041. * Gets the name of the behavior.
  42042. */
  42043. get name(): string;
  42044. private _zoomStopsAnimation;
  42045. private _idleRotationSpeed;
  42046. private _idleRotationWaitTime;
  42047. private _idleRotationSpinupTime;
  42048. /**
  42049. * Sets the flag that indicates if user zooming should stop animation.
  42050. */
  42051. set zoomStopsAnimation(flag: boolean);
  42052. /**
  42053. * Gets the flag that indicates if user zooming should stop animation.
  42054. */
  42055. get zoomStopsAnimation(): boolean;
  42056. /**
  42057. * Sets the default speed at which the camera rotates around the model.
  42058. */
  42059. set idleRotationSpeed(speed: number);
  42060. /**
  42061. * Gets the default speed at which the camera rotates around the model.
  42062. */
  42063. get idleRotationSpeed(): number;
  42064. /**
  42065. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42066. */
  42067. set idleRotationWaitTime(time: number);
  42068. /**
  42069. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42070. */
  42071. get idleRotationWaitTime(): number;
  42072. /**
  42073. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42074. */
  42075. set idleRotationSpinupTime(time: number);
  42076. /**
  42077. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42078. */
  42079. get idleRotationSpinupTime(): number;
  42080. /**
  42081. * Gets a value indicating if the camera is currently rotating because of this behavior
  42082. */
  42083. get rotationInProgress(): boolean;
  42084. private _onPrePointerObservableObserver;
  42085. private _onAfterCheckInputsObserver;
  42086. private _attachedCamera;
  42087. private _isPointerDown;
  42088. private _lastFrameTime;
  42089. private _lastInteractionTime;
  42090. private _cameraRotationSpeed;
  42091. /**
  42092. * Initializes the behavior.
  42093. */
  42094. init(): void;
  42095. /**
  42096. * Attaches the behavior to its arc rotate camera.
  42097. * @param camera Defines the camera to attach the behavior to
  42098. */
  42099. attach(camera: ArcRotateCamera): void;
  42100. /**
  42101. * Detaches the behavior from its current arc rotate camera.
  42102. */
  42103. detach(): void;
  42104. /**
  42105. * Returns true if user is scrolling.
  42106. * @return true if user is scrolling.
  42107. */
  42108. private _userIsZooming;
  42109. private _lastFrameRadius;
  42110. private _shouldAnimationStopForInteraction;
  42111. /**
  42112. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42113. */
  42114. private _applyUserInteraction;
  42115. private _userIsMoving;
  42116. }
  42117. }
  42118. declare module BABYLON {
  42119. /**
  42120. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42121. */
  42122. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42123. private ui;
  42124. /**
  42125. * The name of the behavior
  42126. */
  42127. name: string;
  42128. /**
  42129. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42130. */
  42131. distanceAwayFromFace: number;
  42132. /**
  42133. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42134. */
  42135. distanceAwayFromBottomOfFace: number;
  42136. private _faceVectors;
  42137. private _target;
  42138. private _scene;
  42139. private _onRenderObserver;
  42140. private _tmpMatrix;
  42141. private _tmpVector;
  42142. /**
  42143. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42144. * @param ui The transform node that should be attched to the mesh
  42145. */
  42146. constructor(ui: TransformNode);
  42147. /**
  42148. * Initializes the behavior
  42149. */
  42150. init(): void;
  42151. private _closestFace;
  42152. private _zeroVector;
  42153. private _lookAtTmpMatrix;
  42154. private _lookAtToRef;
  42155. /**
  42156. * Attaches the AttachToBoxBehavior to the passed in mesh
  42157. * @param target The mesh that the specified node will be attached to
  42158. */
  42159. attach(target: Mesh): void;
  42160. /**
  42161. * Detaches the behavior from the mesh
  42162. */
  42163. detach(): void;
  42164. }
  42165. }
  42166. declare module BABYLON {
  42167. /**
  42168. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42169. */
  42170. export class FadeInOutBehavior implements Behavior<Mesh> {
  42171. /**
  42172. * Time in milliseconds to delay before fading in (Default: 0)
  42173. */
  42174. delay: number;
  42175. /**
  42176. * Time in milliseconds for the mesh to fade in (Default: 300)
  42177. */
  42178. fadeInTime: number;
  42179. private _millisecondsPerFrame;
  42180. private _hovered;
  42181. private _hoverValue;
  42182. private _ownerNode;
  42183. /**
  42184. * Instatiates the FadeInOutBehavior
  42185. */
  42186. constructor();
  42187. /**
  42188. * The name of the behavior
  42189. */
  42190. get name(): string;
  42191. /**
  42192. * Initializes the behavior
  42193. */
  42194. init(): void;
  42195. /**
  42196. * Attaches the fade behavior on the passed in mesh
  42197. * @param ownerNode The mesh that will be faded in/out once attached
  42198. */
  42199. attach(ownerNode: Mesh): void;
  42200. /**
  42201. * Detaches the behavior from the mesh
  42202. */
  42203. detach(): void;
  42204. /**
  42205. * Triggers the mesh to begin fading in or out
  42206. * @param value if the object should fade in or out (true to fade in)
  42207. */
  42208. fadeIn(value: boolean): void;
  42209. private _update;
  42210. private _setAllVisibility;
  42211. }
  42212. }
  42213. declare module BABYLON {
  42214. /**
  42215. * Class containing a set of static utilities functions for managing Pivots
  42216. * @hidden
  42217. */
  42218. export class PivotTools {
  42219. private static _PivotCached;
  42220. private static _OldPivotPoint;
  42221. private static _PivotTranslation;
  42222. private static _PivotTmpVector;
  42223. /** @hidden */
  42224. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42225. /** @hidden */
  42226. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42227. }
  42228. }
  42229. declare module BABYLON {
  42230. /**
  42231. * Class containing static functions to help procedurally build meshes
  42232. */
  42233. export class PlaneBuilder {
  42234. /**
  42235. * Creates a plane mesh
  42236. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42237. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42238. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42240. * * 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
  42241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42242. * @param name defines the name of the mesh
  42243. * @param options defines the options used to create the mesh
  42244. * @param scene defines the hosting scene
  42245. * @returns the plane mesh
  42246. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42247. */
  42248. static CreatePlane(name: string, options: {
  42249. size?: number;
  42250. width?: number;
  42251. height?: number;
  42252. sideOrientation?: number;
  42253. frontUVs?: Vector4;
  42254. backUVs?: Vector4;
  42255. updatable?: boolean;
  42256. sourcePlane?: Plane;
  42257. }, scene?: Nullable<Scene>): Mesh;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42263. */
  42264. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42265. private static _AnyMouseID;
  42266. /**
  42267. * Abstract mesh the behavior is set on
  42268. */
  42269. attachedNode: AbstractMesh;
  42270. private _dragPlane;
  42271. private _scene;
  42272. private _pointerObserver;
  42273. private _beforeRenderObserver;
  42274. private static _planeScene;
  42275. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42276. /**
  42277. * 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)
  42278. */
  42279. maxDragAngle: number;
  42280. /**
  42281. * @hidden
  42282. */
  42283. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42284. /**
  42285. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42286. */
  42287. currentDraggingPointerID: number;
  42288. /**
  42289. * The last position where the pointer hit the drag plane in world space
  42290. */
  42291. lastDragPosition: Vector3;
  42292. /**
  42293. * If the behavior is currently in a dragging state
  42294. */
  42295. dragging: boolean;
  42296. /**
  42297. * 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)
  42298. */
  42299. dragDeltaRatio: number;
  42300. /**
  42301. * If the drag plane orientation should be updated during the dragging (Default: true)
  42302. */
  42303. updateDragPlane: boolean;
  42304. private _debugMode;
  42305. private _moving;
  42306. /**
  42307. * Fires each time the attached mesh is dragged with the pointer
  42308. * * delta between last drag position and current drag position in world space
  42309. * * dragDistance along the drag axis
  42310. * * dragPlaneNormal normal of the current drag plane used during the drag
  42311. * * dragPlanePoint in world space where the drag intersects the drag plane
  42312. */
  42313. onDragObservable: Observable<{
  42314. delta: Vector3;
  42315. dragPlanePoint: Vector3;
  42316. dragPlaneNormal: Vector3;
  42317. dragDistance: number;
  42318. pointerId: number;
  42319. }>;
  42320. /**
  42321. * Fires each time a drag begins (eg. mouse down on mesh)
  42322. */
  42323. onDragStartObservable: Observable<{
  42324. dragPlanePoint: Vector3;
  42325. pointerId: number;
  42326. }>;
  42327. /**
  42328. * Fires each time a drag ends (eg. mouse release after drag)
  42329. */
  42330. onDragEndObservable: Observable<{
  42331. dragPlanePoint: Vector3;
  42332. pointerId: number;
  42333. }>;
  42334. /**
  42335. * If the attached mesh should be moved when dragged
  42336. */
  42337. moveAttached: boolean;
  42338. /**
  42339. * If the drag behavior will react to drag events (Default: true)
  42340. */
  42341. enabled: boolean;
  42342. /**
  42343. * If pointer events should start and release the drag (Default: true)
  42344. */
  42345. startAndReleaseDragOnPointerEvents: boolean;
  42346. /**
  42347. * If camera controls should be detached during the drag
  42348. */
  42349. detachCameraControls: boolean;
  42350. /**
  42351. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42352. */
  42353. useObjectOrientationForDragging: boolean;
  42354. private _options;
  42355. /**
  42356. * Gets the options used by the behavior
  42357. */
  42358. get options(): {
  42359. dragAxis?: Vector3;
  42360. dragPlaneNormal?: Vector3;
  42361. };
  42362. /**
  42363. * Sets the options used by the behavior
  42364. */
  42365. set options(options: {
  42366. dragAxis?: Vector3;
  42367. dragPlaneNormal?: Vector3;
  42368. });
  42369. /**
  42370. * Creates a pointer drag behavior that can be attached to a mesh
  42371. * @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)
  42372. */
  42373. constructor(options?: {
  42374. dragAxis?: Vector3;
  42375. dragPlaneNormal?: Vector3;
  42376. });
  42377. /**
  42378. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42379. */
  42380. validateDrag: (targetPosition: Vector3) => boolean;
  42381. /**
  42382. * The name of the behavior
  42383. */
  42384. get name(): string;
  42385. /**
  42386. * Initializes the behavior
  42387. */
  42388. init(): void;
  42389. private _tmpVector;
  42390. private _alternatePickedPoint;
  42391. private _worldDragAxis;
  42392. private _targetPosition;
  42393. private _attachedElement;
  42394. /**
  42395. * Attaches the drag behavior the passed in mesh
  42396. * @param ownerNode The mesh that will be dragged around once attached
  42397. * @param predicate Predicate to use for pick filtering
  42398. */
  42399. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42400. /**
  42401. * Force relase the drag action by code.
  42402. */
  42403. releaseDrag(): void;
  42404. private _startDragRay;
  42405. private _lastPointerRay;
  42406. /**
  42407. * Simulates the start of a pointer drag event on the behavior
  42408. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42409. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42410. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42411. */
  42412. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42413. private _startDrag;
  42414. private _dragDelta;
  42415. private _moveDrag;
  42416. private _pickWithRayOnDragPlane;
  42417. private _pointA;
  42418. private _pointB;
  42419. private _pointC;
  42420. private _lineA;
  42421. private _lineB;
  42422. private _localAxis;
  42423. private _lookAt;
  42424. private _updateDragPlanePosition;
  42425. /**
  42426. * Detaches the behavior from the mesh
  42427. */
  42428. detach(): void;
  42429. }
  42430. }
  42431. declare module BABYLON {
  42432. /**
  42433. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42434. */
  42435. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42436. private _dragBehaviorA;
  42437. private _dragBehaviorB;
  42438. private _startDistance;
  42439. private _initialScale;
  42440. private _targetScale;
  42441. private _ownerNode;
  42442. private _sceneRenderObserver;
  42443. /**
  42444. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42445. */
  42446. constructor();
  42447. /**
  42448. * The name of the behavior
  42449. */
  42450. get name(): string;
  42451. /**
  42452. * Initializes the behavior
  42453. */
  42454. init(): void;
  42455. private _getCurrentDistance;
  42456. /**
  42457. * Attaches the scale behavior the passed in mesh
  42458. * @param ownerNode The mesh that will be scaled around once attached
  42459. */
  42460. attach(ownerNode: Mesh): void;
  42461. /**
  42462. * Detaches the behavior from the mesh
  42463. */
  42464. detach(): void;
  42465. }
  42466. }
  42467. declare module BABYLON {
  42468. /**
  42469. * 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
  42470. */
  42471. export class SixDofDragBehavior implements Behavior<Mesh> {
  42472. private static _virtualScene;
  42473. private _ownerNode;
  42474. private _sceneRenderObserver;
  42475. private _scene;
  42476. private _targetPosition;
  42477. private _virtualOriginMesh;
  42478. private _virtualDragMesh;
  42479. private _pointerObserver;
  42480. private _moving;
  42481. private _startingOrientation;
  42482. private _attachedElement;
  42483. /**
  42484. * 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)
  42485. */
  42486. private zDragFactor;
  42487. /**
  42488. * If the object should rotate to face the drag origin
  42489. */
  42490. rotateDraggedObject: boolean;
  42491. /**
  42492. * If the behavior is currently in a dragging state
  42493. */
  42494. dragging: boolean;
  42495. /**
  42496. * 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)
  42497. */
  42498. dragDeltaRatio: number;
  42499. /**
  42500. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42501. */
  42502. currentDraggingPointerID: number;
  42503. /**
  42504. * If camera controls should be detached during the drag
  42505. */
  42506. detachCameraControls: boolean;
  42507. /**
  42508. * Fires each time a drag starts
  42509. */
  42510. onDragStartObservable: Observable<{}>;
  42511. /**
  42512. * Fires each time a drag ends (eg. mouse release after drag)
  42513. */
  42514. onDragEndObservable: Observable<{}>;
  42515. /**
  42516. * 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
  42517. */
  42518. constructor();
  42519. /**
  42520. * The name of the behavior
  42521. */
  42522. get name(): string;
  42523. /**
  42524. * Initializes the behavior
  42525. */
  42526. init(): void;
  42527. /**
  42528. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42529. */
  42530. private get _pointerCamera();
  42531. /**
  42532. * Attaches the scale behavior the passed in mesh
  42533. * @param ownerNode The mesh that will be scaled around once attached
  42534. */
  42535. attach(ownerNode: Mesh): void;
  42536. /**
  42537. * Detaches the behavior from the mesh
  42538. */
  42539. detach(): void;
  42540. }
  42541. }
  42542. declare module BABYLON {
  42543. /**
  42544. * Class used to apply inverse kinematics to bones
  42545. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42546. */
  42547. export class BoneIKController {
  42548. private static _tmpVecs;
  42549. private static _tmpQuat;
  42550. private static _tmpMats;
  42551. /**
  42552. * Gets or sets the target mesh
  42553. */
  42554. targetMesh: AbstractMesh;
  42555. /** Gets or sets the mesh used as pole */
  42556. poleTargetMesh: AbstractMesh;
  42557. /**
  42558. * Gets or sets the bone used as pole
  42559. */
  42560. poleTargetBone: Nullable<Bone>;
  42561. /**
  42562. * Gets or sets the target position
  42563. */
  42564. targetPosition: Vector3;
  42565. /**
  42566. * Gets or sets the pole target position
  42567. */
  42568. poleTargetPosition: Vector3;
  42569. /**
  42570. * Gets or sets the pole target local offset
  42571. */
  42572. poleTargetLocalOffset: Vector3;
  42573. /**
  42574. * Gets or sets the pole angle
  42575. */
  42576. poleAngle: number;
  42577. /**
  42578. * Gets or sets the mesh associated with the controller
  42579. */
  42580. mesh: AbstractMesh;
  42581. /**
  42582. * 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)
  42583. */
  42584. slerpAmount: number;
  42585. private _bone1Quat;
  42586. private _bone1Mat;
  42587. private _bone2Ang;
  42588. private _bone1;
  42589. private _bone2;
  42590. private _bone1Length;
  42591. private _bone2Length;
  42592. private _maxAngle;
  42593. private _maxReach;
  42594. private _rightHandedSystem;
  42595. private _bendAxis;
  42596. private _slerping;
  42597. private _adjustRoll;
  42598. /**
  42599. * Gets or sets maximum allowed angle
  42600. */
  42601. get maxAngle(): number;
  42602. set maxAngle(value: number);
  42603. /**
  42604. * Creates a new BoneIKController
  42605. * @param mesh defines the mesh to control
  42606. * @param bone defines the bone to control
  42607. * @param options defines options to set up the controller
  42608. */
  42609. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42610. targetMesh?: AbstractMesh;
  42611. poleTargetMesh?: AbstractMesh;
  42612. poleTargetBone?: Bone;
  42613. poleTargetLocalOffset?: Vector3;
  42614. poleAngle?: number;
  42615. bendAxis?: Vector3;
  42616. maxAngle?: number;
  42617. slerpAmount?: number;
  42618. });
  42619. private _setMaxAngle;
  42620. /**
  42621. * Force the controller to update the bones
  42622. */
  42623. update(): void;
  42624. }
  42625. }
  42626. declare module BABYLON {
  42627. /**
  42628. * Class used to make a bone look toward a point in space
  42629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42630. */
  42631. export class BoneLookController {
  42632. private static _tmpVecs;
  42633. private static _tmpQuat;
  42634. private static _tmpMats;
  42635. /**
  42636. * The target Vector3 that the bone will look at
  42637. */
  42638. target: Vector3;
  42639. /**
  42640. * The mesh that the bone is attached to
  42641. */
  42642. mesh: AbstractMesh;
  42643. /**
  42644. * The bone that will be looking to the target
  42645. */
  42646. bone: Bone;
  42647. /**
  42648. * The up axis of the coordinate system that is used when the bone is rotated
  42649. */
  42650. upAxis: Vector3;
  42651. /**
  42652. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42653. */
  42654. upAxisSpace: Space;
  42655. /**
  42656. * Used to make an adjustment to the yaw of the bone
  42657. */
  42658. adjustYaw: number;
  42659. /**
  42660. * Used to make an adjustment to the pitch of the bone
  42661. */
  42662. adjustPitch: number;
  42663. /**
  42664. * Used to make an adjustment to the roll of the bone
  42665. */
  42666. adjustRoll: number;
  42667. /**
  42668. * 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)
  42669. */
  42670. slerpAmount: number;
  42671. private _minYaw;
  42672. private _maxYaw;
  42673. private _minPitch;
  42674. private _maxPitch;
  42675. private _minYawSin;
  42676. private _minYawCos;
  42677. private _maxYawSin;
  42678. private _maxYawCos;
  42679. private _midYawConstraint;
  42680. private _minPitchTan;
  42681. private _maxPitchTan;
  42682. private _boneQuat;
  42683. private _slerping;
  42684. private _transformYawPitch;
  42685. private _transformYawPitchInv;
  42686. private _firstFrameSkipped;
  42687. private _yawRange;
  42688. private _fowardAxis;
  42689. /**
  42690. * Gets or sets the minimum yaw angle that the bone can look to
  42691. */
  42692. get minYaw(): number;
  42693. set minYaw(value: number);
  42694. /**
  42695. * Gets or sets the maximum yaw angle that the bone can look to
  42696. */
  42697. get maxYaw(): number;
  42698. set maxYaw(value: number);
  42699. /**
  42700. * Gets or sets the minimum pitch angle that the bone can look to
  42701. */
  42702. get minPitch(): number;
  42703. set minPitch(value: number);
  42704. /**
  42705. * Gets or sets the maximum pitch angle that the bone can look to
  42706. */
  42707. get maxPitch(): number;
  42708. set maxPitch(value: number);
  42709. /**
  42710. * Create a BoneLookController
  42711. * @param mesh the mesh that the bone belongs to
  42712. * @param bone the bone that will be looking to the target
  42713. * @param target the target Vector3 to look at
  42714. * @param options optional settings:
  42715. * * maxYaw: the maximum angle the bone will yaw to
  42716. * * minYaw: the minimum angle the bone will yaw to
  42717. * * maxPitch: the maximum angle the bone will pitch to
  42718. * * minPitch: the minimum angle the bone will yaw to
  42719. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42720. * * upAxis: the up axis of the coordinate system
  42721. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42722. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42723. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42724. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42725. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42726. * * adjustRoll: used to make an adjustment to the roll of the bone
  42727. **/
  42728. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42729. maxYaw?: number;
  42730. minYaw?: number;
  42731. maxPitch?: number;
  42732. minPitch?: number;
  42733. slerpAmount?: number;
  42734. upAxis?: Vector3;
  42735. upAxisSpace?: Space;
  42736. yawAxis?: Vector3;
  42737. pitchAxis?: Vector3;
  42738. adjustYaw?: number;
  42739. adjustPitch?: number;
  42740. adjustRoll?: number;
  42741. });
  42742. /**
  42743. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42744. */
  42745. update(): void;
  42746. private _getAngleDiff;
  42747. private _getAngleBetween;
  42748. private _isAngleBetween;
  42749. }
  42750. }
  42751. declare module BABYLON {
  42752. /**
  42753. * Manage the gamepad inputs to control an arc rotate camera.
  42754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42755. */
  42756. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42757. /**
  42758. * Defines the camera the input is attached to.
  42759. */
  42760. camera: ArcRotateCamera;
  42761. /**
  42762. * Defines the gamepad the input is gathering event from.
  42763. */
  42764. gamepad: Nullable<Gamepad>;
  42765. /**
  42766. * Defines the gamepad rotation sensiblity.
  42767. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42768. */
  42769. gamepadRotationSensibility: number;
  42770. /**
  42771. * Defines the gamepad move sensiblity.
  42772. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42773. */
  42774. gamepadMoveSensibility: number;
  42775. private _yAxisScale;
  42776. /**
  42777. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42778. */
  42779. get invertYAxis(): boolean;
  42780. set invertYAxis(value: boolean);
  42781. private _onGamepadConnectedObserver;
  42782. private _onGamepadDisconnectedObserver;
  42783. /**
  42784. * Attach the input controls to a specific dom element to get the input from.
  42785. * @param element Defines the element the controls should be listened from
  42786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42787. */
  42788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42789. /**
  42790. * Detach the current controls from the specified dom element.
  42791. * @param element Defines the element to stop listening the inputs from
  42792. */
  42793. detachControl(element: Nullable<HTMLElement>): void;
  42794. /**
  42795. * Update the current camera state depending on the inputs that have been used this frame.
  42796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42797. */
  42798. checkInputs(): void;
  42799. /**
  42800. * Gets the class name of the current intput.
  42801. * @returns the class name
  42802. */
  42803. getClassName(): string;
  42804. /**
  42805. * Get the friendly name associated with the input class.
  42806. * @returns the input friendly name
  42807. */
  42808. getSimpleName(): string;
  42809. }
  42810. }
  42811. declare module BABYLON {
  42812. interface ArcRotateCameraInputsManager {
  42813. /**
  42814. * Add orientation input support to the input manager.
  42815. * @returns the current input manager
  42816. */
  42817. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42818. }
  42819. /**
  42820. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42822. */
  42823. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42824. /**
  42825. * Defines the camera the input is attached to.
  42826. */
  42827. camera: ArcRotateCamera;
  42828. /**
  42829. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42830. */
  42831. alphaCorrection: number;
  42832. /**
  42833. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42834. */
  42835. gammaCorrection: number;
  42836. private _alpha;
  42837. private _gamma;
  42838. private _dirty;
  42839. private _deviceOrientationHandler;
  42840. /**
  42841. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42842. */
  42843. constructor();
  42844. /**
  42845. * Attach the input controls to a specific dom element to get the input from.
  42846. * @param element Defines the element the controls should be listened from
  42847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42848. */
  42849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42850. /** @hidden */
  42851. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42852. /**
  42853. * Update the current camera state depending on the inputs that have been used this frame.
  42854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42855. */
  42856. checkInputs(): void;
  42857. /**
  42858. * Detach the current controls from the specified dom element.
  42859. * @param element Defines the element to stop listening the inputs from
  42860. */
  42861. detachControl(element: Nullable<HTMLElement>): void;
  42862. /**
  42863. * Gets the class name of the current intput.
  42864. * @returns the class name
  42865. */
  42866. getClassName(): string;
  42867. /**
  42868. * Get the friendly name associated with the input class.
  42869. * @returns the input friendly name
  42870. */
  42871. getSimpleName(): string;
  42872. }
  42873. }
  42874. declare module BABYLON {
  42875. /**
  42876. * Listen to mouse events to control the camera.
  42877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42878. */
  42879. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42880. /**
  42881. * Defines the camera the input is attached to.
  42882. */
  42883. camera: FlyCamera;
  42884. /**
  42885. * Defines if touch is enabled. (Default is true.)
  42886. */
  42887. touchEnabled: boolean;
  42888. /**
  42889. * Defines the buttons associated with the input to handle camera rotation.
  42890. */
  42891. buttons: number[];
  42892. /**
  42893. * Assign buttons for Yaw control.
  42894. */
  42895. buttonsYaw: number[];
  42896. /**
  42897. * Assign buttons for Pitch control.
  42898. */
  42899. buttonsPitch: number[];
  42900. /**
  42901. * Assign buttons for Roll control.
  42902. */
  42903. buttonsRoll: number[];
  42904. /**
  42905. * Detect if any button is being pressed while mouse is moved.
  42906. * -1 = Mouse locked.
  42907. * 0 = Left button.
  42908. * 1 = Middle Button.
  42909. * 2 = Right Button.
  42910. */
  42911. activeButton: number;
  42912. /**
  42913. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42914. * Higher values reduce its sensitivity.
  42915. */
  42916. angularSensibility: number;
  42917. private _mousemoveCallback;
  42918. private _observer;
  42919. private _rollObserver;
  42920. private previousPosition;
  42921. private noPreventDefault;
  42922. private element;
  42923. /**
  42924. * Listen to mouse events to control the camera.
  42925. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42927. */
  42928. constructor(touchEnabled?: boolean);
  42929. /**
  42930. * Attach the mouse control to the HTML DOM element.
  42931. * @param element Defines the element that listens to the input events.
  42932. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42933. */
  42934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42935. /**
  42936. * Detach the current controls from the specified dom element.
  42937. * @param element Defines the element to stop listening the inputs from
  42938. */
  42939. detachControl(element: Nullable<HTMLElement>): void;
  42940. /**
  42941. * Gets the class name of the current input.
  42942. * @returns the class name.
  42943. */
  42944. getClassName(): string;
  42945. /**
  42946. * Get the friendly name associated with the input class.
  42947. * @returns the input's friendly name.
  42948. */
  42949. getSimpleName(): string;
  42950. private _pointerInput;
  42951. private _onMouseMove;
  42952. /**
  42953. * Rotate camera by mouse offset.
  42954. */
  42955. private rotateCamera;
  42956. }
  42957. }
  42958. declare module BABYLON {
  42959. /**
  42960. * Default Inputs manager for the FlyCamera.
  42961. * It groups all the default supported inputs for ease of use.
  42962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42963. */
  42964. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42965. /**
  42966. * Instantiates a new FlyCameraInputsManager.
  42967. * @param camera Defines the camera the inputs belong to.
  42968. */
  42969. constructor(camera: FlyCamera);
  42970. /**
  42971. * Add keyboard input support to the input manager.
  42972. * @returns the new FlyCameraKeyboardMoveInput().
  42973. */
  42974. addKeyboard(): FlyCameraInputsManager;
  42975. /**
  42976. * Add mouse input support to the input manager.
  42977. * @param touchEnabled Enable touch screen support.
  42978. * @returns the new FlyCameraMouseInput().
  42979. */
  42980. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42981. }
  42982. }
  42983. declare module BABYLON {
  42984. /**
  42985. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42986. * such as in a 3D Space Shooter or a Flight Simulator.
  42987. */
  42988. export class FlyCamera extends TargetCamera {
  42989. /**
  42990. * Define the collision ellipsoid of the camera.
  42991. * This is helpful for simulating a camera body, like a player's body.
  42992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42993. */
  42994. ellipsoid: Vector3;
  42995. /**
  42996. * Define an offset for the position of the ellipsoid around the camera.
  42997. * This can be helpful if the camera is attached away from the player's body center,
  42998. * such as at its head.
  42999. */
  43000. ellipsoidOffset: Vector3;
  43001. /**
  43002. * Enable or disable collisions of the camera with the rest of the scene objects.
  43003. */
  43004. checkCollisions: boolean;
  43005. /**
  43006. * Enable or disable gravity on the camera.
  43007. */
  43008. applyGravity: boolean;
  43009. /**
  43010. * Define the current direction the camera is moving to.
  43011. */
  43012. cameraDirection: Vector3;
  43013. /**
  43014. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43015. * This overrides and empties cameraRotation.
  43016. */
  43017. rotationQuaternion: Quaternion;
  43018. /**
  43019. * Track Roll to maintain the wanted Rolling when looking around.
  43020. */
  43021. _trackRoll: number;
  43022. /**
  43023. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43024. */
  43025. rollCorrect: number;
  43026. /**
  43027. * Mimic a banked turn, Rolling the camera when Yawing.
  43028. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43029. */
  43030. bankedTurn: boolean;
  43031. /**
  43032. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43033. */
  43034. bankedTurnLimit: number;
  43035. /**
  43036. * Value of 0 disables the banked Roll.
  43037. * Value of 1 is equal to the Yaw angle in radians.
  43038. */
  43039. bankedTurnMultiplier: number;
  43040. /**
  43041. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43042. */
  43043. inputs: FlyCameraInputsManager;
  43044. /**
  43045. * Gets the input sensibility for mouse input.
  43046. * Higher values reduce sensitivity.
  43047. */
  43048. get angularSensibility(): number;
  43049. /**
  43050. * Sets the input sensibility for a mouse input.
  43051. * Higher values reduce sensitivity.
  43052. */
  43053. set angularSensibility(value: number);
  43054. /**
  43055. * Get the keys for camera movement forward.
  43056. */
  43057. get keysForward(): number[];
  43058. /**
  43059. * Set the keys for camera movement forward.
  43060. */
  43061. set keysForward(value: number[]);
  43062. /**
  43063. * Get the keys for camera movement backward.
  43064. */
  43065. get keysBackward(): number[];
  43066. set keysBackward(value: number[]);
  43067. /**
  43068. * Get the keys for camera movement up.
  43069. */
  43070. get keysUp(): number[];
  43071. /**
  43072. * Set the keys for camera movement up.
  43073. */
  43074. set keysUp(value: number[]);
  43075. /**
  43076. * Get the keys for camera movement down.
  43077. */
  43078. get keysDown(): number[];
  43079. /**
  43080. * Set the keys for camera movement down.
  43081. */
  43082. set keysDown(value: number[]);
  43083. /**
  43084. * Get the keys for camera movement left.
  43085. */
  43086. get keysLeft(): number[];
  43087. /**
  43088. * Set the keys for camera movement left.
  43089. */
  43090. set keysLeft(value: number[]);
  43091. /**
  43092. * Set the keys for camera movement right.
  43093. */
  43094. get keysRight(): number[];
  43095. /**
  43096. * Set the keys for camera movement right.
  43097. */
  43098. set keysRight(value: number[]);
  43099. /**
  43100. * Event raised when the camera collides with a mesh in the scene.
  43101. */
  43102. onCollide: (collidedMesh: AbstractMesh) => void;
  43103. private _collider;
  43104. private _needMoveForGravity;
  43105. private _oldPosition;
  43106. private _diffPosition;
  43107. private _newPosition;
  43108. /** @hidden */
  43109. _localDirection: Vector3;
  43110. /** @hidden */
  43111. _transformedDirection: Vector3;
  43112. /**
  43113. * Instantiates a FlyCamera.
  43114. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43115. * such as in a 3D Space Shooter or a Flight Simulator.
  43116. * @param name Define the name of the camera in the scene.
  43117. * @param position Define the starting position of the camera in the scene.
  43118. * @param scene Define the scene the camera belongs to.
  43119. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43120. */
  43121. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43122. /**
  43123. * Attach a control to the HTML DOM element.
  43124. * @param element Defines the element that listens to the input events.
  43125. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43126. */
  43127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43128. /**
  43129. * Detach a control from the HTML DOM element.
  43130. * The camera will stop reacting to that input.
  43131. * @param element Defines the element that listens to the input events.
  43132. */
  43133. detachControl(element: HTMLElement): void;
  43134. private _collisionMask;
  43135. /**
  43136. * Get the mask that the camera ignores in collision events.
  43137. */
  43138. get collisionMask(): number;
  43139. /**
  43140. * Set the mask that the camera ignores in collision events.
  43141. */
  43142. set collisionMask(mask: number);
  43143. /** @hidden */
  43144. _collideWithWorld(displacement: Vector3): void;
  43145. /** @hidden */
  43146. private _onCollisionPositionChange;
  43147. /** @hidden */
  43148. _checkInputs(): void;
  43149. /** @hidden */
  43150. _decideIfNeedsToMove(): boolean;
  43151. /** @hidden */
  43152. _updatePosition(): void;
  43153. /**
  43154. * Restore the Roll to its target value at the rate specified.
  43155. * @param rate - Higher means slower restoring.
  43156. * @hidden
  43157. */
  43158. restoreRoll(rate: number): void;
  43159. /**
  43160. * Destroy the camera and release the current resources held by it.
  43161. */
  43162. dispose(): void;
  43163. /**
  43164. * Get the current object class name.
  43165. * @returns the class name.
  43166. */
  43167. getClassName(): string;
  43168. }
  43169. }
  43170. declare module BABYLON {
  43171. /**
  43172. * Listen to keyboard events to control the camera.
  43173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43174. */
  43175. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43176. /**
  43177. * Defines the camera the input is attached to.
  43178. */
  43179. camera: FlyCamera;
  43180. /**
  43181. * The list of keyboard keys used to control the forward move of the camera.
  43182. */
  43183. keysForward: number[];
  43184. /**
  43185. * The list of keyboard keys used to control the backward move of the camera.
  43186. */
  43187. keysBackward: number[];
  43188. /**
  43189. * The list of keyboard keys used to control the forward move of the camera.
  43190. */
  43191. keysUp: number[];
  43192. /**
  43193. * The list of keyboard keys used to control the backward move of the camera.
  43194. */
  43195. keysDown: number[];
  43196. /**
  43197. * The list of keyboard keys used to control the right strafe move of the camera.
  43198. */
  43199. keysRight: number[];
  43200. /**
  43201. * The list of keyboard keys used to control the left strafe move of the camera.
  43202. */
  43203. keysLeft: number[];
  43204. private _keys;
  43205. private _onCanvasBlurObserver;
  43206. private _onKeyboardObserver;
  43207. private _engine;
  43208. private _scene;
  43209. /**
  43210. * Attach the input controls to a specific dom element to get the input from.
  43211. * @param element Defines the element the controls should be listened from
  43212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43213. */
  43214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43215. /**
  43216. * Detach the current controls from the specified dom element.
  43217. * @param element Defines the element to stop listening the inputs from
  43218. */
  43219. detachControl(element: Nullable<HTMLElement>): void;
  43220. /**
  43221. * Gets the class name of the current intput.
  43222. * @returns the class name
  43223. */
  43224. getClassName(): string;
  43225. /** @hidden */
  43226. _onLostFocus(e: FocusEvent): void;
  43227. /**
  43228. * Get the friendly name associated with the input class.
  43229. * @returns the input friendly name
  43230. */
  43231. getSimpleName(): string;
  43232. /**
  43233. * Update the current camera state depending on the inputs that have been used this frame.
  43234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43235. */
  43236. checkInputs(): void;
  43237. }
  43238. }
  43239. declare module BABYLON {
  43240. /**
  43241. * Manage the mouse wheel inputs to control a follow camera.
  43242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43243. */
  43244. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43245. /**
  43246. * Defines the camera the input is attached to.
  43247. */
  43248. camera: FollowCamera;
  43249. /**
  43250. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43251. */
  43252. axisControlRadius: boolean;
  43253. /**
  43254. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43255. */
  43256. axisControlHeight: boolean;
  43257. /**
  43258. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43259. */
  43260. axisControlRotation: boolean;
  43261. /**
  43262. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43263. * relation to mouseWheel events.
  43264. */
  43265. wheelPrecision: number;
  43266. /**
  43267. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43268. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43269. */
  43270. wheelDeltaPercentage: number;
  43271. private _wheel;
  43272. private _observer;
  43273. /**
  43274. * Attach the input controls to a specific dom element to get the input from.
  43275. * @param element Defines the element the controls should be listened from
  43276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43277. */
  43278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43279. /**
  43280. * Detach the current controls from the specified dom element.
  43281. * @param element Defines the element to stop listening the inputs from
  43282. */
  43283. detachControl(element: Nullable<HTMLElement>): void;
  43284. /**
  43285. * Gets the class name of the current intput.
  43286. * @returns the class name
  43287. */
  43288. getClassName(): string;
  43289. /**
  43290. * Get the friendly name associated with the input class.
  43291. * @returns the input friendly name
  43292. */
  43293. getSimpleName(): string;
  43294. }
  43295. }
  43296. declare module BABYLON {
  43297. /**
  43298. * Manage the pointers inputs to control an follow camera.
  43299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43300. */
  43301. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43302. /**
  43303. * Defines the camera the input is attached to.
  43304. */
  43305. camera: FollowCamera;
  43306. /**
  43307. * Gets the class name of the current input.
  43308. * @returns the class name
  43309. */
  43310. getClassName(): string;
  43311. /**
  43312. * Defines the pointer angular sensibility along the X axis or how fast is
  43313. * the camera rotating.
  43314. * A negative number will reverse the axis direction.
  43315. */
  43316. angularSensibilityX: number;
  43317. /**
  43318. * Defines the pointer angular sensibility along the Y axis or how fast is
  43319. * the camera rotating.
  43320. * A negative number will reverse the axis direction.
  43321. */
  43322. angularSensibilityY: number;
  43323. /**
  43324. * Defines the pointer pinch precision or how fast is the camera zooming.
  43325. * A negative number will reverse the axis direction.
  43326. */
  43327. pinchPrecision: number;
  43328. /**
  43329. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43330. * from 0.
  43331. * It defines the percentage of current camera.radius to use as delta when
  43332. * pinch zoom is used.
  43333. */
  43334. pinchDeltaPercentage: number;
  43335. /**
  43336. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43337. */
  43338. axisXControlRadius: boolean;
  43339. /**
  43340. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43341. */
  43342. axisXControlHeight: boolean;
  43343. /**
  43344. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43345. */
  43346. axisXControlRotation: boolean;
  43347. /**
  43348. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43349. */
  43350. axisYControlRadius: boolean;
  43351. /**
  43352. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43353. */
  43354. axisYControlHeight: boolean;
  43355. /**
  43356. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43357. */
  43358. axisYControlRotation: boolean;
  43359. /**
  43360. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43361. */
  43362. axisPinchControlRadius: boolean;
  43363. /**
  43364. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43365. */
  43366. axisPinchControlHeight: boolean;
  43367. /**
  43368. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43369. */
  43370. axisPinchControlRotation: boolean;
  43371. /**
  43372. * Log error messages if basic misconfiguration has occurred.
  43373. */
  43374. warningEnable: boolean;
  43375. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43376. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43377. private _warningCounter;
  43378. private _warning;
  43379. }
  43380. }
  43381. declare module BABYLON {
  43382. /**
  43383. * Default Inputs manager for the FollowCamera.
  43384. * It groups all the default supported inputs for ease of use.
  43385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43386. */
  43387. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43388. /**
  43389. * Instantiates a new FollowCameraInputsManager.
  43390. * @param camera Defines the camera the inputs belong to
  43391. */
  43392. constructor(camera: FollowCamera);
  43393. /**
  43394. * Add keyboard input support to the input manager.
  43395. * @returns the current input manager
  43396. */
  43397. addKeyboard(): FollowCameraInputsManager;
  43398. /**
  43399. * Add mouse wheel input support to the input manager.
  43400. * @returns the current input manager
  43401. */
  43402. addMouseWheel(): FollowCameraInputsManager;
  43403. /**
  43404. * Add pointers input support to the input manager.
  43405. * @returns the current input manager
  43406. */
  43407. addPointers(): FollowCameraInputsManager;
  43408. /**
  43409. * Add orientation input support to the input manager.
  43410. * @returns the current input manager
  43411. */
  43412. addVRDeviceOrientation(): FollowCameraInputsManager;
  43413. }
  43414. }
  43415. declare module BABYLON {
  43416. /**
  43417. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43418. * an arc rotate version arcFollowCamera are available.
  43419. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43420. */
  43421. export class FollowCamera extends TargetCamera {
  43422. /**
  43423. * Distance the follow camera should follow an object at
  43424. */
  43425. radius: number;
  43426. /**
  43427. * Minimum allowed distance of the camera to the axis of rotation
  43428. * (The camera can not get closer).
  43429. * This can help limiting how the Camera is able to move in the scene.
  43430. */
  43431. lowerRadiusLimit: Nullable<number>;
  43432. /**
  43433. * Maximum allowed distance of the camera to the axis of rotation
  43434. * (The camera can not get further).
  43435. * This can help limiting how the Camera is able to move in the scene.
  43436. */
  43437. upperRadiusLimit: Nullable<number>;
  43438. /**
  43439. * Define a rotation offset between the camera and the object it follows
  43440. */
  43441. rotationOffset: number;
  43442. /**
  43443. * Minimum allowed angle to camera position relative to target object.
  43444. * This can help limiting how the Camera is able to move in the scene.
  43445. */
  43446. lowerRotationOffsetLimit: Nullable<number>;
  43447. /**
  43448. * Maximum allowed angle to camera position relative to target object.
  43449. * This can help limiting how the Camera is able to move in the scene.
  43450. */
  43451. upperRotationOffsetLimit: Nullable<number>;
  43452. /**
  43453. * Define a height offset between the camera and the object it follows.
  43454. * It can help following an object from the top (like a car chaing a plane)
  43455. */
  43456. heightOffset: number;
  43457. /**
  43458. * Minimum allowed height of camera position relative to target object.
  43459. * This can help limiting how the Camera is able to move in the scene.
  43460. */
  43461. lowerHeightOffsetLimit: Nullable<number>;
  43462. /**
  43463. * Maximum allowed height of camera position relative to target object.
  43464. * This can help limiting how the Camera is able to move in the scene.
  43465. */
  43466. upperHeightOffsetLimit: Nullable<number>;
  43467. /**
  43468. * Define how fast the camera can accelerate to follow it s target.
  43469. */
  43470. cameraAcceleration: number;
  43471. /**
  43472. * Define the speed limit of the camera following an object.
  43473. */
  43474. maxCameraSpeed: number;
  43475. /**
  43476. * Define the target of the camera.
  43477. */
  43478. lockedTarget: Nullable<AbstractMesh>;
  43479. /**
  43480. * Defines the input associated with the camera.
  43481. */
  43482. inputs: FollowCameraInputsManager;
  43483. /**
  43484. * Instantiates the follow camera.
  43485. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43486. * @param name Define the name of the camera in the scene
  43487. * @param position Define the position of the camera
  43488. * @param scene Define the scene the camera belong to
  43489. * @param lockedTarget Define the target of the camera
  43490. */
  43491. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43492. private _follow;
  43493. /**
  43494. * Attached controls to the current camera.
  43495. * @param element Defines the element the controls should be listened from
  43496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43497. */
  43498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43499. /**
  43500. * Detach the current controls from the camera.
  43501. * The camera will stop reacting to inputs.
  43502. * @param element Defines the element to stop listening the inputs from
  43503. */
  43504. detachControl(element: HTMLElement): void;
  43505. /** @hidden */
  43506. _checkInputs(): void;
  43507. private _checkLimits;
  43508. /**
  43509. * Gets the camera class name.
  43510. * @returns the class name
  43511. */
  43512. getClassName(): string;
  43513. }
  43514. /**
  43515. * Arc Rotate version of the follow camera.
  43516. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43517. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43518. */
  43519. export class ArcFollowCamera extends TargetCamera {
  43520. /** The longitudinal angle of the camera */
  43521. alpha: number;
  43522. /** The latitudinal angle of the camera */
  43523. beta: number;
  43524. /** The radius of the camera from its target */
  43525. radius: number;
  43526. /** Define the camera target (the messh it should follow) */
  43527. target: Nullable<AbstractMesh>;
  43528. private _cartesianCoordinates;
  43529. /**
  43530. * Instantiates a new ArcFollowCamera
  43531. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43532. * @param name Define the name of the camera
  43533. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43534. * @param beta Define the rotation angle of the camera around the elevation axis
  43535. * @param radius Define the radius of the camera from its target point
  43536. * @param target Define the target of the camera
  43537. * @param scene Define the scene the camera belongs to
  43538. */
  43539. constructor(name: string,
  43540. /** The longitudinal angle of the camera */
  43541. alpha: number,
  43542. /** The latitudinal angle of the camera */
  43543. beta: number,
  43544. /** The radius of the camera from its target */
  43545. radius: number,
  43546. /** Define the camera target (the messh it should follow) */
  43547. target: Nullable<AbstractMesh>, scene: Scene);
  43548. private _follow;
  43549. /** @hidden */
  43550. _checkInputs(): void;
  43551. /**
  43552. * Returns the class name of the object.
  43553. * It is mostly used internally for serialization purposes.
  43554. */
  43555. getClassName(): string;
  43556. }
  43557. }
  43558. declare module BABYLON {
  43559. /**
  43560. * Manage the keyboard inputs to control the movement of a follow camera.
  43561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43562. */
  43563. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43564. /**
  43565. * Defines the camera the input is attached to.
  43566. */
  43567. camera: FollowCamera;
  43568. /**
  43569. * Defines the list of key codes associated with the up action (increase heightOffset)
  43570. */
  43571. keysHeightOffsetIncr: number[];
  43572. /**
  43573. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43574. */
  43575. keysHeightOffsetDecr: number[];
  43576. /**
  43577. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43578. */
  43579. keysHeightOffsetModifierAlt: boolean;
  43580. /**
  43581. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43582. */
  43583. keysHeightOffsetModifierCtrl: boolean;
  43584. /**
  43585. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43586. */
  43587. keysHeightOffsetModifierShift: boolean;
  43588. /**
  43589. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43590. */
  43591. keysRotationOffsetIncr: number[];
  43592. /**
  43593. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43594. */
  43595. keysRotationOffsetDecr: number[];
  43596. /**
  43597. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43598. */
  43599. keysRotationOffsetModifierAlt: boolean;
  43600. /**
  43601. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43602. */
  43603. keysRotationOffsetModifierCtrl: boolean;
  43604. /**
  43605. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43606. */
  43607. keysRotationOffsetModifierShift: boolean;
  43608. /**
  43609. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43610. */
  43611. keysRadiusIncr: number[];
  43612. /**
  43613. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43614. */
  43615. keysRadiusDecr: number[];
  43616. /**
  43617. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43618. */
  43619. keysRadiusModifierAlt: boolean;
  43620. /**
  43621. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43622. */
  43623. keysRadiusModifierCtrl: boolean;
  43624. /**
  43625. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43626. */
  43627. keysRadiusModifierShift: boolean;
  43628. /**
  43629. * Defines the rate of change of heightOffset.
  43630. */
  43631. heightSensibility: number;
  43632. /**
  43633. * Defines the rate of change of rotationOffset.
  43634. */
  43635. rotationSensibility: number;
  43636. /**
  43637. * Defines the rate of change of radius.
  43638. */
  43639. radiusSensibility: number;
  43640. private _keys;
  43641. private _ctrlPressed;
  43642. private _altPressed;
  43643. private _shiftPressed;
  43644. private _onCanvasBlurObserver;
  43645. private _onKeyboardObserver;
  43646. private _engine;
  43647. private _scene;
  43648. /**
  43649. * Attach the input controls to a specific dom element to get the input from.
  43650. * @param element Defines the element the controls should be listened from
  43651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43652. */
  43653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43654. /**
  43655. * Detach the current controls from the specified dom element.
  43656. * @param element Defines the element to stop listening the inputs from
  43657. */
  43658. detachControl(element: Nullable<HTMLElement>): void;
  43659. /**
  43660. * Update the current camera state depending on the inputs that have been used this frame.
  43661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43662. */
  43663. checkInputs(): void;
  43664. /**
  43665. * Gets the class name of the current input.
  43666. * @returns the class name
  43667. */
  43668. getClassName(): string;
  43669. /**
  43670. * Get the friendly name associated with the input class.
  43671. * @returns the input friendly name
  43672. */
  43673. getSimpleName(): string;
  43674. /**
  43675. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43676. * allow modification of the heightOffset value.
  43677. */
  43678. private _modifierHeightOffset;
  43679. /**
  43680. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43681. * allow modification of the rotationOffset value.
  43682. */
  43683. private _modifierRotationOffset;
  43684. /**
  43685. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43686. * allow modification of the radius value.
  43687. */
  43688. private _modifierRadius;
  43689. }
  43690. }
  43691. declare module BABYLON {
  43692. interface FreeCameraInputsManager {
  43693. /**
  43694. * @hidden
  43695. */
  43696. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43697. /**
  43698. * Add orientation input support to the input manager.
  43699. * @returns the current input manager
  43700. */
  43701. addDeviceOrientation(): FreeCameraInputsManager;
  43702. }
  43703. /**
  43704. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43705. * Screen rotation is taken into account.
  43706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43707. */
  43708. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43709. private _camera;
  43710. private _screenOrientationAngle;
  43711. private _constantTranform;
  43712. private _screenQuaternion;
  43713. private _alpha;
  43714. private _beta;
  43715. private _gamma;
  43716. /**
  43717. * Can be used to detect if a device orientation sensor is available on a device
  43718. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43719. * @returns a promise that will resolve on orientation change
  43720. */
  43721. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43722. /**
  43723. * @hidden
  43724. */
  43725. _onDeviceOrientationChangedObservable: Observable<void>;
  43726. /**
  43727. * Instantiates a new input
  43728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43729. */
  43730. constructor();
  43731. /**
  43732. * Define the camera controlled by the input.
  43733. */
  43734. get camera(): FreeCamera;
  43735. set camera(camera: FreeCamera);
  43736. /**
  43737. * Attach the input controls to a specific dom element to get the input from.
  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. private _orientationChanged;
  43743. private _deviceOrientation;
  43744. /**
  43745. * Detach the current controls from the specified dom element.
  43746. * @param element Defines the element to stop listening the inputs from
  43747. */
  43748. detachControl(element: Nullable<HTMLElement>): void;
  43749. /**
  43750. * Update the current camera state depending on the inputs that have been used this frame.
  43751. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43752. */
  43753. checkInputs(): void;
  43754. /**
  43755. * Gets the class name of the current intput.
  43756. * @returns the class name
  43757. */
  43758. getClassName(): string;
  43759. /**
  43760. * Get the friendly name associated with the input class.
  43761. * @returns the input friendly name
  43762. */
  43763. getSimpleName(): string;
  43764. }
  43765. }
  43766. declare module BABYLON {
  43767. /**
  43768. * Manage the gamepad inputs to control a free camera.
  43769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43770. */
  43771. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43772. /**
  43773. * Define the camera the input is attached to.
  43774. */
  43775. camera: FreeCamera;
  43776. /**
  43777. * Define the Gamepad controlling the input
  43778. */
  43779. gamepad: Nullable<Gamepad>;
  43780. /**
  43781. * Defines the gamepad rotation sensiblity.
  43782. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43783. */
  43784. gamepadAngularSensibility: number;
  43785. /**
  43786. * Defines the gamepad move sensiblity.
  43787. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43788. */
  43789. gamepadMoveSensibility: number;
  43790. private _yAxisScale;
  43791. /**
  43792. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43793. */
  43794. get invertYAxis(): boolean;
  43795. set invertYAxis(value: boolean);
  43796. private _onGamepadConnectedObserver;
  43797. private _onGamepadDisconnectedObserver;
  43798. private _cameraTransform;
  43799. private _deltaTransform;
  43800. private _vector3;
  43801. private _vector2;
  43802. /**
  43803. * Attach the input controls to a specific dom element to get the input from.
  43804. * @param element Defines the element the controls should be listened from
  43805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43806. */
  43807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43808. /**
  43809. * Detach the current controls from the specified dom element.
  43810. * @param element Defines the element to stop listening the inputs from
  43811. */
  43812. detachControl(element: Nullable<HTMLElement>): void;
  43813. /**
  43814. * Update the current camera state depending on the inputs that have been used this frame.
  43815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43816. */
  43817. checkInputs(): void;
  43818. /**
  43819. * Gets the class name of the current intput.
  43820. * @returns the class name
  43821. */
  43822. getClassName(): string;
  43823. /**
  43824. * Get the friendly name associated with the input class.
  43825. * @returns the input friendly name
  43826. */
  43827. getSimpleName(): string;
  43828. }
  43829. }
  43830. declare module BABYLON {
  43831. /**
  43832. * Defines the potential axis of a Joystick
  43833. */
  43834. export enum JoystickAxis {
  43835. /** X axis */
  43836. X = 0,
  43837. /** Y axis */
  43838. Y = 1,
  43839. /** Z axis */
  43840. Z = 2
  43841. }
  43842. /**
  43843. * Class used to define virtual joystick (used in touch mode)
  43844. */
  43845. export class VirtualJoystick {
  43846. /**
  43847. * Gets or sets a boolean indicating that left and right values must be inverted
  43848. */
  43849. reverseLeftRight: boolean;
  43850. /**
  43851. * Gets or sets a boolean indicating that up and down values must be inverted
  43852. */
  43853. reverseUpDown: boolean;
  43854. /**
  43855. * Gets the offset value for the position (ie. the change of the position value)
  43856. */
  43857. deltaPosition: Vector3;
  43858. /**
  43859. * Gets a boolean indicating if the virtual joystick was pressed
  43860. */
  43861. pressed: boolean;
  43862. /**
  43863. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43864. */
  43865. static Canvas: Nullable<HTMLCanvasElement>;
  43866. private static _globalJoystickIndex;
  43867. private static vjCanvasContext;
  43868. private static vjCanvasWidth;
  43869. private static vjCanvasHeight;
  43870. private static halfWidth;
  43871. private _action;
  43872. private _axisTargetedByLeftAndRight;
  43873. private _axisTargetedByUpAndDown;
  43874. private _joystickSensibility;
  43875. private _inversedSensibility;
  43876. private _joystickPointerID;
  43877. private _joystickColor;
  43878. private _joystickPointerPos;
  43879. private _joystickPreviousPointerPos;
  43880. private _joystickPointerStartPos;
  43881. private _deltaJoystickVector;
  43882. private _leftJoystick;
  43883. private _touches;
  43884. private _onPointerDownHandlerRef;
  43885. private _onPointerMoveHandlerRef;
  43886. private _onPointerUpHandlerRef;
  43887. private _onResize;
  43888. /**
  43889. * Creates a new virtual joystick
  43890. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43891. */
  43892. constructor(leftJoystick?: boolean);
  43893. /**
  43894. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43895. * @param newJoystickSensibility defines the new sensibility
  43896. */
  43897. setJoystickSensibility(newJoystickSensibility: number): void;
  43898. private _onPointerDown;
  43899. private _onPointerMove;
  43900. private _onPointerUp;
  43901. /**
  43902. * Change the color of the virtual joystick
  43903. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43904. */
  43905. setJoystickColor(newColor: string): void;
  43906. /**
  43907. * Defines a callback to call when the joystick is touched
  43908. * @param action defines the callback
  43909. */
  43910. setActionOnTouch(action: () => any): void;
  43911. /**
  43912. * Defines which axis you'd like to control for left & right
  43913. * @param axis defines the axis to use
  43914. */
  43915. setAxisForLeftRight(axis: JoystickAxis): void;
  43916. /**
  43917. * Defines which axis you'd like to control for up & down
  43918. * @param axis defines the axis to use
  43919. */
  43920. setAxisForUpDown(axis: JoystickAxis): void;
  43921. private _drawVirtualJoystick;
  43922. /**
  43923. * Release internal HTML canvas
  43924. */
  43925. releaseCanvas(): void;
  43926. }
  43927. }
  43928. declare module BABYLON {
  43929. interface FreeCameraInputsManager {
  43930. /**
  43931. * Add virtual joystick input support to the input manager.
  43932. * @returns the current input manager
  43933. */
  43934. addVirtualJoystick(): FreeCameraInputsManager;
  43935. }
  43936. /**
  43937. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43939. */
  43940. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43941. /**
  43942. * Defines the camera the input is attached to.
  43943. */
  43944. camera: FreeCamera;
  43945. private _leftjoystick;
  43946. private _rightjoystick;
  43947. /**
  43948. * Gets the left stick of the virtual joystick.
  43949. * @returns The virtual Joystick
  43950. */
  43951. getLeftJoystick(): VirtualJoystick;
  43952. /**
  43953. * Gets the right stick of the virtual joystick.
  43954. * @returns The virtual Joystick
  43955. */
  43956. getRightJoystick(): VirtualJoystick;
  43957. /**
  43958. * Update the current camera state depending on the inputs that have been used this frame.
  43959. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43960. */
  43961. checkInputs(): void;
  43962. /**
  43963. * Attach the input controls to a specific dom element to get the input from.
  43964. * @param element Defines the element the controls should be listened from
  43965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43966. */
  43967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43968. /**
  43969. * Detach the current controls from the specified dom element.
  43970. * @param element Defines the element to stop listening the inputs from
  43971. */
  43972. detachControl(element: Nullable<HTMLElement>): void;
  43973. /**
  43974. * Gets the class name of the current intput.
  43975. * @returns the class name
  43976. */
  43977. getClassName(): string;
  43978. /**
  43979. * Get the friendly name associated with the input class.
  43980. * @returns the input friendly name
  43981. */
  43982. getSimpleName(): string;
  43983. }
  43984. }
  43985. declare module BABYLON {
  43986. /**
  43987. * This represents a FPS type of camera controlled by touch.
  43988. * This is like a universal camera minus the Gamepad controls.
  43989. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43990. */
  43991. export class TouchCamera extends FreeCamera {
  43992. /**
  43993. * Defines the touch sensibility for rotation.
  43994. * The higher the faster.
  43995. */
  43996. get touchAngularSensibility(): number;
  43997. set touchAngularSensibility(value: number);
  43998. /**
  43999. * Defines the touch sensibility for move.
  44000. * The higher the faster.
  44001. */
  44002. get touchMoveSensibility(): number;
  44003. set touchMoveSensibility(value: number);
  44004. /**
  44005. * Instantiates a new touch camera.
  44006. * This represents a FPS type of camera controlled by touch.
  44007. * This is like a universal camera minus the Gamepad controls.
  44008. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44009. * @param name Define the name of the camera in the scene
  44010. * @param position Define the start position of the camera in the scene
  44011. * @param scene Define the scene the camera belongs to
  44012. */
  44013. constructor(name: string, position: Vector3, scene: Scene);
  44014. /**
  44015. * Gets the current object class name.
  44016. * @return the class name
  44017. */
  44018. getClassName(): string;
  44019. /** @hidden */
  44020. _setupInputs(): void;
  44021. }
  44022. }
  44023. declare module BABYLON {
  44024. /**
  44025. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44026. * being tilted forward or back and left or right.
  44027. */
  44028. export class DeviceOrientationCamera extends FreeCamera {
  44029. private _initialQuaternion;
  44030. private _quaternionCache;
  44031. private _tmpDragQuaternion;
  44032. private _disablePointerInputWhenUsingDeviceOrientation;
  44033. /**
  44034. * Creates a new device orientation camera
  44035. * @param name The name of the camera
  44036. * @param position The start position camera
  44037. * @param scene The scene the camera belongs to
  44038. */
  44039. constructor(name: string, position: Vector3, scene: Scene);
  44040. /**
  44041. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44042. */
  44043. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44044. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44045. private _dragFactor;
  44046. /**
  44047. * Enabled turning on the y axis when the orientation sensor is active
  44048. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44049. */
  44050. enableHorizontalDragging(dragFactor?: number): void;
  44051. /**
  44052. * Gets the current instance class name ("DeviceOrientationCamera").
  44053. * This helps avoiding instanceof at run time.
  44054. * @returns the class name
  44055. */
  44056. getClassName(): string;
  44057. /**
  44058. * @hidden
  44059. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44060. */
  44061. _checkInputs(): void;
  44062. /**
  44063. * Reset the camera to its default orientation on the specified axis only.
  44064. * @param axis The axis to reset
  44065. */
  44066. resetToCurrentRotation(axis?: Axis): void;
  44067. }
  44068. }
  44069. declare module BABYLON {
  44070. /**
  44071. * Defines supported buttons for XBox360 compatible gamepads
  44072. */
  44073. export enum Xbox360Button {
  44074. /** A */
  44075. A = 0,
  44076. /** B */
  44077. B = 1,
  44078. /** X */
  44079. X = 2,
  44080. /** Y */
  44081. Y = 3,
  44082. /** Left button */
  44083. LB = 4,
  44084. /** Right button */
  44085. RB = 5,
  44086. /** Back */
  44087. Back = 8,
  44088. /** Start */
  44089. Start = 9,
  44090. /** Left stick */
  44091. LeftStick = 10,
  44092. /** Right stick */
  44093. RightStick = 11
  44094. }
  44095. /** Defines values for XBox360 DPad */
  44096. export enum Xbox360Dpad {
  44097. /** Up */
  44098. Up = 12,
  44099. /** Down */
  44100. Down = 13,
  44101. /** Left */
  44102. Left = 14,
  44103. /** Right */
  44104. Right = 15
  44105. }
  44106. /**
  44107. * Defines a XBox360 gamepad
  44108. */
  44109. export class Xbox360Pad extends Gamepad {
  44110. private _leftTrigger;
  44111. private _rightTrigger;
  44112. private _onlefttriggerchanged;
  44113. private _onrighttriggerchanged;
  44114. private _onbuttondown;
  44115. private _onbuttonup;
  44116. private _ondpaddown;
  44117. private _ondpadup;
  44118. /** Observable raised when a button is pressed */
  44119. onButtonDownObservable: Observable<Xbox360Button>;
  44120. /** Observable raised when a button is released */
  44121. onButtonUpObservable: Observable<Xbox360Button>;
  44122. /** Observable raised when a pad is pressed */
  44123. onPadDownObservable: Observable<Xbox360Dpad>;
  44124. /** Observable raised when a pad is released */
  44125. onPadUpObservable: Observable<Xbox360Dpad>;
  44126. private _buttonA;
  44127. private _buttonB;
  44128. private _buttonX;
  44129. private _buttonY;
  44130. private _buttonBack;
  44131. private _buttonStart;
  44132. private _buttonLB;
  44133. private _buttonRB;
  44134. private _buttonLeftStick;
  44135. private _buttonRightStick;
  44136. private _dPadUp;
  44137. private _dPadDown;
  44138. private _dPadLeft;
  44139. private _dPadRight;
  44140. private _isXboxOnePad;
  44141. /**
  44142. * Creates a new XBox360 gamepad object
  44143. * @param id defines the id of this gamepad
  44144. * @param index defines its index
  44145. * @param gamepad defines the internal HTML gamepad object
  44146. * @param xboxOne defines if it is a XBox One gamepad
  44147. */
  44148. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44149. /**
  44150. * Defines the callback to call when left trigger is pressed
  44151. * @param callback defines the callback to use
  44152. */
  44153. onlefttriggerchanged(callback: (value: number) => void): void;
  44154. /**
  44155. * Defines the callback to call when right trigger is pressed
  44156. * @param callback defines the callback to use
  44157. */
  44158. onrighttriggerchanged(callback: (value: number) => void): void;
  44159. /**
  44160. * Gets the left trigger value
  44161. */
  44162. get leftTrigger(): number;
  44163. /**
  44164. * Sets the left trigger value
  44165. */
  44166. set leftTrigger(newValue: number);
  44167. /**
  44168. * Gets the right trigger value
  44169. */
  44170. get rightTrigger(): number;
  44171. /**
  44172. * Sets the right trigger value
  44173. */
  44174. set rightTrigger(newValue: number);
  44175. /**
  44176. * Defines the callback to call when a button is pressed
  44177. * @param callback defines the callback to use
  44178. */
  44179. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44180. /**
  44181. * Defines the callback to call when a button is released
  44182. * @param callback defines the callback to use
  44183. */
  44184. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44185. /**
  44186. * Defines the callback to call when a pad is pressed
  44187. * @param callback defines the callback to use
  44188. */
  44189. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44190. /**
  44191. * Defines the callback to call when a pad is released
  44192. * @param callback defines the callback to use
  44193. */
  44194. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44195. private _setButtonValue;
  44196. private _setDPadValue;
  44197. /**
  44198. * Gets the value of the `A` button
  44199. */
  44200. get buttonA(): number;
  44201. /**
  44202. * Sets the value of the `A` button
  44203. */
  44204. set buttonA(value: number);
  44205. /**
  44206. * Gets the value of the `B` button
  44207. */
  44208. get buttonB(): number;
  44209. /**
  44210. * Sets the value of the `B` button
  44211. */
  44212. set buttonB(value: number);
  44213. /**
  44214. * Gets the value of the `X` button
  44215. */
  44216. get buttonX(): number;
  44217. /**
  44218. * Sets the value of the `X` button
  44219. */
  44220. set buttonX(value: number);
  44221. /**
  44222. * Gets the value of the `Y` button
  44223. */
  44224. get buttonY(): number;
  44225. /**
  44226. * Sets the value of the `Y` button
  44227. */
  44228. set buttonY(value: number);
  44229. /**
  44230. * Gets the value of the `Start` button
  44231. */
  44232. get buttonStart(): number;
  44233. /**
  44234. * Sets the value of the `Start` button
  44235. */
  44236. set buttonStart(value: number);
  44237. /**
  44238. * Gets the value of the `Back` button
  44239. */
  44240. get buttonBack(): number;
  44241. /**
  44242. * Sets the value of the `Back` button
  44243. */
  44244. set buttonBack(value: number);
  44245. /**
  44246. * Gets the value of the `Left` button
  44247. */
  44248. get buttonLB(): number;
  44249. /**
  44250. * Sets the value of the `Left` button
  44251. */
  44252. set buttonLB(value: number);
  44253. /**
  44254. * Gets the value of the `Right` button
  44255. */
  44256. get buttonRB(): number;
  44257. /**
  44258. * Sets the value of the `Right` button
  44259. */
  44260. set buttonRB(value: number);
  44261. /**
  44262. * Gets the value of the Left joystick
  44263. */
  44264. get buttonLeftStick(): number;
  44265. /**
  44266. * Sets the value of the Left joystick
  44267. */
  44268. set buttonLeftStick(value: number);
  44269. /**
  44270. * Gets the value of the Right joystick
  44271. */
  44272. get buttonRightStick(): number;
  44273. /**
  44274. * Sets the value of the Right joystick
  44275. */
  44276. set buttonRightStick(value: number);
  44277. /**
  44278. * Gets the value of D-pad up
  44279. */
  44280. get dPadUp(): number;
  44281. /**
  44282. * Sets the value of D-pad up
  44283. */
  44284. set dPadUp(value: number);
  44285. /**
  44286. * Gets the value of D-pad down
  44287. */
  44288. get dPadDown(): number;
  44289. /**
  44290. * Sets the value of D-pad down
  44291. */
  44292. set dPadDown(value: number);
  44293. /**
  44294. * Gets the value of D-pad left
  44295. */
  44296. get dPadLeft(): number;
  44297. /**
  44298. * Sets the value of D-pad left
  44299. */
  44300. set dPadLeft(value: number);
  44301. /**
  44302. * Gets the value of D-pad right
  44303. */
  44304. get dPadRight(): number;
  44305. /**
  44306. * Sets the value of D-pad right
  44307. */
  44308. set dPadRight(value: number);
  44309. /**
  44310. * Force the gamepad to synchronize with device values
  44311. */
  44312. update(): void;
  44313. /**
  44314. * Disposes the gamepad
  44315. */
  44316. dispose(): void;
  44317. }
  44318. }
  44319. declare module BABYLON {
  44320. /**
  44321. * Defines supported buttons for DualShock compatible gamepads
  44322. */
  44323. export enum DualShockButton {
  44324. /** Cross */
  44325. Cross = 0,
  44326. /** Circle */
  44327. Circle = 1,
  44328. /** Square */
  44329. Square = 2,
  44330. /** Triangle */
  44331. Triangle = 3,
  44332. /** L1 */
  44333. L1 = 4,
  44334. /** R1 */
  44335. R1 = 5,
  44336. /** Share */
  44337. Share = 8,
  44338. /** Options */
  44339. Options = 9,
  44340. /** Left stick */
  44341. LeftStick = 10,
  44342. /** Right stick */
  44343. RightStick = 11
  44344. }
  44345. /** Defines values for DualShock DPad */
  44346. export enum DualShockDpad {
  44347. /** Up */
  44348. Up = 12,
  44349. /** Down */
  44350. Down = 13,
  44351. /** Left */
  44352. Left = 14,
  44353. /** Right */
  44354. Right = 15
  44355. }
  44356. /**
  44357. * Defines a DualShock gamepad
  44358. */
  44359. export class DualShockPad extends Gamepad {
  44360. private _leftTrigger;
  44361. private _rightTrigger;
  44362. private _onlefttriggerchanged;
  44363. private _onrighttriggerchanged;
  44364. private _onbuttondown;
  44365. private _onbuttonup;
  44366. private _ondpaddown;
  44367. private _ondpadup;
  44368. /** Observable raised when a button is pressed */
  44369. onButtonDownObservable: Observable<DualShockButton>;
  44370. /** Observable raised when a button is released */
  44371. onButtonUpObservable: Observable<DualShockButton>;
  44372. /** Observable raised when a pad is pressed */
  44373. onPadDownObservable: Observable<DualShockDpad>;
  44374. /** Observable raised when a pad is released */
  44375. onPadUpObservable: Observable<DualShockDpad>;
  44376. private _buttonCross;
  44377. private _buttonCircle;
  44378. private _buttonSquare;
  44379. private _buttonTriangle;
  44380. private _buttonShare;
  44381. private _buttonOptions;
  44382. private _buttonL1;
  44383. private _buttonR1;
  44384. private _buttonLeftStick;
  44385. private _buttonRightStick;
  44386. private _dPadUp;
  44387. private _dPadDown;
  44388. private _dPadLeft;
  44389. private _dPadRight;
  44390. /**
  44391. * Creates a new DualShock gamepad object
  44392. * @param id defines the id of this gamepad
  44393. * @param index defines its index
  44394. * @param gamepad defines the internal HTML gamepad object
  44395. */
  44396. constructor(id: string, index: number, gamepad: any);
  44397. /**
  44398. * Defines the callback to call when left trigger is pressed
  44399. * @param callback defines the callback to use
  44400. */
  44401. onlefttriggerchanged(callback: (value: number) => void): void;
  44402. /**
  44403. * Defines the callback to call when right trigger is pressed
  44404. * @param callback defines the callback to use
  44405. */
  44406. onrighttriggerchanged(callback: (value: number) => void): void;
  44407. /**
  44408. * Gets the left trigger value
  44409. */
  44410. get leftTrigger(): number;
  44411. /**
  44412. * Sets the left trigger value
  44413. */
  44414. set leftTrigger(newValue: number);
  44415. /**
  44416. * Gets the right trigger value
  44417. */
  44418. get rightTrigger(): number;
  44419. /**
  44420. * Sets the right trigger value
  44421. */
  44422. set rightTrigger(newValue: number);
  44423. /**
  44424. * Defines the callback to call when a button is pressed
  44425. * @param callback defines the callback to use
  44426. */
  44427. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44428. /**
  44429. * Defines the callback to call when a button is released
  44430. * @param callback defines the callback to use
  44431. */
  44432. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44433. /**
  44434. * Defines the callback to call when a pad is pressed
  44435. * @param callback defines the callback to use
  44436. */
  44437. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44438. /**
  44439. * Defines the callback to call when a pad is released
  44440. * @param callback defines the callback to use
  44441. */
  44442. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44443. private _setButtonValue;
  44444. private _setDPadValue;
  44445. /**
  44446. * Gets the value of the `Cross` button
  44447. */
  44448. get buttonCross(): number;
  44449. /**
  44450. * Sets the value of the `Cross` button
  44451. */
  44452. set buttonCross(value: number);
  44453. /**
  44454. * Gets the value of the `Circle` button
  44455. */
  44456. get buttonCircle(): number;
  44457. /**
  44458. * Sets the value of the `Circle` button
  44459. */
  44460. set buttonCircle(value: number);
  44461. /**
  44462. * Gets the value of the `Square` button
  44463. */
  44464. get buttonSquare(): number;
  44465. /**
  44466. * Sets the value of the `Square` button
  44467. */
  44468. set buttonSquare(value: number);
  44469. /**
  44470. * Gets the value of the `Triangle` button
  44471. */
  44472. get buttonTriangle(): number;
  44473. /**
  44474. * Sets the value of the `Triangle` button
  44475. */
  44476. set buttonTriangle(value: number);
  44477. /**
  44478. * Gets the value of the `Options` button
  44479. */
  44480. get buttonOptions(): number;
  44481. /**
  44482. * Sets the value of the `Options` button
  44483. */
  44484. set buttonOptions(value: number);
  44485. /**
  44486. * Gets the value of the `Share` button
  44487. */
  44488. get buttonShare(): number;
  44489. /**
  44490. * Sets the value of the `Share` button
  44491. */
  44492. set buttonShare(value: number);
  44493. /**
  44494. * Gets the value of the `L1` button
  44495. */
  44496. get buttonL1(): number;
  44497. /**
  44498. * Sets the value of the `L1` button
  44499. */
  44500. set buttonL1(value: number);
  44501. /**
  44502. * Gets the value of the `R1` button
  44503. */
  44504. get buttonR1(): number;
  44505. /**
  44506. * Sets the value of the `R1` button
  44507. */
  44508. set buttonR1(value: number);
  44509. /**
  44510. * Gets the value of the Left joystick
  44511. */
  44512. get buttonLeftStick(): number;
  44513. /**
  44514. * Sets the value of the Left joystick
  44515. */
  44516. set buttonLeftStick(value: number);
  44517. /**
  44518. * Gets the value of the Right joystick
  44519. */
  44520. get buttonRightStick(): number;
  44521. /**
  44522. * Sets the value of the Right joystick
  44523. */
  44524. set buttonRightStick(value: number);
  44525. /**
  44526. * Gets the value of D-pad up
  44527. */
  44528. get dPadUp(): number;
  44529. /**
  44530. * Sets the value of D-pad up
  44531. */
  44532. set dPadUp(value: number);
  44533. /**
  44534. * Gets the value of D-pad down
  44535. */
  44536. get dPadDown(): number;
  44537. /**
  44538. * Sets the value of D-pad down
  44539. */
  44540. set dPadDown(value: number);
  44541. /**
  44542. * Gets the value of D-pad left
  44543. */
  44544. get dPadLeft(): number;
  44545. /**
  44546. * Sets the value of D-pad left
  44547. */
  44548. set dPadLeft(value: number);
  44549. /**
  44550. * Gets the value of D-pad right
  44551. */
  44552. get dPadRight(): number;
  44553. /**
  44554. * Sets the value of D-pad right
  44555. */
  44556. set dPadRight(value: number);
  44557. /**
  44558. * Force the gamepad to synchronize with device values
  44559. */
  44560. update(): void;
  44561. /**
  44562. * Disposes the gamepad
  44563. */
  44564. dispose(): void;
  44565. }
  44566. }
  44567. declare module BABYLON {
  44568. /**
  44569. * Manager for handling gamepads
  44570. */
  44571. export class GamepadManager {
  44572. private _scene?;
  44573. private _babylonGamepads;
  44574. private _oneGamepadConnected;
  44575. /** @hidden */
  44576. _isMonitoring: boolean;
  44577. private _gamepadEventSupported;
  44578. private _gamepadSupport?;
  44579. /**
  44580. * observable to be triggered when the gamepad controller has been connected
  44581. */
  44582. onGamepadConnectedObservable: Observable<Gamepad>;
  44583. /**
  44584. * observable to be triggered when the gamepad controller has been disconnected
  44585. */
  44586. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44587. private _onGamepadConnectedEvent;
  44588. private _onGamepadDisconnectedEvent;
  44589. /**
  44590. * Initializes the gamepad manager
  44591. * @param _scene BabylonJS scene
  44592. */
  44593. constructor(_scene?: Scene | undefined);
  44594. /**
  44595. * The gamepads in the game pad manager
  44596. */
  44597. get gamepads(): Gamepad[];
  44598. /**
  44599. * Get the gamepad controllers based on type
  44600. * @param type The type of gamepad controller
  44601. * @returns Nullable gamepad
  44602. */
  44603. getGamepadByType(type?: number): Nullable<Gamepad>;
  44604. /**
  44605. * Disposes the gamepad manager
  44606. */
  44607. dispose(): void;
  44608. private _addNewGamepad;
  44609. private _startMonitoringGamepads;
  44610. private _stopMonitoringGamepads;
  44611. /** @hidden */
  44612. _checkGamepadsStatus(): void;
  44613. private _updateGamepadObjects;
  44614. }
  44615. }
  44616. declare module BABYLON {
  44617. interface Scene {
  44618. /** @hidden */
  44619. _gamepadManager: Nullable<GamepadManager>;
  44620. /**
  44621. * Gets the gamepad manager associated with the scene
  44622. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44623. */
  44624. gamepadManager: GamepadManager;
  44625. }
  44626. /**
  44627. * Interface representing a free camera inputs manager
  44628. */
  44629. interface FreeCameraInputsManager {
  44630. /**
  44631. * Adds gamepad input support to the FreeCameraInputsManager.
  44632. * @returns the FreeCameraInputsManager
  44633. */
  44634. addGamepad(): FreeCameraInputsManager;
  44635. }
  44636. /**
  44637. * Interface representing an arc rotate camera inputs manager
  44638. */
  44639. interface ArcRotateCameraInputsManager {
  44640. /**
  44641. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44642. * @returns the camera inputs manager
  44643. */
  44644. addGamepad(): ArcRotateCameraInputsManager;
  44645. }
  44646. /**
  44647. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44648. */
  44649. export class GamepadSystemSceneComponent implements ISceneComponent {
  44650. /**
  44651. * The component name helpfull to identify the component in the list of scene components.
  44652. */
  44653. readonly name: string;
  44654. /**
  44655. * The scene the component belongs to.
  44656. */
  44657. scene: Scene;
  44658. /**
  44659. * Creates a new instance of the component for the given scene
  44660. * @param scene Defines the scene to register the component in
  44661. */
  44662. constructor(scene: Scene);
  44663. /**
  44664. * Registers the component in a given scene
  44665. */
  44666. register(): void;
  44667. /**
  44668. * Rebuilds the elements related to this component in case of
  44669. * context lost for instance.
  44670. */
  44671. rebuild(): void;
  44672. /**
  44673. * Disposes the component and the associated ressources
  44674. */
  44675. dispose(): void;
  44676. private _beforeCameraUpdate;
  44677. }
  44678. }
  44679. declare module BABYLON {
  44680. /**
  44681. * 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,
  44682. * which still works and will still be found in many Playgrounds.
  44683. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44684. */
  44685. export class UniversalCamera extends TouchCamera {
  44686. /**
  44687. * Defines the gamepad rotation sensiblity.
  44688. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44689. */
  44690. get gamepadAngularSensibility(): number;
  44691. set gamepadAngularSensibility(value: number);
  44692. /**
  44693. * Defines the gamepad move sensiblity.
  44694. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44695. */
  44696. get gamepadMoveSensibility(): number;
  44697. set gamepadMoveSensibility(value: number);
  44698. /**
  44699. * 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,
  44700. * which still works and will still be found in many Playgrounds.
  44701. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44702. * @param name Define the name of the camera in the scene
  44703. * @param position Define the start position of the camera in the scene
  44704. * @param scene Define the scene the camera belongs to
  44705. */
  44706. constructor(name: string, position: Vector3, scene: Scene);
  44707. /**
  44708. * Gets the current object class name.
  44709. * @return the class name
  44710. */
  44711. getClassName(): string;
  44712. }
  44713. }
  44714. declare module BABYLON {
  44715. /**
  44716. * This represents a FPS type of camera. This is only here for back compat purpose.
  44717. * Please use the UniversalCamera instead as both are identical.
  44718. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44719. */
  44720. export class GamepadCamera extends UniversalCamera {
  44721. /**
  44722. * Instantiates a new Gamepad Camera
  44723. * This represents a FPS type of camera. This is only here for back compat purpose.
  44724. * Please use the UniversalCamera instead as both are identical.
  44725. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44726. * @param name Define the name of the camera in the scene
  44727. * @param position Define the start position of the camera in the scene
  44728. * @param scene Define the scene the camera belongs to
  44729. */
  44730. constructor(name: string, position: Vector3, scene: Scene);
  44731. /**
  44732. * Gets the current object class name.
  44733. * @return the class name
  44734. */
  44735. getClassName(): string;
  44736. }
  44737. }
  44738. declare module BABYLON {
  44739. /** @hidden */
  44740. export var passPixelShader: {
  44741. name: string;
  44742. shader: string;
  44743. };
  44744. }
  44745. declare module BABYLON {
  44746. /** @hidden */
  44747. export var passCubePixelShader: {
  44748. name: string;
  44749. shader: string;
  44750. };
  44751. }
  44752. declare module BABYLON {
  44753. /**
  44754. * PassPostProcess which produces an output the same as it's input
  44755. */
  44756. export class PassPostProcess extends PostProcess {
  44757. /**
  44758. * Creates the PassPostProcess
  44759. * @param name The name of the effect.
  44760. * @param options The required width/height ratio to downsize to before computing the render pass.
  44761. * @param camera The camera to apply the render pass to.
  44762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44763. * @param engine The engine which the post process will be applied. (default: current engine)
  44764. * @param reusable If the post process can be reused on the same frame. (default: false)
  44765. * @param textureType The type of texture to be used when performing the post processing.
  44766. * @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)
  44767. */
  44768. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44769. }
  44770. /**
  44771. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44772. */
  44773. export class PassCubePostProcess extends PostProcess {
  44774. private _face;
  44775. /**
  44776. * Gets or sets the cube face to display.
  44777. * * 0 is +X
  44778. * * 1 is -X
  44779. * * 2 is +Y
  44780. * * 3 is -Y
  44781. * * 4 is +Z
  44782. * * 5 is -Z
  44783. */
  44784. get face(): number;
  44785. set face(value: number);
  44786. /**
  44787. * Creates the PassCubePostProcess
  44788. * @param name The name of the effect.
  44789. * @param options The required width/height ratio to downsize to before computing the render pass.
  44790. * @param camera The camera to apply the render pass to.
  44791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44792. * @param engine The engine which the post process will be applied. (default: current engine)
  44793. * @param reusable If the post process can be reused on the same frame. (default: false)
  44794. * @param textureType The type of texture to be used when performing the post processing.
  44795. * @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)
  44796. */
  44797. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44798. }
  44799. }
  44800. declare module BABYLON {
  44801. /** @hidden */
  44802. export var anaglyphPixelShader: {
  44803. name: string;
  44804. shader: string;
  44805. };
  44806. }
  44807. declare module BABYLON {
  44808. /**
  44809. * Postprocess used to generate anaglyphic rendering
  44810. */
  44811. export class AnaglyphPostProcess extends PostProcess {
  44812. private _passedProcess;
  44813. /**
  44814. * Creates a new AnaglyphPostProcess
  44815. * @param name defines postprocess name
  44816. * @param options defines creation options or target ratio scale
  44817. * @param rigCameras defines cameras using this postprocess
  44818. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44819. * @param engine defines hosting engine
  44820. * @param reusable defines if the postprocess will be reused multiple times per frame
  44821. */
  44822. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44823. }
  44824. }
  44825. declare module BABYLON {
  44826. /**
  44827. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44828. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44829. */
  44830. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44831. /**
  44832. * Creates a new AnaglyphArcRotateCamera
  44833. * @param name defines camera name
  44834. * @param alpha defines alpha angle (in radians)
  44835. * @param beta defines beta angle (in radians)
  44836. * @param radius defines radius
  44837. * @param target defines camera target
  44838. * @param interaxialDistance defines distance between each color axis
  44839. * @param scene defines the hosting scene
  44840. */
  44841. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44842. /**
  44843. * Gets camera class name
  44844. * @returns AnaglyphArcRotateCamera
  44845. */
  44846. getClassName(): string;
  44847. }
  44848. }
  44849. declare module BABYLON {
  44850. /**
  44851. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44852. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44853. */
  44854. export class AnaglyphFreeCamera extends FreeCamera {
  44855. /**
  44856. * Creates a new AnaglyphFreeCamera
  44857. * @param name defines camera name
  44858. * @param position defines initial position
  44859. * @param interaxialDistance defines distance between each color axis
  44860. * @param scene defines the hosting scene
  44861. */
  44862. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44863. /**
  44864. * Gets camera class name
  44865. * @returns AnaglyphFreeCamera
  44866. */
  44867. getClassName(): string;
  44868. }
  44869. }
  44870. declare module BABYLON {
  44871. /**
  44872. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44873. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44874. */
  44875. export class AnaglyphGamepadCamera extends GamepadCamera {
  44876. /**
  44877. * Creates a new AnaglyphGamepadCamera
  44878. * @param name defines camera name
  44879. * @param position defines initial position
  44880. * @param interaxialDistance defines distance between each color axis
  44881. * @param scene defines the hosting scene
  44882. */
  44883. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44884. /**
  44885. * Gets camera class name
  44886. * @returns AnaglyphGamepadCamera
  44887. */
  44888. getClassName(): string;
  44889. }
  44890. }
  44891. declare module BABYLON {
  44892. /**
  44893. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44894. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44895. */
  44896. export class AnaglyphUniversalCamera extends UniversalCamera {
  44897. /**
  44898. * Creates a new AnaglyphUniversalCamera
  44899. * @param name defines camera name
  44900. * @param position defines initial position
  44901. * @param interaxialDistance defines distance between each color axis
  44902. * @param scene defines the hosting scene
  44903. */
  44904. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44905. /**
  44906. * Gets camera class name
  44907. * @returns AnaglyphUniversalCamera
  44908. */
  44909. getClassName(): string;
  44910. }
  44911. }
  44912. declare module BABYLON {
  44913. /**
  44914. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44915. * @see http://doc.babylonjs.com/features/cameras
  44916. */
  44917. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44918. /**
  44919. * Creates a new StereoscopicArcRotateCamera
  44920. * @param name defines camera name
  44921. * @param alpha defines alpha angle (in radians)
  44922. * @param beta defines beta angle (in radians)
  44923. * @param radius defines radius
  44924. * @param target defines camera target
  44925. * @param interaxialDistance defines distance between each color axis
  44926. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44927. * @param scene defines the hosting scene
  44928. */
  44929. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44930. /**
  44931. * Gets camera class name
  44932. * @returns StereoscopicArcRotateCamera
  44933. */
  44934. getClassName(): string;
  44935. }
  44936. }
  44937. declare module BABYLON {
  44938. /**
  44939. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44940. * @see http://doc.babylonjs.com/features/cameras
  44941. */
  44942. export class StereoscopicFreeCamera extends FreeCamera {
  44943. /**
  44944. * Creates a new StereoscopicFreeCamera
  44945. * @param name defines camera name
  44946. * @param position defines initial position
  44947. * @param interaxialDistance defines distance between each color axis
  44948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44949. * @param scene defines the hosting scene
  44950. */
  44951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44952. /**
  44953. * Gets camera class name
  44954. * @returns StereoscopicFreeCamera
  44955. */
  44956. getClassName(): string;
  44957. }
  44958. }
  44959. declare module BABYLON {
  44960. /**
  44961. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44962. * @see http://doc.babylonjs.com/features/cameras
  44963. */
  44964. export class StereoscopicGamepadCamera extends GamepadCamera {
  44965. /**
  44966. * Creates a new StereoscopicGamepadCamera
  44967. * @param name defines camera name
  44968. * @param position defines initial position
  44969. * @param interaxialDistance defines distance between each color axis
  44970. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44971. * @param scene defines the hosting scene
  44972. */
  44973. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44974. /**
  44975. * Gets camera class name
  44976. * @returns StereoscopicGamepadCamera
  44977. */
  44978. getClassName(): string;
  44979. }
  44980. }
  44981. declare module BABYLON {
  44982. /**
  44983. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44984. * @see http://doc.babylonjs.com/features/cameras
  44985. */
  44986. export class StereoscopicUniversalCamera extends UniversalCamera {
  44987. /**
  44988. * Creates a new StereoscopicUniversalCamera
  44989. * @param name defines camera name
  44990. * @param position defines initial position
  44991. * @param interaxialDistance defines distance between each color axis
  44992. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44993. * @param scene defines the hosting scene
  44994. */
  44995. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44996. /**
  44997. * Gets camera class name
  44998. * @returns StereoscopicUniversalCamera
  44999. */
  45000. getClassName(): string;
  45001. }
  45002. }
  45003. declare module BABYLON {
  45004. /**
  45005. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45006. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45007. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45008. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45009. */
  45010. export class VirtualJoysticksCamera extends FreeCamera {
  45011. /**
  45012. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45013. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45014. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45015. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45016. * @param name Define the name of the camera in the scene
  45017. * @param position Define the start position of the camera in the scene
  45018. * @param scene Define the scene the camera belongs to
  45019. */
  45020. constructor(name: string, position: Vector3, scene: Scene);
  45021. /**
  45022. * Gets the current object class name.
  45023. * @return the class name
  45024. */
  45025. getClassName(): string;
  45026. }
  45027. }
  45028. declare module BABYLON {
  45029. /**
  45030. * This represents all the required metrics to create a VR camera.
  45031. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45032. */
  45033. export class VRCameraMetrics {
  45034. /**
  45035. * Define the horizontal resolution off the screen.
  45036. */
  45037. hResolution: number;
  45038. /**
  45039. * Define the vertical resolution off the screen.
  45040. */
  45041. vResolution: number;
  45042. /**
  45043. * Define the horizontal screen size.
  45044. */
  45045. hScreenSize: number;
  45046. /**
  45047. * Define the vertical screen size.
  45048. */
  45049. vScreenSize: number;
  45050. /**
  45051. * Define the vertical screen center position.
  45052. */
  45053. vScreenCenter: number;
  45054. /**
  45055. * Define the distance of the eyes to the screen.
  45056. */
  45057. eyeToScreenDistance: number;
  45058. /**
  45059. * Define the distance between both lenses
  45060. */
  45061. lensSeparationDistance: number;
  45062. /**
  45063. * Define the distance between both viewer's eyes.
  45064. */
  45065. interpupillaryDistance: number;
  45066. /**
  45067. * Define the distortion factor of the VR postprocess.
  45068. * Please, touch with care.
  45069. */
  45070. distortionK: number[];
  45071. /**
  45072. * Define the chromatic aberration correction factors for the VR post process.
  45073. */
  45074. chromaAbCorrection: number[];
  45075. /**
  45076. * Define the scale factor of the post process.
  45077. * The smaller the better but the slower.
  45078. */
  45079. postProcessScaleFactor: number;
  45080. /**
  45081. * Define an offset for the lens center.
  45082. */
  45083. lensCenterOffset: number;
  45084. /**
  45085. * Define if the current vr camera should compensate the distortion of the lense or not.
  45086. */
  45087. compensateDistortion: boolean;
  45088. /**
  45089. * Defines if multiview should be enabled when rendering (Default: false)
  45090. */
  45091. multiviewEnabled: boolean;
  45092. /**
  45093. * Gets the rendering aspect ratio based on the provided resolutions.
  45094. */
  45095. get aspectRatio(): number;
  45096. /**
  45097. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45098. */
  45099. get aspectRatioFov(): number;
  45100. /**
  45101. * @hidden
  45102. */
  45103. get leftHMatrix(): Matrix;
  45104. /**
  45105. * @hidden
  45106. */
  45107. get rightHMatrix(): Matrix;
  45108. /**
  45109. * @hidden
  45110. */
  45111. get leftPreViewMatrix(): Matrix;
  45112. /**
  45113. * @hidden
  45114. */
  45115. get rightPreViewMatrix(): Matrix;
  45116. /**
  45117. * Get the default VRMetrics based on the most generic setup.
  45118. * @returns the default vr metrics
  45119. */
  45120. static GetDefault(): VRCameraMetrics;
  45121. }
  45122. }
  45123. declare module BABYLON {
  45124. /** @hidden */
  45125. export var vrDistortionCorrectionPixelShader: {
  45126. name: string;
  45127. shader: string;
  45128. };
  45129. }
  45130. declare module BABYLON {
  45131. /**
  45132. * VRDistortionCorrectionPostProcess used for mobile VR
  45133. */
  45134. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45135. private _isRightEye;
  45136. private _distortionFactors;
  45137. private _postProcessScaleFactor;
  45138. private _lensCenterOffset;
  45139. private _scaleIn;
  45140. private _scaleFactor;
  45141. private _lensCenter;
  45142. /**
  45143. * Initializes the VRDistortionCorrectionPostProcess
  45144. * @param name The name of the effect.
  45145. * @param camera The camera to apply the render pass to.
  45146. * @param isRightEye If this is for the right eye distortion
  45147. * @param vrMetrics All the required metrics for the VR camera
  45148. */
  45149. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45150. }
  45151. }
  45152. declare module BABYLON {
  45153. /**
  45154. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45155. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45156. */
  45157. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45158. /**
  45159. * Creates a new VRDeviceOrientationArcRotateCamera
  45160. * @param name defines camera name
  45161. * @param alpha defines the camera rotation along the logitudinal axis
  45162. * @param beta defines the camera rotation along the latitudinal axis
  45163. * @param radius defines the camera distance from its target
  45164. * @param target defines the camera target
  45165. * @param scene defines the scene the camera belongs to
  45166. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45167. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45168. */
  45169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45170. /**
  45171. * Gets camera class name
  45172. * @returns VRDeviceOrientationArcRotateCamera
  45173. */
  45174. getClassName(): string;
  45175. }
  45176. }
  45177. declare module BABYLON {
  45178. /**
  45179. * Camera used to simulate VR rendering (based on FreeCamera)
  45180. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45181. */
  45182. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45183. /**
  45184. * Creates a new VRDeviceOrientationFreeCamera
  45185. * @param name defines camera name
  45186. * @param position defines the start position of the camera
  45187. * @param scene defines the scene the camera belongs to
  45188. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45189. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45190. */
  45191. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45192. /**
  45193. * Gets camera class name
  45194. * @returns VRDeviceOrientationFreeCamera
  45195. */
  45196. getClassName(): string;
  45197. }
  45198. }
  45199. declare module BABYLON {
  45200. /**
  45201. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45202. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45203. */
  45204. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45205. /**
  45206. * Creates a new VRDeviceOrientationGamepadCamera
  45207. * @param name defines camera name
  45208. * @param position defines the start position of the camera
  45209. * @param scene defines the scene the camera belongs to
  45210. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45211. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45212. */
  45213. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45214. /**
  45215. * Gets camera class name
  45216. * @returns VRDeviceOrientationGamepadCamera
  45217. */
  45218. getClassName(): string;
  45219. }
  45220. }
  45221. declare module BABYLON {
  45222. /** @hidden */
  45223. export var imageProcessingPixelShader: {
  45224. name: string;
  45225. shader: string;
  45226. };
  45227. }
  45228. declare module BABYLON {
  45229. /**
  45230. * ImageProcessingPostProcess
  45231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45232. */
  45233. export class ImageProcessingPostProcess extends PostProcess {
  45234. /**
  45235. * Default configuration related to image processing available in the PBR Material.
  45236. */
  45237. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45238. /**
  45239. * Gets the image processing configuration used either in this material.
  45240. */
  45241. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45242. /**
  45243. * Sets the Default image processing configuration used either in the this material.
  45244. *
  45245. * If sets to null, the scene one is in use.
  45246. */
  45247. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45248. /**
  45249. * Keep track of the image processing observer to allow dispose and replace.
  45250. */
  45251. private _imageProcessingObserver;
  45252. /**
  45253. * Attaches a new image processing configuration to the PBR Material.
  45254. * @param configuration
  45255. */
  45256. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45257. /**
  45258. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45259. */
  45260. get colorCurves(): Nullable<ColorCurves>;
  45261. /**
  45262. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45263. */
  45264. set colorCurves(value: Nullable<ColorCurves>);
  45265. /**
  45266. * Gets wether the color curves effect is enabled.
  45267. */
  45268. get colorCurvesEnabled(): boolean;
  45269. /**
  45270. * Sets wether the color curves effect is enabled.
  45271. */
  45272. set colorCurvesEnabled(value: boolean);
  45273. /**
  45274. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45275. */
  45276. get colorGradingTexture(): Nullable<BaseTexture>;
  45277. /**
  45278. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45279. */
  45280. set colorGradingTexture(value: Nullable<BaseTexture>);
  45281. /**
  45282. * Gets wether the color grading effect is enabled.
  45283. */
  45284. get colorGradingEnabled(): boolean;
  45285. /**
  45286. * Gets wether the color grading effect is enabled.
  45287. */
  45288. set colorGradingEnabled(value: boolean);
  45289. /**
  45290. * Gets exposure used in the effect.
  45291. */
  45292. get exposure(): number;
  45293. /**
  45294. * Sets exposure used in the effect.
  45295. */
  45296. set exposure(value: number);
  45297. /**
  45298. * Gets wether tonemapping is enabled or not.
  45299. */
  45300. get toneMappingEnabled(): boolean;
  45301. /**
  45302. * Sets wether tonemapping is enabled or not
  45303. */
  45304. set toneMappingEnabled(value: boolean);
  45305. /**
  45306. * Gets the type of tone mapping effect.
  45307. */
  45308. get toneMappingType(): number;
  45309. /**
  45310. * Sets the type of tone mapping effect.
  45311. */
  45312. set toneMappingType(value: number);
  45313. /**
  45314. * Gets contrast used in the effect.
  45315. */
  45316. get contrast(): number;
  45317. /**
  45318. * Sets contrast used in the effect.
  45319. */
  45320. set contrast(value: number);
  45321. /**
  45322. * Gets Vignette stretch size.
  45323. */
  45324. get vignetteStretch(): number;
  45325. /**
  45326. * Sets Vignette stretch size.
  45327. */
  45328. set vignetteStretch(value: number);
  45329. /**
  45330. * Gets Vignette centre X Offset.
  45331. */
  45332. get vignetteCentreX(): number;
  45333. /**
  45334. * Sets Vignette centre X Offset.
  45335. */
  45336. set vignetteCentreX(value: number);
  45337. /**
  45338. * Gets Vignette centre Y Offset.
  45339. */
  45340. get vignetteCentreY(): number;
  45341. /**
  45342. * Sets Vignette centre Y Offset.
  45343. */
  45344. set vignetteCentreY(value: number);
  45345. /**
  45346. * Gets Vignette weight or intensity of the vignette effect.
  45347. */
  45348. get vignetteWeight(): number;
  45349. /**
  45350. * Sets Vignette weight or intensity of the vignette effect.
  45351. */
  45352. set vignetteWeight(value: number);
  45353. /**
  45354. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45355. * if vignetteEnabled is set to true.
  45356. */
  45357. get vignetteColor(): Color4;
  45358. /**
  45359. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45360. * if vignetteEnabled is set to true.
  45361. */
  45362. set vignetteColor(value: Color4);
  45363. /**
  45364. * Gets Camera field of view used by the Vignette effect.
  45365. */
  45366. get vignetteCameraFov(): number;
  45367. /**
  45368. * Sets Camera field of view used by the Vignette effect.
  45369. */
  45370. set vignetteCameraFov(value: number);
  45371. /**
  45372. * Gets the vignette blend mode allowing different kind of effect.
  45373. */
  45374. get vignetteBlendMode(): number;
  45375. /**
  45376. * Sets the vignette blend mode allowing different kind of effect.
  45377. */
  45378. set vignetteBlendMode(value: number);
  45379. /**
  45380. * Gets wether the vignette effect is enabled.
  45381. */
  45382. get vignetteEnabled(): boolean;
  45383. /**
  45384. * Sets wether the vignette effect is enabled.
  45385. */
  45386. set vignetteEnabled(value: boolean);
  45387. private _fromLinearSpace;
  45388. /**
  45389. * Gets wether the input of the processing is in Gamma or Linear Space.
  45390. */
  45391. get fromLinearSpace(): boolean;
  45392. /**
  45393. * Sets wether the input of the processing is in Gamma or Linear Space.
  45394. */
  45395. set fromLinearSpace(value: boolean);
  45396. /**
  45397. * Defines cache preventing GC.
  45398. */
  45399. private _defines;
  45400. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45401. /**
  45402. * "ImageProcessingPostProcess"
  45403. * @returns "ImageProcessingPostProcess"
  45404. */
  45405. getClassName(): string;
  45406. protected _updateParameters(): void;
  45407. dispose(camera?: Camera): void;
  45408. }
  45409. }
  45410. declare module BABYLON {
  45411. /**
  45412. * Class containing static functions to help procedurally build meshes
  45413. */
  45414. export class GroundBuilder {
  45415. /**
  45416. * Creates a ground mesh
  45417. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45418. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45420. * @param name defines the name of the mesh
  45421. * @param options defines the options used to create the mesh
  45422. * @param scene defines the hosting scene
  45423. * @returns the ground mesh
  45424. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45425. */
  45426. static CreateGround(name: string, options: {
  45427. width?: number;
  45428. height?: number;
  45429. subdivisions?: number;
  45430. subdivisionsX?: number;
  45431. subdivisionsY?: number;
  45432. updatable?: boolean;
  45433. }, scene: any): Mesh;
  45434. /**
  45435. * Creates a tiled ground mesh
  45436. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45437. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45438. * * 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
  45439. * * 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
  45440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45441. * @param name defines the name of the mesh
  45442. * @param options defines the options used to create the mesh
  45443. * @param scene defines the hosting scene
  45444. * @returns the tiled ground mesh
  45445. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45446. */
  45447. static CreateTiledGround(name: string, options: {
  45448. xmin: number;
  45449. zmin: number;
  45450. xmax: number;
  45451. zmax: number;
  45452. subdivisions?: {
  45453. w: number;
  45454. h: number;
  45455. };
  45456. precision?: {
  45457. w: number;
  45458. h: number;
  45459. };
  45460. updatable?: boolean;
  45461. }, scene?: Nullable<Scene>): Mesh;
  45462. /**
  45463. * Creates a ground mesh from a height map
  45464. * * The parameter `url` sets the URL of the height map image resource.
  45465. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45466. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45467. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45468. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45469. * * 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.
  45470. * * 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).
  45471. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45473. * @param name defines the name of the mesh
  45474. * @param url defines the url to the height map
  45475. * @param options defines the options used to create the mesh
  45476. * @param scene defines the hosting scene
  45477. * @returns the ground mesh
  45478. * @see https://doc.babylonjs.com/babylon101/height_map
  45479. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45480. */
  45481. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45482. width?: number;
  45483. height?: number;
  45484. subdivisions?: number;
  45485. minHeight?: number;
  45486. maxHeight?: number;
  45487. colorFilter?: Color3;
  45488. alphaFilter?: number;
  45489. updatable?: boolean;
  45490. onReady?: (mesh: GroundMesh) => void;
  45491. }, scene?: Nullable<Scene>): GroundMesh;
  45492. }
  45493. }
  45494. declare module BABYLON {
  45495. /**
  45496. * Class containing static functions to help procedurally build meshes
  45497. */
  45498. export class TorusBuilder {
  45499. /**
  45500. * Creates a torus mesh
  45501. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45502. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45503. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45505. * * 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
  45506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45507. * @param name defines the name of the mesh
  45508. * @param options defines the options used to create the mesh
  45509. * @param scene defines the hosting scene
  45510. * @returns the torus mesh
  45511. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45512. */
  45513. static CreateTorus(name: string, options: {
  45514. diameter?: number;
  45515. thickness?: number;
  45516. tessellation?: number;
  45517. updatable?: boolean;
  45518. sideOrientation?: number;
  45519. frontUVs?: Vector4;
  45520. backUVs?: Vector4;
  45521. }, scene: any): Mesh;
  45522. }
  45523. }
  45524. declare module BABYLON {
  45525. /**
  45526. * Class containing static functions to help procedurally build meshes
  45527. */
  45528. export class CylinderBuilder {
  45529. /**
  45530. * Creates a cylinder or a cone mesh
  45531. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45532. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45533. * * 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.
  45534. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45535. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45536. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45537. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45538. * * 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).
  45539. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45540. * * 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).
  45541. * * 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
  45542. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45543. * * 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
  45544. * * 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.
  45545. * * If `enclose` is false, a ring surface is one element.
  45546. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45547. * * 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
  45548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45549. * * 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
  45550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45551. * @param name defines the name of the mesh
  45552. * @param options defines the options used to create the mesh
  45553. * @param scene defines the hosting scene
  45554. * @returns the cylinder mesh
  45555. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45556. */
  45557. static CreateCylinder(name: string, options: {
  45558. height?: number;
  45559. diameterTop?: number;
  45560. diameterBottom?: number;
  45561. diameter?: number;
  45562. tessellation?: number;
  45563. subdivisions?: number;
  45564. arc?: number;
  45565. faceColors?: Color4[];
  45566. faceUV?: Vector4[];
  45567. updatable?: boolean;
  45568. hasRings?: boolean;
  45569. enclose?: boolean;
  45570. cap?: number;
  45571. sideOrientation?: number;
  45572. frontUVs?: Vector4;
  45573. backUVs?: Vector4;
  45574. }, scene: any): Mesh;
  45575. }
  45576. }
  45577. declare module BABYLON {
  45578. /**
  45579. * States of the webXR experience
  45580. */
  45581. export enum WebXRState {
  45582. /**
  45583. * Transitioning to being in XR mode
  45584. */
  45585. ENTERING_XR = 0,
  45586. /**
  45587. * Transitioning to non XR mode
  45588. */
  45589. EXITING_XR = 1,
  45590. /**
  45591. * In XR mode and presenting
  45592. */
  45593. IN_XR = 2,
  45594. /**
  45595. * Not entered XR mode
  45596. */
  45597. NOT_IN_XR = 3
  45598. }
  45599. /**
  45600. * Abstraction of the XR render target
  45601. */
  45602. export interface WebXRRenderTarget extends IDisposable {
  45603. /**
  45604. * xrpresent context of the canvas which can be used to display/mirror xr content
  45605. */
  45606. canvasContext: WebGLRenderingContext;
  45607. /**
  45608. * xr layer for the canvas
  45609. */
  45610. xrLayer: Nullable<XRWebGLLayer>;
  45611. /**
  45612. * Initializes the xr layer for the session
  45613. * @param xrSession xr session
  45614. * @returns a promise that will resolve once the XR Layer has been created
  45615. */
  45616. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45617. }
  45618. }
  45619. declare module BABYLON {
  45620. /**
  45621. * COnfiguration object for WebXR output canvas
  45622. */
  45623. export class WebXRManagedOutputCanvasOptions {
  45624. /**
  45625. * An optional canvas in case you wish to create it yourself and provide it here.
  45626. * If not provided, a new canvas will be created
  45627. */
  45628. canvasElement?: HTMLCanvasElement;
  45629. /**
  45630. * Options for this XR Layer output
  45631. */
  45632. canvasOptions?: XRWebGLLayerOptions;
  45633. /**
  45634. * CSS styling for a newly created canvas (if not provided)
  45635. */
  45636. newCanvasCssStyle?: string;
  45637. /**
  45638. * Get the default values of the configuration object
  45639. * @returns default values of this configuration object
  45640. */
  45641. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45642. }
  45643. /**
  45644. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45645. */
  45646. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45647. private _options;
  45648. private _canvas;
  45649. private _engine;
  45650. /**
  45651. * Rendering context of the canvas which can be used to display/mirror xr content
  45652. */
  45653. canvasContext: WebGLRenderingContext;
  45654. /**
  45655. * xr layer for the canvas
  45656. */
  45657. xrLayer: Nullable<XRWebGLLayer>;
  45658. /**
  45659. * Initializes the canvas to be added/removed upon entering/exiting xr
  45660. * @param _xrSessionManager The XR Session manager
  45661. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45662. */
  45663. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45664. /**
  45665. * Disposes of the object
  45666. */
  45667. dispose(): void;
  45668. /**
  45669. * Initializes the xr layer for the session
  45670. * @param xrSession xr session
  45671. * @returns a promise that will resolve once the XR Layer has been created
  45672. */
  45673. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45674. private _addCanvas;
  45675. private _removeCanvas;
  45676. private _setManagedOutputCanvas;
  45677. }
  45678. }
  45679. declare module BABYLON {
  45680. /**
  45681. * Manages an XRSession to work with Babylon's engine
  45682. * @see https://doc.babylonjs.com/how_to/webxr
  45683. */
  45684. export class WebXRSessionManager implements IDisposable {
  45685. /** The scene which the session should be created for */
  45686. scene: Scene;
  45687. private _referenceSpace;
  45688. private _rttProvider;
  45689. private _sessionEnded;
  45690. private _xrNavigator;
  45691. private baseLayer;
  45692. /**
  45693. * The base reference space from which the session started. good if you want to reset your
  45694. * reference space
  45695. */
  45696. baseReferenceSpace: XRReferenceSpace;
  45697. /**
  45698. * Current XR frame
  45699. */
  45700. currentFrame: Nullable<XRFrame>;
  45701. /** WebXR timestamp updated every frame */
  45702. currentTimestamp: number;
  45703. /**
  45704. * Used just in case of a failure to initialize an immersive session.
  45705. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45706. */
  45707. defaultHeightCompensation: number;
  45708. /**
  45709. * Fires every time a new xrFrame arrives which can be used to update the camera
  45710. */
  45711. onXRFrameObservable: Observable<XRFrame>;
  45712. /**
  45713. * Fires when the reference space changed
  45714. */
  45715. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45716. /**
  45717. * Fires when the xr session is ended either by the device or manually done
  45718. */
  45719. onXRSessionEnded: Observable<any>;
  45720. /**
  45721. * Fires when the xr session is ended either by the device or manually done
  45722. */
  45723. onXRSessionInit: Observable<XRSession>;
  45724. /**
  45725. * Underlying xr session
  45726. */
  45727. session: XRSession;
  45728. /**
  45729. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45730. * or get the offset the player is currently at.
  45731. */
  45732. viewerReferenceSpace: XRReferenceSpace;
  45733. /**
  45734. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45735. * @param scene The scene which the session should be created for
  45736. */
  45737. constructor(
  45738. /** The scene which the session should be created for */
  45739. scene: Scene);
  45740. /**
  45741. * The current reference space used in this session. This reference space can constantly change!
  45742. * It is mainly used to offset the camera's position.
  45743. */
  45744. get referenceSpace(): XRReferenceSpace;
  45745. /**
  45746. * Set a new reference space and triggers the observable
  45747. */
  45748. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45749. /**
  45750. * Disposes of the session manager
  45751. */
  45752. dispose(): void;
  45753. /**
  45754. * Stops the xrSession and restores the render loop
  45755. * @returns Promise which resolves after it exits XR
  45756. */
  45757. exitXRAsync(): Promise<void>;
  45758. /**
  45759. * Gets the correct render target texture to be rendered this frame for this eye
  45760. * @param eye the eye for which to get the render target
  45761. * @returns the render target for the specified eye
  45762. */
  45763. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45764. /**
  45765. * Creates a WebXRRenderTarget object for the XR session
  45766. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45767. * @param options optional options to provide when creating a new render target
  45768. * @returns a WebXR render target to which the session can render
  45769. */
  45770. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45771. /**
  45772. * Initializes the manager
  45773. * After initialization enterXR can be called to start an XR session
  45774. * @returns Promise which resolves after it is initialized
  45775. */
  45776. initializeAsync(): Promise<void>;
  45777. /**
  45778. * Initializes an xr session
  45779. * @param xrSessionMode mode to initialize
  45780. * @param xrSessionInit defines optional and required values to pass to the session builder
  45781. * @returns a promise which will resolve once the session has been initialized
  45782. */
  45783. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45784. /**
  45785. * Checks if a session would be supported for the creation options specified
  45786. * @param sessionMode session mode to check if supported eg. immersive-vr
  45787. * @returns A Promise that resolves to true if supported and false if not
  45788. */
  45789. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45790. /**
  45791. * Resets the reference space to the one started the session
  45792. */
  45793. resetReferenceSpace(): void;
  45794. /**
  45795. * Starts rendering to the xr layer
  45796. */
  45797. runXRRenderLoop(): void;
  45798. /**
  45799. * Sets the reference space on the xr session
  45800. * @param referenceSpaceType space to set
  45801. * @returns a promise that will resolve once the reference space has been set
  45802. */
  45803. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45804. /**
  45805. * Updates the render state of the session
  45806. * @param state state to set
  45807. * @returns a promise that resolves once the render state has been updated
  45808. */
  45809. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45810. /**
  45811. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45812. * @param sessionMode defines the session to test
  45813. * @returns a promise with boolean as final value
  45814. */
  45815. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45816. private _createRenderTargetTexture;
  45817. }
  45818. }
  45819. declare module BABYLON {
  45820. /**
  45821. * WebXR Camera which holds the views for the xrSession
  45822. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45823. */
  45824. export class WebXRCamera extends FreeCamera {
  45825. private _xrSessionManager;
  45826. private _firstFrame;
  45827. private _referenceQuaternion;
  45828. private _referencedPosition;
  45829. private _xrInvPositionCache;
  45830. private _xrInvQuaternionCache;
  45831. /**
  45832. * Should position compensation execute on first frame.
  45833. * This is used when copying the position from a native (non XR) camera
  45834. */
  45835. compensateOnFirstFrame: boolean;
  45836. /**
  45837. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45838. * @param name the name of the camera
  45839. * @param scene the scene to add the camera to
  45840. * @param _xrSessionManager a constructed xr session manager
  45841. */
  45842. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45843. /**
  45844. * Return the user's height, unrelated to the current ground.
  45845. * This will be the y position of this camera, when ground level is 0.
  45846. */
  45847. get realWorldHeight(): number;
  45848. /** @hidden */
  45849. _updateForDualEyeDebugging(): void;
  45850. /**
  45851. * Sets this camera's transformation based on a non-vr camera
  45852. * @param otherCamera the non-vr camera to copy the transformation from
  45853. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45854. */
  45855. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45856. /**
  45857. * Gets the current instance class name ("WebXRCamera").
  45858. * @returns the class name
  45859. */
  45860. getClassName(): string;
  45861. /**
  45862. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45863. */
  45864. _getViewMatrix(): Matrix;
  45865. private _updateFromXRSession;
  45866. private _updateNumberOfRigCameras;
  45867. private _updateReferenceSpace;
  45868. private _updateReferenceSpaceOffset;
  45869. }
  45870. }
  45871. declare module BABYLON {
  45872. /**
  45873. * Defining the interface required for a (webxr) feature
  45874. */
  45875. export interface IWebXRFeature extends IDisposable {
  45876. /**
  45877. * Is this feature attached
  45878. */
  45879. attached: boolean;
  45880. /**
  45881. * Should auto-attach be disabled?
  45882. */
  45883. disableAutoAttach: boolean;
  45884. /**
  45885. * Attach the feature to the session
  45886. * Will usually be called by the features manager
  45887. *
  45888. * @param force should attachment be forced (even when already attached)
  45889. * @returns true if successful.
  45890. */
  45891. attach(force?: boolean): boolean;
  45892. /**
  45893. * Detach the feature from the session
  45894. * Will usually be called by the features manager
  45895. *
  45896. * @returns true if successful.
  45897. */
  45898. detach(): boolean;
  45899. }
  45900. /**
  45901. * A list of the currently available features without referencing them
  45902. */
  45903. export class WebXRFeatureName {
  45904. /**
  45905. * The name of the anchor system feature
  45906. */
  45907. static ANCHOR_SYSTEM: string;
  45908. /**
  45909. * The name of the background remover feature
  45910. */
  45911. static BACKGROUND_REMOVER: string;
  45912. /**
  45913. * The name of the hit test feature
  45914. */
  45915. static HIT_TEST: string;
  45916. /**
  45917. * physics impostors for xr controllers feature
  45918. */
  45919. static PHYSICS_CONTROLLERS: string;
  45920. /**
  45921. * The name of the plane detection feature
  45922. */
  45923. static PLANE_DETECTION: string;
  45924. /**
  45925. * The name of the pointer selection feature
  45926. */
  45927. static POINTER_SELECTION: string;
  45928. /**
  45929. * The name of the teleportation feature
  45930. */
  45931. static TELEPORTATION: string;
  45932. }
  45933. /**
  45934. * Defining the constructor of a feature. Used to register the modules.
  45935. */
  45936. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45937. /**
  45938. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45939. * It is mainly used in AR sessions.
  45940. *
  45941. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45942. */
  45943. export class WebXRFeaturesManager implements IDisposable {
  45944. private _xrSessionManager;
  45945. private static readonly _AvailableFeatures;
  45946. private _features;
  45947. /**
  45948. * constructs a new features manages.
  45949. *
  45950. * @param _xrSessionManager an instance of WebXRSessionManager
  45951. */
  45952. constructor(_xrSessionManager: WebXRSessionManager);
  45953. /**
  45954. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45955. * Mainly used internally.
  45956. *
  45957. * @param featureName the name of the feature to register
  45958. * @param constructorFunction the function used to construct the module
  45959. * @param version the (babylon) version of the module
  45960. * @param stable is that a stable version of this module
  45961. */
  45962. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45963. /**
  45964. * Returns a constructor of a specific feature.
  45965. *
  45966. * @param featureName the name of the feature to construct
  45967. * @param version the version of the feature to load
  45968. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45969. * @param options optional options provided to the module.
  45970. * @returns a function that, when called, will return a new instance of this feature
  45971. */
  45972. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45973. /**
  45974. * Can be used to return the list of features currently registered
  45975. *
  45976. * @returns an Array of available features
  45977. */
  45978. static GetAvailableFeatures(): string[];
  45979. /**
  45980. * Gets the versions available for a specific feature
  45981. * @param featureName the name of the feature
  45982. * @returns an array with the available versions
  45983. */
  45984. static GetAvailableVersions(featureName: string): string[];
  45985. /**
  45986. * Return the latest unstable version of this feature
  45987. * @param featureName the name of the feature to search
  45988. * @returns the version number. if not found will return -1
  45989. */
  45990. static GetLatestVersionOfFeature(featureName: string): number;
  45991. /**
  45992. * Return the latest stable version of this feature
  45993. * @param featureName the name of the feature to search
  45994. * @returns the version number. if not found will return -1
  45995. */
  45996. static GetStableVersionOfFeature(featureName: string): number;
  45997. /**
  45998. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45999. * Can be used during a session to start a feature
  46000. * @param featureName the name of feature to attach
  46001. */
  46002. attachFeature(featureName: string): void;
  46003. /**
  46004. * Can be used inside a session or when the session ends to detach a specific feature
  46005. * @param featureName the name of the feature to detach
  46006. */
  46007. detachFeature(featureName: string): void;
  46008. /**
  46009. * Used to disable an already-enabled feature
  46010. * The feature will be disposed and will be recreated once enabled.
  46011. * @param featureName the feature to disable
  46012. * @returns true if disable was successful
  46013. */
  46014. disableFeature(featureName: string | {
  46015. Name: string;
  46016. }): boolean;
  46017. /**
  46018. * dispose this features manager
  46019. */
  46020. dispose(): void;
  46021. /**
  46022. * 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.
  46023. * 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.
  46024. *
  46025. * @param featureName the name of the feature to load or the class of the feature
  46026. * @param version optional version to load. if not provided the latest version will be enabled
  46027. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46028. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46029. * @returns a new constructed feature or throws an error if feature not found.
  46030. */
  46031. enableFeature(featureName: string | {
  46032. Name: string;
  46033. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46034. /**
  46035. * get the implementation of an enabled feature.
  46036. * @param featureName the name of the feature to load
  46037. * @returns the feature class, if found
  46038. */
  46039. getEnabledFeature(featureName: string): IWebXRFeature;
  46040. /**
  46041. * Get the list of enabled features
  46042. * @returns an array of enabled features
  46043. */
  46044. getEnabledFeatures(): string[];
  46045. }
  46046. }
  46047. declare module BABYLON {
  46048. /**
  46049. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46050. * @see https://doc.babylonjs.com/how_to/webxr
  46051. */
  46052. export class WebXRExperienceHelper implements IDisposable {
  46053. private scene;
  46054. private _nonVRCamera;
  46055. private _originalSceneAutoClear;
  46056. private _supported;
  46057. /**
  46058. * Camera used to render xr content
  46059. */
  46060. camera: WebXRCamera;
  46061. /** A features manager for this xr session */
  46062. featuresManager: WebXRFeaturesManager;
  46063. /**
  46064. * Observers registered here will be triggered after the camera's initial transformation is set
  46065. * This can be used to set a different ground level or an extra rotation.
  46066. *
  46067. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46068. * to the position set after this observable is done executing.
  46069. */
  46070. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46071. /**
  46072. * Fires when the state of the experience helper has changed
  46073. */
  46074. onStateChangedObservable: Observable<WebXRState>;
  46075. /** Session manager used to keep track of xr session */
  46076. sessionManager: WebXRSessionManager;
  46077. /**
  46078. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46079. */
  46080. state: WebXRState;
  46081. /**
  46082. * Creates a WebXRExperienceHelper
  46083. * @param scene The scene the helper should be created in
  46084. */
  46085. private constructor();
  46086. /**
  46087. * Creates the experience helper
  46088. * @param scene the scene to attach the experience helper to
  46089. * @returns a promise for the experience helper
  46090. */
  46091. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46092. /**
  46093. * Disposes of the experience helper
  46094. */
  46095. dispose(): void;
  46096. /**
  46097. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46098. * @param sessionMode options for the XR session
  46099. * @param referenceSpaceType frame of reference of the XR session
  46100. * @param renderTarget the output canvas that will be used to enter XR mode
  46101. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46102. * @returns promise that resolves after xr mode has entered
  46103. */
  46104. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46105. /**
  46106. * Exits XR mode and returns the scene to its original state
  46107. * @returns promise that resolves after xr mode has exited
  46108. */
  46109. exitXRAsync(): Promise<void>;
  46110. private _nonXRToXRCamera;
  46111. private _setState;
  46112. }
  46113. }
  46114. declare module BABYLON {
  46115. /**
  46116. * X-Y values for axes in WebXR
  46117. */
  46118. export interface IWebXRMotionControllerAxesValue {
  46119. /**
  46120. * The value of the x axis
  46121. */
  46122. x: number;
  46123. /**
  46124. * The value of the y-axis
  46125. */
  46126. y: number;
  46127. }
  46128. /**
  46129. * changed / previous values for the values of this component
  46130. */
  46131. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46132. /**
  46133. * current (this frame) value
  46134. */
  46135. current: T;
  46136. /**
  46137. * previous (last change) value
  46138. */
  46139. previous: T;
  46140. }
  46141. /**
  46142. * Represents changes in the component between current frame and last values recorded
  46143. */
  46144. export interface IWebXRMotionControllerComponentChanges {
  46145. /**
  46146. * will be populated with previous and current values if axes changed
  46147. */
  46148. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46149. /**
  46150. * will be populated with previous and current values if pressed changed
  46151. */
  46152. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46153. /**
  46154. * will be populated with previous and current values if touched changed
  46155. */
  46156. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46157. /**
  46158. * will be populated with previous and current values if value changed
  46159. */
  46160. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46161. }
  46162. /**
  46163. * This class represents a single component (for example button or thumbstick) of a motion controller
  46164. */
  46165. export class WebXRControllerComponent implements IDisposable {
  46166. /**
  46167. * the id of this component
  46168. */
  46169. id: string;
  46170. /**
  46171. * the type of the component
  46172. */
  46173. type: MotionControllerComponentType;
  46174. private _buttonIndex;
  46175. private _axesIndices;
  46176. private _axes;
  46177. private _changes;
  46178. private _currentValue;
  46179. private _hasChanges;
  46180. private _pressed;
  46181. private _touched;
  46182. /**
  46183. * button component type
  46184. */
  46185. static BUTTON_TYPE: MotionControllerComponentType;
  46186. /**
  46187. * squeeze component type
  46188. */
  46189. static SQUEEZE_TYPE: MotionControllerComponentType;
  46190. /**
  46191. * Thumbstick component type
  46192. */
  46193. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46194. /**
  46195. * Touchpad component type
  46196. */
  46197. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46198. /**
  46199. * trigger component type
  46200. */
  46201. static TRIGGER_TYPE: MotionControllerComponentType;
  46202. /**
  46203. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46204. * the axes data changes
  46205. */
  46206. onAxisValueChangedObservable: Observable<{
  46207. x: number;
  46208. y: number;
  46209. }>;
  46210. /**
  46211. * Observers registered here will be triggered when the state of a button changes
  46212. * State change is either pressed / touched / value
  46213. */
  46214. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46215. /**
  46216. * Creates a new component for a motion controller.
  46217. * It is created by the motion controller itself
  46218. *
  46219. * @param id the id of this component
  46220. * @param type the type of the component
  46221. * @param _buttonIndex index in the buttons array of the gamepad
  46222. * @param _axesIndices indices of the values in the axes array of the gamepad
  46223. */
  46224. constructor(
  46225. /**
  46226. * the id of this component
  46227. */
  46228. id: string,
  46229. /**
  46230. * the type of the component
  46231. */
  46232. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46233. /**
  46234. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46235. */
  46236. get axes(): IWebXRMotionControllerAxesValue;
  46237. /**
  46238. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46239. */
  46240. get changes(): IWebXRMotionControllerComponentChanges;
  46241. /**
  46242. * Return whether or not the component changed the last frame
  46243. */
  46244. get hasChanges(): boolean;
  46245. /**
  46246. * is the button currently pressed
  46247. */
  46248. get pressed(): boolean;
  46249. /**
  46250. * is the button currently touched
  46251. */
  46252. get touched(): boolean;
  46253. /**
  46254. * Get the current value of this component
  46255. */
  46256. get value(): number;
  46257. /**
  46258. * Dispose this component
  46259. */
  46260. dispose(): void;
  46261. /**
  46262. * Are there axes correlating to this component
  46263. * @return true is axes data is available
  46264. */
  46265. isAxes(): boolean;
  46266. /**
  46267. * Is this component a button (hence - pressable)
  46268. * @returns true if can be pressed
  46269. */
  46270. isButton(): boolean;
  46271. /**
  46272. * update this component using the gamepad object it is in. Called on every frame
  46273. * @param nativeController the native gamepad controller object
  46274. */
  46275. update(nativeController: IMinimalMotionControllerObject): void;
  46276. }
  46277. }
  46278. declare module BABYLON {
  46279. /**
  46280. * Class used to represent data loading progression
  46281. */
  46282. export class SceneLoaderProgressEvent {
  46283. /** defines if data length to load can be evaluated */
  46284. readonly lengthComputable: boolean;
  46285. /** defines the loaded data length */
  46286. readonly loaded: number;
  46287. /** defines the data length to load */
  46288. readonly total: number;
  46289. /**
  46290. * Create a new progress event
  46291. * @param lengthComputable defines if data length to load can be evaluated
  46292. * @param loaded defines the loaded data length
  46293. * @param total defines the data length to load
  46294. */
  46295. constructor(
  46296. /** defines if data length to load can be evaluated */
  46297. lengthComputable: boolean,
  46298. /** defines the loaded data length */
  46299. loaded: number,
  46300. /** defines the data length to load */
  46301. total: number);
  46302. /**
  46303. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46304. * @param event defines the source event
  46305. * @returns a new SceneLoaderProgressEvent
  46306. */
  46307. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46308. }
  46309. /**
  46310. * Interface used by SceneLoader plugins to define supported file extensions
  46311. */
  46312. export interface ISceneLoaderPluginExtensions {
  46313. /**
  46314. * Defines the list of supported extensions
  46315. */
  46316. [extension: string]: {
  46317. isBinary: boolean;
  46318. };
  46319. }
  46320. /**
  46321. * Interface used by SceneLoader plugin factory
  46322. */
  46323. export interface ISceneLoaderPluginFactory {
  46324. /**
  46325. * Defines the name of the factory
  46326. */
  46327. name: string;
  46328. /**
  46329. * Function called to create a new plugin
  46330. * @return the new plugin
  46331. */
  46332. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46333. /**
  46334. * The callback that returns true if the data can be directly loaded.
  46335. * @param data string containing the file data
  46336. * @returns if the data can be loaded directly
  46337. */
  46338. canDirectLoad?(data: string): boolean;
  46339. }
  46340. /**
  46341. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46342. */
  46343. export interface ISceneLoaderPluginBase {
  46344. /**
  46345. * The friendly name of this plugin.
  46346. */
  46347. name: string;
  46348. /**
  46349. * The file extensions supported by this plugin.
  46350. */
  46351. extensions: string | ISceneLoaderPluginExtensions;
  46352. /**
  46353. * The callback called when loading from a url.
  46354. * @param scene scene loading this url
  46355. * @param url url to load
  46356. * @param onSuccess callback called when the file successfully loads
  46357. * @param onProgress callback called while file is loading (if the server supports this mode)
  46358. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46359. * @param onError callback called when the file fails to load
  46360. * @returns a file request object
  46361. */
  46362. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46363. /**
  46364. * The callback called when loading from a file object.
  46365. * @param scene scene loading this file
  46366. * @param file defines the file to load
  46367. * @param onSuccess defines the callback to call when data is loaded
  46368. * @param onProgress defines the callback to call during loading process
  46369. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46370. * @param onError defines the callback to call when an error occurs
  46371. * @returns a file request object
  46372. */
  46373. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46374. /**
  46375. * The callback that returns true if the data can be directly loaded.
  46376. * @param data string containing the file data
  46377. * @returns if the data can be loaded directly
  46378. */
  46379. canDirectLoad?(data: string): boolean;
  46380. /**
  46381. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46382. * @param scene scene loading this data
  46383. * @param data string containing the data
  46384. * @returns data to pass to the plugin
  46385. */
  46386. directLoad?(scene: Scene, data: string): any;
  46387. /**
  46388. * The callback that allows custom handling of the root url based on the response url.
  46389. * @param rootUrl the original root url
  46390. * @param responseURL the response url if available
  46391. * @returns the new root url
  46392. */
  46393. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46394. }
  46395. /**
  46396. * Interface used to define a SceneLoader plugin
  46397. */
  46398. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46399. /**
  46400. * Import meshes into a scene.
  46401. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46402. * @param scene The scene to import into
  46403. * @param data The data to import
  46404. * @param rootUrl The root url for scene and resources
  46405. * @param meshes The meshes array to import into
  46406. * @param particleSystems The particle systems array to import into
  46407. * @param skeletons The skeletons array to import into
  46408. * @param onError The callback when import fails
  46409. * @returns True if successful or false otherwise
  46410. */
  46411. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46412. /**
  46413. * Load into a scene.
  46414. * @param scene The scene to load into
  46415. * @param data The data to import
  46416. * @param rootUrl The root url for scene and resources
  46417. * @param onError The callback when import fails
  46418. * @returns True if successful or false otherwise
  46419. */
  46420. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46421. /**
  46422. * Load into an asset container.
  46423. * @param scene The scene to load into
  46424. * @param data The data to import
  46425. * @param rootUrl The root url for scene and resources
  46426. * @param onError The callback when import fails
  46427. * @returns The loaded asset container
  46428. */
  46429. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46430. }
  46431. /**
  46432. * Interface used to define an async SceneLoader plugin
  46433. */
  46434. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46435. /**
  46436. * Import meshes into a scene.
  46437. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46438. * @param scene The scene to import into
  46439. * @param data The data to import
  46440. * @param rootUrl The root url for scene and resources
  46441. * @param onProgress The callback when the load progresses
  46442. * @param fileName Defines the name of the file to load
  46443. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46444. */
  46445. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46446. meshes: AbstractMesh[];
  46447. particleSystems: IParticleSystem[];
  46448. skeletons: Skeleton[];
  46449. animationGroups: AnimationGroup[];
  46450. }>;
  46451. /**
  46452. * Load into a scene.
  46453. * @param scene The scene to load into
  46454. * @param data The data to import
  46455. * @param rootUrl The root url for scene and resources
  46456. * @param onProgress The callback when the load progresses
  46457. * @param fileName Defines the name of the file to load
  46458. * @returns Nothing
  46459. */
  46460. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46461. /**
  46462. * Load into an asset container.
  46463. * @param scene The scene to load into
  46464. * @param data The data to import
  46465. * @param rootUrl The root url for scene and resources
  46466. * @param onProgress The callback when the load progresses
  46467. * @param fileName Defines the name of the file to load
  46468. * @returns The loaded asset container
  46469. */
  46470. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46471. }
  46472. /**
  46473. * Mode that determines how to handle old animation groups before loading new ones.
  46474. */
  46475. export enum SceneLoaderAnimationGroupLoadingMode {
  46476. /**
  46477. * Reset all old animations to initial state then dispose them.
  46478. */
  46479. Clean = 0,
  46480. /**
  46481. * Stop all old animations.
  46482. */
  46483. Stop = 1,
  46484. /**
  46485. * Restart old animations from first frame.
  46486. */
  46487. Sync = 2,
  46488. /**
  46489. * Old animations remains untouched.
  46490. */
  46491. NoSync = 3
  46492. }
  46493. /**
  46494. * Class used to load scene from various file formats using registered plugins
  46495. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46496. */
  46497. export class SceneLoader {
  46498. /**
  46499. * No logging while loading
  46500. */
  46501. static readonly NO_LOGGING: number;
  46502. /**
  46503. * Minimal logging while loading
  46504. */
  46505. static readonly MINIMAL_LOGGING: number;
  46506. /**
  46507. * Summary logging while loading
  46508. */
  46509. static readonly SUMMARY_LOGGING: number;
  46510. /**
  46511. * Detailled logging while loading
  46512. */
  46513. static readonly DETAILED_LOGGING: number;
  46514. /**
  46515. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46516. */
  46517. static get ForceFullSceneLoadingForIncremental(): boolean;
  46518. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46519. /**
  46520. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46521. */
  46522. static get ShowLoadingScreen(): boolean;
  46523. static set ShowLoadingScreen(value: boolean);
  46524. /**
  46525. * Defines the current logging level (while loading the scene)
  46526. * @ignorenaming
  46527. */
  46528. static get loggingLevel(): number;
  46529. static set loggingLevel(value: number);
  46530. /**
  46531. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46532. */
  46533. static get CleanBoneMatrixWeights(): boolean;
  46534. static set CleanBoneMatrixWeights(value: boolean);
  46535. /**
  46536. * Event raised when a plugin is used to load a scene
  46537. */
  46538. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46539. private static _registeredPlugins;
  46540. private static _getDefaultPlugin;
  46541. private static _getPluginForExtension;
  46542. private static _getPluginForDirectLoad;
  46543. private static _getPluginForFilename;
  46544. private static _getDirectLoad;
  46545. private static _loadData;
  46546. private static _getFileInfo;
  46547. /**
  46548. * Gets a plugin that can load the given extension
  46549. * @param extension defines the extension to load
  46550. * @returns a plugin or null if none works
  46551. */
  46552. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46553. /**
  46554. * Gets a boolean indicating that the given extension can be loaded
  46555. * @param extension defines the extension to load
  46556. * @returns true if the extension is supported
  46557. */
  46558. static IsPluginForExtensionAvailable(extension: string): boolean;
  46559. /**
  46560. * Adds a new plugin to the list of registered plugins
  46561. * @param plugin defines the plugin to add
  46562. */
  46563. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46564. /**
  46565. * Import meshes into a scene
  46566. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46567. * @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)
  46568. * @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)
  46569. * @param scene the instance of BABYLON.Scene to append to
  46570. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46571. * @param onProgress a callback with a progress event for each file being loaded
  46572. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46573. * @param pluginExtension the extension used to determine the plugin
  46574. * @returns The loaded plugin
  46575. */
  46576. 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>;
  46577. /**
  46578. * Import meshes into a scene
  46579. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46580. * @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)
  46581. * @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)
  46582. * @param scene the instance of BABYLON.Scene to append to
  46583. * @param onProgress a callback with a progress event for each file being loaded
  46584. * @param pluginExtension the extension used to determine the plugin
  46585. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46586. */
  46587. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46588. meshes: AbstractMesh[];
  46589. particleSystems: IParticleSystem[];
  46590. skeletons: Skeleton[];
  46591. animationGroups: AnimationGroup[];
  46592. }>;
  46593. /**
  46594. * Load a scene
  46595. * @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)
  46596. * @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)
  46597. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46598. * @param onSuccess a callback with the scene when import succeeds
  46599. * @param onProgress a callback with a progress event for each file being loaded
  46600. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46601. * @param pluginExtension the extension used to determine the plugin
  46602. * @returns The loaded plugin
  46603. */
  46604. 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>;
  46605. /**
  46606. * Load a scene
  46607. * @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)
  46608. * @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)
  46609. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46610. * @param onProgress a callback with a progress event for each file being loaded
  46611. * @param pluginExtension the extension used to determine the plugin
  46612. * @returns The loaded scene
  46613. */
  46614. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46615. /**
  46616. * Append a scene
  46617. * @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)
  46618. * @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)
  46619. * @param scene is the instance of BABYLON.Scene to append to
  46620. * @param onSuccess a callback with the scene when import succeeds
  46621. * @param onProgress a callback with a progress event for each file being loaded
  46622. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46623. * @param pluginExtension the extension used to determine the plugin
  46624. * @returns The loaded plugin
  46625. */
  46626. 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>;
  46627. /**
  46628. * Append a scene
  46629. * @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)
  46630. * @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)
  46631. * @param scene is the instance of BABYLON.Scene to append to
  46632. * @param onProgress a callback with a progress event for each file being loaded
  46633. * @param pluginExtension the extension used to determine the plugin
  46634. * @returns The given scene
  46635. */
  46636. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46637. /**
  46638. * Load a scene into an asset container
  46639. * @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)
  46640. * @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)
  46641. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46642. * @param onSuccess a callback with the scene when import succeeds
  46643. * @param onProgress a callback with a progress event for each file being loaded
  46644. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46645. * @param pluginExtension the extension used to determine the plugin
  46646. * @returns The loaded plugin
  46647. */
  46648. 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>;
  46649. /**
  46650. * Load a scene into an asset container
  46651. * @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)
  46652. * @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)
  46653. * @param scene is the instance of Scene to append to
  46654. * @param onProgress a callback with a progress event for each file being loaded
  46655. * @param pluginExtension the extension used to determine the plugin
  46656. * @returns The loaded asset container
  46657. */
  46658. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46659. /**
  46660. * Import animations from a file into a scene
  46661. * @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)
  46662. * @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)
  46663. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46664. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46665. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46666. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46667. * @param onSuccess a callback with the scene when import succeeds
  46668. * @param onProgress a callback with a progress event for each file being loaded
  46669. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46670. */
  46671. 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;
  46672. /**
  46673. * Import animations from a file into a scene
  46674. * @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)
  46675. * @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)
  46676. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46677. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46678. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46679. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46680. * @param onSuccess a callback with the scene when import succeeds
  46681. * @param onProgress a callback with a progress event for each file being loaded
  46682. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46683. * @returns the updated scene with imported animations
  46684. */
  46685. 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>;
  46686. }
  46687. }
  46688. declare module BABYLON {
  46689. /**
  46690. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46691. */
  46692. export type MotionControllerHandedness = "none" | "left" | "right";
  46693. /**
  46694. * The type of components available in motion controllers.
  46695. * This is not the name of the component.
  46696. */
  46697. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46698. /**
  46699. * The state of a controller component
  46700. */
  46701. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46702. /**
  46703. * The schema of motion controller layout.
  46704. * No object will be initialized using this interface
  46705. * This is used just to define the profile.
  46706. */
  46707. export interface IMotionControllerLayout {
  46708. /**
  46709. * Path to load the assets. Usually relative to the base path
  46710. */
  46711. assetPath: string;
  46712. /**
  46713. * Available components (unsorted)
  46714. */
  46715. components: {
  46716. /**
  46717. * A map of component Ids
  46718. */
  46719. [componentId: string]: {
  46720. /**
  46721. * The type of input the component outputs
  46722. */
  46723. type: MotionControllerComponentType;
  46724. /**
  46725. * The indices of this component in the gamepad object
  46726. */
  46727. gamepadIndices: {
  46728. /**
  46729. * Index of button
  46730. */
  46731. button?: number;
  46732. /**
  46733. * If available, index of x-axis
  46734. */
  46735. xAxis?: number;
  46736. /**
  46737. * If available, index of y-axis
  46738. */
  46739. yAxis?: number;
  46740. };
  46741. /**
  46742. * The mesh's root node name
  46743. */
  46744. rootNodeName: string;
  46745. /**
  46746. * Animation definitions for this model
  46747. */
  46748. visualResponses: {
  46749. [stateKey: string]: {
  46750. /**
  46751. * What property will be animated
  46752. */
  46753. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46754. /**
  46755. * What states influence this visual response
  46756. */
  46757. states: MotionControllerComponentStateType[];
  46758. /**
  46759. * Type of animation - movement or visibility
  46760. */
  46761. valueNodeProperty: "transform" | "visibility";
  46762. /**
  46763. * Base node name to move. Its position will be calculated according to the min and max nodes
  46764. */
  46765. valueNodeName?: string;
  46766. /**
  46767. * Minimum movement node
  46768. */
  46769. minNodeName?: string;
  46770. /**
  46771. * Max movement node
  46772. */
  46773. maxNodeName?: string;
  46774. };
  46775. };
  46776. /**
  46777. * If touch enabled, what is the name of node to display user feedback
  46778. */
  46779. touchPointNodeName?: string;
  46780. };
  46781. };
  46782. /**
  46783. * Is it xr standard mapping or not
  46784. */
  46785. gamepadMapping: "" | "xr-standard";
  46786. /**
  46787. * Base root node of this entire model
  46788. */
  46789. rootNodeName: string;
  46790. /**
  46791. * Defines the main button component id
  46792. */
  46793. selectComponentId: string;
  46794. }
  46795. /**
  46796. * A definition for the layout map in the input profile
  46797. */
  46798. export interface IMotionControllerLayoutMap {
  46799. /**
  46800. * Layouts with handedness type as a key
  46801. */
  46802. [handedness: string]: IMotionControllerLayout;
  46803. }
  46804. /**
  46805. * The XR Input profile schema
  46806. * Profiles can be found here:
  46807. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46808. */
  46809. export interface IMotionControllerProfile {
  46810. /**
  46811. * fallback profiles for this profileId
  46812. */
  46813. fallbackProfileIds: string[];
  46814. /**
  46815. * The layout map, with handedness as key
  46816. */
  46817. layouts: IMotionControllerLayoutMap;
  46818. /**
  46819. * The id of this profile
  46820. * correlates to the profile(s) in the xrInput.profiles array
  46821. */
  46822. profileId: string;
  46823. }
  46824. /**
  46825. * A helper-interface for the 3 meshes needed for controller button animation
  46826. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46827. */
  46828. export interface IMotionControllerButtonMeshMap {
  46829. /**
  46830. * the mesh that defines the pressed value mesh position.
  46831. * This is used to find the max-position of this button
  46832. */
  46833. pressedMesh: AbstractMesh;
  46834. /**
  46835. * the mesh that defines the unpressed value mesh position.
  46836. * This is used to find the min (or initial) position of this button
  46837. */
  46838. unpressedMesh: AbstractMesh;
  46839. /**
  46840. * The mesh that will be changed when value changes
  46841. */
  46842. valueMesh: AbstractMesh;
  46843. }
  46844. /**
  46845. * A helper-interface for the 3 meshes needed for controller axis animation.
  46846. * This will be expanded when touchpad animations are fully supported
  46847. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46848. */
  46849. export interface IMotionControllerMeshMap {
  46850. /**
  46851. * the mesh that defines the maximum value mesh position.
  46852. */
  46853. maxMesh?: AbstractMesh;
  46854. /**
  46855. * the mesh that defines the minimum value mesh position.
  46856. */
  46857. minMesh?: AbstractMesh;
  46858. /**
  46859. * The mesh that will be changed when axis value changes
  46860. */
  46861. valueMesh: AbstractMesh;
  46862. }
  46863. /**
  46864. * The elements needed for change-detection of the gamepad objects in motion controllers
  46865. */
  46866. export interface IMinimalMotionControllerObject {
  46867. /**
  46868. * Available axes of this controller
  46869. */
  46870. axes: number[];
  46871. /**
  46872. * An array of available buttons
  46873. */
  46874. buttons: Array<{
  46875. /**
  46876. * Value of the button/trigger
  46877. */
  46878. value: number;
  46879. /**
  46880. * If the button/trigger is currently touched
  46881. */
  46882. touched: boolean;
  46883. /**
  46884. * If the button/trigger is currently pressed
  46885. */
  46886. pressed: boolean;
  46887. }>;
  46888. /**
  46889. * EXPERIMENTAL haptic support.
  46890. */
  46891. hapticActuators?: Array<{
  46892. pulse: (value: number, duration: number) => Promise<boolean>;
  46893. }>;
  46894. }
  46895. /**
  46896. * An Abstract Motion controller
  46897. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46898. * Each component has an observable to check for changes in value and state
  46899. */
  46900. export abstract class WebXRAbstractMotionController implements IDisposable {
  46901. protected scene: Scene;
  46902. protected layout: IMotionControllerLayout;
  46903. /**
  46904. * The gamepad object correlating to this controller
  46905. */
  46906. gamepadObject: IMinimalMotionControllerObject;
  46907. /**
  46908. * handedness (left/right/none) of this controller
  46909. */
  46910. handedness: MotionControllerHandedness;
  46911. private _initComponent;
  46912. private _modelReady;
  46913. /**
  46914. * A map of components (WebXRControllerComponent) in this motion controller
  46915. * Components have a ComponentType and can also have both button and axis definitions
  46916. */
  46917. readonly components: {
  46918. [id: string]: WebXRControllerComponent;
  46919. };
  46920. /**
  46921. * Disable the model's animation. Can be set at any time.
  46922. */
  46923. disableAnimation: boolean;
  46924. /**
  46925. * Observers registered here will be triggered when the model of this controller is done loading
  46926. */
  46927. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46928. /**
  46929. * The profile id of this motion controller
  46930. */
  46931. abstract profileId: string;
  46932. /**
  46933. * The root mesh of the model. It is null if the model was not yet initialized
  46934. */
  46935. rootMesh: Nullable<AbstractMesh>;
  46936. /**
  46937. * constructs a new abstract motion controller
  46938. * @param scene the scene to which the model of the controller will be added
  46939. * @param layout The profile layout to load
  46940. * @param gamepadObject The gamepad object correlating to this controller
  46941. * @param handedness handedness (left/right/none) of this controller
  46942. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46943. */
  46944. constructor(scene: Scene, layout: IMotionControllerLayout,
  46945. /**
  46946. * The gamepad object correlating to this controller
  46947. */
  46948. gamepadObject: IMinimalMotionControllerObject,
  46949. /**
  46950. * handedness (left/right/none) of this controller
  46951. */
  46952. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46953. /**
  46954. * Dispose this controller, the model mesh and all its components
  46955. */
  46956. dispose(): void;
  46957. /**
  46958. * Returns all components of specific type
  46959. * @param type the type to search for
  46960. * @return an array of components with this type
  46961. */
  46962. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46963. /**
  46964. * get a component based an its component id as defined in layout.components
  46965. * @param id the id of the component
  46966. * @returns the component correlates to the id or undefined if not found
  46967. */
  46968. getComponent(id: string): WebXRControllerComponent;
  46969. /**
  46970. * Get the list of components available in this motion controller
  46971. * @returns an array of strings correlating to available components
  46972. */
  46973. getComponentIds(): string[];
  46974. /**
  46975. * Get the first component of specific type
  46976. * @param type type of component to find
  46977. * @return a controller component or null if not found
  46978. */
  46979. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46980. /**
  46981. * Get the main (Select) component of this controller as defined in the layout
  46982. * @returns the main component of this controller
  46983. */
  46984. getMainComponent(): WebXRControllerComponent;
  46985. /**
  46986. * Loads the model correlating to this controller
  46987. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46988. * @returns A promise fulfilled with the result of the model loading
  46989. */
  46990. loadModel(): Promise<boolean>;
  46991. /**
  46992. * Update this model using the current XRFrame
  46993. * @param xrFrame the current xr frame to use and update the model
  46994. */
  46995. updateFromXRFrame(xrFrame: XRFrame): void;
  46996. /**
  46997. * Backwards compatibility due to a deeply-integrated typo
  46998. */
  46999. get handness(): XREye;
  47000. /**
  47001. * Pulse (vibrate) this controller
  47002. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47003. * Consecutive calls to this function will cancel the last pulse call
  47004. *
  47005. * @param value the strength of the pulse in 0.0...1.0 range
  47006. * @param duration Duration of the pulse in milliseconds
  47007. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47008. * @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
  47009. */
  47010. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47011. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47012. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47013. /**
  47014. * Moves the axis on the controller mesh based on its current state
  47015. * @param axis the index of the axis
  47016. * @param axisValue the value of the axis which determines the meshes new position
  47017. * @hidden
  47018. */
  47019. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47020. /**
  47021. * Update the model itself with the current frame data
  47022. * @param xrFrame the frame to use for updating the model mesh
  47023. */
  47024. protected updateModel(xrFrame: XRFrame): void;
  47025. /**
  47026. * Get the filename and path for this controller's model
  47027. * @returns a map of filename and path
  47028. */
  47029. protected abstract _getFilenameAndPath(): {
  47030. filename: string;
  47031. path: string;
  47032. };
  47033. /**
  47034. * This function is called before the mesh is loaded. It checks for loading constraints.
  47035. * For example, this function can check if the GLB loader is available
  47036. * If this function returns false, the generic controller will be loaded instead
  47037. * @returns Is the client ready to load the mesh
  47038. */
  47039. protected abstract _getModelLoadingConstraints(): boolean;
  47040. /**
  47041. * This function will be called after the model was successfully loaded and can be used
  47042. * for mesh transformations before it is available for the user
  47043. * @param meshes the loaded meshes
  47044. */
  47045. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47046. /**
  47047. * Set the root mesh for this controller. Important for the WebXR controller class
  47048. * @param meshes the loaded meshes
  47049. */
  47050. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47051. /**
  47052. * A function executed each frame that updates the mesh (if needed)
  47053. * @param xrFrame the current xrFrame
  47054. */
  47055. protected abstract _updateModel(xrFrame: XRFrame): void;
  47056. private _getGenericFilenameAndPath;
  47057. private _getGenericParentMesh;
  47058. }
  47059. }
  47060. declare module BABYLON {
  47061. /**
  47062. * A generic trigger-only motion controller for WebXR
  47063. */
  47064. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47065. /**
  47066. * Static version of the profile id of this controller
  47067. */
  47068. static ProfileId: string;
  47069. profileId: string;
  47070. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47071. protected _getFilenameAndPath(): {
  47072. filename: string;
  47073. path: string;
  47074. };
  47075. protected _getModelLoadingConstraints(): boolean;
  47076. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47077. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47078. protected _updateModel(): void;
  47079. }
  47080. }
  47081. declare module BABYLON {
  47082. /**
  47083. * Class containing static functions to help procedurally build meshes
  47084. */
  47085. export class SphereBuilder {
  47086. /**
  47087. * Creates a sphere mesh
  47088. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47089. * * 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`)
  47090. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47091. * * 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
  47092. * * 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)
  47093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47094. * * 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
  47095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47096. * @param name defines the name of the mesh
  47097. * @param options defines the options used to create the mesh
  47098. * @param scene defines the hosting scene
  47099. * @returns the sphere mesh
  47100. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47101. */
  47102. static CreateSphere(name: string, options: {
  47103. segments?: number;
  47104. diameter?: number;
  47105. diameterX?: number;
  47106. diameterY?: number;
  47107. diameterZ?: number;
  47108. arc?: number;
  47109. slice?: number;
  47110. sideOrientation?: number;
  47111. frontUVs?: Vector4;
  47112. backUVs?: Vector4;
  47113. updatable?: boolean;
  47114. }, scene?: Nullable<Scene>): Mesh;
  47115. }
  47116. }
  47117. declare module BABYLON {
  47118. /**
  47119. * A profiled motion controller has its profile loaded from an online repository.
  47120. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47121. */
  47122. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47123. private _repositoryUrl;
  47124. private _buttonMeshMapping;
  47125. private _touchDots;
  47126. /**
  47127. * The profile ID of this controller. Will be populated when the controller initializes.
  47128. */
  47129. profileId: string;
  47130. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47131. dispose(): void;
  47132. protected _getFilenameAndPath(): {
  47133. filename: string;
  47134. path: string;
  47135. };
  47136. protected _getModelLoadingConstraints(): boolean;
  47137. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47138. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47139. protected _updateModel(_xrFrame: XRFrame): void;
  47140. }
  47141. }
  47142. declare module BABYLON {
  47143. /**
  47144. * A construction function type to create a new controller based on an xrInput object
  47145. */
  47146. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47147. /**
  47148. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47149. *
  47150. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47151. * it should be replaced with auto-loaded controllers.
  47152. *
  47153. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47154. */
  47155. export class WebXRMotionControllerManager {
  47156. private static _AvailableControllers;
  47157. private static _Fallbacks;
  47158. private static _ProfileLoadingPromises;
  47159. private static _ProfilesList;
  47160. /**
  47161. * The base URL of the online controller repository. Can be changed at any time.
  47162. */
  47163. static BaseRepositoryUrl: string;
  47164. /**
  47165. * Which repository gets priority - local or online
  47166. */
  47167. static PrioritizeOnlineRepository: boolean;
  47168. /**
  47169. * Use the online repository, or use only locally-defined controllers
  47170. */
  47171. static UseOnlineRepository: boolean;
  47172. /**
  47173. * Clear the cache used for profile loading and reload when requested again
  47174. */
  47175. static ClearProfilesCache(): void;
  47176. /**
  47177. * Register the default fallbacks.
  47178. * This function is called automatically when this file is imported.
  47179. */
  47180. static DefaultFallbacks(): void;
  47181. /**
  47182. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47183. * @param profileId the profile to which a fallback needs to be found
  47184. * @return an array with corresponding fallback profiles
  47185. */
  47186. static FindFallbackWithProfileId(profileId: string): string[];
  47187. /**
  47188. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47189. * The order of search:
  47190. *
  47191. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47192. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47193. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47194. * 4) return the generic trigger controller if none were found
  47195. *
  47196. * @param xrInput the xrInput to which a new controller is initialized
  47197. * @param scene the scene to which the model will be added
  47198. * @param forceProfile force a certain profile for this controller
  47199. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47200. */
  47201. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47202. /**
  47203. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47204. *
  47205. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47206. *
  47207. * @param type the profile type to register
  47208. * @param constructFunction the function to be called when loading this profile
  47209. */
  47210. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47211. /**
  47212. * Register a fallback to a specific profile.
  47213. * @param profileId the profileId that will receive the fallbacks
  47214. * @param fallbacks A list of fallback profiles
  47215. */
  47216. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47217. /**
  47218. * Will update the list of profiles available in the repository
  47219. * @return a promise that resolves to a map of profiles available online
  47220. */
  47221. static UpdateProfilesList(): Promise<{
  47222. [profile: string]: string;
  47223. }>;
  47224. private static _LoadProfileFromRepository;
  47225. private static _LoadProfilesFromAvailableControllers;
  47226. }
  47227. }
  47228. declare module BABYLON {
  47229. /**
  47230. * Configuration options for the WebXR controller creation
  47231. */
  47232. export interface IWebXRControllerOptions {
  47233. /**
  47234. * Should the controller mesh be animated when a user interacts with it
  47235. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47236. */
  47237. disableMotionControllerAnimation?: boolean;
  47238. /**
  47239. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47240. */
  47241. doNotLoadControllerMesh?: boolean;
  47242. /**
  47243. * Force a specific controller type for this controller.
  47244. * This can be used when creating your own profile or when testing different controllers
  47245. */
  47246. forceControllerProfile?: string;
  47247. /**
  47248. * Defines a rendering group ID for meshes that will be loaded.
  47249. * This is for the default controllers only.
  47250. */
  47251. renderingGroupId?: number;
  47252. }
  47253. /**
  47254. * Represents an XR controller
  47255. */
  47256. export class WebXRInputSource {
  47257. private _scene;
  47258. /** The underlying input source for the controller */
  47259. inputSource: XRInputSource;
  47260. private _options;
  47261. private _tmpVector;
  47262. private _uniqueId;
  47263. /**
  47264. * 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
  47265. */
  47266. grip?: AbstractMesh;
  47267. /**
  47268. * If available, this is the gamepad object related to this controller.
  47269. * Using this object it is possible to get click events and trackpad changes of the
  47270. * webxr controller that is currently being used.
  47271. */
  47272. motionController?: WebXRAbstractMotionController;
  47273. /**
  47274. * Event that fires when the controller is removed/disposed.
  47275. * The object provided as event data is this controller, after associated assets were disposed.
  47276. * uniqueId is still available.
  47277. */
  47278. onDisposeObservable: Observable<WebXRInputSource>;
  47279. /**
  47280. * Will be triggered when the mesh associated with the motion controller is done loading.
  47281. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47282. * A shortened version of controller -> motion controller -> on mesh loaded.
  47283. */
  47284. onMeshLoadedObservable: Observable<AbstractMesh>;
  47285. /**
  47286. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47287. */
  47288. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47289. /**
  47290. * Pointer which can be used to select objects or attach a visible laser to
  47291. */
  47292. pointer: AbstractMesh;
  47293. /**
  47294. * Creates the controller
  47295. * @see https://doc.babylonjs.com/how_to/webxr
  47296. * @param _scene the scene which the controller should be associated to
  47297. * @param inputSource the underlying input source for the controller
  47298. * @param _options options for this controller creation
  47299. */
  47300. constructor(_scene: Scene,
  47301. /** The underlying input source for the controller */
  47302. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47303. /**
  47304. * Get this controllers unique id
  47305. */
  47306. get uniqueId(): string;
  47307. /**
  47308. * Disposes of the object
  47309. */
  47310. dispose(): void;
  47311. /**
  47312. * Gets a world space ray coming from the pointer or grip
  47313. * @param result the resulting ray
  47314. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47315. */
  47316. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47317. /**
  47318. * Updates the controller pose based on the given XRFrame
  47319. * @param xrFrame xr frame to update the pose with
  47320. * @param referenceSpace reference space to use
  47321. */
  47322. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47323. }
  47324. }
  47325. declare module BABYLON {
  47326. /**
  47327. * The schema for initialization options of the XR Input class
  47328. */
  47329. export interface IWebXRInputOptions {
  47330. /**
  47331. * If set to true no model will be automatically loaded
  47332. */
  47333. doNotLoadControllerMeshes?: boolean;
  47334. /**
  47335. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47336. * If not found, the xr input profile data will be used.
  47337. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47338. */
  47339. forceInputProfile?: string;
  47340. /**
  47341. * Do not send a request to the controller repository to load the profile.
  47342. *
  47343. * Instead, use the controllers available in babylon itself.
  47344. */
  47345. disableOnlineControllerRepository?: boolean;
  47346. /**
  47347. * A custom URL for the controllers repository
  47348. */
  47349. customControllersRepositoryURL?: string;
  47350. /**
  47351. * Should the controller model's components not move according to the user input
  47352. */
  47353. disableControllerAnimation?: boolean;
  47354. /**
  47355. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47356. */
  47357. controllerOptions?: IWebXRControllerOptions;
  47358. }
  47359. /**
  47360. * XR input used to track XR inputs such as controllers/rays
  47361. */
  47362. export class WebXRInput implements IDisposable {
  47363. /**
  47364. * the xr session manager for this session
  47365. */
  47366. xrSessionManager: WebXRSessionManager;
  47367. /**
  47368. * the WebXR camera for this session. Mainly used for teleportation
  47369. */
  47370. xrCamera: WebXRCamera;
  47371. private readonly options;
  47372. /**
  47373. * XR controllers being tracked
  47374. */
  47375. controllers: Array<WebXRInputSource>;
  47376. private _frameObserver;
  47377. private _sessionEndedObserver;
  47378. private _sessionInitObserver;
  47379. /**
  47380. * Event when a controller has been connected/added
  47381. */
  47382. onControllerAddedObservable: Observable<WebXRInputSource>;
  47383. /**
  47384. * Event when a controller has been removed/disconnected
  47385. */
  47386. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47387. /**
  47388. * Initializes the WebXRInput
  47389. * @param xrSessionManager the xr session manager for this session
  47390. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47391. * @param options = initialization options for this xr input
  47392. */
  47393. constructor(
  47394. /**
  47395. * the xr session manager for this session
  47396. */
  47397. xrSessionManager: WebXRSessionManager,
  47398. /**
  47399. * the WebXR camera for this session. Mainly used for teleportation
  47400. */
  47401. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47402. private _onInputSourcesChange;
  47403. private _addAndRemoveControllers;
  47404. /**
  47405. * Disposes of the object
  47406. */
  47407. dispose(): void;
  47408. }
  47409. }
  47410. declare module BABYLON {
  47411. /**
  47412. * This is the base class for all WebXR features.
  47413. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47414. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47415. */
  47416. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47417. protected _xrSessionManager: WebXRSessionManager;
  47418. private _attached;
  47419. private _removeOnDetach;
  47420. /**
  47421. * Should auto-attach be disabled?
  47422. */
  47423. disableAutoAttach: boolean;
  47424. /**
  47425. * Construct a new (abstract) WebXR feature
  47426. * @param _xrSessionManager the xr session manager for this feature
  47427. */
  47428. constructor(_xrSessionManager: WebXRSessionManager);
  47429. /**
  47430. * Is this feature attached
  47431. */
  47432. get attached(): boolean;
  47433. /**
  47434. * attach this feature
  47435. *
  47436. * @param force should attachment be forced (even when already attached)
  47437. * @returns true if successful, false is failed or already attached
  47438. */
  47439. attach(force?: boolean): boolean;
  47440. /**
  47441. * detach this feature.
  47442. *
  47443. * @returns true if successful, false if failed or already detached
  47444. */
  47445. detach(): boolean;
  47446. /**
  47447. * Dispose this feature and all of the resources attached
  47448. */
  47449. dispose(): void;
  47450. /**
  47451. * This is used to register callbacks that will automatically be removed when detach is called.
  47452. * @param observable the observable to which the observer will be attached
  47453. * @param callback the callback to register
  47454. */
  47455. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47456. /**
  47457. * Code in this function will be executed on each xrFrame received from the browser.
  47458. * This function will not execute after the feature is detached.
  47459. * @param _xrFrame the current frame
  47460. */
  47461. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47462. }
  47463. }
  47464. declare module BABYLON {
  47465. /**
  47466. * Renders a layer on top of an existing scene
  47467. */
  47468. export class UtilityLayerRenderer implements IDisposable {
  47469. /** the original scene that will be rendered on top of */
  47470. originalScene: Scene;
  47471. private _pointerCaptures;
  47472. private _lastPointerEvents;
  47473. private static _DefaultUtilityLayer;
  47474. private static _DefaultKeepDepthUtilityLayer;
  47475. private _sharedGizmoLight;
  47476. private _renderCamera;
  47477. /**
  47478. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47479. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47480. * @returns the camera that is used when rendering the utility layer
  47481. */
  47482. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47483. /**
  47484. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47485. * @param cam the camera that should be used when rendering the utility layer
  47486. */
  47487. setRenderCamera(cam: Nullable<Camera>): void;
  47488. /**
  47489. * @hidden
  47490. * Light which used by gizmos to get light shading
  47491. */
  47492. _getSharedGizmoLight(): HemisphericLight;
  47493. /**
  47494. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47495. */
  47496. pickUtilitySceneFirst: boolean;
  47497. /**
  47498. * 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)
  47499. */
  47500. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47501. /**
  47502. * 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)
  47503. */
  47504. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47505. /**
  47506. * The scene that is rendered on top of the original scene
  47507. */
  47508. utilityLayerScene: Scene;
  47509. /**
  47510. * If the utility layer should automatically be rendered on top of existing scene
  47511. */
  47512. shouldRender: boolean;
  47513. /**
  47514. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47515. */
  47516. onlyCheckPointerDownEvents: boolean;
  47517. /**
  47518. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47519. */
  47520. processAllEvents: boolean;
  47521. /**
  47522. * Observable raised when the pointer move from the utility layer scene to the main scene
  47523. */
  47524. onPointerOutObservable: Observable<number>;
  47525. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47526. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47527. private _afterRenderObserver;
  47528. private _sceneDisposeObserver;
  47529. private _originalPointerObserver;
  47530. /**
  47531. * Instantiates a UtilityLayerRenderer
  47532. * @param originalScene the original scene that will be rendered on top of
  47533. * @param handleEvents boolean indicating if the utility layer should handle events
  47534. */
  47535. constructor(
  47536. /** the original scene that will be rendered on top of */
  47537. originalScene: Scene, handleEvents?: boolean);
  47538. private _notifyObservers;
  47539. /**
  47540. * Renders the utility layers scene on top of the original scene
  47541. */
  47542. render(): void;
  47543. /**
  47544. * Disposes of the renderer
  47545. */
  47546. dispose(): void;
  47547. private _updateCamera;
  47548. }
  47549. }
  47550. declare module BABYLON {
  47551. /**
  47552. * Options interface for the pointer selection module
  47553. */
  47554. export interface IWebXRControllerPointerSelectionOptions {
  47555. /**
  47556. * if provided, this scene will be used to render meshes.
  47557. */
  47558. customUtilityLayerScene?: Scene;
  47559. /**
  47560. * 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)
  47561. * If not disabled, the last picked point will be used to execute a pointer up event
  47562. * If disabled, pointer up event will be triggered right after the pointer down event.
  47563. * Used in screen and gaze target ray mode only
  47564. */
  47565. disablePointerUpOnTouchOut: boolean;
  47566. /**
  47567. * For gaze mode (time to select instead of press)
  47568. */
  47569. forceGazeMode: boolean;
  47570. /**
  47571. * 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
  47572. * to start a new countdown to the pointer down event.
  47573. * Defaults to 1.
  47574. */
  47575. gazeModePointerMovedFactor?: number;
  47576. /**
  47577. * Different button type to use instead of the main component
  47578. */
  47579. overrideButtonId?: string;
  47580. /**
  47581. * use this rendering group id for the meshes (optional)
  47582. */
  47583. renderingGroupId?: number;
  47584. /**
  47585. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47586. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47587. * 3000 means 3 seconds between pointing at something and selecting it
  47588. */
  47589. timeToSelect?: number;
  47590. /**
  47591. * Should meshes created here be added to a utility layer or the main scene
  47592. */
  47593. useUtilityLayer?: boolean;
  47594. /**
  47595. * the xr input to use with this pointer selection
  47596. */
  47597. xrInput: WebXRInput;
  47598. }
  47599. /**
  47600. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47601. */
  47602. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47603. private readonly _options;
  47604. private static _idCounter;
  47605. private _attachController;
  47606. private _controllers;
  47607. private _scene;
  47608. private _tmpVectorForPickCompare;
  47609. /**
  47610. * The module's name
  47611. */
  47612. static readonly Name: string;
  47613. /**
  47614. * The (Babylon) version of this module.
  47615. * This is an integer representing the implementation version.
  47616. * This number does not correspond to the WebXR specs version
  47617. */
  47618. static readonly Version: number;
  47619. /**
  47620. * Disable lighting on the laser pointer (so it will always be visible)
  47621. */
  47622. disablePointerLighting: boolean;
  47623. /**
  47624. * Disable lighting on the selection mesh (so it will always be visible)
  47625. */
  47626. disableSelectionMeshLighting: boolean;
  47627. /**
  47628. * Should the laser pointer be displayed
  47629. */
  47630. displayLaserPointer: boolean;
  47631. /**
  47632. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47633. */
  47634. displaySelectionMesh: boolean;
  47635. /**
  47636. * This color will be set to the laser pointer when selection is triggered
  47637. */
  47638. laserPointerPickedColor: Color3;
  47639. /**
  47640. * Default color of the laser pointer
  47641. */
  47642. lasterPointerDefaultColor: Color3;
  47643. /**
  47644. * default color of the selection ring
  47645. */
  47646. selectionMeshDefaultColor: Color3;
  47647. /**
  47648. * This color will be applied to the selection ring when selection is triggered
  47649. */
  47650. selectionMeshPickedColor: Color3;
  47651. /**
  47652. * Optional filter to be used for ray selection. This predicate shares behavior with
  47653. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47654. */
  47655. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47656. /**
  47657. * constructs a new background remover module
  47658. * @param _xrSessionManager the session manager for this module
  47659. * @param _options read-only options to be used in this module
  47660. */
  47661. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47662. /**
  47663. * attach this feature
  47664. * Will usually be called by the features manager
  47665. *
  47666. * @returns true if successful.
  47667. */
  47668. attach(): boolean;
  47669. /**
  47670. * detach this feature.
  47671. * Will usually be called by the features manager
  47672. *
  47673. * @returns true if successful.
  47674. */
  47675. detach(): boolean;
  47676. /**
  47677. * Will get the mesh under a specific pointer.
  47678. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47679. * @param controllerId the controllerId to check
  47680. * @returns The mesh under pointer or null if no mesh is under the pointer
  47681. */
  47682. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47683. /**
  47684. * Get the xr controller that correlates to the pointer id in the pointer event
  47685. *
  47686. * @param id the pointer id to search for
  47687. * @returns the controller that correlates to this id or null if not found
  47688. */
  47689. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47690. protected _onXRFrame(_xrFrame: XRFrame): void;
  47691. private _attachGazeMode;
  47692. private _attachScreenRayMode;
  47693. private _attachTrackedPointerRayMode;
  47694. private _convertNormalToDirectionOfRay;
  47695. private _detachController;
  47696. private _generateNewMeshPair;
  47697. private _pickingMoved;
  47698. private _updatePointerDistance;
  47699. }
  47700. }
  47701. declare module BABYLON {
  47702. /**
  47703. * Button which can be used to enter a different mode of XR
  47704. */
  47705. export class WebXREnterExitUIButton {
  47706. /** button element */
  47707. element: HTMLElement;
  47708. /** XR initialization options for the button */
  47709. sessionMode: XRSessionMode;
  47710. /** Reference space type */
  47711. referenceSpaceType: XRReferenceSpaceType;
  47712. /**
  47713. * Creates a WebXREnterExitUIButton
  47714. * @param element button element
  47715. * @param sessionMode XR initialization session mode
  47716. * @param referenceSpaceType the type of reference space to be used
  47717. */
  47718. constructor(
  47719. /** button element */
  47720. element: HTMLElement,
  47721. /** XR initialization options for the button */
  47722. sessionMode: XRSessionMode,
  47723. /** Reference space type */
  47724. referenceSpaceType: XRReferenceSpaceType);
  47725. /**
  47726. * Extendable function which can be used to update the button's visuals when the state changes
  47727. * @param activeButton the current active button in the UI
  47728. */
  47729. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47730. }
  47731. /**
  47732. * Options to create the webXR UI
  47733. */
  47734. export class WebXREnterExitUIOptions {
  47735. /**
  47736. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47737. */
  47738. customButtons?: Array<WebXREnterExitUIButton>;
  47739. /**
  47740. * A reference space type to use when creating the default button.
  47741. * Default is local-floor
  47742. */
  47743. referenceSpaceType?: XRReferenceSpaceType;
  47744. /**
  47745. * Context to enter xr with
  47746. */
  47747. renderTarget?: Nullable<WebXRRenderTarget>;
  47748. /**
  47749. * A session mode to use when creating the default button.
  47750. * Default is immersive-vr
  47751. */
  47752. sessionMode?: XRSessionMode;
  47753. /**
  47754. * A list of optional features to init the session with
  47755. */
  47756. optionalFeatures?: string[];
  47757. }
  47758. /**
  47759. * UI to allow the user to enter/exit XR mode
  47760. */
  47761. export class WebXREnterExitUI implements IDisposable {
  47762. private scene;
  47763. /** version of the options passed to this UI */
  47764. options: WebXREnterExitUIOptions;
  47765. private _activeButton;
  47766. private _buttons;
  47767. private _overlay;
  47768. /**
  47769. * Fired every time the active button is changed.
  47770. *
  47771. * When xr is entered via a button that launches xr that button will be the callback parameter
  47772. *
  47773. * When exiting xr the callback parameter will be null)
  47774. */
  47775. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47776. /**
  47777. *
  47778. * @param scene babylon scene object to use
  47779. * @param options (read-only) version of the options passed to this UI
  47780. */
  47781. private constructor();
  47782. /**
  47783. * Creates UI to allow the user to enter/exit XR mode
  47784. * @param scene the scene to add the ui to
  47785. * @param helper the xr experience helper to enter/exit xr with
  47786. * @param options options to configure the UI
  47787. * @returns the created ui
  47788. */
  47789. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47790. /**
  47791. * Disposes of the XR UI component
  47792. */
  47793. dispose(): void;
  47794. private _updateButtons;
  47795. }
  47796. }
  47797. declare module BABYLON {
  47798. /**
  47799. * Class containing static functions to help procedurally build meshes
  47800. */
  47801. export class LinesBuilder {
  47802. /**
  47803. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47804. * * 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
  47805. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47806. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47807. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47808. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47809. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47810. * * 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
  47811. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47814. * @param name defines the name of the new line system
  47815. * @param options defines the options used to create the line system
  47816. * @param scene defines the hosting scene
  47817. * @returns a new line system mesh
  47818. */
  47819. static CreateLineSystem(name: string, options: {
  47820. lines: Vector3[][];
  47821. updatable?: boolean;
  47822. instance?: Nullable<LinesMesh>;
  47823. colors?: Nullable<Color4[][]>;
  47824. useVertexAlpha?: boolean;
  47825. }, scene: Nullable<Scene>): LinesMesh;
  47826. /**
  47827. * Creates a line mesh
  47828. * 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
  47829. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47830. * * The parameter `points` is an array successive Vector3
  47831. * * 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
  47832. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47833. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47834. * * When updating an instance, remember that only point positions can change, not the number of points
  47835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47837. * @param name defines the name of the new line system
  47838. * @param options defines the options used to create the line system
  47839. * @param scene defines the hosting scene
  47840. * @returns a new line mesh
  47841. */
  47842. static CreateLines(name: string, options: {
  47843. points: Vector3[];
  47844. updatable?: boolean;
  47845. instance?: Nullable<LinesMesh>;
  47846. colors?: Color4[];
  47847. useVertexAlpha?: boolean;
  47848. }, scene?: Nullable<Scene>): LinesMesh;
  47849. /**
  47850. * Creates a dashed line mesh
  47851. * * 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
  47852. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47853. * * The parameter `points` is an array successive Vector3
  47854. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47855. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47856. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47857. * * 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
  47858. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47859. * * When updating an instance, remember that only point positions can change, not the number of points
  47860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47861. * @param name defines the name of the mesh
  47862. * @param options defines the options used to create the mesh
  47863. * @param scene defines the hosting scene
  47864. * @returns the dashed line mesh
  47865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47866. */
  47867. static CreateDashedLines(name: string, options: {
  47868. points: Vector3[];
  47869. dashSize?: number;
  47870. gapSize?: number;
  47871. dashNb?: number;
  47872. updatable?: boolean;
  47873. instance?: LinesMesh;
  47874. useVertexAlpha?: boolean;
  47875. }, scene?: Nullable<Scene>): LinesMesh;
  47876. }
  47877. }
  47878. declare module BABYLON {
  47879. /**
  47880. * The options container for the teleportation module
  47881. */
  47882. export interface IWebXRTeleportationOptions {
  47883. /**
  47884. * if provided, this scene will be used to render meshes.
  47885. */
  47886. customUtilityLayerScene?: Scene;
  47887. /**
  47888. * Values to configure the default target mesh
  47889. */
  47890. defaultTargetMeshOptions?: {
  47891. /**
  47892. * Fill color of the teleportation area
  47893. */
  47894. teleportationFillColor?: string;
  47895. /**
  47896. * Border color for the teleportation area
  47897. */
  47898. teleportationBorderColor?: string;
  47899. /**
  47900. * Disable the mesh's animation sequence
  47901. */
  47902. disableAnimation?: boolean;
  47903. /**
  47904. * Disable lighting on the material or the ring and arrow
  47905. */
  47906. disableLighting?: boolean;
  47907. /**
  47908. * Override the default material of the torus and arrow
  47909. */
  47910. torusArrowMaterial?: Material;
  47911. };
  47912. /**
  47913. * A list of meshes to use as floor meshes.
  47914. * Meshes can be added and removed after initializing the feature using the
  47915. * addFloorMesh and removeFloorMesh functions
  47916. * If empty, rotation will still work
  47917. */
  47918. floorMeshes?: AbstractMesh[];
  47919. /**
  47920. * use this rendering group id for the meshes (optional)
  47921. */
  47922. renderingGroupId?: number;
  47923. /**
  47924. * Should teleportation move only to snap points
  47925. */
  47926. snapPointsOnly?: boolean;
  47927. /**
  47928. * An array of points to which the teleportation will snap to.
  47929. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47930. */
  47931. snapPositions?: Vector3[];
  47932. /**
  47933. * How close should the teleportation ray be in order to snap to position.
  47934. * Default to 0.8 units (meters)
  47935. */
  47936. snapToPositionRadius?: number;
  47937. /**
  47938. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47939. * If you want to support rotation, make sure your mesh has a direction indicator.
  47940. *
  47941. * When left untouched, the default mesh will be initialized.
  47942. */
  47943. teleportationTargetMesh?: AbstractMesh;
  47944. /**
  47945. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47946. */
  47947. timeToTeleport?: number;
  47948. /**
  47949. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47950. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47951. */
  47952. useMainComponentOnly?: boolean;
  47953. /**
  47954. * Should meshes created here be added to a utility layer or the main scene
  47955. */
  47956. useUtilityLayer?: boolean;
  47957. /**
  47958. * Babylon XR Input class for controller
  47959. */
  47960. xrInput: WebXRInput;
  47961. }
  47962. /**
  47963. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47964. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47965. * the input of the attached controllers.
  47966. */
  47967. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47968. private _options;
  47969. private _controllers;
  47970. private _currentTeleportationControllerId;
  47971. private _floorMeshes;
  47972. private _quadraticBezierCurve;
  47973. private _selectionFeature;
  47974. private _snapToPositions;
  47975. private _snappedToPoint;
  47976. private _teleportationRingMaterial?;
  47977. private _tmpRay;
  47978. private _tmpVector;
  47979. /**
  47980. * The module's name
  47981. */
  47982. static readonly Name: string;
  47983. /**
  47984. * The (Babylon) version of this module.
  47985. * This is an integer representing the implementation version.
  47986. * This number does not correspond to the webxr specs version
  47987. */
  47988. static readonly Version: number;
  47989. /**
  47990. * Is movement backwards enabled
  47991. */
  47992. backwardsMovementEnabled: boolean;
  47993. /**
  47994. * Distance to travel when moving backwards
  47995. */
  47996. backwardsTeleportationDistance: number;
  47997. /**
  47998. * The distance from the user to the inspection point in the direction of the controller
  47999. * A higher number will allow the user to move further
  48000. * defaults to 5 (meters, in xr units)
  48001. */
  48002. parabolicCheckRadius: number;
  48003. /**
  48004. * Should the module support parabolic ray on top of direct ray
  48005. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48006. * Very helpful when moving between floors / different heights
  48007. */
  48008. parabolicRayEnabled: boolean;
  48009. /**
  48010. * How much rotation should be applied when rotating right and left
  48011. */
  48012. rotationAngle: number;
  48013. /**
  48014. * Is rotation enabled when moving forward?
  48015. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48016. */
  48017. rotationEnabled: boolean;
  48018. /**
  48019. * constructs a new anchor system
  48020. * @param _xrSessionManager an instance of WebXRSessionManager
  48021. * @param _options configuration object for this feature
  48022. */
  48023. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48024. /**
  48025. * Get the snapPointsOnly flag
  48026. */
  48027. get snapPointsOnly(): boolean;
  48028. /**
  48029. * Sets the snapPointsOnly flag
  48030. * @param snapToPoints should teleportation be exclusively to snap points
  48031. */
  48032. set snapPointsOnly(snapToPoints: boolean);
  48033. /**
  48034. * Add a new mesh to the floor meshes array
  48035. * @param mesh the mesh to use as floor mesh
  48036. */
  48037. addFloorMesh(mesh: AbstractMesh): void;
  48038. /**
  48039. * Add a new snap-to point to fix teleportation to this position
  48040. * @param newSnapPoint The new Snap-To point
  48041. */
  48042. addSnapPoint(newSnapPoint: Vector3): void;
  48043. attach(): boolean;
  48044. detach(): boolean;
  48045. dispose(): void;
  48046. /**
  48047. * Remove a mesh from the floor meshes array
  48048. * @param mesh the mesh to remove
  48049. */
  48050. removeFloorMesh(mesh: AbstractMesh): void;
  48051. /**
  48052. * Remove a mesh from the floor meshes array using its name
  48053. * @param name the mesh name to remove
  48054. */
  48055. removeFloorMeshByName(name: string): void;
  48056. /**
  48057. * 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
  48058. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48059. * @returns was the point found and removed or not
  48060. */
  48061. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48062. /**
  48063. * This function sets a selection feature that will be disabled when
  48064. * the forward ray is shown and will be reattached when hidden.
  48065. * This is used to remove the selection rays when moving.
  48066. * @param selectionFeature the feature to disable when forward movement is enabled
  48067. */
  48068. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48069. protected _onXRFrame(_xrFrame: XRFrame): void;
  48070. private _attachController;
  48071. private _createDefaultTargetMesh;
  48072. private _detachController;
  48073. private _findClosestSnapPointWithRadius;
  48074. private _setTargetMeshPosition;
  48075. private _setTargetMeshVisibility;
  48076. private _showParabolicPath;
  48077. private _teleportForward;
  48078. }
  48079. }
  48080. declare module BABYLON {
  48081. /**
  48082. * Options for the default xr helper
  48083. */
  48084. export class WebXRDefaultExperienceOptions {
  48085. /**
  48086. * Enable or disable default UI to enter XR
  48087. */
  48088. disableDefaultUI?: boolean;
  48089. /**
  48090. * Should teleportation not initialize. defaults to false.
  48091. */
  48092. disableTeleportation?: boolean;
  48093. /**
  48094. * Floor meshes that will be used for teleport
  48095. */
  48096. floorMeshes?: Array<AbstractMesh>;
  48097. /**
  48098. * If set to true, the first frame will not be used to reset position
  48099. * The first frame is mainly used when copying transformation from the old camera
  48100. * Mainly used in AR
  48101. */
  48102. ignoreNativeCameraTransformation?: boolean;
  48103. /**
  48104. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48105. */
  48106. inputOptions?: IWebXRInputOptions;
  48107. /**
  48108. * optional configuration for the output canvas
  48109. */
  48110. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48111. /**
  48112. * optional UI options. This can be used among other to change session mode and reference space type
  48113. */
  48114. uiOptions?: WebXREnterExitUIOptions;
  48115. /**
  48116. * When loading teleportation and pointer select, use stable versions instead of latest.
  48117. */
  48118. useStablePlugins?: boolean;
  48119. /**
  48120. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48121. */
  48122. renderingGroupId?: number;
  48123. /**
  48124. * A list of optional features to init the session with
  48125. * If set to true, all features we support will be added
  48126. */
  48127. optionalFeatures?: boolean | string[];
  48128. }
  48129. /**
  48130. * Default experience which provides a similar setup to the previous webVRExperience
  48131. */
  48132. export class WebXRDefaultExperience {
  48133. /**
  48134. * Base experience
  48135. */
  48136. baseExperience: WebXRExperienceHelper;
  48137. /**
  48138. * Enables ui for entering/exiting xr
  48139. */
  48140. enterExitUI: WebXREnterExitUI;
  48141. /**
  48142. * Input experience extension
  48143. */
  48144. input: WebXRInput;
  48145. /**
  48146. * Enables laser pointer and selection
  48147. */
  48148. pointerSelection: WebXRControllerPointerSelection;
  48149. /**
  48150. * Default target xr should render to
  48151. */
  48152. renderTarget: WebXRRenderTarget;
  48153. /**
  48154. * Enables teleportation
  48155. */
  48156. teleportation: WebXRMotionControllerTeleportation;
  48157. private constructor();
  48158. /**
  48159. * Creates the default xr experience
  48160. * @param scene scene
  48161. * @param options options for basic configuration
  48162. * @returns resulting WebXRDefaultExperience
  48163. */
  48164. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48165. /**
  48166. * DIsposes of the experience helper
  48167. */
  48168. dispose(): void;
  48169. }
  48170. }
  48171. declare module BABYLON {
  48172. /**
  48173. * Options to modify the vr teleportation behavior.
  48174. */
  48175. export interface VRTeleportationOptions {
  48176. /**
  48177. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48178. */
  48179. floorMeshName?: string;
  48180. /**
  48181. * A list of meshes to be used as the teleportation floor. (default: empty)
  48182. */
  48183. floorMeshes?: Mesh[];
  48184. /**
  48185. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48186. */
  48187. teleportationMode?: number;
  48188. /**
  48189. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48190. */
  48191. teleportationTime?: number;
  48192. /**
  48193. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48194. */
  48195. teleportationSpeed?: number;
  48196. /**
  48197. * The easing function used in the animation or null for Linear. (default CircleEase)
  48198. */
  48199. easingFunction?: EasingFunction;
  48200. }
  48201. /**
  48202. * Options to modify the vr experience helper's behavior.
  48203. */
  48204. export interface VRExperienceHelperOptions extends WebVROptions {
  48205. /**
  48206. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48207. */
  48208. createDeviceOrientationCamera?: boolean;
  48209. /**
  48210. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48211. */
  48212. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48213. /**
  48214. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48215. */
  48216. laserToggle?: boolean;
  48217. /**
  48218. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48219. */
  48220. floorMeshes?: Mesh[];
  48221. /**
  48222. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48223. */
  48224. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48225. /**
  48226. * Defines if WebXR should be used instead of WebVR (if available)
  48227. */
  48228. useXR?: boolean;
  48229. }
  48230. /**
  48231. * Event containing information after VR has been entered
  48232. */
  48233. export class OnAfterEnteringVRObservableEvent {
  48234. /**
  48235. * If entering vr was successful
  48236. */
  48237. success: boolean;
  48238. }
  48239. /**
  48240. * Helps to quickly add VR support to an existing scene.
  48241. * See http://doc.babylonjs.com/how_to/webvr_helper
  48242. */
  48243. export class VRExperienceHelper {
  48244. /** Options to modify the vr experience helper's behavior. */
  48245. webVROptions: VRExperienceHelperOptions;
  48246. private _scene;
  48247. private _position;
  48248. private _btnVR;
  48249. private _btnVRDisplayed;
  48250. private _webVRsupported;
  48251. private _webVRready;
  48252. private _webVRrequesting;
  48253. private _webVRpresenting;
  48254. private _hasEnteredVR;
  48255. private _fullscreenVRpresenting;
  48256. private _inputElement;
  48257. private _webVRCamera;
  48258. private _vrDeviceOrientationCamera;
  48259. private _deviceOrientationCamera;
  48260. private _existingCamera;
  48261. private _onKeyDown;
  48262. private _onVrDisplayPresentChange;
  48263. private _onVRDisplayChanged;
  48264. private _onVRRequestPresentStart;
  48265. private _onVRRequestPresentComplete;
  48266. /**
  48267. * 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)
  48268. */
  48269. enableGazeEvenWhenNoPointerLock: boolean;
  48270. /**
  48271. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48272. */
  48273. exitVROnDoubleTap: boolean;
  48274. /**
  48275. * Observable raised right before entering VR.
  48276. */
  48277. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48278. /**
  48279. * Observable raised when entering VR has completed.
  48280. */
  48281. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48282. /**
  48283. * Observable raised when exiting VR.
  48284. */
  48285. onExitingVRObservable: Observable<VRExperienceHelper>;
  48286. /**
  48287. * Observable raised when controller mesh is loaded.
  48288. */
  48289. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48290. /** Return this.onEnteringVRObservable
  48291. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48292. */
  48293. get onEnteringVR(): Observable<VRExperienceHelper>;
  48294. /** Return this.onExitingVRObservable
  48295. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48296. */
  48297. get onExitingVR(): Observable<VRExperienceHelper>;
  48298. /** Return this.onControllerMeshLoadedObservable
  48299. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48300. */
  48301. get onControllerMeshLoaded(): Observable<WebVRController>;
  48302. private _rayLength;
  48303. private _useCustomVRButton;
  48304. private _teleportationRequested;
  48305. private _teleportActive;
  48306. private _floorMeshName;
  48307. private _floorMeshesCollection;
  48308. private _teleportationMode;
  48309. private _teleportationTime;
  48310. private _teleportationSpeed;
  48311. private _teleportationEasing;
  48312. private _rotationAllowed;
  48313. private _teleportBackwardsVector;
  48314. private _teleportationTarget;
  48315. private _isDefaultTeleportationTarget;
  48316. private _postProcessMove;
  48317. private _teleportationFillColor;
  48318. private _teleportationBorderColor;
  48319. private _rotationAngle;
  48320. private _haloCenter;
  48321. private _cameraGazer;
  48322. private _padSensibilityUp;
  48323. private _padSensibilityDown;
  48324. private _leftController;
  48325. private _rightController;
  48326. private _gazeColor;
  48327. private _laserColor;
  48328. private _pickedLaserColor;
  48329. private _pickedGazeColor;
  48330. /**
  48331. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48332. */
  48333. onNewMeshSelected: Observable<AbstractMesh>;
  48334. /**
  48335. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48336. * This observable will provide the mesh and the controller used to select the mesh
  48337. */
  48338. onMeshSelectedWithController: Observable<{
  48339. mesh: AbstractMesh;
  48340. controller: WebVRController;
  48341. }>;
  48342. /**
  48343. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48344. */
  48345. onNewMeshPicked: Observable<PickingInfo>;
  48346. private _circleEase;
  48347. /**
  48348. * Observable raised before camera teleportation
  48349. */
  48350. onBeforeCameraTeleport: Observable<Vector3>;
  48351. /**
  48352. * Observable raised after camera teleportation
  48353. */
  48354. onAfterCameraTeleport: Observable<Vector3>;
  48355. /**
  48356. * Observable raised when current selected mesh gets unselected
  48357. */
  48358. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48359. private _raySelectionPredicate;
  48360. /**
  48361. * To be optionaly changed by user to define custom ray selection
  48362. */
  48363. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48364. /**
  48365. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48366. */
  48367. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48368. /**
  48369. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48370. */
  48371. teleportationEnabled: boolean;
  48372. private _defaultHeight;
  48373. private _teleportationInitialized;
  48374. private _interactionsEnabled;
  48375. private _interactionsRequested;
  48376. private _displayGaze;
  48377. private _displayLaserPointer;
  48378. /**
  48379. * The mesh used to display where the user is going to teleport.
  48380. */
  48381. get teleportationTarget(): Mesh;
  48382. /**
  48383. * Sets the mesh to be used to display where the user is going to teleport.
  48384. */
  48385. set teleportationTarget(value: Mesh);
  48386. /**
  48387. * 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
  48388. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48389. * See http://doc.babylonjs.com/resources/baking_transformations
  48390. */
  48391. get gazeTrackerMesh(): Mesh;
  48392. set gazeTrackerMesh(value: Mesh);
  48393. /**
  48394. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48395. */
  48396. updateGazeTrackerScale: boolean;
  48397. /**
  48398. * If the gaze trackers color should be updated when selecting meshes
  48399. */
  48400. updateGazeTrackerColor: boolean;
  48401. /**
  48402. * If the controller laser color should be updated when selecting meshes
  48403. */
  48404. updateControllerLaserColor: boolean;
  48405. /**
  48406. * The gaze tracking mesh corresponding to the left controller
  48407. */
  48408. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48409. /**
  48410. * The gaze tracking mesh corresponding to the right controller
  48411. */
  48412. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48413. /**
  48414. * If the ray of the gaze should be displayed.
  48415. */
  48416. get displayGaze(): boolean;
  48417. /**
  48418. * Sets if the ray of the gaze should be displayed.
  48419. */
  48420. set displayGaze(value: boolean);
  48421. /**
  48422. * If the ray of the LaserPointer should be displayed.
  48423. */
  48424. get displayLaserPointer(): boolean;
  48425. /**
  48426. * Sets if the ray of the LaserPointer should be displayed.
  48427. */
  48428. set displayLaserPointer(value: boolean);
  48429. /**
  48430. * The deviceOrientationCamera used as the camera when not in VR.
  48431. */
  48432. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48433. /**
  48434. * Based on the current WebVR support, returns the current VR camera used.
  48435. */
  48436. get currentVRCamera(): Nullable<Camera>;
  48437. /**
  48438. * The webVRCamera which is used when in VR.
  48439. */
  48440. get webVRCamera(): WebVRFreeCamera;
  48441. /**
  48442. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48443. */
  48444. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48445. /**
  48446. * The html button that is used to trigger entering into VR.
  48447. */
  48448. get vrButton(): Nullable<HTMLButtonElement>;
  48449. private get _teleportationRequestInitiated();
  48450. /**
  48451. * Defines whether or not Pointer lock should be requested when switching to
  48452. * full screen.
  48453. */
  48454. requestPointerLockOnFullScreen: boolean;
  48455. /**
  48456. * If asking to force XR, this will be populated with the default xr experience
  48457. */
  48458. xr: WebXRDefaultExperience;
  48459. /**
  48460. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48461. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48462. */
  48463. xrTestDone: boolean;
  48464. /**
  48465. * Instantiates a VRExperienceHelper.
  48466. * Helps to quickly add VR support to an existing scene.
  48467. * @param scene The scene the VRExperienceHelper belongs to.
  48468. * @param webVROptions Options to modify the vr experience helper's behavior.
  48469. */
  48470. constructor(scene: Scene,
  48471. /** Options to modify the vr experience helper's behavior. */
  48472. webVROptions?: VRExperienceHelperOptions);
  48473. private completeVRInit;
  48474. private _onDefaultMeshLoaded;
  48475. private _onResize;
  48476. private _onFullscreenChange;
  48477. /**
  48478. * Gets a value indicating if we are currently in VR mode.
  48479. */
  48480. get isInVRMode(): boolean;
  48481. private onVrDisplayPresentChange;
  48482. private onVRDisplayChanged;
  48483. private moveButtonToBottomRight;
  48484. private displayVRButton;
  48485. private updateButtonVisibility;
  48486. private _cachedAngularSensibility;
  48487. /**
  48488. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48489. * Otherwise, will use the fullscreen API.
  48490. */
  48491. enterVR(): void;
  48492. /**
  48493. * Attempt to exit VR, or fullscreen.
  48494. */
  48495. exitVR(): void;
  48496. /**
  48497. * The position of the vr experience helper.
  48498. */
  48499. get position(): Vector3;
  48500. /**
  48501. * Sets the position of the vr experience helper.
  48502. */
  48503. set position(value: Vector3);
  48504. /**
  48505. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48506. */
  48507. enableInteractions(): void;
  48508. private get _noControllerIsActive();
  48509. private beforeRender;
  48510. private _isTeleportationFloor;
  48511. /**
  48512. * Adds a floor mesh to be used for teleportation.
  48513. * @param floorMesh the mesh to be used for teleportation.
  48514. */
  48515. addFloorMesh(floorMesh: Mesh): void;
  48516. /**
  48517. * Removes a floor mesh from being used for teleportation.
  48518. * @param floorMesh the mesh to be removed.
  48519. */
  48520. removeFloorMesh(floorMesh: Mesh): void;
  48521. /**
  48522. * Enables interactions and teleportation using the VR controllers and gaze.
  48523. * @param vrTeleportationOptions options to modify teleportation behavior.
  48524. */
  48525. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48526. private _onNewGamepadConnected;
  48527. private _tryEnableInteractionOnController;
  48528. private _onNewGamepadDisconnected;
  48529. private _enableInteractionOnController;
  48530. private _checkTeleportWithRay;
  48531. private _checkRotate;
  48532. private _checkTeleportBackwards;
  48533. private _enableTeleportationOnController;
  48534. private _createTeleportationCircles;
  48535. private _displayTeleportationTarget;
  48536. private _hideTeleportationTarget;
  48537. private _rotateCamera;
  48538. private _moveTeleportationSelectorTo;
  48539. private _workingVector;
  48540. private _workingQuaternion;
  48541. private _workingMatrix;
  48542. /**
  48543. * Time Constant Teleportation Mode
  48544. */
  48545. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48546. /**
  48547. * Speed Constant Teleportation Mode
  48548. */
  48549. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48550. /**
  48551. * Teleports the users feet to the desired location
  48552. * @param location The location where the user's feet should be placed
  48553. */
  48554. teleportCamera(location: Vector3): void;
  48555. private _convertNormalToDirectionOfRay;
  48556. private _castRayAndSelectObject;
  48557. private _notifySelectedMeshUnselected;
  48558. /**
  48559. * Permanently set new colors for the laser pointer
  48560. * @param color the new laser color
  48561. * @param pickedColor the new laser color when picked mesh detected
  48562. */
  48563. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48564. /**
  48565. * Set lighting enabled / disabled on the laser pointer of both controllers
  48566. * @param enabled should the lighting be enabled on the laser pointer
  48567. */
  48568. setLaserLightingState(enabled?: boolean): void;
  48569. /**
  48570. * Permanently set new colors for the gaze pointer
  48571. * @param color the new gaze color
  48572. * @param pickedColor the new gaze color when picked mesh detected
  48573. */
  48574. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48575. /**
  48576. * Sets the color of the laser ray from the vr controllers.
  48577. * @param color new color for the ray.
  48578. */
  48579. changeLaserColor(color: Color3): void;
  48580. /**
  48581. * Sets the color of the ray from the vr headsets gaze.
  48582. * @param color new color for the ray.
  48583. */
  48584. changeGazeColor(color: Color3): void;
  48585. /**
  48586. * Exits VR and disposes of the vr experience helper
  48587. */
  48588. dispose(): void;
  48589. /**
  48590. * Gets the name of the VRExperienceHelper class
  48591. * @returns "VRExperienceHelper"
  48592. */
  48593. getClassName(): string;
  48594. }
  48595. }
  48596. declare module BABYLON {
  48597. /**
  48598. * Contains an array of blocks representing the octree
  48599. */
  48600. export interface IOctreeContainer<T> {
  48601. /**
  48602. * Blocks within the octree
  48603. */
  48604. blocks: Array<OctreeBlock<T>>;
  48605. }
  48606. /**
  48607. * Class used to store a cell in an octree
  48608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48609. */
  48610. export class OctreeBlock<T> {
  48611. /**
  48612. * Gets the content of the current block
  48613. */
  48614. entries: T[];
  48615. /**
  48616. * Gets the list of block children
  48617. */
  48618. blocks: Array<OctreeBlock<T>>;
  48619. private _depth;
  48620. private _maxDepth;
  48621. private _capacity;
  48622. private _minPoint;
  48623. private _maxPoint;
  48624. private _boundingVectors;
  48625. private _creationFunc;
  48626. /**
  48627. * Creates a new block
  48628. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48629. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48630. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48631. * @param depth defines the current depth of this block in the octree
  48632. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48633. * @param creationFunc defines a callback to call when an element is added to the block
  48634. */
  48635. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48636. /**
  48637. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48638. */
  48639. get capacity(): number;
  48640. /**
  48641. * Gets the minimum vector (in world space) of the block's bounding box
  48642. */
  48643. get minPoint(): Vector3;
  48644. /**
  48645. * Gets the maximum vector (in world space) of the block's bounding box
  48646. */
  48647. get maxPoint(): Vector3;
  48648. /**
  48649. * Add a new element to this block
  48650. * @param entry defines the element to add
  48651. */
  48652. addEntry(entry: T): void;
  48653. /**
  48654. * Remove an element from this block
  48655. * @param entry defines the element to remove
  48656. */
  48657. removeEntry(entry: T): void;
  48658. /**
  48659. * Add an array of elements to this block
  48660. * @param entries defines the array of elements to add
  48661. */
  48662. addEntries(entries: T[]): void;
  48663. /**
  48664. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48665. * @param frustumPlanes defines the frustum planes to test
  48666. * @param selection defines the array to store current content if selection is positive
  48667. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48668. */
  48669. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48670. /**
  48671. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48672. * @param sphereCenter defines the bounding sphere center
  48673. * @param sphereRadius defines the bounding sphere radius
  48674. * @param selection defines the array to store current content if selection is positive
  48675. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48676. */
  48677. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48678. /**
  48679. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48680. * @param ray defines the ray to test with
  48681. * @param selection defines the array to store current content if selection is positive
  48682. */
  48683. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48684. /**
  48685. * Subdivide the content into child blocks (this block will then be empty)
  48686. */
  48687. createInnerBlocks(): void;
  48688. /**
  48689. * @hidden
  48690. */
  48691. 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;
  48692. }
  48693. }
  48694. declare module BABYLON {
  48695. /**
  48696. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48697. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48698. */
  48699. export class Octree<T> {
  48700. /** 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.) */
  48701. maxDepth: number;
  48702. /**
  48703. * Blocks within the octree containing objects
  48704. */
  48705. blocks: Array<OctreeBlock<T>>;
  48706. /**
  48707. * Content stored in the octree
  48708. */
  48709. dynamicContent: T[];
  48710. private _maxBlockCapacity;
  48711. private _selectionContent;
  48712. private _creationFunc;
  48713. /**
  48714. * Creates a octree
  48715. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48716. * @param creationFunc function to be used to instatiate the octree
  48717. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48718. * @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.)
  48719. */
  48720. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48721. /** 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.) */
  48722. maxDepth?: number);
  48723. /**
  48724. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48725. * @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);
  48726. * @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);
  48727. * @param entries meshes to be added to the octree blocks
  48728. */
  48729. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48730. /**
  48731. * Adds a mesh to the octree
  48732. * @param entry Mesh to add to the octree
  48733. */
  48734. addMesh(entry: T): void;
  48735. /**
  48736. * Remove an element from the octree
  48737. * @param entry defines the element to remove
  48738. */
  48739. removeMesh(entry: T): void;
  48740. /**
  48741. * Selects an array of meshes within the frustum
  48742. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48743. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48744. * @returns array of meshes within the frustum
  48745. */
  48746. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48747. /**
  48748. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48749. * @param sphereCenter defines the bounding sphere center
  48750. * @param sphereRadius defines the bounding sphere radius
  48751. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48752. * @returns an array of objects that intersect the sphere
  48753. */
  48754. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48755. /**
  48756. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48757. * @param ray defines the ray to test with
  48758. * @returns array of intersected objects
  48759. */
  48760. intersectsRay(ray: Ray): SmartArray<T>;
  48761. /**
  48762. * Adds a mesh into the octree block if it intersects the block
  48763. */
  48764. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48765. /**
  48766. * Adds a submesh into the octree block if it intersects the block
  48767. */
  48768. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48769. }
  48770. }
  48771. declare module BABYLON {
  48772. interface Scene {
  48773. /**
  48774. * @hidden
  48775. * Backing Filed
  48776. */
  48777. _selectionOctree: Octree<AbstractMesh>;
  48778. /**
  48779. * Gets the octree used to boost mesh selection (picking)
  48780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48781. */
  48782. selectionOctree: Octree<AbstractMesh>;
  48783. /**
  48784. * Creates or updates the octree used to boost selection (picking)
  48785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48786. * @param maxCapacity defines the maximum capacity per leaf
  48787. * @param maxDepth defines the maximum depth of the octree
  48788. * @returns an octree of AbstractMesh
  48789. */
  48790. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48791. }
  48792. interface AbstractMesh {
  48793. /**
  48794. * @hidden
  48795. * Backing Field
  48796. */
  48797. _submeshesOctree: Octree<SubMesh>;
  48798. /**
  48799. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48800. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48801. * @param maxCapacity defines the maximum size of each block (64 by default)
  48802. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48803. * @returns the new octree
  48804. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48806. */
  48807. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48808. }
  48809. /**
  48810. * Defines the octree scene component responsible to manage any octrees
  48811. * in a given scene.
  48812. */
  48813. export class OctreeSceneComponent {
  48814. /**
  48815. * The component name help to identify the component in the list of scene components.
  48816. */
  48817. readonly name: string;
  48818. /**
  48819. * The scene the component belongs to.
  48820. */
  48821. scene: Scene;
  48822. /**
  48823. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48824. */
  48825. readonly checksIsEnabled: boolean;
  48826. /**
  48827. * Creates a new instance of the component for the given scene
  48828. * @param scene Defines the scene to register the component in
  48829. */
  48830. constructor(scene: Scene);
  48831. /**
  48832. * Registers the component in a given scene
  48833. */
  48834. register(): void;
  48835. /**
  48836. * Return the list of active meshes
  48837. * @returns the list of active meshes
  48838. */
  48839. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48840. /**
  48841. * Return the list of active sub meshes
  48842. * @param mesh The mesh to get the candidates sub meshes from
  48843. * @returns the list of active sub meshes
  48844. */
  48845. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48846. private _tempRay;
  48847. /**
  48848. * Return the list of sub meshes intersecting with a given local ray
  48849. * @param mesh defines the mesh to find the submesh for
  48850. * @param localRay defines the ray in local space
  48851. * @returns the list of intersecting sub meshes
  48852. */
  48853. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48854. /**
  48855. * Return the list of sub meshes colliding with a collider
  48856. * @param mesh defines the mesh to find the submesh for
  48857. * @param collider defines the collider to evaluate the collision against
  48858. * @returns the list of colliding sub meshes
  48859. */
  48860. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48861. /**
  48862. * Rebuilds the elements related to this component in case of
  48863. * context lost for instance.
  48864. */
  48865. rebuild(): void;
  48866. /**
  48867. * Disposes the component and the associated ressources.
  48868. */
  48869. dispose(): void;
  48870. }
  48871. }
  48872. declare module BABYLON {
  48873. /**
  48874. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48875. */
  48876. export class Gizmo implements IDisposable {
  48877. /** The utility layer the gizmo will be added to */
  48878. gizmoLayer: UtilityLayerRenderer;
  48879. /**
  48880. * The root mesh of the gizmo
  48881. */
  48882. _rootMesh: Mesh;
  48883. private _attachedMesh;
  48884. /**
  48885. * Ratio for the scale of the gizmo (Default: 1)
  48886. */
  48887. scaleRatio: number;
  48888. /**
  48889. * If a custom mesh has been set (Default: false)
  48890. */
  48891. protected _customMeshSet: boolean;
  48892. /**
  48893. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48894. * * When set, interactions will be enabled
  48895. */
  48896. get attachedMesh(): Nullable<AbstractMesh>;
  48897. set attachedMesh(value: Nullable<AbstractMesh>);
  48898. /**
  48899. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48900. * @param mesh The mesh to replace the default mesh of the gizmo
  48901. */
  48902. setCustomMesh(mesh: Mesh): void;
  48903. /**
  48904. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48905. */
  48906. updateGizmoRotationToMatchAttachedMesh: boolean;
  48907. /**
  48908. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48909. */
  48910. updateGizmoPositionToMatchAttachedMesh: boolean;
  48911. /**
  48912. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48913. */
  48914. updateScale: boolean;
  48915. protected _interactionsEnabled: boolean;
  48916. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48917. private _beforeRenderObserver;
  48918. private _tempVector;
  48919. /**
  48920. * Creates a gizmo
  48921. * @param gizmoLayer The utility layer the gizmo will be added to
  48922. */
  48923. constructor(
  48924. /** The utility layer the gizmo will be added to */
  48925. gizmoLayer?: UtilityLayerRenderer);
  48926. /**
  48927. * Updates the gizmo to match the attached mesh's position/rotation
  48928. */
  48929. protected _update(): void;
  48930. /**
  48931. * Disposes of the gizmo
  48932. */
  48933. dispose(): void;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. /**
  48938. * Single plane drag gizmo
  48939. */
  48940. export class PlaneDragGizmo extends Gizmo {
  48941. /**
  48942. * Drag behavior responsible for the gizmos dragging interactions
  48943. */
  48944. dragBehavior: PointerDragBehavior;
  48945. private _pointerObserver;
  48946. /**
  48947. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48948. */
  48949. snapDistance: number;
  48950. /**
  48951. * Event that fires each time the gizmo snaps to a new location.
  48952. * * snapDistance is the the change in distance
  48953. */
  48954. onSnapObservable: Observable<{
  48955. snapDistance: number;
  48956. }>;
  48957. private _plane;
  48958. private _coloredMaterial;
  48959. private _hoverMaterial;
  48960. private _isEnabled;
  48961. private _parent;
  48962. /** @hidden */
  48963. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48964. /** @hidden */
  48965. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48966. /**
  48967. * Creates a PlaneDragGizmo
  48968. * @param gizmoLayer The utility layer the gizmo will be added to
  48969. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48970. * @param color The color of the gizmo
  48971. */
  48972. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48973. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48974. /**
  48975. * If the gizmo is enabled
  48976. */
  48977. set isEnabled(value: boolean);
  48978. get isEnabled(): boolean;
  48979. /**
  48980. * Disposes of the gizmo
  48981. */
  48982. dispose(): void;
  48983. }
  48984. }
  48985. declare module BABYLON {
  48986. /**
  48987. * Gizmo that enables dragging a mesh along 3 axis
  48988. */
  48989. export class PositionGizmo extends Gizmo {
  48990. /**
  48991. * Internal gizmo used for interactions on the x axis
  48992. */
  48993. xGizmo: AxisDragGizmo;
  48994. /**
  48995. * Internal gizmo used for interactions on the y axis
  48996. */
  48997. yGizmo: AxisDragGizmo;
  48998. /**
  48999. * Internal gizmo used for interactions on the z axis
  49000. */
  49001. zGizmo: AxisDragGizmo;
  49002. /**
  49003. * Internal gizmo used for interactions on the yz plane
  49004. */
  49005. xPlaneGizmo: PlaneDragGizmo;
  49006. /**
  49007. * Internal gizmo used for interactions on the xz plane
  49008. */
  49009. yPlaneGizmo: PlaneDragGizmo;
  49010. /**
  49011. * Internal gizmo used for interactions on the xy plane
  49012. */
  49013. zPlaneGizmo: PlaneDragGizmo;
  49014. /**
  49015. * private variables
  49016. */
  49017. private _meshAttached;
  49018. private _updateGizmoRotationToMatchAttachedMesh;
  49019. private _snapDistance;
  49020. private _scaleRatio;
  49021. /** Fires an event when any of it's sub gizmos are dragged */
  49022. onDragStartObservable: Observable<unknown>;
  49023. /** Fires an event when any of it's sub gizmos are released from dragging */
  49024. onDragEndObservable: Observable<unknown>;
  49025. /**
  49026. * If set to true, planar drag is enabled
  49027. */
  49028. private _planarGizmoEnabled;
  49029. get attachedMesh(): Nullable<AbstractMesh>;
  49030. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49031. /**
  49032. * Creates a PositionGizmo
  49033. * @param gizmoLayer The utility layer the gizmo will be added to
  49034. */
  49035. constructor(gizmoLayer?: UtilityLayerRenderer);
  49036. /**
  49037. * If the planar drag gizmo is enabled
  49038. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49039. */
  49040. set planarGizmoEnabled(value: boolean);
  49041. get planarGizmoEnabled(): boolean;
  49042. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49043. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49044. /**
  49045. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49046. */
  49047. set snapDistance(value: number);
  49048. get snapDistance(): number;
  49049. /**
  49050. * Ratio for the scale of the gizmo (Default: 1)
  49051. */
  49052. set scaleRatio(value: number);
  49053. get scaleRatio(): number;
  49054. /**
  49055. * Disposes of the gizmo
  49056. */
  49057. dispose(): void;
  49058. /**
  49059. * CustomMeshes are not supported by this gizmo
  49060. * @param mesh The mesh to replace the default mesh of the gizmo
  49061. */
  49062. setCustomMesh(mesh: Mesh): void;
  49063. }
  49064. }
  49065. declare module BABYLON {
  49066. /**
  49067. * Single axis drag gizmo
  49068. */
  49069. export class AxisDragGizmo extends Gizmo {
  49070. /**
  49071. * Drag behavior responsible for the gizmos dragging interactions
  49072. */
  49073. dragBehavior: PointerDragBehavior;
  49074. private _pointerObserver;
  49075. /**
  49076. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49077. */
  49078. snapDistance: number;
  49079. /**
  49080. * Event that fires each time the gizmo snaps to a new location.
  49081. * * snapDistance is the the change in distance
  49082. */
  49083. onSnapObservable: Observable<{
  49084. snapDistance: number;
  49085. }>;
  49086. private _isEnabled;
  49087. private _parent;
  49088. private _arrow;
  49089. private _coloredMaterial;
  49090. private _hoverMaterial;
  49091. /** @hidden */
  49092. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49093. /** @hidden */
  49094. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49095. /**
  49096. * Creates an AxisDragGizmo
  49097. * @param gizmoLayer The utility layer the gizmo will be added to
  49098. * @param dragAxis The axis which the gizmo will be able to drag on
  49099. * @param color The color of the gizmo
  49100. */
  49101. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49102. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49103. /**
  49104. * If the gizmo is enabled
  49105. */
  49106. set isEnabled(value: boolean);
  49107. get isEnabled(): boolean;
  49108. /**
  49109. * Disposes of the gizmo
  49110. */
  49111. dispose(): void;
  49112. }
  49113. }
  49114. declare module BABYLON.Debug {
  49115. /**
  49116. * The Axes viewer will show 3 axes in a specific point in space
  49117. */
  49118. export class AxesViewer {
  49119. private _xAxis;
  49120. private _yAxis;
  49121. private _zAxis;
  49122. private _scaleLinesFactor;
  49123. private _instanced;
  49124. /**
  49125. * Gets the hosting scene
  49126. */
  49127. scene: Scene;
  49128. /**
  49129. * Gets or sets a number used to scale line length
  49130. */
  49131. scaleLines: number;
  49132. /** Gets the node hierarchy used to render x-axis */
  49133. get xAxis(): TransformNode;
  49134. /** Gets the node hierarchy used to render y-axis */
  49135. get yAxis(): TransformNode;
  49136. /** Gets the node hierarchy used to render z-axis */
  49137. get zAxis(): TransformNode;
  49138. /**
  49139. * Creates a new AxesViewer
  49140. * @param scene defines the hosting scene
  49141. * @param scaleLines defines a number used to scale line length (1 by default)
  49142. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49143. * @param xAxis defines the node hierarchy used to render the x-axis
  49144. * @param yAxis defines the node hierarchy used to render the y-axis
  49145. * @param zAxis defines the node hierarchy used to render the z-axis
  49146. */
  49147. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49148. /**
  49149. * Force the viewer to update
  49150. * @param position defines the position of the viewer
  49151. * @param xaxis defines the x axis of the viewer
  49152. * @param yaxis defines the y axis of the viewer
  49153. * @param zaxis defines the z axis of the viewer
  49154. */
  49155. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49156. /**
  49157. * Creates an instance of this axes viewer.
  49158. * @returns a new axes viewer with instanced meshes
  49159. */
  49160. createInstance(): AxesViewer;
  49161. /** Releases resources */
  49162. dispose(): void;
  49163. private static _SetRenderingGroupId;
  49164. }
  49165. }
  49166. declare module BABYLON.Debug {
  49167. /**
  49168. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49169. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49170. */
  49171. export class BoneAxesViewer extends AxesViewer {
  49172. /**
  49173. * Gets or sets the target mesh where to display the axes viewer
  49174. */
  49175. mesh: Nullable<Mesh>;
  49176. /**
  49177. * Gets or sets the target bone where to display the axes viewer
  49178. */
  49179. bone: Nullable<Bone>;
  49180. /** Gets current position */
  49181. pos: Vector3;
  49182. /** Gets direction of X axis */
  49183. xaxis: Vector3;
  49184. /** Gets direction of Y axis */
  49185. yaxis: Vector3;
  49186. /** Gets direction of Z axis */
  49187. zaxis: Vector3;
  49188. /**
  49189. * Creates a new BoneAxesViewer
  49190. * @param scene defines the hosting scene
  49191. * @param bone defines the target bone
  49192. * @param mesh defines the target mesh
  49193. * @param scaleLines defines a scaling factor for line length (1 by default)
  49194. */
  49195. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49196. /**
  49197. * Force the viewer to update
  49198. */
  49199. update(): void;
  49200. /** Releases resources */
  49201. dispose(): void;
  49202. }
  49203. }
  49204. declare module BABYLON {
  49205. /**
  49206. * Interface used to define scene explorer extensibility option
  49207. */
  49208. export interface IExplorerExtensibilityOption {
  49209. /**
  49210. * Define the option label
  49211. */
  49212. label: string;
  49213. /**
  49214. * Defines the action to execute on click
  49215. */
  49216. action: (entity: any) => void;
  49217. }
  49218. /**
  49219. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49220. */
  49221. export interface IExplorerExtensibilityGroup {
  49222. /**
  49223. * Defines a predicate to test if a given type mut be extended
  49224. */
  49225. predicate: (entity: any) => boolean;
  49226. /**
  49227. * Gets the list of options added to a type
  49228. */
  49229. entries: IExplorerExtensibilityOption[];
  49230. }
  49231. /**
  49232. * Interface used to define the options to use to create the Inspector
  49233. */
  49234. export interface IInspectorOptions {
  49235. /**
  49236. * Display in overlay mode (default: false)
  49237. */
  49238. overlay?: boolean;
  49239. /**
  49240. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49241. */
  49242. globalRoot?: HTMLElement;
  49243. /**
  49244. * Display the Scene explorer
  49245. */
  49246. showExplorer?: boolean;
  49247. /**
  49248. * Display the property inspector
  49249. */
  49250. showInspector?: boolean;
  49251. /**
  49252. * Display in embed mode (both panes on the right)
  49253. */
  49254. embedMode?: boolean;
  49255. /**
  49256. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49257. */
  49258. handleResize?: boolean;
  49259. /**
  49260. * Allow the panes to popup (default: true)
  49261. */
  49262. enablePopup?: boolean;
  49263. /**
  49264. * Allow the panes to be closed by users (default: true)
  49265. */
  49266. enableClose?: boolean;
  49267. /**
  49268. * Optional list of extensibility entries
  49269. */
  49270. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49271. /**
  49272. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49273. */
  49274. inspectorURL?: string;
  49275. /**
  49276. * Optional initial tab (default to DebugLayerTab.Properties)
  49277. */
  49278. initialTab?: DebugLayerTab;
  49279. }
  49280. interface Scene {
  49281. /**
  49282. * @hidden
  49283. * Backing field
  49284. */
  49285. _debugLayer: DebugLayer;
  49286. /**
  49287. * Gets the debug layer (aka Inspector) associated with the scene
  49288. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49289. */
  49290. debugLayer: DebugLayer;
  49291. }
  49292. /**
  49293. * Enum of inspector action tab
  49294. */
  49295. export enum DebugLayerTab {
  49296. /**
  49297. * Properties tag (default)
  49298. */
  49299. Properties = 0,
  49300. /**
  49301. * Debug tab
  49302. */
  49303. Debug = 1,
  49304. /**
  49305. * Statistics tab
  49306. */
  49307. Statistics = 2,
  49308. /**
  49309. * Tools tab
  49310. */
  49311. Tools = 3,
  49312. /**
  49313. * Settings tab
  49314. */
  49315. Settings = 4
  49316. }
  49317. /**
  49318. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49319. * what is happening in your scene
  49320. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49321. */
  49322. export class DebugLayer {
  49323. /**
  49324. * Define the url to get the inspector script from.
  49325. * By default it uses the babylonjs CDN.
  49326. * @ignoreNaming
  49327. */
  49328. static InspectorURL: string;
  49329. private _scene;
  49330. private BJSINSPECTOR;
  49331. private _onPropertyChangedObservable?;
  49332. /**
  49333. * Observable triggered when a property is changed through the inspector.
  49334. */
  49335. get onPropertyChangedObservable(): any;
  49336. /**
  49337. * Instantiates a new debug layer.
  49338. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49339. * what is happening in your scene
  49340. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49341. * @param scene Defines the scene to inspect
  49342. */
  49343. constructor(scene: Scene);
  49344. /** Creates the inspector window. */
  49345. private _createInspector;
  49346. /**
  49347. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49348. * @param entity defines the entity to select
  49349. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49350. */
  49351. select(entity: any, lineContainerTitles?: string | string[]): void;
  49352. /** Get the inspector from bundle or global */
  49353. private _getGlobalInspector;
  49354. /**
  49355. * Get if the inspector is visible or not.
  49356. * @returns true if visible otherwise, false
  49357. */
  49358. isVisible(): boolean;
  49359. /**
  49360. * Hide the inspector and close its window.
  49361. */
  49362. hide(): void;
  49363. /**
  49364. * Update the scene in the inspector
  49365. */
  49366. setAsActiveScene(): void;
  49367. /**
  49368. * Launch the debugLayer.
  49369. * @param config Define the configuration of the inspector
  49370. * @return a promise fulfilled when the debug layer is visible
  49371. */
  49372. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * Class containing static functions to help procedurally build meshes
  49378. */
  49379. export class BoxBuilder {
  49380. /**
  49381. * Creates a box mesh
  49382. * * The parameter `size` sets the size (float) of each box side (default 1)
  49383. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49384. * * 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)
  49385. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49387. * * 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
  49388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49389. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49390. * @param name defines the name of the mesh
  49391. * @param options defines the options used to create the mesh
  49392. * @param scene defines the hosting scene
  49393. * @returns the box mesh
  49394. */
  49395. static CreateBox(name: string, options: {
  49396. size?: number;
  49397. width?: number;
  49398. height?: number;
  49399. depth?: number;
  49400. faceUV?: Vector4[];
  49401. faceColors?: Color4[];
  49402. sideOrientation?: number;
  49403. frontUVs?: Vector4;
  49404. backUVs?: Vector4;
  49405. wrap?: boolean;
  49406. topBaseAt?: number;
  49407. bottomBaseAt?: number;
  49408. updatable?: boolean;
  49409. }, scene?: Nullable<Scene>): Mesh;
  49410. }
  49411. }
  49412. declare module BABYLON.Debug {
  49413. /**
  49414. * Used to show the physics impostor around the specific mesh
  49415. */
  49416. export class PhysicsViewer {
  49417. /** @hidden */
  49418. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49419. /** @hidden */
  49420. protected _meshes: Array<Nullable<AbstractMesh>>;
  49421. /** @hidden */
  49422. protected _scene: Nullable<Scene>;
  49423. /** @hidden */
  49424. protected _numMeshes: number;
  49425. /** @hidden */
  49426. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49427. private _renderFunction;
  49428. private _utilityLayer;
  49429. private _debugBoxMesh;
  49430. private _debugSphereMesh;
  49431. private _debugCylinderMesh;
  49432. private _debugMaterial;
  49433. private _debugMeshMeshes;
  49434. /**
  49435. * Creates a new PhysicsViewer
  49436. * @param scene defines the hosting scene
  49437. */
  49438. constructor(scene: Scene);
  49439. /** @hidden */
  49440. protected _updateDebugMeshes(): void;
  49441. /**
  49442. * Renders a specified physic impostor
  49443. * @param impostor defines the impostor to render
  49444. * @param targetMesh defines the mesh represented by the impostor
  49445. * @returns the new debug mesh used to render the impostor
  49446. */
  49447. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49448. /**
  49449. * Hides a specified physic impostor
  49450. * @param impostor defines the impostor to hide
  49451. */
  49452. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49453. private _getDebugMaterial;
  49454. private _getDebugBoxMesh;
  49455. private _getDebugSphereMesh;
  49456. private _getDebugCylinderMesh;
  49457. private _getDebugMeshMesh;
  49458. private _getDebugMesh;
  49459. /** Releases all resources */
  49460. dispose(): void;
  49461. }
  49462. }
  49463. declare module BABYLON {
  49464. /**
  49465. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49466. * in order to better appreciate the issue one might have.
  49467. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49468. */
  49469. export class RayHelper {
  49470. /**
  49471. * Defines the ray we are currently tryin to visualize.
  49472. */
  49473. ray: Nullable<Ray>;
  49474. private _renderPoints;
  49475. private _renderLine;
  49476. private _renderFunction;
  49477. private _scene;
  49478. private _updateToMeshFunction;
  49479. private _attachedToMesh;
  49480. private _meshSpaceDirection;
  49481. private _meshSpaceOrigin;
  49482. /**
  49483. * Helper function to create a colored helper in a scene in one line.
  49484. * @param ray Defines the ray we are currently tryin to visualize
  49485. * @param scene Defines the scene the ray is used in
  49486. * @param color Defines the color we want to see the ray in
  49487. * @returns The newly created ray helper.
  49488. */
  49489. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49490. /**
  49491. * Instantiate a new ray helper.
  49492. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49493. * in order to better appreciate the issue one might have.
  49494. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49495. * @param ray Defines the ray we are currently tryin to visualize
  49496. */
  49497. constructor(ray: Ray);
  49498. /**
  49499. * Shows the ray we are willing to debug.
  49500. * @param scene Defines the scene the ray needs to be rendered in
  49501. * @param color Defines the color the ray needs to be rendered in
  49502. */
  49503. show(scene: Scene, color?: Color3): void;
  49504. /**
  49505. * Hides the ray we are debugging.
  49506. */
  49507. hide(): void;
  49508. private _render;
  49509. /**
  49510. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49511. * @param mesh Defines the mesh we want the helper attached to
  49512. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49513. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49514. * @param length Defines the length of the ray
  49515. */
  49516. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49517. /**
  49518. * Detach the ray helper from the mesh it has previously been attached to.
  49519. */
  49520. detachFromMesh(): void;
  49521. private _updateToMesh;
  49522. /**
  49523. * Dispose the helper and release its associated resources.
  49524. */
  49525. dispose(): void;
  49526. }
  49527. }
  49528. declare module BABYLON.Debug {
  49529. /**
  49530. * Class used to render a debug view of a given skeleton
  49531. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49532. */
  49533. export class SkeletonViewer {
  49534. /** defines the skeleton to render */
  49535. skeleton: Skeleton;
  49536. /** defines the mesh attached to the skeleton */
  49537. mesh: AbstractMesh;
  49538. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49539. autoUpdateBonesMatrices: boolean;
  49540. /** defines the rendering group id to use with the viewer */
  49541. renderingGroupId: number;
  49542. /** Gets or sets the color used to render the skeleton */
  49543. color: Color3;
  49544. private _scene;
  49545. private _debugLines;
  49546. private _debugMesh;
  49547. private _isEnabled;
  49548. private _renderFunction;
  49549. private _utilityLayer;
  49550. /**
  49551. * Returns the mesh used to render the bones
  49552. */
  49553. get debugMesh(): Nullable<LinesMesh>;
  49554. /**
  49555. * Creates a new SkeletonViewer
  49556. * @param skeleton defines the skeleton to render
  49557. * @param mesh defines the mesh attached to the skeleton
  49558. * @param scene defines the hosting scene
  49559. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49560. * @param renderingGroupId defines the rendering group id to use with the viewer
  49561. */
  49562. constructor(
  49563. /** defines the skeleton to render */
  49564. skeleton: Skeleton,
  49565. /** defines the mesh attached to the skeleton */
  49566. mesh: AbstractMesh, scene: Scene,
  49567. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49568. autoUpdateBonesMatrices?: boolean,
  49569. /** defines the rendering group id to use with the viewer */
  49570. renderingGroupId?: number);
  49571. /** Gets or sets a boolean indicating if the viewer is enabled */
  49572. set isEnabled(value: boolean);
  49573. get isEnabled(): boolean;
  49574. private _getBonePosition;
  49575. private _getLinesForBonesWithLength;
  49576. private _getLinesForBonesNoLength;
  49577. /** Update the viewer to sync with current skeleton state */
  49578. update(): void;
  49579. /** Release associated resources */
  49580. dispose(): void;
  49581. }
  49582. }
  49583. declare module BABYLON {
  49584. /**
  49585. * Enum for Device Types
  49586. */
  49587. export enum DeviceType {
  49588. /** Generic */
  49589. Generic = 0,
  49590. /** Keyboard */
  49591. Keyboard = 1,
  49592. /** Mouse */
  49593. Mouse = 2,
  49594. /** Touch Pointers */
  49595. Touch = 3,
  49596. /** PS4 Dual Shock */
  49597. DualShock = 4,
  49598. /** Xbox */
  49599. Xbox = 5,
  49600. /** Switch Controller */
  49601. Switch = 6
  49602. }
  49603. /**
  49604. * Enum for All Pointers (Touch/Mouse)
  49605. */
  49606. export enum PointerInput {
  49607. /** Horizontal Axis */
  49608. Horizontal = 0,
  49609. /** Vertical Axis */
  49610. Vertical = 1,
  49611. /** Left Click or Touch */
  49612. LeftClick = 2,
  49613. /** Middle Click */
  49614. MiddleClick = 3,
  49615. /** Right Click */
  49616. RightClick = 4,
  49617. /** Browser Back */
  49618. BrowserBack = 5,
  49619. /** Browser Forward */
  49620. BrowserForward = 6
  49621. }
  49622. /**
  49623. * Enum for Dual Shock Gamepad
  49624. */
  49625. export enum DualShockInput {
  49626. /** Cross */
  49627. Cross = 0,
  49628. /** Circle */
  49629. Circle = 1,
  49630. /** Square */
  49631. Square = 2,
  49632. /** Triangle */
  49633. Triangle = 3,
  49634. /** L1 */
  49635. L1 = 4,
  49636. /** R1 */
  49637. R1 = 5,
  49638. /** L2 */
  49639. L2 = 6,
  49640. /** R2 */
  49641. R2 = 7,
  49642. /** Share */
  49643. Share = 8,
  49644. /** Options */
  49645. Options = 9,
  49646. /** L3 */
  49647. L3 = 10,
  49648. /** R3 */
  49649. R3 = 11,
  49650. /** DPadUp */
  49651. DPadUp = 12,
  49652. /** DPadDown */
  49653. DPadDown = 13,
  49654. /** DPadLeft */
  49655. DPadLeft = 14,
  49656. /** DRight */
  49657. DPadRight = 15,
  49658. /** Home */
  49659. Home = 16,
  49660. /** TouchPad */
  49661. TouchPad = 17,
  49662. /** LStickXAxis */
  49663. LStickXAxis = 18,
  49664. /** LStickYAxis */
  49665. LStickYAxis = 19,
  49666. /** RStickXAxis */
  49667. RStickXAxis = 20,
  49668. /** RStickYAxis */
  49669. RStickYAxis = 21
  49670. }
  49671. /**
  49672. * Enum for Xbox Gamepad
  49673. */
  49674. export enum XboxInput {
  49675. /** A */
  49676. A = 0,
  49677. /** B */
  49678. B = 1,
  49679. /** X */
  49680. X = 2,
  49681. /** Y */
  49682. Y = 3,
  49683. /** LB */
  49684. LB = 4,
  49685. /** RB */
  49686. RB = 5,
  49687. /** LT */
  49688. LT = 6,
  49689. /** RT */
  49690. RT = 7,
  49691. /** Back */
  49692. Back = 8,
  49693. /** Start */
  49694. Start = 9,
  49695. /** LS */
  49696. LS = 10,
  49697. /** RS */
  49698. RS = 11,
  49699. /** DPadUp */
  49700. DPadUp = 12,
  49701. /** DPadDown */
  49702. DPadDown = 13,
  49703. /** DPadLeft */
  49704. DPadLeft = 14,
  49705. /** DRight */
  49706. DPadRight = 15,
  49707. /** Home */
  49708. Home = 16,
  49709. /** LStickXAxis */
  49710. LStickXAxis = 17,
  49711. /** LStickYAxis */
  49712. LStickYAxis = 18,
  49713. /** RStickXAxis */
  49714. RStickXAxis = 19,
  49715. /** RStickYAxis */
  49716. RStickYAxis = 20
  49717. }
  49718. /**
  49719. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49720. */
  49721. export enum SwitchInput {
  49722. /** B */
  49723. B = 0,
  49724. /** A */
  49725. A = 1,
  49726. /** Y */
  49727. Y = 2,
  49728. /** X */
  49729. X = 3,
  49730. /** L */
  49731. L = 4,
  49732. /** R */
  49733. R = 5,
  49734. /** ZL */
  49735. ZL = 6,
  49736. /** ZR */
  49737. ZR = 7,
  49738. /** Minus */
  49739. Minus = 8,
  49740. /** Plus */
  49741. Plus = 9,
  49742. /** LS */
  49743. LS = 10,
  49744. /** RS */
  49745. RS = 11,
  49746. /** DPadUp */
  49747. DPadUp = 12,
  49748. /** DPadDown */
  49749. DPadDown = 13,
  49750. /** DPadLeft */
  49751. DPadLeft = 14,
  49752. /** DRight */
  49753. DPadRight = 15,
  49754. /** Home */
  49755. Home = 16,
  49756. /** Capture */
  49757. Capture = 17,
  49758. /** LStickXAxis */
  49759. LStickXAxis = 18,
  49760. /** LStickYAxis */
  49761. LStickYAxis = 19,
  49762. /** RStickXAxis */
  49763. RStickXAxis = 20,
  49764. /** RStickYAxis */
  49765. RStickYAxis = 21
  49766. }
  49767. }
  49768. declare module BABYLON {
  49769. /**
  49770. * This class will take all inputs from Keyboard, Pointer, and
  49771. * any Gamepads and provide a polling system that all devices
  49772. * will use. This class assumes that there will only be one
  49773. * pointer device and one keyboard.
  49774. */
  49775. export class DeviceInputSystem implements IDisposable {
  49776. /**
  49777. * Callback to be triggered when a device is connected
  49778. */
  49779. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49780. /**
  49781. * Callback to be triggered when a device is disconnected
  49782. */
  49783. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49784. /**
  49785. * Callback to be triggered when event driven input is updated
  49786. */
  49787. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49788. private _inputs;
  49789. private _gamepads;
  49790. private _keyboardActive;
  49791. private _pointerActive;
  49792. private _elementToAttachTo;
  49793. private _keyboardDownEvent;
  49794. private _keyboardUpEvent;
  49795. private _pointerMoveEvent;
  49796. private _pointerDownEvent;
  49797. private _pointerUpEvent;
  49798. private _gamepadConnectedEvent;
  49799. private _gamepadDisconnectedEvent;
  49800. private static _MAX_KEYCODES;
  49801. private static _MAX_POINTER_INPUTS;
  49802. private constructor();
  49803. /**
  49804. * Creates a new DeviceInputSystem instance
  49805. * @param engine Engine to pull input element from
  49806. * @returns The new instance
  49807. */
  49808. static Create(engine: Engine): DeviceInputSystem;
  49809. /**
  49810. * Checks for current device input value, given an id and input index
  49811. * @param deviceName Id of connected device
  49812. * @param inputIndex Index of device input
  49813. * @returns Current value of input
  49814. */
  49815. /**
  49816. * Checks for current device input value, given an id and input index
  49817. * @param deviceType Enum specifiying device type
  49818. * @param deviceSlot "Slot" or index that device is referenced in
  49819. * @param inputIndex Id of input to be checked
  49820. * @returns Current value of input
  49821. */
  49822. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49823. /**
  49824. * Dispose of all the eventlisteners
  49825. */
  49826. dispose(): void;
  49827. /**
  49828. * Add device and inputs to device array
  49829. * @param deviceType Enum specifiying device type
  49830. * @param deviceSlot "Slot" or index that device is referenced in
  49831. * @param numberOfInputs Number of input entries to create for given device
  49832. */
  49833. private _registerDevice;
  49834. /**
  49835. * Given a specific device name, remove that device from the device map
  49836. * @param deviceType Enum specifiying device type
  49837. * @param deviceSlot "Slot" or index that device is referenced in
  49838. */
  49839. private _unregisterDevice;
  49840. /**
  49841. * Handle all actions that come from keyboard interaction
  49842. */
  49843. private _handleKeyActions;
  49844. /**
  49845. * Handle all actions that come from pointer interaction
  49846. */
  49847. private _handlePointerActions;
  49848. /**
  49849. * Handle all actions that come from gamepad interaction
  49850. */
  49851. private _handleGamepadActions;
  49852. /**
  49853. * Update all non-event based devices with each frame
  49854. * @param deviceType Enum specifiying device type
  49855. * @param deviceSlot "Slot" or index that device is referenced in
  49856. * @param inputIndex Id of input to be checked
  49857. */
  49858. private _updateDevice;
  49859. /**
  49860. * Gets DeviceType from the device name
  49861. * @param deviceName Name of Device from DeviceInputSystem
  49862. * @returns DeviceType enum value
  49863. */
  49864. private _getGamepadDeviceType;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * Type to handle enforcement of inputs
  49870. */
  49871. 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;
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Class that handles all input for a specific device
  49876. */
  49877. export class DeviceSource<T extends DeviceType> {
  49878. /** Type of device */
  49879. readonly deviceType: DeviceType;
  49880. /** "Slot" or index that device is referenced in */
  49881. readonly deviceSlot: number;
  49882. /**
  49883. * Observable to handle device input changes per device
  49884. */
  49885. readonly onInputChangedObservable: Observable<{
  49886. inputIndex: DeviceInput<T>;
  49887. previousState: Nullable<number>;
  49888. currentState: Nullable<number>;
  49889. }>;
  49890. private readonly _deviceInputSystem;
  49891. /**
  49892. * Default Constructor
  49893. * @param deviceInputSystem Reference to DeviceInputSystem
  49894. * @param deviceType Type of device
  49895. * @param deviceSlot "Slot" or index that device is referenced in
  49896. */
  49897. constructor(deviceInputSystem: DeviceInputSystem,
  49898. /** Type of device */
  49899. deviceType: DeviceType,
  49900. /** "Slot" or index that device is referenced in */
  49901. deviceSlot?: number);
  49902. /**
  49903. * Get input for specific input
  49904. * @param inputIndex index of specific input on device
  49905. * @returns Input value from DeviceInputSystem
  49906. */
  49907. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49908. }
  49909. /**
  49910. * Class to keep track of devices
  49911. */
  49912. export class DeviceSourceManager implements IDisposable {
  49913. /**
  49914. * Observable to be triggered when before a device is connected
  49915. */
  49916. readonly onBeforeDeviceConnectedObservable: Observable<{
  49917. deviceType: DeviceType;
  49918. deviceSlot: number;
  49919. }>;
  49920. /**
  49921. * Observable to be triggered when before a device is disconnected
  49922. */
  49923. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49924. deviceType: DeviceType;
  49925. deviceSlot: number;
  49926. }>;
  49927. /**
  49928. * Observable to be triggered when after a device is connected
  49929. */
  49930. readonly onAfterDeviceConnectedObservable: Observable<{
  49931. deviceType: DeviceType;
  49932. deviceSlot: number;
  49933. }>;
  49934. /**
  49935. * Observable to be triggered when after a device is disconnected
  49936. */
  49937. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49938. deviceType: DeviceType;
  49939. deviceSlot: number;
  49940. }>;
  49941. private readonly _devices;
  49942. private readonly _firstDevice;
  49943. private readonly _deviceInputSystem;
  49944. /**
  49945. * Default Constructor
  49946. * @param engine engine to pull input element from
  49947. */
  49948. constructor(engine: Engine);
  49949. /**
  49950. * Gets a DeviceSource, given a type and slot
  49951. * @param deviceType Enum specifying device type
  49952. * @param deviceSlot "Slot" or index that device is referenced in
  49953. * @returns DeviceSource object
  49954. */
  49955. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49956. /**
  49957. * Gets an array of DeviceSource objects for a given device type
  49958. * @param deviceType Enum specifying device type
  49959. * @returns Array of DeviceSource objects
  49960. */
  49961. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49962. /**
  49963. * Dispose of DeviceInputSystem and other parts
  49964. */
  49965. dispose(): void;
  49966. /**
  49967. * Function to add device name to device list
  49968. * @param deviceType Enum specifying device type
  49969. * @param deviceSlot "Slot" or index that device is referenced in
  49970. */
  49971. private _addDevice;
  49972. /**
  49973. * Function to remove device name to device list
  49974. * @param deviceType Enum specifying device type
  49975. * @param deviceSlot "Slot" or index that device is referenced in
  49976. */
  49977. private _removeDevice;
  49978. /**
  49979. * Updates array storing first connected device of each type
  49980. * @param type Type of Device
  49981. */
  49982. private _updateFirstDevices;
  49983. }
  49984. }
  49985. declare module BABYLON {
  49986. /**
  49987. * Options to create the null engine
  49988. */
  49989. export class NullEngineOptions {
  49990. /**
  49991. * Render width (Default: 512)
  49992. */
  49993. renderWidth: number;
  49994. /**
  49995. * Render height (Default: 256)
  49996. */
  49997. renderHeight: number;
  49998. /**
  49999. * Texture size (Default: 512)
  50000. */
  50001. textureSize: number;
  50002. /**
  50003. * If delta time between frames should be constant
  50004. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50005. */
  50006. deterministicLockstep: boolean;
  50007. /**
  50008. * Maximum about of steps between frames (Default: 4)
  50009. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50010. */
  50011. lockstepMaxSteps: number;
  50012. }
  50013. /**
  50014. * The null engine class provides support for headless version of babylon.js.
  50015. * This can be used in server side scenario or for testing purposes
  50016. */
  50017. export class NullEngine extends Engine {
  50018. private _options;
  50019. /**
  50020. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50021. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50022. * @returns true if engine is in deterministic lock step mode
  50023. */
  50024. isDeterministicLockStep(): boolean;
  50025. /**
  50026. * Gets the max steps when engine is running in deterministic lock step
  50027. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50028. * @returns the max steps
  50029. */
  50030. getLockstepMaxSteps(): number;
  50031. /**
  50032. * Gets the current hardware scaling level.
  50033. * By default the hardware scaling level is computed from the window device ratio.
  50034. * 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.
  50035. * @returns a number indicating the current hardware scaling level
  50036. */
  50037. getHardwareScalingLevel(): number;
  50038. constructor(options?: NullEngineOptions);
  50039. /**
  50040. * Creates a vertex buffer
  50041. * @param vertices the data for the vertex buffer
  50042. * @returns the new WebGL static buffer
  50043. */
  50044. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50045. /**
  50046. * Creates a new index buffer
  50047. * @param indices defines the content of the index buffer
  50048. * @param updatable defines if the index buffer must be updatable
  50049. * @returns a new webGL buffer
  50050. */
  50051. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50052. /**
  50053. * Clear the current render buffer or the current render target (if any is set up)
  50054. * @param color defines the color to use
  50055. * @param backBuffer defines if the back buffer must be cleared
  50056. * @param depth defines if the depth buffer must be cleared
  50057. * @param stencil defines if the stencil buffer must be cleared
  50058. */
  50059. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50060. /**
  50061. * Gets the current render width
  50062. * @param useScreen defines if screen size must be used (or the current render target if any)
  50063. * @returns a number defining the current render width
  50064. */
  50065. getRenderWidth(useScreen?: boolean): number;
  50066. /**
  50067. * Gets the current render height
  50068. * @param useScreen defines if screen size must be used (or the current render target if any)
  50069. * @returns a number defining the current render height
  50070. */
  50071. getRenderHeight(useScreen?: boolean): number;
  50072. /**
  50073. * Set the WebGL's viewport
  50074. * @param viewport defines the viewport element to be used
  50075. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50076. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50077. */
  50078. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50079. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50080. /**
  50081. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50082. * @param pipelineContext defines the pipeline context to use
  50083. * @param uniformsNames defines the list of uniform names
  50084. * @returns an array of webGL uniform locations
  50085. */
  50086. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50087. /**
  50088. * Gets the lsit of active attributes for a given webGL program
  50089. * @param pipelineContext defines the pipeline context to use
  50090. * @param attributesNames defines the list of attribute names to get
  50091. * @returns an array of indices indicating the offset of each attribute
  50092. */
  50093. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50094. /**
  50095. * Binds an effect to the webGL context
  50096. * @param effect defines the effect to bind
  50097. */
  50098. bindSamplers(effect: Effect): void;
  50099. /**
  50100. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50101. * @param effect defines the effect to activate
  50102. */
  50103. enableEffect(effect: Effect): void;
  50104. /**
  50105. * Set various states to the webGL context
  50106. * @param culling defines backface culling state
  50107. * @param zOffset defines the value to apply to zOffset (0 by default)
  50108. * @param force defines if states must be applied even if cache is up to date
  50109. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50110. */
  50111. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50112. /**
  50113. * Set the value of an uniform to an array of int32
  50114. * @param uniform defines the webGL uniform location where to store the value
  50115. * @param array defines the array of int32 to store
  50116. */
  50117. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50118. /**
  50119. * Set the value of an uniform to an array of int32 (stored as vec2)
  50120. * @param uniform defines the webGL uniform location where to store the value
  50121. * @param array defines the array of int32 to store
  50122. */
  50123. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50124. /**
  50125. * Set the value of an uniform to an array of int32 (stored as vec3)
  50126. * @param uniform defines the webGL uniform location where to store the value
  50127. * @param array defines the array of int32 to store
  50128. */
  50129. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50130. /**
  50131. * Set the value of an uniform to an array of int32 (stored as vec4)
  50132. * @param uniform defines the webGL uniform location where to store the value
  50133. * @param array defines the array of int32 to store
  50134. */
  50135. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50136. /**
  50137. * Set the value of an uniform to an array of float32
  50138. * @param uniform defines the webGL uniform location where to store the value
  50139. * @param array defines the array of float32 to store
  50140. */
  50141. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50142. /**
  50143. * Set the value of an uniform to an array of float32 (stored as vec2)
  50144. * @param uniform defines the webGL uniform location where to store the value
  50145. * @param array defines the array of float32 to store
  50146. */
  50147. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50148. /**
  50149. * Set the value of an uniform to an array of float32 (stored as vec3)
  50150. * @param uniform defines the webGL uniform location where to store the value
  50151. * @param array defines the array of float32 to store
  50152. */
  50153. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50154. /**
  50155. * Set the value of an uniform to an array of float32 (stored as vec4)
  50156. * @param uniform defines the webGL uniform location where to store the value
  50157. * @param array defines the array of float32 to store
  50158. */
  50159. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50160. /**
  50161. * Set the value of an uniform to an array of number
  50162. * @param uniform defines the webGL uniform location where to store the value
  50163. * @param array defines the array of number to store
  50164. */
  50165. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50166. /**
  50167. * Set the value of an uniform to an array of number (stored as vec2)
  50168. * @param uniform defines the webGL uniform location where to store the value
  50169. * @param array defines the array of number to store
  50170. */
  50171. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50172. /**
  50173. * Set the value of an uniform to an array of number (stored as vec3)
  50174. * @param uniform defines the webGL uniform location where to store the value
  50175. * @param array defines the array of number to store
  50176. */
  50177. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50178. /**
  50179. * Set the value of an uniform to an array of number (stored as vec4)
  50180. * @param uniform defines the webGL uniform location where to store the value
  50181. * @param array defines the array of number to store
  50182. */
  50183. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50184. /**
  50185. * Set the value of an uniform to an array of float32 (stored as matrices)
  50186. * @param uniform defines the webGL uniform location where to store the value
  50187. * @param matrices defines the array of float32 to store
  50188. */
  50189. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50190. /**
  50191. * Set the value of an uniform to a matrix (3x3)
  50192. * @param uniform defines the webGL uniform location where to store the value
  50193. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50194. */
  50195. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50196. /**
  50197. * Set the value of an uniform to a matrix (2x2)
  50198. * @param uniform defines the webGL uniform location where to store the value
  50199. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50200. */
  50201. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50202. /**
  50203. * Set the value of an uniform to a number (float)
  50204. * @param uniform defines the webGL uniform location where to store the value
  50205. * @param value defines the float number to store
  50206. */
  50207. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50208. /**
  50209. * Set the value of an uniform to a vec2
  50210. * @param uniform defines the webGL uniform location where to store the value
  50211. * @param x defines the 1st component of the value
  50212. * @param y defines the 2nd component of the value
  50213. */
  50214. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50215. /**
  50216. * Set the value of an uniform to a vec3
  50217. * @param uniform defines the webGL uniform location where to store the value
  50218. * @param x defines the 1st component of the value
  50219. * @param y defines the 2nd component of the value
  50220. * @param z defines the 3rd component of the value
  50221. */
  50222. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50223. /**
  50224. * Set the value of an uniform to a boolean
  50225. * @param uniform defines the webGL uniform location where to store the value
  50226. * @param bool defines the boolean to store
  50227. */
  50228. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50229. /**
  50230. * Set the value of an uniform to a vec4
  50231. * @param uniform defines the webGL uniform location where to store the value
  50232. * @param x defines the 1st component of the value
  50233. * @param y defines the 2nd component of the value
  50234. * @param z defines the 3rd component of the value
  50235. * @param w defines the 4th component of the value
  50236. */
  50237. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50238. /**
  50239. * Sets the current alpha mode
  50240. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50241. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50242. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50243. */
  50244. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50245. /**
  50246. * Bind webGl buffers directly to the webGL context
  50247. * @param vertexBuffers defines the vertex buffer to bind
  50248. * @param indexBuffer defines the index buffer to bind
  50249. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50250. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50251. * @param effect defines the effect associated with the vertex buffer
  50252. */
  50253. bindBuffers(vertexBuffers: {
  50254. [key: string]: VertexBuffer;
  50255. }, indexBuffer: DataBuffer, effect: Effect): void;
  50256. /**
  50257. * Force the entire cache to be cleared
  50258. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50259. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50260. */
  50261. wipeCaches(bruteForce?: boolean): void;
  50262. /**
  50263. * Send a draw order
  50264. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50265. * @param indexStart defines the starting index
  50266. * @param indexCount defines the number of index to draw
  50267. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50268. */
  50269. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50270. /**
  50271. * Draw a list of indexed primitives
  50272. * @param fillMode defines the primitive to use
  50273. * @param indexStart defines the starting index
  50274. * @param indexCount defines the number of index to draw
  50275. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50276. */
  50277. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50278. /**
  50279. * Draw a list of unindexed primitives
  50280. * @param fillMode defines the primitive to use
  50281. * @param verticesStart defines the index of first vertex to draw
  50282. * @param verticesCount defines the count of vertices to draw
  50283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50284. */
  50285. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50286. /** @hidden */
  50287. _createTexture(): WebGLTexture;
  50288. /** @hidden */
  50289. _releaseTexture(texture: InternalTexture): void;
  50290. /**
  50291. * Usually called from Texture.ts.
  50292. * Passed information to create a WebGLTexture
  50293. * @param urlArg defines a value which contains one of the following:
  50294. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50295. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50296. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50297. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50298. * @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)
  50299. * @param scene needed for loading to the correct scene
  50300. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50301. * @param onLoad optional callback to be called upon successful completion
  50302. * @param onError optional callback to be called upon failure
  50303. * @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
  50304. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50305. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50306. * @param forcedExtension defines the extension to use to pick the right loader
  50307. * @param mimeType defines an optional mime type
  50308. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50309. */
  50310. 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;
  50311. /**
  50312. * Creates a new render target texture
  50313. * @param size defines the size of the texture
  50314. * @param options defines the options used to create the texture
  50315. * @returns a new render target texture stored in an InternalTexture
  50316. */
  50317. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50318. /**
  50319. * Update the sampling mode of a given texture
  50320. * @param samplingMode defines the required sampling mode
  50321. * @param texture defines the texture to update
  50322. */
  50323. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50324. /**
  50325. * Binds the frame buffer to the specified texture.
  50326. * @param texture The texture to render to or null for the default canvas
  50327. * @param faceIndex The face of the texture to render to in case of cube texture
  50328. * @param requiredWidth The width of the target to render to
  50329. * @param requiredHeight The height of the target to render to
  50330. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50331. * @param lodLevel defines le lod level to bind to the frame buffer
  50332. */
  50333. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50334. /**
  50335. * Unbind the current render target texture from the webGL context
  50336. * @param texture defines the render target texture to unbind
  50337. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50338. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50339. */
  50340. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50341. /**
  50342. * Creates a dynamic vertex buffer
  50343. * @param vertices the data for the dynamic vertex buffer
  50344. * @returns the new WebGL dynamic buffer
  50345. */
  50346. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50347. /**
  50348. * Update the content of a dynamic texture
  50349. * @param texture defines the texture to update
  50350. * @param canvas defines the canvas containing the source
  50351. * @param invertY defines if data must be stored with Y axis inverted
  50352. * @param premulAlpha defines if alpha is stored as premultiplied
  50353. * @param format defines the format of the data
  50354. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50355. */
  50356. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50357. /**
  50358. * Gets a boolean indicating if all created effects are ready
  50359. * @returns true if all effects are ready
  50360. */
  50361. areAllEffectsReady(): boolean;
  50362. /**
  50363. * @hidden
  50364. * Get the current error code of the webGL context
  50365. * @returns the error code
  50366. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50367. */
  50368. getError(): number;
  50369. /** @hidden */
  50370. _getUnpackAlignement(): number;
  50371. /** @hidden */
  50372. _unpackFlipY(value: boolean): void;
  50373. /**
  50374. * Update a dynamic index buffer
  50375. * @param indexBuffer defines the target index buffer
  50376. * @param indices defines the data to update
  50377. * @param offset defines the offset in the target index buffer where update should start
  50378. */
  50379. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50380. /**
  50381. * Updates a dynamic vertex buffer.
  50382. * @param vertexBuffer the vertex buffer to update
  50383. * @param vertices the data used to update the vertex buffer
  50384. * @param byteOffset the byte offset of the data (optional)
  50385. * @param byteLength the byte length of the data (optional)
  50386. */
  50387. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50388. /** @hidden */
  50389. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50390. /** @hidden */
  50391. _bindTexture(channel: number, texture: InternalTexture): void;
  50392. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50393. /**
  50394. * 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
  50395. */
  50396. releaseEffects(): void;
  50397. displayLoadingUI(): void;
  50398. hideLoadingUI(): void;
  50399. /** @hidden */
  50400. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50401. /** @hidden */
  50402. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50403. /** @hidden */
  50404. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50405. /** @hidden */
  50406. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50407. }
  50408. }
  50409. declare module BABYLON {
  50410. /**
  50411. * @hidden
  50412. **/
  50413. export class _TimeToken {
  50414. _startTimeQuery: Nullable<WebGLQuery>;
  50415. _endTimeQuery: Nullable<WebGLQuery>;
  50416. _timeElapsedQuery: Nullable<WebGLQuery>;
  50417. _timeElapsedQueryEnded: boolean;
  50418. }
  50419. }
  50420. declare module BABYLON {
  50421. /** @hidden */
  50422. export class _OcclusionDataStorage {
  50423. /** @hidden */
  50424. occlusionInternalRetryCounter: number;
  50425. /** @hidden */
  50426. isOcclusionQueryInProgress: boolean;
  50427. /** @hidden */
  50428. isOccluded: boolean;
  50429. /** @hidden */
  50430. occlusionRetryCount: number;
  50431. /** @hidden */
  50432. occlusionType: number;
  50433. /** @hidden */
  50434. occlusionQueryAlgorithmType: number;
  50435. }
  50436. interface Engine {
  50437. /**
  50438. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50439. * @return the new query
  50440. */
  50441. createQuery(): WebGLQuery;
  50442. /**
  50443. * Delete and release a webGL query
  50444. * @param query defines the query to delete
  50445. * @return the current engine
  50446. */
  50447. deleteQuery(query: WebGLQuery): Engine;
  50448. /**
  50449. * Check if a given query has resolved and got its value
  50450. * @param query defines the query to check
  50451. * @returns true if the query got its value
  50452. */
  50453. isQueryResultAvailable(query: WebGLQuery): boolean;
  50454. /**
  50455. * Gets the value of a given query
  50456. * @param query defines the query to check
  50457. * @returns the value of the query
  50458. */
  50459. getQueryResult(query: WebGLQuery): number;
  50460. /**
  50461. * Initiates an occlusion query
  50462. * @param algorithmType defines the algorithm to use
  50463. * @param query defines the query to use
  50464. * @returns the current engine
  50465. * @see http://doc.babylonjs.com/features/occlusionquery
  50466. */
  50467. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50468. /**
  50469. * Ends an occlusion query
  50470. * @see http://doc.babylonjs.com/features/occlusionquery
  50471. * @param algorithmType defines the algorithm to use
  50472. * @returns the current engine
  50473. */
  50474. endOcclusionQuery(algorithmType: number): Engine;
  50475. /**
  50476. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50477. * Please note that only one query can be issued at a time
  50478. * @returns a time token used to track the time span
  50479. */
  50480. startTimeQuery(): Nullable<_TimeToken>;
  50481. /**
  50482. * Ends a time query
  50483. * @param token defines the token used to measure the time span
  50484. * @returns the time spent (in ns)
  50485. */
  50486. endTimeQuery(token: _TimeToken): int;
  50487. /** @hidden */
  50488. _currentNonTimestampToken: Nullable<_TimeToken>;
  50489. /** @hidden */
  50490. _createTimeQuery(): WebGLQuery;
  50491. /** @hidden */
  50492. _deleteTimeQuery(query: WebGLQuery): void;
  50493. /** @hidden */
  50494. _getGlAlgorithmType(algorithmType: number): number;
  50495. /** @hidden */
  50496. _getTimeQueryResult(query: WebGLQuery): any;
  50497. /** @hidden */
  50498. _getTimeQueryAvailability(query: WebGLQuery): any;
  50499. }
  50500. interface AbstractMesh {
  50501. /**
  50502. * Backing filed
  50503. * @hidden
  50504. */
  50505. __occlusionDataStorage: _OcclusionDataStorage;
  50506. /**
  50507. * Access property
  50508. * @hidden
  50509. */
  50510. _occlusionDataStorage: _OcclusionDataStorage;
  50511. /**
  50512. * 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.
  50513. * The default value is -1 which means don't break the query and wait till the result
  50514. * @see http://doc.babylonjs.com/features/occlusionquery
  50515. */
  50516. occlusionRetryCount: number;
  50517. /**
  50518. * 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:
  50519. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50520. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50521. * * 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.
  50522. * @see http://doc.babylonjs.com/features/occlusionquery
  50523. */
  50524. occlusionType: number;
  50525. /**
  50526. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50527. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50528. * * 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.
  50529. * @see http://doc.babylonjs.com/features/occlusionquery
  50530. */
  50531. occlusionQueryAlgorithmType: number;
  50532. /**
  50533. * 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
  50534. * @see http://doc.babylonjs.com/features/occlusionquery
  50535. */
  50536. isOccluded: boolean;
  50537. /**
  50538. * Flag to check the progress status of the query
  50539. * @see http://doc.babylonjs.com/features/occlusionquery
  50540. */
  50541. isOcclusionQueryInProgress: boolean;
  50542. }
  50543. }
  50544. declare module BABYLON {
  50545. /** @hidden */
  50546. export var _forceTransformFeedbackToBundle: boolean;
  50547. interface Engine {
  50548. /**
  50549. * Creates a webGL transform feedback object
  50550. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50551. * @returns the webGL transform feedback object
  50552. */
  50553. createTransformFeedback(): WebGLTransformFeedback;
  50554. /**
  50555. * Delete a webGL transform feedback object
  50556. * @param value defines the webGL transform feedback object to delete
  50557. */
  50558. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50559. /**
  50560. * Bind a webGL transform feedback object to the webgl context
  50561. * @param value defines the webGL transform feedback object to bind
  50562. */
  50563. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50564. /**
  50565. * Begins a transform feedback operation
  50566. * @param usePoints defines if points or triangles must be used
  50567. */
  50568. beginTransformFeedback(usePoints: boolean): void;
  50569. /**
  50570. * Ends a transform feedback operation
  50571. */
  50572. endTransformFeedback(): void;
  50573. /**
  50574. * Specify the varyings to use with transform feedback
  50575. * @param program defines the associated webGL program
  50576. * @param value defines the list of strings representing the varying names
  50577. */
  50578. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50579. /**
  50580. * Bind a webGL buffer for a transform feedback operation
  50581. * @param value defines the webGL buffer to bind
  50582. */
  50583. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50584. }
  50585. }
  50586. declare module BABYLON {
  50587. /**
  50588. * Creation options of the multi render target texture.
  50589. */
  50590. export interface IMultiRenderTargetOptions {
  50591. /**
  50592. * Define if the texture needs to create mip maps after render.
  50593. */
  50594. generateMipMaps?: boolean;
  50595. /**
  50596. * Define the types of all the draw buffers we want to create
  50597. */
  50598. types?: number[];
  50599. /**
  50600. * Define the sampling modes of all the draw buffers we want to create
  50601. */
  50602. samplingModes?: number[];
  50603. /**
  50604. * Define if a depth buffer is required
  50605. */
  50606. generateDepthBuffer?: boolean;
  50607. /**
  50608. * Define if a stencil buffer is required
  50609. */
  50610. generateStencilBuffer?: boolean;
  50611. /**
  50612. * Define if a depth texture is required instead of a depth buffer
  50613. */
  50614. generateDepthTexture?: boolean;
  50615. /**
  50616. * Define the number of desired draw buffers
  50617. */
  50618. textureCount?: number;
  50619. /**
  50620. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50621. */
  50622. doNotChangeAspectRatio?: boolean;
  50623. /**
  50624. * Define the default type of the buffers we are creating
  50625. */
  50626. defaultType?: number;
  50627. }
  50628. /**
  50629. * A multi render target, like a render target provides the ability to render to a texture.
  50630. * Unlike the render target, it can render to several draw buffers in one draw.
  50631. * This is specially interesting in deferred rendering or for any effects requiring more than
  50632. * just one color from a single pass.
  50633. */
  50634. export class MultiRenderTarget extends RenderTargetTexture {
  50635. private _internalTextures;
  50636. private _textures;
  50637. private _multiRenderTargetOptions;
  50638. /**
  50639. * Get if draw buffers are currently supported by the used hardware and browser.
  50640. */
  50641. get isSupported(): boolean;
  50642. /**
  50643. * Get the list of textures generated by the multi render target.
  50644. */
  50645. get textures(): Texture[];
  50646. /**
  50647. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50648. */
  50649. get depthTexture(): Texture;
  50650. /**
  50651. * Set the wrapping mode on U of all the textures we are rendering to.
  50652. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50653. */
  50654. set wrapU(wrap: number);
  50655. /**
  50656. * Set the wrapping mode on V of all the textures we are rendering to.
  50657. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50658. */
  50659. set wrapV(wrap: number);
  50660. /**
  50661. * Instantiate a new multi render target texture.
  50662. * A multi render target, like a render target provides the ability to render to a texture.
  50663. * Unlike the render target, it can render to several draw buffers in one draw.
  50664. * This is specially interesting in deferred rendering or for any effects requiring more than
  50665. * just one color from a single pass.
  50666. * @param name Define the name of the texture
  50667. * @param size Define the size of the buffers to render to
  50668. * @param count Define the number of target we are rendering into
  50669. * @param scene Define the scene the texture belongs to
  50670. * @param options Define the options used to create the multi render target
  50671. */
  50672. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50673. /** @hidden */
  50674. _rebuild(): void;
  50675. private _createInternalTextures;
  50676. private _createTextures;
  50677. /**
  50678. * Define the number of samples used if MSAA is enabled.
  50679. */
  50680. get samples(): number;
  50681. set samples(value: number);
  50682. /**
  50683. * Resize all the textures in the multi render target.
  50684. * Be carrefull as it will recreate all the data in the new texture.
  50685. * @param size Define the new size
  50686. */
  50687. resize(size: any): void;
  50688. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50689. /**
  50690. * Dispose the render targets and their associated resources
  50691. */
  50692. dispose(): void;
  50693. /**
  50694. * Release all the underlying texture used as draw buffers.
  50695. */
  50696. releaseInternalTextures(): void;
  50697. }
  50698. }
  50699. declare module BABYLON {
  50700. interface ThinEngine {
  50701. /**
  50702. * Unbind a list of render target textures from the webGL context
  50703. * This is used only when drawBuffer extension or webGL2 are active
  50704. * @param textures defines the render target textures to unbind
  50705. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50706. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50707. */
  50708. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50709. /**
  50710. * Create a multi render target texture
  50711. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50712. * @param size defines the size of the texture
  50713. * @param options defines the creation options
  50714. * @returns the cube texture as an InternalTexture
  50715. */
  50716. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50717. /**
  50718. * Update the sample count for a given multiple render target texture
  50719. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50720. * @param textures defines the textures to update
  50721. * @param samples defines the sample count to set
  50722. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50723. */
  50724. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50725. }
  50726. }
  50727. declare module BABYLON {
  50728. /**
  50729. * Class used to define an additional view for the engine
  50730. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50731. */
  50732. export class EngineView {
  50733. /** Defines the canvas where to render the view */
  50734. target: HTMLCanvasElement;
  50735. /** Defines an optional camera used to render the view (will use active camera else) */
  50736. camera?: Camera;
  50737. }
  50738. interface Engine {
  50739. /**
  50740. * Gets or sets the HTML element to use for attaching events
  50741. */
  50742. inputElement: Nullable<HTMLElement>;
  50743. /**
  50744. * Gets the current engine view
  50745. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50746. */
  50747. activeView: Nullable<EngineView>;
  50748. /** Gets or sets the list of views */
  50749. views: EngineView[];
  50750. /**
  50751. * Register a new child canvas
  50752. * @param canvas defines the canvas to register
  50753. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50754. * @returns the associated view
  50755. */
  50756. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50757. /**
  50758. * Remove a registered child canvas
  50759. * @param canvas defines the canvas to remove
  50760. * @returns the current engine
  50761. */
  50762. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50763. }
  50764. }
  50765. declare module BABYLON {
  50766. interface Engine {
  50767. /** @hidden */
  50768. _excludedCompressedTextures: string[];
  50769. /** @hidden */
  50770. _textureFormatInUse: string;
  50771. /**
  50772. * Gets the list of texture formats supported
  50773. */
  50774. readonly texturesSupported: Array<string>;
  50775. /**
  50776. * Gets the texture format in use
  50777. */
  50778. readonly textureFormatInUse: Nullable<string>;
  50779. /**
  50780. * Set the compressed texture extensions or file names to skip.
  50781. *
  50782. * @param skippedFiles defines the list of those texture files you want to skip
  50783. * Example: [".dds", ".env", "myfile.png"]
  50784. */
  50785. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50786. /**
  50787. * Set the compressed texture format to use, based on the formats you have, and the formats
  50788. * supported by the hardware / browser.
  50789. *
  50790. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50791. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50792. * to API arguments needed to compressed textures. This puts the burden on the container
  50793. * generator to house the arcane code for determining these for current & future formats.
  50794. *
  50795. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50796. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50797. *
  50798. * Note: The result of this call is not taken into account when a texture is base64.
  50799. *
  50800. * @param formatsAvailable defines the list of those format families you have created
  50801. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50802. *
  50803. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50804. * @returns The extension selected.
  50805. */
  50806. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50807. }
  50808. }
  50809. declare module BABYLON {
  50810. /**
  50811. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50812. */
  50813. export interface CubeMapInfo {
  50814. /**
  50815. * The pixel array for the front face.
  50816. * This is stored in format, left to right, up to down format.
  50817. */
  50818. front: Nullable<ArrayBufferView>;
  50819. /**
  50820. * The pixel array for the back face.
  50821. * This is stored in format, left to right, up to down format.
  50822. */
  50823. back: Nullable<ArrayBufferView>;
  50824. /**
  50825. * The pixel array for the left face.
  50826. * This is stored in format, left to right, up to down format.
  50827. */
  50828. left: Nullable<ArrayBufferView>;
  50829. /**
  50830. * The pixel array for the right face.
  50831. * This is stored in format, left to right, up to down format.
  50832. */
  50833. right: Nullable<ArrayBufferView>;
  50834. /**
  50835. * The pixel array for the up face.
  50836. * This is stored in format, left to right, up to down format.
  50837. */
  50838. up: Nullable<ArrayBufferView>;
  50839. /**
  50840. * The pixel array for the down face.
  50841. * This is stored in format, left to right, up to down format.
  50842. */
  50843. down: Nullable<ArrayBufferView>;
  50844. /**
  50845. * The size of the cubemap stored.
  50846. *
  50847. * Each faces will be size * size pixels.
  50848. */
  50849. size: number;
  50850. /**
  50851. * The format of the texture.
  50852. *
  50853. * RGBA, RGB.
  50854. */
  50855. format: number;
  50856. /**
  50857. * The type of the texture data.
  50858. *
  50859. * UNSIGNED_INT, FLOAT.
  50860. */
  50861. type: number;
  50862. /**
  50863. * Specifies whether the texture is in gamma space.
  50864. */
  50865. gammaSpace: boolean;
  50866. }
  50867. /**
  50868. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50869. */
  50870. export class PanoramaToCubeMapTools {
  50871. private static FACE_LEFT;
  50872. private static FACE_RIGHT;
  50873. private static FACE_FRONT;
  50874. private static FACE_BACK;
  50875. private static FACE_DOWN;
  50876. private static FACE_UP;
  50877. /**
  50878. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50879. *
  50880. * @param float32Array The source data.
  50881. * @param inputWidth The width of the input panorama.
  50882. * @param inputHeight The height of the input panorama.
  50883. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50884. * @return The cubemap data
  50885. */
  50886. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50887. private static CreateCubemapTexture;
  50888. private static CalcProjectionSpherical;
  50889. }
  50890. }
  50891. declare module BABYLON {
  50892. /**
  50893. * Helper class dealing with the extraction of spherical polynomial dataArray
  50894. * from a cube map.
  50895. */
  50896. export class CubeMapToSphericalPolynomialTools {
  50897. private static FileFaces;
  50898. /**
  50899. * Converts a texture to the according Spherical Polynomial data.
  50900. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50901. *
  50902. * @param texture The texture to extract the information from.
  50903. * @return The Spherical Polynomial data.
  50904. */
  50905. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50906. /**
  50907. * Converts a cubemap to the according Spherical Polynomial data.
  50908. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50909. *
  50910. * @param cubeInfo The Cube map to extract the information from.
  50911. * @return The Spherical Polynomial data.
  50912. */
  50913. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50914. }
  50915. }
  50916. declare module BABYLON {
  50917. interface BaseTexture {
  50918. /**
  50919. * Get the polynomial representation of the texture data.
  50920. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50921. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50922. */
  50923. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50924. }
  50925. }
  50926. declare module BABYLON {
  50927. /** @hidden */
  50928. export var rgbdEncodePixelShader: {
  50929. name: string;
  50930. shader: string;
  50931. };
  50932. }
  50933. declare module BABYLON {
  50934. /** @hidden */
  50935. export var rgbdDecodePixelShader: {
  50936. name: string;
  50937. shader: string;
  50938. };
  50939. }
  50940. declare module BABYLON {
  50941. /**
  50942. * Raw texture data and descriptor sufficient for WebGL texture upload
  50943. */
  50944. export interface EnvironmentTextureInfo {
  50945. /**
  50946. * Version of the environment map
  50947. */
  50948. version: number;
  50949. /**
  50950. * Width of image
  50951. */
  50952. width: number;
  50953. /**
  50954. * Irradiance information stored in the file.
  50955. */
  50956. irradiance: any;
  50957. /**
  50958. * Specular information stored in the file.
  50959. */
  50960. specular: any;
  50961. }
  50962. /**
  50963. * Defines One Image in the file. It requires only the position in the file
  50964. * as well as the length.
  50965. */
  50966. interface BufferImageData {
  50967. /**
  50968. * Length of the image data.
  50969. */
  50970. length: number;
  50971. /**
  50972. * Position of the data from the null terminator delimiting the end of the JSON.
  50973. */
  50974. position: number;
  50975. }
  50976. /**
  50977. * Defines the specular data enclosed in the file.
  50978. * This corresponds to the version 1 of the data.
  50979. */
  50980. export interface EnvironmentTextureSpecularInfoV1 {
  50981. /**
  50982. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50983. */
  50984. specularDataPosition?: number;
  50985. /**
  50986. * This contains all the images data needed to reconstruct the cubemap.
  50987. */
  50988. mipmaps: Array<BufferImageData>;
  50989. /**
  50990. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50991. */
  50992. lodGenerationScale: number;
  50993. }
  50994. /**
  50995. * Sets of helpers addressing the serialization and deserialization of environment texture
  50996. * stored in a BabylonJS env file.
  50997. * Those files are usually stored as .env files.
  50998. */
  50999. export class EnvironmentTextureTools {
  51000. /**
  51001. * Magic number identifying the env file.
  51002. */
  51003. private static _MagicBytes;
  51004. /**
  51005. * Gets the environment info from an env file.
  51006. * @param data The array buffer containing the .env bytes.
  51007. * @returns the environment file info (the json header) if successfully parsed.
  51008. */
  51009. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51010. /**
  51011. * Creates an environment texture from a loaded cube texture.
  51012. * @param texture defines the cube texture to convert in env file
  51013. * @return a promise containing the environment data if succesfull.
  51014. */
  51015. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51016. /**
  51017. * Creates a JSON representation of the spherical data.
  51018. * @param texture defines the texture containing the polynomials
  51019. * @return the JSON representation of the spherical info
  51020. */
  51021. private static _CreateEnvTextureIrradiance;
  51022. /**
  51023. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51024. * @param data the image data
  51025. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51026. * @return the views described by info providing access to the underlying buffer
  51027. */
  51028. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51029. /**
  51030. * Uploads the texture info contained in the env file to the GPU.
  51031. * @param texture defines the internal texture to upload to
  51032. * @param data defines the data to load
  51033. * @param info defines the texture info retrieved through the GetEnvInfo method
  51034. * @returns a promise
  51035. */
  51036. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51037. private static _OnImageReadyAsync;
  51038. /**
  51039. * Uploads the levels of image data to the GPU.
  51040. * @param texture defines the internal texture to upload to
  51041. * @param imageData defines the array buffer views of image data [mipmap][face]
  51042. * @returns a promise
  51043. */
  51044. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51045. /**
  51046. * Uploads spherical polynomials information to the texture.
  51047. * @param texture defines the texture we are trying to upload the information to
  51048. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51049. */
  51050. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51051. /** @hidden */
  51052. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51053. }
  51054. }
  51055. declare module BABYLON {
  51056. /** @hidden */
  51057. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51058. private _genericAttributeLocation;
  51059. private _varyingLocationCount;
  51060. private _varyingLocationMap;
  51061. private _replacements;
  51062. private _textureCount;
  51063. private _uniforms;
  51064. lineProcessor(line: string): string;
  51065. attributeProcessor(attribute: string): string;
  51066. varyingProcessor(varying: string, isFragment: boolean): string;
  51067. uniformProcessor(uniform: string): string;
  51068. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51069. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51070. }
  51071. }
  51072. declare module BABYLON {
  51073. /**
  51074. * Class used to inline functions in shader code
  51075. */
  51076. export class ShaderCodeInliner {
  51077. private static readonly _RegexpFindFunctionNameAndType;
  51078. private _sourceCode;
  51079. private _functionDescr;
  51080. private _numMaxIterations;
  51081. /** Gets or sets the token used to mark the functions to inline */
  51082. inlineToken: string;
  51083. /** Gets or sets the debug mode */
  51084. debug: boolean;
  51085. /** Gets the code after the inlining process */
  51086. get code(): string;
  51087. /**
  51088. * Initializes the inliner
  51089. * @param sourceCode shader code source to inline
  51090. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51091. */
  51092. constructor(sourceCode: string, numMaxIterations?: number);
  51093. /**
  51094. * Start the processing of the shader code
  51095. */
  51096. processCode(): void;
  51097. private _collectFunctions;
  51098. private _processInlining;
  51099. private _extractBetweenMarkers;
  51100. private _skipWhitespaces;
  51101. private _removeComments;
  51102. private _replaceFunctionCallsByCode;
  51103. private _findBackward;
  51104. private _escapeRegExp;
  51105. private _replaceNames;
  51106. }
  51107. }
  51108. declare module BABYLON {
  51109. /**
  51110. * Container for accessors for natively-stored mesh data buffers.
  51111. */
  51112. class NativeDataBuffer extends DataBuffer {
  51113. /**
  51114. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51115. */
  51116. nativeIndexBuffer?: any;
  51117. /**
  51118. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51119. */
  51120. nativeVertexBuffer?: any;
  51121. }
  51122. /** @hidden */
  51123. class NativeTexture extends InternalTexture {
  51124. getInternalTexture(): InternalTexture;
  51125. getViewCount(): number;
  51126. }
  51127. /** @hidden */
  51128. export class NativeEngine extends Engine {
  51129. private readonly _native;
  51130. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51131. private readonly INVALID_HANDLE;
  51132. getHardwareScalingLevel(): number;
  51133. constructor();
  51134. dispose(): void;
  51135. /**
  51136. * Can be used to override the current requestAnimationFrame requester.
  51137. * @hidden
  51138. */
  51139. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51140. /**
  51141. * Override default engine behavior.
  51142. * @param color
  51143. * @param backBuffer
  51144. * @param depth
  51145. * @param stencil
  51146. */
  51147. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51148. /**
  51149. * Gets host document
  51150. * @returns the host document object
  51151. */
  51152. getHostDocument(): Nullable<Document>;
  51153. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51154. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51155. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51156. recordVertexArrayObject(vertexBuffers: {
  51157. [key: string]: VertexBuffer;
  51158. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51159. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51160. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51161. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51162. /**
  51163. * Draw a list of indexed primitives
  51164. * @param fillMode defines the primitive to use
  51165. * @param indexStart defines the starting index
  51166. * @param indexCount defines the number of index to draw
  51167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51168. */
  51169. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51170. /**
  51171. * Draw a list of unindexed primitives
  51172. * @param fillMode defines the primitive to use
  51173. * @param verticesStart defines the index of first vertex to draw
  51174. * @param verticesCount defines the count of vertices to draw
  51175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51176. */
  51177. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51178. createPipelineContext(): IPipelineContext;
  51179. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51180. /** @hidden */
  51181. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51182. /** @hidden */
  51183. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51184. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51185. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51186. protected _setProgram(program: WebGLProgram): void;
  51187. _releaseEffect(effect: Effect): void;
  51188. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51190. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51191. bindSamplers(effect: Effect): void;
  51192. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51193. getRenderWidth(useScreen?: boolean): number;
  51194. getRenderHeight(useScreen?: boolean): number;
  51195. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51196. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51197. /**
  51198. * Set the z offset to apply to current rendering
  51199. * @param value defines the offset to apply
  51200. */
  51201. setZOffset(value: number): void;
  51202. /**
  51203. * Gets the current value of the zOffset
  51204. * @returns the current zOffset state
  51205. */
  51206. getZOffset(): number;
  51207. /**
  51208. * Enable or disable depth buffering
  51209. * @param enable defines the state to set
  51210. */
  51211. setDepthBuffer(enable: boolean): void;
  51212. /**
  51213. * Gets a boolean indicating if depth writing is enabled
  51214. * @returns the current depth writing state
  51215. */
  51216. getDepthWrite(): boolean;
  51217. /**
  51218. * Enable or disable depth writing
  51219. * @param enable defines the state to set
  51220. */
  51221. setDepthWrite(enable: boolean): void;
  51222. /**
  51223. * Enable or disable color writing
  51224. * @param enable defines the state to set
  51225. */
  51226. setColorWrite(enable: boolean): void;
  51227. /**
  51228. * Gets a boolean indicating if color writing is enabled
  51229. * @returns the current color writing state
  51230. */
  51231. getColorWrite(): boolean;
  51232. /**
  51233. * Sets alpha constants used by some alpha blending modes
  51234. * @param r defines the red component
  51235. * @param g defines the green component
  51236. * @param b defines the blue component
  51237. * @param a defines the alpha component
  51238. */
  51239. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51240. /**
  51241. * Sets the current alpha mode
  51242. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51243. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51244. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51245. */
  51246. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51247. /**
  51248. * Gets the current alpha mode
  51249. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51250. * @returns the current alpha mode
  51251. */
  51252. getAlphaMode(): number;
  51253. setInt(uniform: WebGLUniformLocation, int: number): void;
  51254. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51255. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51256. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51257. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51258. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51259. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51260. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51261. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51262. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51263. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51264. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51265. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51266. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51267. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51268. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51269. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51270. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51271. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51272. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51273. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51274. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51275. wipeCaches(bruteForce?: boolean): void;
  51276. _createTexture(): WebGLTexture;
  51277. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51278. /**
  51279. * Usually called from Texture.ts.
  51280. * Passed information to create a WebGLTexture
  51281. * @param url defines a value which contains one of the following:
  51282. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51283. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51284. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51285. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51286. * @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)
  51287. * @param scene needed for loading to the correct scene
  51288. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51289. * @param onLoad optional callback to be called upon successful completion
  51290. * @param onError optional callback to be called upon failure
  51291. * @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
  51292. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51293. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51294. * @param forcedExtension defines the extension to use to pick the right loader
  51295. * @param mimeType defines an optional mime type
  51296. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51297. */
  51298. 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;
  51299. /**
  51300. * Creates a cube texture
  51301. * @param rootUrl defines the url where the files to load is located
  51302. * @param scene defines the current scene
  51303. * @param files defines the list of files to load (1 per face)
  51304. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51305. * @param onLoad defines an optional callback raised when the texture is loaded
  51306. * @param onError defines an optional callback raised if there is an issue to load the texture
  51307. * @param format defines the format of the data
  51308. * @param forcedExtension defines the extension to use to pick the right loader
  51309. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51310. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51311. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51312. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51313. * @returns the cube texture as an InternalTexture
  51314. */
  51315. 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;
  51316. private _getSamplingFilter;
  51317. private static _GetNativeTextureFormat;
  51318. createRenderTargetTexture(size: number | {
  51319. width: number;
  51320. height: number;
  51321. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51322. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51323. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51324. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51325. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51326. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51327. /**
  51328. * Updates a dynamic vertex buffer.
  51329. * @param vertexBuffer the vertex buffer to update
  51330. * @param data the data used to update the vertex buffer
  51331. * @param byteOffset the byte offset of the data (optional)
  51332. * @param byteLength the byte length of the data (optional)
  51333. */
  51334. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51335. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51336. private _updateAnisotropicLevel;
  51337. private _getAddressMode;
  51338. /** @hidden */
  51339. _bindTexture(channel: number, texture: InternalTexture): void;
  51340. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51341. releaseEffects(): void;
  51342. /** @hidden */
  51343. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51344. /** @hidden */
  51345. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51346. /** @hidden */
  51347. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51348. /** @hidden */
  51349. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51350. }
  51351. }
  51352. declare module BABYLON {
  51353. /**
  51354. * Gather the list of clipboard event types as constants.
  51355. */
  51356. export class ClipboardEventTypes {
  51357. /**
  51358. * The clipboard event is fired when a copy command is active (pressed).
  51359. */
  51360. static readonly COPY: number;
  51361. /**
  51362. * The clipboard event is fired when a cut command is active (pressed).
  51363. */
  51364. static readonly CUT: number;
  51365. /**
  51366. * The clipboard event is fired when a paste command is active (pressed).
  51367. */
  51368. static readonly PASTE: number;
  51369. }
  51370. /**
  51371. * This class is used to store clipboard related info for the onClipboardObservable event.
  51372. */
  51373. export class ClipboardInfo {
  51374. /**
  51375. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51376. */
  51377. type: number;
  51378. /**
  51379. * Defines the related dom event
  51380. */
  51381. event: ClipboardEvent;
  51382. /**
  51383. *Creates an instance of ClipboardInfo.
  51384. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51385. * @param event Defines the related dom event
  51386. */
  51387. constructor(
  51388. /**
  51389. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51390. */
  51391. type: number,
  51392. /**
  51393. * Defines the related dom event
  51394. */
  51395. event: ClipboardEvent);
  51396. /**
  51397. * Get the clipboard event's type from the keycode.
  51398. * @param keyCode Defines the keyCode for the current keyboard event.
  51399. * @return {number}
  51400. */
  51401. static GetTypeFromCharacter(keyCode: number): number;
  51402. }
  51403. }
  51404. declare module BABYLON {
  51405. /**
  51406. * Google Daydream controller
  51407. */
  51408. export class DaydreamController extends WebVRController {
  51409. /**
  51410. * Base Url for the controller model.
  51411. */
  51412. static MODEL_BASE_URL: string;
  51413. /**
  51414. * File name for the controller model.
  51415. */
  51416. static MODEL_FILENAME: string;
  51417. /**
  51418. * Gamepad Id prefix used to identify Daydream Controller.
  51419. */
  51420. static readonly GAMEPAD_ID_PREFIX: string;
  51421. /**
  51422. * Creates a new DaydreamController from a gamepad
  51423. * @param vrGamepad the gamepad that the controller should be created from
  51424. */
  51425. constructor(vrGamepad: any);
  51426. /**
  51427. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51428. * @param scene scene in which to add meshes
  51429. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51430. */
  51431. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51432. /**
  51433. * Called once for each button that changed state since the last frame
  51434. * @param buttonIdx Which button index changed
  51435. * @param state New state of the button
  51436. * @param changes Which properties on the state changed since last frame
  51437. */
  51438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51439. }
  51440. }
  51441. declare module BABYLON {
  51442. /**
  51443. * Gear VR Controller
  51444. */
  51445. export class GearVRController extends WebVRController {
  51446. /**
  51447. * Base Url for the controller model.
  51448. */
  51449. static MODEL_BASE_URL: string;
  51450. /**
  51451. * File name for the controller model.
  51452. */
  51453. static MODEL_FILENAME: string;
  51454. /**
  51455. * Gamepad Id prefix used to identify this controller.
  51456. */
  51457. static readonly GAMEPAD_ID_PREFIX: string;
  51458. private readonly _buttonIndexToObservableNameMap;
  51459. /**
  51460. * Creates a new GearVRController from a gamepad
  51461. * @param vrGamepad the gamepad that the controller should be created from
  51462. */
  51463. constructor(vrGamepad: any);
  51464. /**
  51465. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51466. * @param scene scene in which to add meshes
  51467. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51468. */
  51469. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51470. /**
  51471. * Called once for each button that changed state since the last frame
  51472. * @param buttonIdx Which button index changed
  51473. * @param state New state of the button
  51474. * @param changes Which properties on the state changed since last frame
  51475. */
  51476. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51477. }
  51478. }
  51479. declare module BABYLON {
  51480. /**
  51481. * Generic Controller
  51482. */
  51483. export class GenericController extends WebVRController {
  51484. /**
  51485. * Base Url for the controller model.
  51486. */
  51487. static readonly MODEL_BASE_URL: string;
  51488. /**
  51489. * File name for the controller model.
  51490. */
  51491. static readonly MODEL_FILENAME: string;
  51492. /**
  51493. * Creates a new GenericController from a gamepad
  51494. * @param vrGamepad the gamepad that the controller should be created from
  51495. */
  51496. constructor(vrGamepad: any);
  51497. /**
  51498. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51499. * @param scene scene in which to add meshes
  51500. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51501. */
  51502. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51503. /**
  51504. * Called once for each button that changed state since the last frame
  51505. * @param buttonIdx Which button index changed
  51506. * @param state New state of the button
  51507. * @param changes Which properties on the state changed since last frame
  51508. */
  51509. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51510. }
  51511. }
  51512. declare module BABYLON {
  51513. /**
  51514. * Oculus Touch Controller
  51515. */
  51516. export class OculusTouchController extends WebVRController {
  51517. /**
  51518. * Base Url for the controller model.
  51519. */
  51520. static MODEL_BASE_URL: string;
  51521. /**
  51522. * File name for the left controller model.
  51523. */
  51524. static MODEL_LEFT_FILENAME: string;
  51525. /**
  51526. * File name for the right controller model.
  51527. */
  51528. static MODEL_RIGHT_FILENAME: string;
  51529. /**
  51530. * Base Url for the Quest controller model.
  51531. */
  51532. static QUEST_MODEL_BASE_URL: string;
  51533. /**
  51534. * @hidden
  51535. * If the controllers are running on a device that needs the updated Quest controller models
  51536. */
  51537. static _IsQuest: boolean;
  51538. /**
  51539. * Fired when the secondary trigger on this controller is modified
  51540. */
  51541. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51542. /**
  51543. * Fired when the thumb rest on this controller is modified
  51544. */
  51545. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51546. /**
  51547. * Creates a new OculusTouchController from a gamepad
  51548. * @param vrGamepad the gamepad that the controller should be created from
  51549. */
  51550. constructor(vrGamepad: any);
  51551. /**
  51552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51553. * @param scene scene in which to add meshes
  51554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51555. */
  51556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51557. /**
  51558. * Fired when the A button on this controller is modified
  51559. */
  51560. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51561. /**
  51562. * Fired when the B button on this controller is modified
  51563. */
  51564. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51565. /**
  51566. * Fired when the X button on this controller is modified
  51567. */
  51568. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51569. /**
  51570. * Fired when the Y button on this controller is modified
  51571. */
  51572. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51573. /**
  51574. * Called once for each button that changed state since the last frame
  51575. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51576. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51577. * 2) secondary trigger (same)
  51578. * 3) A (right) X (left), touch, pressed = value
  51579. * 4) B / Y
  51580. * 5) thumb rest
  51581. * @param buttonIdx Which button index changed
  51582. * @param state New state of the button
  51583. * @param changes Which properties on the state changed since last frame
  51584. */
  51585. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51586. }
  51587. }
  51588. declare module BABYLON {
  51589. /**
  51590. * Vive Controller
  51591. */
  51592. export class ViveController extends WebVRController {
  51593. /**
  51594. * Base Url for the controller model.
  51595. */
  51596. static MODEL_BASE_URL: string;
  51597. /**
  51598. * File name for the controller model.
  51599. */
  51600. static MODEL_FILENAME: string;
  51601. /**
  51602. * Creates a new ViveController from a gamepad
  51603. * @param vrGamepad the gamepad that the controller should be created from
  51604. */
  51605. constructor(vrGamepad: any);
  51606. /**
  51607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51608. * @param scene scene in which to add meshes
  51609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51610. */
  51611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51612. /**
  51613. * Fired when the left button on this controller is modified
  51614. */
  51615. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51616. /**
  51617. * Fired when the right button on this controller is modified
  51618. */
  51619. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51620. /**
  51621. * Fired when the menu button on this controller is modified
  51622. */
  51623. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51624. /**
  51625. * Called once for each button that changed state since the last frame
  51626. * Vive mapping:
  51627. * 0: touchpad
  51628. * 1: trigger
  51629. * 2: left AND right buttons
  51630. * 3: menu button
  51631. * @param buttonIdx Which button index changed
  51632. * @param state New state of the button
  51633. * @param changes Which properties on the state changed since last frame
  51634. */
  51635. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51636. }
  51637. }
  51638. declare module BABYLON {
  51639. /**
  51640. * Defines the WindowsMotionController object that the state of the windows motion controller
  51641. */
  51642. export class WindowsMotionController extends WebVRController {
  51643. /**
  51644. * The base url used to load the left and right controller models
  51645. */
  51646. static MODEL_BASE_URL: string;
  51647. /**
  51648. * The name of the left controller model file
  51649. */
  51650. static MODEL_LEFT_FILENAME: string;
  51651. /**
  51652. * The name of the right controller model file
  51653. */
  51654. static MODEL_RIGHT_FILENAME: string;
  51655. /**
  51656. * The controller name prefix for this controller type
  51657. */
  51658. static readonly GAMEPAD_ID_PREFIX: string;
  51659. /**
  51660. * The controller id pattern for this controller type
  51661. */
  51662. private static readonly GAMEPAD_ID_PATTERN;
  51663. private _loadedMeshInfo;
  51664. protected readonly _mapping: {
  51665. buttons: string[];
  51666. buttonMeshNames: {
  51667. trigger: string;
  51668. menu: string;
  51669. grip: string;
  51670. thumbstick: string;
  51671. trackpad: string;
  51672. };
  51673. buttonObservableNames: {
  51674. trigger: string;
  51675. menu: string;
  51676. grip: string;
  51677. thumbstick: string;
  51678. trackpad: string;
  51679. };
  51680. axisMeshNames: string[];
  51681. pointingPoseMeshName: string;
  51682. };
  51683. /**
  51684. * Fired when the trackpad on this controller is clicked
  51685. */
  51686. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51687. /**
  51688. * Fired when the trackpad on this controller is modified
  51689. */
  51690. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51691. /**
  51692. * The current x and y values of this controller's trackpad
  51693. */
  51694. trackpad: StickValues;
  51695. /**
  51696. * Creates a new WindowsMotionController from a gamepad
  51697. * @param vrGamepad the gamepad that the controller should be created from
  51698. */
  51699. constructor(vrGamepad: any);
  51700. /**
  51701. * Fired when the trigger on this controller is modified
  51702. */
  51703. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51704. /**
  51705. * Fired when the menu button on this controller is modified
  51706. */
  51707. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51708. /**
  51709. * Fired when the grip button on this controller is modified
  51710. */
  51711. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51712. /**
  51713. * Fired when the thumbstick button on this controller is modified
  51714. */
  51715. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51716. /**
  51717. * Fired when the touchpad button on this controller is modified
  51718. */
  51719. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51720. /**
  51721. * Fired when the touchpad values on this controller are modified
  51722. */
  51723. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51724. protected _updateTrackpad(): void;
  51725. /**
  51726. * Called once per frame by the engine.
  51727. */
  51728. update(): void;
  51729. /**
  51730. * Called once for each button that changed state since the last frame
  51731. * @param buttonIdx Which button index changed
  51732. * @param state New state of the button
  51733. * @param changes Which properties on the state changed since last frame
  51734. */
  51735. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51736. /**
  51737. * Moves the buttons on the controller mesh based on their current state
  51738. * @param buttonName the name of the button to move
  51739. * @param buttonValue the value of the button which determines the buttons new position
  51740. */
  51741. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51742. /**
  51743. * Moves the axis on the controller mesh based on its current state
  51744. * @param axis the index of the axis
  51745. * @param axisValue the value of the axis which determines the meshes new position
  51746. * @hidden
  51747. */
  51748. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51749. /**
  51750. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51751. * @param scene scene in which to add meshes
  51752. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51753. */
  51754. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51755. /**
  51756. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51757. * can be transformed by button presses and axes values, based on this._mapping.
  51758. *
  51759. * @param scene scene in which the meshes exist
  51760. * @param meshes list of meshes that make up the controller model to process
  51761. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51762. */
  51763. private processModel;
  51764. private createMeshInfo;
  51765. /**
  51766. * Gets the ray of the controller in the direction the controller is pointing
  51767. * @param length the length the resulting ray should be
  51768. * @returns a ray in the direction the controller is pointing
  51769. */
  51770. getForwardRay(length?: number): Ray;
  51771. /**
  51772. * Disposes of the controller
  51773. */
  51774. dispose(): void;
  51775. }
  51776. /**
  51777. * This class represents a new windows motion controller in XR.
  51778. */
  51779. export class XRWindowsMotionController extends WindowsMotionController {
  51780. /**
  51781. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51782. */
  51783. protected readonly _mapping: {
  51784. buttons: string[];
  51785. buttonMeshNames: {
  51786. trigger: string;
  51787. menu: string;
  51788. grip: string;
  51789. thumbstick: string;
  51790. trackpad: string;
  51791. };
  51792. buttonObservableNames: {
  51793. trigger: string;
  51794. menu: string;
  51795. grip: string;
  51796. thumbstick: string;
  51797. trackpad: string;
  51798. };
  51799. axisMeshNames: string[];
  51800. pointingPoseMeshName: string;
  51801. };
  51802. /**
  51803. * Construct a new XR-Based windows motion controller
  51804. *
  51805. * @param gamepadInfo the gamepad object from the browser
  51806. */
  51807. constructor(gamepadInfo: any);
  51808. /**
  51809. * holds the thumbstick values (X,Y)
  51810. */
  51811. thumbstickValues: StickValues;
  51812. /**
  51813. * Fired when the thumbstick on this controller is clicked
  51814. */
  51815. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51816. /**
  51817. * Fired when the thumbstick on this controller is modified
  51818. */
  51819. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51820. /**
  51821. * Fired when the touchpad button on this controller is modified
  51822. */
  51823. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51824. /**
  51825. * Fired when the touchpad values on this controller are modified
  51826. */
  51827. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51828. /**
  51829. * Fired when the thumbstick button on this controller is modified
  51830. * here to prevent breaking changes
  51831. */
  51832. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51833. /**
  51834. * updating the thumbstick(!) and not the trackpad.
  51835. * This is named this way due to the difference between WebVR and XR and to avoid
  51836. * changing the parent class.
  51837. */
  51838. protected _updateTrackpad(): void;
  51839. /**
  51840. * Disposes the class with joy
  51841. */
  51842. dispose(): void;
  51843. }
  51844. }
  51845. declare module BABYLON {
  51846. /**
  51847. * Class containing static functions to help procedurally build meshes
  51848. */
  51849. export class PolyhedronBuilder {
  51850. /**
  51851. * Creates a polyhedron mesh
  51852. * * 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
  51853. * * The parameter `size` (positive float, default 1) sets the polygon size
  51854. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51855. * * 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`
  51856. * * 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
  51857. * * 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)`)
  51858. * * 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
  51859. * * 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
  51860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51861. * * 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
  51862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51863. * @param name defines the name of the mesh
  51864. * @param options defines the options used to create the mesh
  51865. * @param scene defines the hosting scene
  51866. * @returns the polyhedron mesh
  51867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51868. */
  51869. static CreatePolyhedron(name: string, options: {
  51870. type?: number;
  51871. size?: number;
  51872. sizeX?: number;
  51873. sizeY?: number;
  51874. sizeZ?: number;
  51875. custom?: any;
  51876. faceUV?: Vector4[];
  51877. faceColors?: Color4[];
  51878. flat?: boolean;
  51879. updatable?: boolean;
  51880. sideOrientation?: number;
  51881. frontUVs?: Vector4;
  51882. backUVs?: Vector4;
  51883. }, scene?: Nullable<Scene>): Mesh;
  51884. }
  51885. }
  51886. declare module BABYLON {
  51887. /**
  51888. * Gizmo that enables scaling a mesh along 3 axis
  51889. */
  51890. export class ScaleGizmo extends Gizmo {
  51891. /**
  51892. * Internal gizmo used for interactions on the x axis
  51893. */
  51894. xGizmo: AxisScaleGizmo;
  51895. /**
  51896. * Internal gizmo used for interactions on the y axis
  51897. */
  51898. yGizmo: AxisScaleGizmo;
  51899. /**
  51900. * Internal gizmo used for interactions on the z axis
  51901. */
  51902. zGizmo: AxisScaleGizmo;
  51903. /**
  51904. * Internal gizmo used to scale all axis equally
  51905. */
  51906. uniformScaleGizmo: AxisScaleGizmo;
  51907. private _meshAttached;
  51908. private _updateGizmoRotationToMatchAttachedMesh;
  51909. private _snapDistance;
  51910. private _scaleRatio;
  51911. private _uniformScalingMesh;
  51912. private _octahedron;
  51913. private _sensitivity;
  51914. /** Fires an event when any of it's sub gizmos are dragged */
  51915. onDragStartObservable: Observable<unknown>;
  51916. /** Fires an event when any of it's sub gizmos are released from dragging */
  51917. onDragEndObservable: Observable<unknown>;
  51918. get attachedMesh(): Nullable<AbstractMesh>;
  51919. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51920. /**
  51921. * Creates a ScaleGizmo
  51922. * @param gizmoLayer The utility layer the gizmo will be added to
  51923. */
  51924. constructor(gizmoLayer?: UtilityLayerRenderer);
  51925. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51926. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51927. /**
  51928. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51929. */
  51930. set snapDistance(value: number);
  51931. get snapDistance(): number;
  51932. /**
  51933. * Ratio for the scale of the gizmo (Default: 1)
  51934. */
  51935. set scaleRatio(value: number);
  51936. get scaleRatio(): number;
  51937. /**
  51938. * Sensitivity factor for dragging (Default: 1)
  51939. */
  51940. set sensitivity(value: number);
  51941. get sensitivity(): number;
  51942. /**
  51943. * Disposes of the gizmo
  51944. */
  51945. dispose(): void;
  51946. }
  51947. }
  51948. declare module BABYLON {
  51949. /**
  51950. * Single axis scale gizmo
  51951. */
  51952. export class AxisScaleGizmo extends Gizmo {
  51953. /**
  51954. * Drag behavior responsible for the gizmos dragging interactions
  51955. */
  51956. dragBehavior: PointerDragBehavior;
  51957. private _pointerObserver;
  51958. /**
  51959. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51960. */
  51961. snapDistance: number;
  51962. /**
  51963. * Event that fires each time the gizmo snaps to a new location.
  51964. * * snapDistance is the the change in distance
  51965. */
  51966. onSnapObservable: Observable<{
  51967. snapDistance: number;
  51968. }>;
  51969. /**
  51970. * If the scaling operation should be done on all axis (default: false)
  51971. */
  51972. uniformScaling: boolean;
  51973. /**
  51974. * Custom sensitivity value for the drag strength
  51975. */
  51976. sensitivity: number;
  51977. private _isEnabled;
  51978. private _parent;
  51979. private _arrow;
  51980. private _coloredMaterial;
  51981. private _hoverMaterial;
  51982. /**
  51983. * Creates an AxisScaleGizmo
  51984. * @param gizmoLayer The utility layer the gizmo will be added to
  51985. * @param dragAxis The axis which the gizmo will be able to scale on
  51986. * @param color The color of the gizmo
  51987. */
  51988. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51990. /**
  51991. * If the gizmo is enabled
  51992. */
  51993. set isEnabled(value: boolean);
  51994. get isEnabled(): boolean;
  51995. /**
  51996. * Disposes of the gizmo
  51997. */
  51998. dispose(): void;
  51999. /**
  52000. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52001. * @param mesh The mesh to replace the default mesh of the gizmo
  52002. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52003. */
  52004. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52005. }
  52006. }
  52007. declare module BABYLON {
  52008. /**
  52009. * Bounding box gizmo
  52010. */
  52011. export class BoundingBoxGizmo extends Gizmo {
  52012. private _lineBoundingBox;
  52013. private _rotateSpheresParent;
  52014. private _scaleBoxesParent;
  52015. private _boundingDimensions;
  52016. private _renderObserver;
  52017. private _pointerObserver;
  52018. private _scaleDragSpeed;
  52019. private _tmpQuaternion;
  52020. private _tmpVector;
  52021. private _tmpRotationMatrix;
  52022. /**
  52023. * 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)
  52024. */
  52025. ignoreChildren: boolean;
  52026. /**
  52027. * 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)
  52028. */
  52029. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52030. /**
  52031. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52032. */
  52033. rotationSphereSize: number;
  52034. /**
  52035. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52036. */
  52037. scaleBoxSize: number;
  52038. /**
  52039. * 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)
  52040. */
  52041. fixedDragMeshScreenSize: boolean;
  52042. /**
  52043. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52044. */
  52045. fixedDragMeshScreenSizeDistanceFactor: number;
  52046. /**
  52047. * Fired when a rotation sphere or scale box is dragged
  52048. */
  52049. onDragStartObservable: Observable<{}>;
  52050. /**
  52051. * Fired when a scale box is dragged
  52052. */
  52053. onScaleBoxDragObservable: Observable<{}>;
  52054. /**
  52055. * Fired when a scale box drag is ended
  52056. */
  52057. onScaleBoxDragEndObservable: Observable<{}>;
  52058. /**
  52059. * Fired when a rotation sphere is dragged
  52060. */
  52061. onRotationSphereDragObservable: Observable<{}>;
  52062. /**
  52063. * Fired when a rotation sphere drag is ended
  52064. */
  52065. onRotationSphereDragEndObservable: Observable<{}>;
  52066. /**
  52067. * 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)
  52068. */
  52069. scalePivot: Nullable<Vector3>;
  52070. /**
  52071. * Mesh used as a pivot to rotate the attached mesh
  52072. */
  52073. private _anchorMesh;
  52074. private _existingMeshScale;
  52075. private _dragMesh;
  52076. private pointerDragBehavior;
  52077. private coloredMaterial;
  52078. private hoverColoredMaterial;
  52079. /**
  52080. * Sets the color of the bounding box gizmo
  52081. * @param color the color to set
  52082. */
  52083. setColor(color: Color3): void;
  52084. /**
  52085. * Creates an BoundingBoxGizmo
  52086. * @param gizmoLayer The utility layer the gizmo will be added to
  52087. * @param color The color of the gizmo
  52088. */
  52089. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52090. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52091. private _selectNode;
  52092. /**
  52093. * Updates the bounding box information for the Gizmo
  52094. */
  52095. updateBoundingBox(): void;
  52096. private _updateRotationSpheres;
  52097. private _updateScaleBoxes;
  52098. /**
  52099. * Enables rotation on the specified axis and disables rotation on the others
  52100. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52101. */
  52102. setEnabledRotationAxis(axis: string): void;
  52103. /**
  52104. * Enables/disables scaling
  52105. * @param enable if scaling should be enabled
  52106. * @param homogeneousScaling defines if scaling should only be homogeneous
  52107. */
  52108. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52109. private _updateDummy;
  52110. /**
  52111. * Enables a pointer drag behavior on the bounding box of the gizmo
  52112. */
  52113. enableDragBehavior(): void;
  52114. /**
  52115. * Disposes of the gizmo
  52116. */
  52117. dispose(): void;
  52118. /**
  52119. * 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)
  52120. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52121. * @returns the bounding box mesh with the passed in mesh as a child
  52122. */
  52123. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52124. /**
  52125. * CustomMeshes are not supported by this gizmo
  52126. * @param mesh The mesh to replace the default mesh of the gizmo
  52127. */
  52128. setCustomMesh(mesh: Mesh): void;
  52129. }
  52130. }
  52131. declare module BABYLON {
  52132. /**
  52133. * Single plane rotation gizmo
  52134. */
  52135. export class PlaneRotationGizmo extends Gizmo {
  52136. /**
  52137. * Drag behavior responsible for the gizmos dragging interactions
  52138. */
  52139. dragBehavior: PointerDragBehavior;
  52140. private _pointerObserver;
  52141. /**
  52142. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52143. */
  52144. snapDistance: number;
  52145. /**
  52146. * Event that fires each time the gizmo snaps to a new location.
  52147. * * snapDistance is the the change in distance
  52148. */
  52149. onSnapObservable: Observable<{
  52150. snapDistance: number;
  52151. }>;
  52152. private _isEnabled;
  52153. private _parent;
  52154. /**
  52155. * Creates a PlaneRotationGizmo
  52156. * @param gizmoLayer The utility layer the gizmo will be added to
  52157. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52158. * @param color The color of the gizmo
  52159. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52160. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52161. */
  52162. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52163. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52164. /**
  52165. * If the gizmo is enabled
  52166. */
  52167. set isEnabled(value: boolean);
  52168. get isEnabled(): boolean;
  52169. /**
  52170. * Disposes of the gizmo
  52171. */
  52172. dispose(): void;
  52173. }
  52174. }
  52175. declare module BABYLON {
  52176. /**
  52177. * Gizmo that enables rotating a mesh along 3 axis
  52178. */
  52179. export class RotationGizmo extends Gizmo {
  52180. /**
  52181. * Internal gizmo used for interactions on the x axis
  52182. */
  52183. xGizmo: PlaneRotationGizmo;
  52184. /**
  52185. * Internal gizmo used for interactions on the y axis
  52186. */
  52187. yGizmo: PlaneRotationGizmo;
  52188. /**
  52189. * Internal gizmo used for interactions on the z axis
  52190. */
  52191. zGizmo: PlaneRotationGizmo;
  52192. /** Fires an event when any of it's sub gizmos are dragged */
  52193. onDragStartObservable: Observable<unknown>;
  52194. /** Fires an event when any of it's sub gizmos are released from dragging */
  52195. onDragEndObservable: Observable<unknown>;
  52196. private _meshAttached;
  52197. get attachedMesh(): Nullable<AbstractMesh>;
  52198. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52199. /**
  52200. * Creates a RotationGizmo
  52201. * @param gizmoLayer The utility layer the gizmo will be added to
  52202. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52203. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52204. */
  52205. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52206. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52207. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52208. /**
  52209. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52210. */
  52211. set snapDistance(value: number);
  52212. get snapDistance(): number;
  52213. /**
  52214. * Ratio for the scale of the gizmo (Default: 1)
  52215. */
  52216. set scaleRatio(value: number);
  52217. get scaleRatio(): number;
  52218. /**
  52219. * Disposes of the gizmo
  52220. */
  52221. dispose(): void;
  52222. /**
  52223. * CustomMeshes are not supported by this gizmo
  52224. * @param mesh The mesh to replace the default mesh of the gizmo
  52225. */
  52226. setCustomMesh(mesh: Mesh): void;
  52227. }
  52228. }
  52229. declare module BABYLON {
  52230. /**
  52231. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52232. */
  52233. export class GizmoManager implements IDisposable {
  52234. private scene;
  52235. /**
  52236. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52237. */
  52238. gizmos: {
  52239. positionGizmo: Nullable<PositionGizmo>;
  52240. rotationGizmo: Nullable<RotationGizmo>;
  52241. scaleGizmo: Nullable<ScaleGizmo>;
  52242. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52243. };
  52244. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52245. clearGizmoOnEmptyPointerEvent: boolean;
  52246. /** Fires an event when the manager is attached to a mesh */
  52247. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52248. private _gizmosEnabled;
  52249. private _pointerObserver;
  52250. private _attachedMesh;
  52251. private _boundingBoxColor;
  52252. private _defaultUtilityLayer;
  52253. private _defaultKeepDepthUtilityLayer;
  52254. /**
  52255. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52256. */
  52257. boundingBoxDragBehavior: SixDofDragBehavior;
  52258. /**
  52259. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52260. */
  52261. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52262. /**
  52263. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52264. */
  52265. usePointerToAttachGizmos: boolean;
  52266. /**
  52267. * Utility layer that the bounding box gizmo belongs to
  52268. */
  52269. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52270. /**
  52271. * Utility layer that all gizmos besides bounding box belong to
  52272. */
  52273. get utilityLayer(): UtilityLayerRenderer;
  52274. /**
  52275. * Instatiates a gizmo manager
  52276. * @param scene the scene to overlay the gizmos on top of
  52277. */
  52278. constructor(scene: Scene);
  52279. /**
  52280. * Attaches a set of gizmos to the specified mesh
  52281. * @param mesh The mesh the gizmo's should be attached to
  52282. */
  52283. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52284. /**
  52285. * If the position gizmo is enabled
  52286. */
  52287. set positionGizmoEnabled(value: boolean);
  52288. get positionGizmoEnabled(): boolean;
  52289. /**
  52290. * If the rotation gizmo is enabled
  52291. */
  52292. set rotationGizmoEnabled(value: boolean);
  52293. get rotationGizmoEnabled(): boolean;
  52294. /**
  52295. * If the scale gizmo is enabled
  52296. */
  52297. set scaleGizmoEnabled(value: boolean);
  52298. get scaleGizmoEnabled(): boolean;
  52299. /**
  52300. * If the boundingBox gizmo is enabled
  52301. */
  52302. set boundingBoxGizmoEnabled(value: boolean);
  52303. get boundingBoxGizmoEnabled(): boolean;
  52304. /**
  52305. * Disposes of the gizmo manager
  52306. */
  52307. dispose(): void;
  52308. }
  52309. }
  52310. declare module BABYLON {
  52311. /**
  52312. * A directional light is defined by a direction (what a surprise!).
  52313. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52314. * 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.
  52315. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52316. */
  52317. export class DirectionalLight extends ShadowLight {
  52318. private _shadowFrustumSize;
  52319. /**
  52320. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52321. */
  52322. get shadowFrustumSize(): number;
  52323. /**
  52324. * Specifies a fix frustum size for the shadow generation.
  52325. */
  52326. set shadowFrustumSize(value: number);
  52327. private _shadowOrthoScale;
  52328. /**
  52329. * Gets the shadow projection scale against the optimal computed one.
  52330. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52331. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52332. */
  52333. get shadowOrthoScale(): number;
  52334. /**
  52335. * Sets the shadow projection scale against the optimal computed one.
  52336. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52337. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52338. */
  52339. set shadowOrthoScale(value: number);
  52340. /**
  52341. * Automatically compute the projection matrix to best fit (including all the casters)
  52342. * on each frame.
  52343. */
  52344. autoUpdateExtends: boolean;
  52345. /**
  52346. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52347. * on each frame. autoUpdateExtends must be set to true for this to work
  52348. */
  52349. autoCalcShadowZBounds: boolean;
  52350. private _orthoLeft;
  52351. private _orthoRight;
  52352. private _orthoTop;
  52353. private _orthoBottom;
  52354. /**
  52355. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52356. * The directional light is emitted from everywhere in the given direction.
  52357. * It can cast shadows.
  52358. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52359. * @param name The friendly name of the light
  52360. * @param direction The direction of the light
  52361. * @param scene The scene the light belongs to
  52362. */
  52363. constructor(name: string, direction: Vector3, scene: Scene);
  52364. /**
  52365. * Returns the string "DirectionalLight".
  52366. * @return The class name
  52367. */
  52368. getClassName(): string;
  52369. /**
  52370. * Returns the integer 1.
  52371. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52372. */
  52373. getTypeID(): number;
  52374. /**
  52375. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52376. * Returns the DirectionalLight Shadow projection matrix.
  52377. */
  52378. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52379. /**
  52380. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52381. * Returns the DirectionalLight Shadow projection matrix.
  52382. */
  52383. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52384. /**
  52385. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52386. * Returns the DirectionalLight Shadow projection matrix.
  52387. */
  52388. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52389. protected _buildUniformLayout(): void;
  52390. /**
  52391. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52392. * @param effect The effect to update
  52393. * @param lightIndex The index of the light in the effect to update
  52394. * @returns The directional light
  52395. */
  52396. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52397. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52398. /**
  52399. * Gets the minZ used for shadow according to both the scene and the light.
  52400. *
  52401. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52402. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52403. * @param activeCamera The camera we are returning the min for
  52404. * @returns the depth min z
  52405. */
  52406. getDepthMinZ(activeCamera: Camera): number;
  52407. /**
  52408. * Gets the maxZ used for shadow according to both the scene and the light.
  52409. *
  52410. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52411. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52412. * @param activeCamera The camera we are returning the max for
  52413. * @returns the depth max z
  52414. */
  52415. getDepthMaxZ(activeCamera: Camera): number;
  52416. /**
  52417. * Prepares the list of defines specific to the light type.
  52418. * @param defines the list of defines
  52419. * @param lightIndex defines the index of the light for the effect
  52420. */
  52421. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52422. }
  52423. }
  52424. declare module BABYLON {
  52425. /**
  52426. * Class containing static functions to help procedurally build meshes
  52427. */
  52428. export class HemisphereBuilder {
  52429. /**
  52430. * Creates a hemisphere mesh
  52431. * @param name defines the name of the mesh
  52432. * @param options defines the options used to create the mesh
  52433. * @param scene defines the hosting scene
  52434. * @returns the hemisphere mesh
  52435. */
  52436. static CreateHemisphere(name: string, options: {
  52437. segments?: number;
  52438. diameter?: number;
  52439. sideOrientation?: number;
  52440. }, scene: any): Mesh;
  52441. }
  52442. }
  52443. declare module BABYLON {
  52444. /**
  52445. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52446. * These values define a cone of light starting from the position, emitting toward the direction.
  52447. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52448. * and the exponent defines the speed of the decay of the light with distance (reach).
  52449. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52450. */
  52451. export class SpotLight extends ShadowLight {
  52452. private _angle;
  52453. private _innerAngle;
  52454. private _cosHalfAngle;
  52455. private _lightAngleScale;
  52456. private _lightAngleOffset;
  52457. /**
  52458. * Gets the cone angle of the spot light in Radians.
  52459. */
  52460. get angle(): number;
  52461. /**
  52462. * Sets the cone angle of the spot light in Radians.
  52463. */
  52464. set angle(value: number);
  52465. /**
  52466. * Only used in gltf falloff mode, this defines the angle where
  52467. * the directional falloff will start before cutting at angle which could be seen
  52468. * as outer angle.
  52469. */
  52470. get innerAngle(): number;
  52471. /**
  52472. * Only used in gltf falloff mode, this defines the angle where
  52473. * the directional falloff will start before cutting at angle which could be seen
  52474. * as outer angle.
  52475. */
  52476. set innerAngle(value: number);
  52477. private _shadowAngleScale;
  52478. /**
  52479. * Allows scaling the angle of the light for shadow generation only.
  52480. */
  52481. get shadowAngleScale(): number;
  52482. /**
  52483. * Allows scaling the angle of the light for shadow generation only.
  52484. */
  52485. set shadowAngleScale(value: number);
  52486. /**
  52487. * The light decay speed with the distance from the emission spot.
  52488. */
  52489. exponent: number;
  52490. private _projectionTextureMatrix;
  52491. /**
  52492. * Allows reading the projecton texture
  52493. */
  52494. get projectionTextureMatrix(): Matrix;
  52495. protected _projectionTextureLightNear: number;
  52496. /**
  52497. * Gets the near clip of the Spotlight for texture projection.
  52498. */
  52499. get projectionTextureLightNear(): number;
  52500. /**
  52501. * Sets the near clip of the Spotlight for texture projection.
  52502. */
  52503. set projectionTextureLightNear(value: number);
  52504. protected _projectionTextureLightFar: number;
  52505. /**
  52506. * Gets the far clip of the Spotlight for texture projection.
  52507. */
  52508. get projectionTextureLightFar(): number;
  52509. /**
  52510. * Sets the far clip of the Spotlight for texture projection.
  52511. */
  52512. set projectionTextureLightFar(value: number);
  52513. protected _projectionTextureUpDirection: Vector3;
  52514. /**
  52515. * Gets the Up vector of the Spotlight for texture projection.
  52516. */
  52517. get projectionTextureUpDirection(): Vector3;
  52518. /**
  52519. * Sets the Up vector of the Spotlight for texture projection.
  52520. */
  52521. set projectionTextureUpDirection(value: Vector3);
  52522. private _projectionTexture;
  52523. /**
  52524. * Gets the projection texture of the light.
  52525. */
  52526. get projectionTexture(): Nullable<BaseTexture>;
  52527. /**
  52528. * Sets the projection texture of the light.
  52529. */
  52530. set projectionTexture(value: Nullable<BaseTexture>);
  52531. private _projectionTextureViewLightDirty;
  52532. private _projectionTextureProjectionLightDirty;
  52533. private _projectionTextureDirty;
  52534. private _projectionTextureViewTargetVector;
  52535. private _projectionTextureViewLightMatrix;
  52536. private _projectionTextureProjectionLightMatrix;
  52537. private _projectionTextureScalingMatrix;
  52538. /**
  52539. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52540. * It can cast shadows.
  52541. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52542. * @param name The light friendly name
  52543. * @param position The position of the spot light in the scene
  52544. * @param direction The direction of the light in the scene
  52545. * @param angle The cone angle of the light in Radians
  52546. * @param exponent The light decay speed with the distance from the emission spot
  52547. * @param scene The scene the lights belongs to
  52548. */
  52549. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52550. /**
  52551. * Returns the string "SpotLight".
  52552. * @returns the class name
  52553. */
  52554. getClassName(): string;
  52555. /**
  52556. * Returns the integer 2.
  52557. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52558. */
  52559. getTypeID(): number;
  52560. /**
  52561. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52562. */
  52563. protected _setDirection(value: Vector3): void;
  52564. /**
  52565. * Overrides the position setter to recompute the projection texture view light Matrix.
  52566. */
  52567. protected _setPosition(value: Vector3): void;
  52568. /**
  52569. * 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.
  52570. * Returns the SpotLight.
  52571. */
  52572. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52573. protected _computeProjectionTextureViewLightMatrix(): void;
  52574. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52575. /**
  52576. * Main function for light texture projection matrix computing.
  52577. */
  52578. protected _computeProjectionTextureMatrix(): void;
  52579. protected _buildUniformLayout(): void;
  52580. private _computeAngleValues;
  52581. /**
  52582. * Sets the passed Effect "effect" with the Light textures.
  52583. * @param effect The effect to update
  52584. * @param lightIndex The index of the light in the effect to update
  52585. * @returns The light
  52586. */
  52587. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52588. /**
  52589. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52590. * @param effect The effect to update
  52591. * @param lightIndex The index of the light in the effect to update
  52592. * @returns The spot light
  52593. */
  52594. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52595. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52596. /**
  52597. * Disposes the light and the associated resources.
  52598. */
  52599. dispose(): void;
  52600. /**
  52601. * Prepares the list of defines specific to the light type.
  52602. * @param defines the list of defines
  52603. * @param lightIndex defines the index of the light for the effect
  52604. */
  52605. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52606. }
  52607. }
  52608. declare module BABYLON {
  52609. /**
  52610. * Gizmo that enables viewing a light
  52611. */
  52612. export class LightGizmo extends Gizmo {
  52613. private _lightMesh;
  52614. private _material;
  52615. private _cachedPosition;
  52616. private _cachedForward;
  52617. private _attachedMeshParent;
  52618. /**
  52619. * Creates a LightGizmo
  52620. * @param gizmoLayer The utility layer the gizmo will be added to
  52621. */
  52622. constructor(gizmoLayer?: UtilityLayerRenderer);
  52623. private _light;
  52624. /**
  52625. * The light that the gizmo is attached to
  52626. */
  52627. set light(light: Nullable<Light>);
  52628. get light(): Nullable<Light>;
  52629. /**
  52630. * Gets the material used to render the light gizmo
  52631. */
  52632. get material(): StandardMaterial;
  52633. /**
  52634. * @hidden
  52635. * Updates the gizmo to match the attached mesh's position/rotation
  52636. */
  52637. protected _update(): void;
  52638. private static _Scale;
  52639. /**
  52640. * Creates the lines for a light mesh
  52641. */
  52642. private static _CreateLightLines;
  52643. /**
  52644. * Disposes of the light gizmo
  52645. */
  52646. dispose(): void;
  52647. private static _CreateHemisphericLightMesh;
  52648. private static _CreatePointLightMesh;
  52649. private static _CreateSpotLightMesh;
  52650. private static _CreateDirectionalLightMesh;
  52651. }
  52652. }
  52653. declare module BABYLON {
  52654. /** @hidden */
  52655. export var backgroundFragmentDeclaration: {
  52656. name: string;
  52657. shader: string;
  52658. };
  52659. }
  52660. declare module BABYLON {
  52661. /** @hidden */
  52662. export var backgroundUboDeclaration: {
  52663. name: string;
  52664. shader: string;
  52665. };
  52666. }
  52667. declare module BABYLON {
  52668. /** @hidden */
  52669. export var backgroundPixelShader: {
  52670. name: string;
  52671. shader: string;
  52672. };
  52673. }
  52674. declare module BABYLON {
  52675. /** @hidden */
  52676. export var backgroundVertexDeclaration: {
  52677. name: string;
  52678. shader: string;
  52679. };
  52680. }
  52681. declare module BABYLON {
  52682. /** @hidden */
  52683. export var backgroundVertexShader: {
  52684. name: string;
  52685. shader: string;
  52686. };
  52687. }
  52688. declare module BABYLON {
  52689. /**
  52690. * Background material used to create an efficient environement around your scene.
  52691. */
  52692. export class BackgroundMaterial extends PushMaterial {
  52693. /**
  52694. * Standard reflectance value at parallel view angle.
  52695. */
  52696. static StandardReflectance0: number;
  52697. /**
  52698. * Standard reflectance value at grazing angle.
  52699. */
  52700. static StandardReflectance90: number;
  52701. protected _primaryColor: Color3;
  52702. /**
  52703. * Key light Color (multiply against the environement texture)
  52704. */
  52705. primaryColor: Color3;
  52706. protected __perceptualColor: Nullable<Color3>;
  52707. /**
  52708. * Experimental Internal Use Only.
  52709. *
  52710. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52711. * This acts as a helper to set the primary color to a more "human friendly" value.
  52712. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52713. * output color as close as possible from the chosen value.
  52714. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52715. * part of lighting setup.)
  52716. */
  52717. get _perceptualColor(): Nullable<Color3>;
  52718. set _perceptualColor(value: Nullable<Color3>);
  52719. protected _primaryColorShadowLevel: float;
  52720. /**
  52721. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52722. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52723. */
  52724. get primaryColorShadowLevel(): float;
  52725. set primaryColorShadowLevel(value: float);
  52726. protected _primaryColorHighlightLevel: float;
  52727. /**
  52728. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52729. * The primary color is used at the level chosen to define what the white area would look.
  52730. */
  52731. get primaryColorHighlightLevel(): float;
  52732. set primaryColorHighlightLevel(value: float);
  52733. protected _reflectionTexture: Nullable<BaseTexture>;
  52734. /**
  52735. * Reflection Texture used in the material.
  52736. * Should be author in a specific way for the best result (refer to the documentation).
  52737. */
  52738. reflectionTexture: Nullable<BaseTexture>;
  52739. protected _reflectionBlur: float;
  52740. /**
  52741. * Reflection Texture level of blur.
  52742. *
  52743. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52744. * texture twice.
  52745. */
  52746. reflectionBlur: float;
  52747. protected _diffuseTexture: Nullable<BaseTexture>;
  52748. /**
  52749. * Diffuse Texture used in the material.
  52750. * Should be author in a specific way for the best result (refer to the documentation).
  52751. */
  52752. diffuseTexture: Nullable<BaseTexture>;
  52753. protected _shadowLights: Nullable<IShadowLight[]>;
  52754. /**
  52755. * Specify the list of lights casting shadow on the material.
  52756. * All scene shadow lights will be included if null.
  52757. */
  52758. shadowLights: Nullable<IShadowLight[]>;
  52759. protected _shadowLevel: float;
  52760. /**
  52761. * Helps adjusting the shadow to a softer level if required.
  52762. * 0 means black shadows and 1 means no shadows.
  52763. */
  52764. shadowLevel: float;
  52765. protected _sceneCenter: Vector3;
  52766. /**
  52767. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52768. * It is usually zero but might be interesting to modify according to your setup.
  52769. */
  52770. sceneCenter: Vector3;
  52771. protected _opacityFresnel: boolean;
  52772. /**
  52773. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52774. * This helps ensuring a nice transition when the camera goes under the ground.
  52775. */
  52776. opacityFresnel: boolean;
  52777. protected _reflectionFresnel: boolean;
  52778. /**
  52779. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52780. * This helps adding a mirror texture on the ground.
  52781. */
  52782. reflectionFresnel: boolean;
  52783. protected _reflectionFalloffDistance: number;
  52784. /**
  52785. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52786. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52787. */
  52788. reflectionFalloffDistance: number;
  52789. protected _reflectionAmount: number;
  52790. /**
  52791. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52792. */
  52793. reflectionAmount: number;
  52794. protected _reflectionReflectance0: number;
  52795. /**
  52796. * This specifies the weight of the reflection at grazing angle.
  52797. */
  52798. reflectionReflectance0: number;
  52799. protected _reflectionReflectance90: number;
  52800. /**
  52801. * This specifies the weight of the reflection at a perpendicular point of view.
  52802. */
  52803. reflectionReflectance90: number;
  52804. /**
  52805. * Sets the reflection reflectance fresnel values according to the default standard
  52806. * empirically know to work well :-)
  52807. */
  52808. set reflectionStandardFresnelWeight(value: number);
  52809. protected _useRGBColor: boolean;
  52810. /**
  52811. * Helps to directly use the maps channels instead of their level.
  52812. */
  52813. useRGBColor: boolean;
  52814. protected _enableNoise: boolean;
  52815. /**
  52816. * This helps reducing the banding effect that could occur on the background.
  52817. */
  52818. enableNoise: boolean;
  52819. /**
  52820. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52821. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52822. * Recommended to be keep at 1.0 except for special cases.
  52823. */
  52824. get fovMultiplier(): number;
  52825. set fovMultiplier(value: number);
  52826. private _fovMultiplier;
  52827. /**
  52828. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52829. */
  52830. useEquirectangularFOV: boolean;
  52831. private _maxSimultaneousLights;
  52832. /**
  52833. * Number of Simultaneous lights allowed on the material.
  52834. */
  52835. maxSimultaneousLights: int;
  52836. /**
  52837. * Default configuration related to image processing available in the Background Material.
  52838. */
  52839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52840. /**
  52841. * Keep track of the image processing observer to allow dispose and replace.
  52842. */
  52843. private _imageProcessingObserver;
  52844. /**
  52845. * Attaches a new image processing configuration to the PBR Material.
  52846. * @param configuration (if null the scene configuration will be use)
  52847. */
  52848. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52849. /**
  52850. * Gets the image processing configuration used either in this material.
  52851. */
  52852. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52853. /**
  52854. * Sets the Default image processing configuration used either in the this material.
  52855. *
  52856. * If sets to null, the scene one is in use.
  52857. */
  52858. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52859. /**
  52860. * Gets wether the color curves effect is enabled.
  52861. */
  52862. get cameraColorCurvesEnabled(): boolean;
  52863. /**
  52864. * Sets wether the color curves effect is enabled.
  52865. */
  52866. set cameraColorCurvesEnabled(value: boolean);
  52867. /**
  52868. * Gets wether the color grading effect is enabled.
  52869. */
  52870. get cameraColorGradingEnabled(): boolean;
  52871. /**
  52872. * Gets wether the color grading effect is enabled.
  52873. */
  52874. set cameraColorGradingEnabled(value: boolean);
  52875. /**
  52876. * Gets wether tonemapping is enabled or not.
  52877. */
  52878. get cameraToneMappingEnabled(): boolean;
  52879. /**
  52880. * Sets wether tonemapping is enabled or not
  52881. */
  52882. set cameraToneMappingEnabled(value: boolean);
  52883. /**
  52884. * The camera exposure used on this material.
  52885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52886. * This corresponds to a photographic exposure.
  52887. */
  52888. get cameraExposure(): float;
  52889. /**
  52890. * The camera exposure used on this material.
  52891. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52892. * This corresponds to a photographic exposure.
  52893. */
  52894. set cameraExposure(value: float);
  52895. /**
  52896. * Gets The camera contrast used on this material.
  52897. */
  52898. get cameraContrast(): float;
  52899. /**
  52900. * Sets The camera contrast used on this material.
  52901. */
  52902. set cameraContrast(value: float);
  52903. /**
  52904. * Gets the Color Grading 2D Lookup Texture.
  52905. */
  52906. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52907. /**
  52908. * Sets the Color Grading 2D Lookup Texture.
  52909. */
  52910. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52911. /**
  52912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52914. * 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;
  52915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52916. */
  52917. get cameraColorCurves(): Nullable<ColorCurves>;
  52918. /**
  52919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52921. * 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;
  52922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52923. */
  52924. set cameraColorCurves(value: Nullable<ColorCurves>);
  52925. /**
  52926. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52927. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52928. */
  52929. switchToBGR: boolean;
  52930. private _renderTargets;
  52931. private _reflectionControls;
  52932. private _white;
  52933. private _primaryShadowColor;
  52934. private _primaryHighlightColor;
  52935. /**
  52936. * Instantiates a Background Material in the given scene
  52937. * @param name The friendly name of the material
  52938. * @param scene The scene to add the material to
  52939. */
  52940. constructor(name: string, scene: Scene);
  52941. /**
  52942. * Gets a boolean indicating that current material needs to register RTT
  52943. */
  52944. get hasRenderTargetTextures(): boolean;
  52945. /**
  52946. * The entire material has been created in order to prevent overdraw.
  52947. * @returns false
  52948. */
  52949. needAlphaTesting(): boolean;
  52950. /**
  52951. * The entire material has been created in order to prevent overdraw.
  52952. * @returns true if blending is enable
  52953. */
  52954. needAlphaBlending(): boolean;
  52955. /**
  52956. * Checks wether the material is ready to be rendered for a given mesh.
  52957. * @param mesh The mesh to render
  52958. * @param subMesh The submesh to check against
  52959. * @param useInstances Specify wether or not the material is used with instances
  52960. * @returns true if all the dependencies are ready (Textures, Effects...)
  52961. */
  52962. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52963. /**
  52964. * Compute the primary color according to the chosen perceptual color.
  52965. */
  52966. private _computePrimaryColorFromPerceptualColor;
  52967. /**
  52968. * Compute the highlights and shadow colors according to their chosen levels.
  52969. */
  52970. private _computePrimaryColors;
  52971. /**
  52972. * Build the uniform buffer used in the material.
  52973. */
  52974. buildUniformLayout(): void;
  52975. /**
  52976. * Unbind the material.
  52977. */
  52978. unbind(): void;
  52979. /**
  52980. * Bind only the world matrix to the material.
  52981. * @param world The world matrix to bind.
  52982. */
  52983. bindOnlyWorldMatrix(world: Matrix): void;
  52984. /**
  52985. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52986. * @param world The world matrix to bind.
  52987. * @param subMesh The submesh to bind for.
  52988. */
  52989. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52990. /**
  52991. * Checks to see if a texture is used in the material.
  52992. * @param texture - Base texture to use.
  52993. * @returns - Boolean specifying if a texture is used in the material.
  52994. */
  52995. hasTexture(texture: BaseTexture): boolean;
  52996. /**
  52997. * Dispose the material.
  52998. * @param forceDisposeEffect Force disposal of the associated effect.
  52999. * @param forceDisposeTextures Force disposal of the associated textures.
  53000. */
  53001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53002. /**
  53003. * Clones the material.
  53004. * @param name The cloned name.
  53005. * @returns The cloned material.
  53006. */
  53007. clone(name: string): BackgroundMaterial;
  53008. /**
  53009. * Serializes the current material to its JSON representation.
  53010. * @returns The JSON representation.
  53011. */
  53012. serialize(): any;
  53013. /**
  53014. * Gets the class name of the material
  53015. * @returns "BackgroundMaterial"
  53016. */
  53017. getClassName(): string;
  53018. /**
  53019. * Parse a JSON input to create back a background material.
  53020. * @param source The JSON data to parse
  53021. * @param scene The scene to create the parsed material in
  53022. * @param rootUrl The root url of the assets the material depends upon
  53023. * @returns the instantiated BackgroundMaterial.
  53024. */
  53025. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53026. }
  53027. }
  53028. declare module BABYLON {
  53029. /**
  53030. * Represents the different options available during the creation of
  53031. * a Environment helper.
  53032. *
  53033. * This can control the default ground, skybox and image processing setup of your scene.
  53034. */
  53035. export interface IEnvironmentHelperOptions {
  53036. /**
  53037. * Specifies whether or not to create a ground.
  53038. * True by default.
  53039. */
  53040. createGround: boolean;
  53041. /**
  53042. * Specifies the ground size.
  53043. * 15 by default.
  53044. */
  53045. groundSize: number;
  53046. /**
  53047. * The texture used on the ground for the main color.
  53048. * Comes from the BabylonJS CDN by default.
  53049. *
  53050. * Remarks: Can be either a texture or a url.
  53051. */
  53052. groundTexture: string | BaseTexture;
  53053. /**
  53054. * The color mixed in the ground texture by default.
  53055. * BabylonJS clearColor by default.
  53056. */
  53057. groundColor: Color3;
  53058. /**
  53059. * Specifies the ground opacity.
  53060. * 1 by default.
  53061. */
  53062. groundOpacity: number;
  53063. /**
  53064. * Enables the ground to receive shadows.
  53065. * True by default.
  53066. */
  53067. enableGroundShadow: boolean;
  53068. /**
  53069. * Helps preventing the shadow to be fully black on the ground.
  53070. * 0.5 by default.
  53071. */
  53072. groundShadowLevel: number;
  53073. /**
  53074. * Creates a mirror texture attach to the ground.
  53075. * false by default.
  53076. */
  53077. enableGroundMirror: boolean;
  53078. /**
  53079. * Specifies the ground mirror size ratio.
  53080. * 0.3 by default as the default kernel is 64.
  53081. */
  53082. groundMirrorSizeRatio: number;
  53083. /**
  53084. * Specifies the ground mirror blur kernel size.
  53085. * 64 by default.
  53086. */
  53087. groundMirrorBlurKernel: number;
  53088. /**
  53089. * Specifies the ground mirror visibility amount.
  53090. * 1 by default
  53091. */
  53092. groundMirrorAmount: number;
  53093. /**
  53094. * Specifies the ground mirror reflectance weight.
  53095. * This uses the standard weight of the background material to setup the fresnel effect
  53096. * of the mirror.
  53097. * 1 by default.
  53098. */
  53099. groundMirrorFresnelWeight: number;
  53100. /**
  53101. * Specifies the ground mirror Falloff distance.
  53102. * This can helps reducing the size of the reflection.
  53103. * 0 by Default.
  53104. */
  53105. groundMirrorFallOffDistance: number;
  53106. /**
  53107. * Specifies the ground mirror texture type.
  53108. * Unsigned Int by Default.
  53109. */
  53110. groundMirrorTextureType: number;
  53111. /**
  53112. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53113. * the shown objects.
  53114. */
  53115. groundYBias: number;
  53116. /**
  53117. * Specifies whether or not to create a skybox.
  53118. * True by default.
  53119. */
  53120. createSkybox: boolean;
  53121. /**
  53122. * Specifies the skybox size.
  53123. * 20 by default.
  53124. */
  53125. skyboxSize: number;
  53126. /**
  53127. * The texture used on the skybox for the main color.
  53128. * Comes from the BabylonJS CDN by default.
  53129. *
  53130. * Remarks: Can be either a texture or a url.
  53131. */
  53132. skyboxTexture: string | BaseTexture;
  53133. /**
  53134. * The color mixed in the skybox texture by default.
  53135. * BabylonJS clearColor by default.
  53136. */
  53137. skyboxColor: Color3;
  53138. /**
  53139. * The background rotation around the Y axis of the scene.
  53140. * This helps aligning the key lights of your scene with the background.
  53141. * 0 by default.
  53142. */
  53143. backgroundYRotation: number;
  53144. /**
  53145. * Compute automatically the size of the elements to best fit with the scene.
  53146. */
  53147. sizeAuto: boolean;
  53148. /**
  53149. * Default position of the rootMesh if autoSize is not true.
  53150. */
  53151. rootPosition: Vector3;
  53152. /**
  53153. * Sets up the image processing in the scene.
  53154. * true by default.
  53155. */
  53156. setupImageProcessing: boolean;
  53157. /**
  53158. * The texture used as your environment texture in the scene.
  53159. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53160. *
  53161. * Remarks: Can be either a texture or a url.
  53162. */
  53163. environmentTexture: string | BaseTexture;
  53164. /**
  53165. * The value of the exposure to apply to the scene.
  53166. * 0.6 by default if setupImageProcessing is true.
  53167. */
  53168. cameraExposure: number;
  53169. /**
  53170. * The value of the contrast to apply to the scene.
  53171. * 1.6 by default if setupImageProcessing is true.
  53172. */
  53173. cameraContrast: number;
  53174. /**
  53175. * Specifies whether or not tonemapping should be enabled in the scene.
  53176. * true by default if setupImageProcessing is true.
  53177. */
  53178. toneMappingEnabled: boolean;
  53179. }
  53180. /**
  53181. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53182. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53183. * It also helps with the default setup of your imageProcessing configuration.
  53184. */
  53185. export class EnvironmentHelper {
  53186. /**
  53187. * Default ground texture URL.
  53188. */
  53189. private static _groundTextureCDNUrl;
  53190. /**
  53191. * Default skybox texture URL.
  53192. */
  53193. private static _skyboxTextureCDNUrl;
  53194. /**
  53195. * Default environment texture URL.
  53196. */
  53197. private static _environmentTextureCDNUrl;
  53198. /**
  53199. * Creates the default options for the helper.
  53200. */
  53201. private static _getDefaultOptions;
  53202. private _rootMesh;
  53203. /**
  53204. * Gets the root mesh created by the helper.
  53205. */
  53206. get rootMesh(): Mesh;
  53207. private _skybox;
  53208. /**
  53209. * Gets the skybox created by the helper.
  53210. */
  53211. get skybox(): Nullable<Mesh>;
  53212. private _skyboxTexture;
  53213. /**
  53214. * Gets the skybox texture created by the helper.
  53215. */
  53216. get skyboxTexture(): Nullable<BaseTexture>;
  53217. private _skyboxMaterial;
  53218. /**
  53219. * Gets the skybox material created by the helper.
  53220. */
  53221. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53222. private _ground;
  53223. /**
  53224. * Gets the ground mesh created by the helper.
  53225. */
  53226. get ground(): Nullable<Mesh>;
  53227. private _groundTexture;
  53228. /**
  53229. * Gets the ground texture created by the helper.
  53230. */
  53231. get groundTexture(): Nullable<BaseTexture>;
  53232. private _groundMirror;
  53233. /**
  53234. * Gets the ground mirror created by the helper.
  53235. */
  53236. get groundMirror(): Nullable<MirrorTexture>;
  53237. /**
  53238. * Gets the ground mirror render list to helps pushing the meshes
  53239. * you wish in the ground reflection.
  53240. */
  53241. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53242. private _groundMaterial;
  53243. /**
  53244. * Gets the ground material created by the helper.
  53245. */
  53246. get groundMaterial(): Nullable<BackgroundMaterial>;
  53247. /**
  53248. * Stores the creation options.
  53249. */
  53250. private readonly _scene;
  53251. private _options;
  53252. /**
  53253. * This observable will be notified with any error during the creation of the environment,
  53254. * mainly texture creation errors.
  53255. */
  53256. onErrorObservable: Observable<{
  53257. message?: string;
  53258. exception?: any;
  53259. }>;
  53260. /**
  53261. * constructor
  53262. * @param options Defines the options we want to customize the helper
  53263. * @param scene The scene to add the material to
  53264. */
  53265. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53266. /**
  53267. * Updates the background according to the new options
  53268. * @param options
  53269. */
  53270. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53271. /**
  53272. * Sets the primary color of all the available elements.
  53273. * @param color the main color to affect to the ground and the background
  53274. */
  53275. setMainColor(color: Color3): void;
  53276. /**
  53277. * Setup the image processing according to the specified options.
  53278. */
  53279. private _setupImageProcessing;
  53280. /**
  53281. * Setup the environment texture according to the specified options.
  53282. */
  53283. private _setupEnvironmentTexture;
  53284. /**
  53285. * Setup the background according to the specified options.
  53286. */
  53287. private _setupBackground;
  53288. /**
  53289. * Get the scene sizes according to the setup.
  53290. */
  53291. private _getSceneSize;
  53292. /**
  53293. * Setup the ground according to the specified options.
  53294. */
  53295. private _setupGround;
  53296. /**
  53297. * Setup the ground material according to the specified options.
  53298. */
  53299. private _setupGroundMaterial;
  53300. /**
  53301. * Setup the ground diffuse texture according to the specified options.
  53302. */
  53303. private _setupGroundDiffuseTexture;
  53304. /**
  53305. * Setup the ground mirror texture according to the specified options.
  53306. */
  53307. private _setupGroundMirrorTexture;
  53308. /**
  53309. * Setup the ground to receive the mirror texture.
  53310. */
  53311. private _setupMirrorInGroundMaterial;
  53312. /**
  53313. * Setup the skybox according to the specified options.
  53314. */
  53315. private _setupSkybox;
  53316. /**
  53317. * Setup the skybox material according to the specified options.
  53318. */
  53319. private _setupSkyboxMaterial;
  53320. /**
  53321. * Setup the skybox reflection texture according to the specified options.
  53322. */
  53323. private _setupSkyboxReflectionTexture;
  53324. private _errorHandler;
  53325. /**
  53326. * Dispose all the elements created by the Helper.
  53327. */
  53328. dispose(): void;
  53329. }
  53330. }
  53331. declare module BABYLON {
  53332. /**
  53333. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53334. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53335. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53336. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53337. */
  53338. export class PhotoDome extends TransformNode {
  53339. /**
  53340. * Define the image as a Monoscopic panoramic 360 image.
  53341. */
  53342. static readonly MODE_MONOSCOPIC: number;
  53343. /**
  53344. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53345. */
  53346. static readonly MODE_TOPBOTTOM: number;
  53347. /**
  53348. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53349. */
  53350. static readonly MODE_SIDEBYSIDE: number;
  53351. private _useDirectMapping;
  53352. /**
  53353. * The texture being displayed on the sphere
  53354. */
  53355. protected _photoTexture: Texture;
  53356. /**
  53357. * Gets or sets the texture being displayed on the sphere
  53358. */
  53359. get photoTexture(): Texture;
  53360. set photoTexture(value: Texture);
  53361. /**
  53362. * Observable raised when an error occured while loading the 360 image
  53363. */
  53364. onLoadErrorObservable: Observable<string>;
  53365. /**
  53366. * The skybox material
  53367. */
  53368. protected _material: BackgroundMaterial;
  53369. /**
  53370. * The surface used for the skybox
  53371. */
  53372. protected _mesh: Mesh;
  53373. /**
  53374. * Gets the mesh used for the skybox.
  53375. */
  53376. get mesh(): Mesh;
  53377. /**
  53378. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53379. * Also see the options.resolution property.
  53380. */
  53381. get fovMultiplier(): number;
  53382. set fovMultiplier(value: number);
  53383. private _imageMode;
  53384. /**
  53385. * Gets or set the current video mode for the video. It can be:
  53386. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53387. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53388. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53389. */
  53390. get imageMode(): number;
  53391. set imageMode(value: number);
  53392. /**
  53393. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53394. * @param name Element's name, child elements will append suffixes for their own names.
  53395. * @param urlsOfPhoto defines the url of the photo to display
  53396. * @param options defines an object containing optional or exposed sub element properties
  53397. * @param onError defines a callback called when an error occured while loading the texture
  53398. */
  53399. constructor(name: string, urlOfPhoto: string, options: {
  53400. resolution?: number;
  53401. size?: number;
  53402. useDirectMapping?: boolean;
  53403. faceForward?: boolean;
  53404. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53405. private _onBeforeCameraRenderObserver;
  53406. private _changeImageMode;
  53407. /**
  53408. * Releases resources associated with this node.
  53409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53411. */
  53412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53413. }
  53414. }
  53415. declare module BABYLON {
  53416. /**
  53417. * Class used to host RGBD texture specific utilities
  53418. */
  53419. export class RGBDTextureTools {
  53420. /**
  53421. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53422. * @param texture the texture to expand.
  53423. */
  53424. static ExpandRGBDTexture(texture: Texture): void;
  53425. }
  53426. }
  53427. declare module BABYLON {
  53428. /**
  53429. * Class used to host texture specific utilities
  53430. */
  53431. export class BRDFTextureTools {
  53432. /**
  53433. * Prevents texture cache collision
  53434. */
  53435. private static _instanceNumber;
  53436. /**
  53437. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53438. * @param scene defines the hosting scene
  53439. * @returns the environment BRDF texture
  53440. */
  53441. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53442. private static _environmentBRDFBase64Texture;
  53443. }
  53444. }
  53445. declare module BABYLON {
  53446. /**
  53447. * @hidden
  53448. */
  53449. export interface IMaterialClearCoatDefines {
  53450. CLEARCOAT: boolean;
  53451. CLEARCOAT_DEFAULTIOR: boolean;
  53452. CLEARCOAT_TEXTURE: boolean;
  53453. CLEARCOAT_TEXTUREDIRECTUV: number;
  53454. CLEARCOAT_BUMP: boolean;
  53455. CLEARCOAT_BUMPDIRECTUV: number;
  53456. CLEARCOAT_TINT: boolean;
  53457. CLEARCOAT_TINT_TEXTURE: boolean;
  53458. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53459. /** @hidden */
  53460. _areTexturesDirty: boolean;
  53461. }
  53462. /**
  53463. * Define the code related to the clear coat parameters of the pbr material.
  53464. */
  53465. export class PBRClearCoatConfiguration {
  53466. /**
  53467. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53468. * The default fits with a polyurethane material.
  53469. */
  53470. private static readonly _DefaultIndexOfRefraction;
  53471. private _isEnabled;
  53472. /**
  53473. * Defines if the clear coat is enabled in the material.
  53474. */
  53475. isEnabled: boolean;
  53476. /**
  53477. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53478. */
  53479. intensity: number;
  53480. /**
  53481. * Defines the clear coat layer roughness.
  53482. */
  53483. roughness: number;
  53484. private _indexOfRefraction;
  53485. /**
  53486. * Defines the index of refraction of the clear coat.
  53487. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53488. * The default fits with a polyurethane material.
  53489. * Changing the default value is more performance intensive.
  53490. */
  53491. indexOfRefraction: number;
  53492. private _texture;
  53493. /**
  53494. * Stores the clear coat values in a texture.
  53495. */
  53496. texture: Nullable<BaseTexture>;
  53497. private _bumpTexture;
  53498. /**
  53499. * Define the clear coat specific bump texture.
  53500. */
  53501. bumpTexture: Nullable<BaseTexture>;
  53502. private _isTintEnabled;
  53503. /**
  53504. * Defines if the clear coat tint is enabled in the material.
  53505. */
  53506. isTintEnabled: boolean;
  53507. /**
  53508. * Defines the clear coat tint of the material.
  53509. * This is only use if tint is enabled
  53510. */
  53511. tintColor: Color3;
  53512. /**
  53513. * Defines the distance at which the tint color should be found in the
  53514. * clear coat media.
  53515. * This is only use if tint is enabled
  53516. */
  53517. tintColorAtDistance: number;
  53518. /**
  53519. * Defines the clear coat layer thickness.
  53520. * This is only use if tint is enabled
  53521. */
  53522. tintThickness: number;
  53523. private _tintTexture;
  53524. /**
  53525. * Stores the clear tint values in a texture.
  53526. * rgb is tint
  53527. * a is a thickness factor
  53528. */
  53529. tintTexture: Nullable<BaseTexture>;
  53530. /** @hidden */
  53531. private _internalMarkAllSubMeshesAsTexturesDirty;
  53532. /** @hidden */
  53533. _markAllSubMeshesAsTexturesDirty(): void;
  53534. /**
  53535. * Instantiate a new istance of clear coat configuration.
  53536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53537. */
  53538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53539. /**
  53540. * Gets wehter the submesh is ready to be used or not.
  53541. * @param defines the list of "defines" to update.
  53542. * @param scene defines the scene the material belongs to.
  53543. * @param engine defines the engine the material belongs to.
  53544. * @param disableBumpMap defines wether the material disables bump or not.
  53545. * @returns - boolean indicating that the submesh is ready or not.
  53546. */
  53547. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53548. /**
  53549. * Checks to see if a texture is used in the material.
  53550. * @param defines the list of "defines" to update.
  53551. * @param scene defines the scene to the material belongs to.
  53552. */
  53553. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53554. /**
  53555. * Binds the material data.
  53556. * @param uniformBuffer defines the Uniform buffer to fill in.
  53557. * @param scene defines the scene the material belongs to.
  53558. * @param engine defines the engine the material belongs to.
  53559. * @param disableBumpMap defines wether the material disables bump or not.
  53560. * @param isFrozen defines wether the material is frozen or not.
  53561. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53562. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53563. */
  53564. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53565. /**
  53566. * Checks to see if a texture is used in the material.
  53567. * @param texture - Base texture to use.
  53568. * @returns - Boolean specifying if a texture is used in the material.
  53569. */
  53570. hasTexture(texture: BaseTexture): boolean;
  53571. /**
  53572. * Returns an array of the actively used textures.
  53573. * @param activeTextures Array of BaseTextures
  53574. */
  53575. getActiveTextures(activeTextures: BaseTexture[]): void;
  53576. /**
  53577. * Returns the animatable textures.
  53578. * @param animatables Array of animatable textures.
  53579. */
  53580. getAnimatables(animatables: IAnimatable[]): void;
  53581. /**
  53582. * Disposes the resources of the material.
  53583. * @param forceDisposeTextures - Forces the disposal of all textures.
  53584. */
  53585. dispose(forceDisposeTextures?: boolean): void;
  53586. /**
  53587. * Get the current class name of the texture useful for serialization or dynamic coding.
  53588. * @returns "PBRClearCoatConfiguration"
  53589. */
  53590. getClassName(): string;
  53591. /**
  53592. * Add fallbacks to the effect fallbacks list.
  53593. * @param defines defines the Base texture to use.
  53594. * @param fallbacks defines the current fallback list.
  53595. * @param currentRank defines the current fallback rank.
  53596. * @returns the new fallback rank.
  53597. */
  53598. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53599. /**
  53600. * Add the required uniforms to the current list.
  53601. * @param uniforms defines the current uniform list.
  53602. */
  53603. static AddUniforms(uniforms: string[]): void;
  53604. /**
  53605. * Add the required samplers to the current list.
  53606. * @param samplers defines the current sampler list.
  53607. */
  53608. static AddSamplers(samplers: string[]): void;
  53609. /**
  53610. * Add the required uniforms to the current buffer.
  53611. * @param uniformBuffer defines the current uniform buffer.
  53612. */
  53613. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53614. /**
  53615. * Makes a duplicate of the current configuration into another one.
  53616. * @param clearCoatConfiguration define the config where to copy the info
  53617. */
  53618. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53619. /**
  53620. * Serializes this clear coat configuration.
  53621. * @returns - An object with the serialized config.
  53622. */
  53623. serialize(): any;
  53624. /**
  53625. * Parses a anisotropy Configuration from a serialized object.
  53626. * @param source - Serialized object.
  53627. * @param scene Defines the scene we are parsing for
  53628. * @param rootUrl Defines the rootUrl to load from
  53629. */
  53630. parse(source: any, scene: Scene, rootUrl: string): void;
  53631. }
  53632. }
  53633. declare module BABYLON {
  53634. /**
  53635. * @hidden
  53636. */
  53637. export interface IMaterialAnisotropicDefines {
  53638. ANISOTROPIC: boolean;
  53639. ANISOTROPIC_TEXTURE: boolean;
  53640. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53641. MAINUV1: boolean;
  53642. _areTexturesDirty: boolean;
  53643. _needUVs: boolean;
  53644. }
  53645. /**
  53646. * Define the code related to the anisotropic parameters of the pbr material.
  53647. */
  53648. export class PBRAnisotropicConfiguration {
  53649. private _isEnabled;
  53650. /**
  53651. * Defines if the anisotropy is enabled in the material.
  53652. */
  53653. isEnabled: boolean;
  53654. /**
  53655. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53656. */
  53657. intensity: number;
  53658. /**
  53659. * Defines if the effect is along the tangents, bitangents or in between.
  53660. * By default, the effect is "strectching" the highlights along the tangents.
  53661. */
  53662. direction: Vector2;
  53663. private _texture;
  53664. /**
  53665. * Stores the anisotropy values in a texture.
  53666. * rg is direction (like normal from -1 to 1)
  53667. * b is a intensity
  53668. */
  53669. texture: Nullable<BaseTexture>;
  53670. /** @hidden */
  53671. private _internalMarkAllSubMeshesAsTexturesDirty;
  53672. /** @hidden */
  53673. _markAllSubMeshesAsTexturesDirty(): void;
  53674. /**
  53675. * Instantiate a new istance of anisotropy configuration.
  53676. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53677. */
  53678. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53679. /**
  53680. * Specifies that the submesh is ready to be used.
  53681. * @param defines the list of "defines" to update.
  53682. * @param scene defines the scene the material belongs to.
  53683. * @returns - boolean indicating that the submesh is ready or not.
  53684. */
  53685. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53686. /**
  53687. * Checks to see if a texture is used in the material.
  53688. * @param defines the list of "defines" to update.
  53689. * @param mesh the mesh we are preparing the defines for.
  53690. * @param scene defines the scene the material belongs to.
  53691. */
  53692. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53693. /**
  53694. * Binds the material data.
  53695. * @param uniformBuffer defines the Uniform buffer to fill in.
  53696. * @param scene defines the scene the material belongs to.
  53697. * @param isFrozen defines wether the material is frozen or not.
  53698. */
  53699. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53700. /**
  53701. * Checks to see if a texture is used in the material.
  53702. * @param texture - Base texture to use.
  53703. * @returns - Boolean specifying if a texture is used in the material.
  53704. */
  53705. hasTexture(texture: BaseTexture): boolean;
  53706. /**
  53707. * Returns an array of the actively used textures.
  53708. * @param activeTextures Array of BaseTextures
  53709. */
  53710. getActiveTextures(activeTextures: BaseTexture[]): void;
  53711. /**
  53712. * Returns the animatable textures.
  53713. * @param animatables Array of animatable textures.
  53714. */
  53715. getAnimatables(animatables: IAnimatable[]): void;
  53716. /**
  53717. * Disposes the resources of the material.
  53718. * @param forceDisposeTextures - Forces the disposal of all textures.
  53719. */
  53720. dispose(forceDisposeTextures?: boolean): void;
  53721. /**
  53722. * Get the current class name of the texture useful for serialization or dynamic coding.
  53723. * @returns "PBRAnisotropicConfiguration"
  53724. */
  53725. getClassName(): string;
  53726. /**
  53727. * Add fallbacks to the effect fallbacks list.
  53728. * @param defines defines the Base texture to use.
  53729. * @param fallbacks defines the current fallback list.
  53730. * @param currentRank defines the current fallback rank.
  53731. * @returns the new fallback rank.
  53732. */
  53733. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53734. /**
  53735. * Add the required uniforms to the current list.
  53736. * @param uniforms defines the current uniform list.
  53737. */
  53738. static AddUniforms(uniforms: string[]): void;
  53739. /**
  53740. * Add the required uniforms to the current buffer.
  53741. * @param uniformBuffer defines the current uniform buffer.
  53742. */
  53743. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53744. /**
  53745. * Add the required samplers to the current list.
  53746. * @param samplers defines the current sampler list.
  53747. */
  53748. static AddSamplers(samplers: string[]): void;
  53749. /**
  53750. * Makes a duplicate of the current configuration into another one.
  53751. * @param anisotropicConfiguration define the config where to copy the info
  53752. */
  53753. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53754. /**
  53755. * Serializes this anisotropy configuration.
  53756. * @returns - An object with the serialized config.
  53757. */
  53758. serialize(): any;
  53759. /**
  53760. * Parses a anisotropy Configuration from a serialized object.
  53761. * @param source - Serialized object.
  53762. * @param scene Defines the scene we are parsing for
  53763. * @param rootUrl Defines the rootUrl to load from
  53764. */
  53765. parse(source: any, scene: Scene, rootUrl: string): void;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /**
  53770. * @hidden
  53771. */
  53772. export interface IMaterialBRDFDefines {
  53773. BRDF_V_HEIGHT_CORRELATED: boolean;
  53774. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53775. SPHERICAL_HARMONICS: boolean;
  53776. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53777. /** @hidden */
  53778. _areMiscDirty: boolean;
  53779. }
  53780. /**
  53781. * Define the code related to the BRDF parameters of the pbr material.
  53782. */
  53783. export class PBRBRDFConfiguration {
  53784. /**
  53785. * Default value used for the energy conservation.
  53786. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53787. */
  53788. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53789. /**
  53790. * Default value used for the Smith Visibility Height Correlated mode.
  53791. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53792. */
  53793. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53794. /**
  53795. * Default value used for the IBL diffuse part.
  53796. * This can help switching back to the polynomials mode globally which is a tiny bit
  53797. * less GPU intensive at the drawback of a lower quality.
  53798. */
  53799. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53800. /**
  53801. * Default value used for activating energy conservation for the specular workflow.
  53802. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53803. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53804. */
  53805. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53806. private _useEnergyConservation;
  53807. /**
  53808. * Defines if the material uses energy conservation.
  53809. */
  53810. useEnergyConservation: boolean;
  53811. private _useSmithVisibilityHeightCorrelated;
  53812. /**
  53813. * LEGACY Mode set to false
  53814. * Defines if the material uses height smith correlated visibility term.
  53815. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53816. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53817. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53818. * Not relying on height correlated will also disable energy conservation.
  53819. */
  53820. useSmithVisibilityHeightCorrelated: boolean;
  53821. private _useSphericalHarmonics;
  53822. /**
  53823. * LEGACY Mode set to false
  53824. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53825. * diffuse part of the IBL.
  53826. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53827. * to the ground truth.
  53828. */
  53829. useSphericalHarmonics: boolean;
  53830. private _useSpecularGlossinessInputEnergyConservation;
  53831. /**
  53832. * Defines if the material uses energy conservation, when the specular workflow is active.
  53833. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53834. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53835. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53836. */
  53837. useSpecularGlossinessInputEnergyConservation: boolean;
  53838. /** @hidden */
  53839. private _internalMarkAllSubMeshesAsMiscDirty;
  53840. /** @hidden */
  53841. _markAllSubMeshesAsMiscDirty(): void;
  53842. /**
  53843. * Instantiate a new istance of clear coat configuration.
  53844. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53845. */
  53846. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53847. /**
  53848. * Checks to see if a texture is used in the material.
  53849. * @param defines the list of "defines" to update.
  53850. */
  53851. prepareDefines(defines: IMaterialBRDFDefines): void;
  53852. /**
  53853. * Get the current class name of the texture useful for serialization or dynamic coding.
  53854. * @returns "PBRClearCoatConfiguration"
  53855. */
  53856. getClassName(): string;
  53857. /**
  53858. * Makes a duplicate of the current configuration into another one.
  53859. * @param brdfConfiguration define the config where to copy the info
  53860. */
  53861. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53862. /**
  53863. * Serializes this BRDF configuration.
  53864. * @returns - An object with the serialized config.
  53865. */
  53866. serialize(): any;
  53867. /**
  53868. * Parses a anisotropy Configuration from a serialized object.
  53869. * @param source - Serialized object.
  53870. * @param scene Defines the scene we are parsing for
  53871. * @param rootUrl Defines the rootUrl to load from
  53872. */
  53873. parse(source: any, scene: Scene, rootUrl: string): void;
  53874. }
  53875. }
  53876. declare module BABYLON {
  53877. /**
  53878. * @hidden
  53879. */
  53880. export interface IMaterialSheenDefines {
  53881. SHEEN: boolean;
  53882. SHEEN_TEXTURE: boolean;
  53883. SHEEN_TEXTUREDIRECTUV: number;
  53884. SHEEN_LINKWITHALBEDO: boolean;
  53885. SHEEN_ROUGHNESS: boolean;
  53886. SHEEN_ALBEDOSCALING: boolean;
  53887. /** @hidden */
  53888. _areTexturesDirty: boolean;
  53889. }
  53890. /**
  53891. * Define the code related to the Sheen parameters of the pbr material.
  53892. */
  53893. export class PBRSheenConfiguration {
  53894. private _isEnabled;
  53895. /**
  53896. * Defines if the material uses sheen.
  53897. */
  53898. isEnabled: boolean;
  53899. private _linkSheenWithAlbedo;
  53900. /**
  53901. * Defines if the sheen is linked to the sheen color.
  53902. */
  53903. linkSheenWithAlbedo: boolean;
  53904. /**
  53905. * Defines the sheen intensity.
  53906. */
  53907. intensity: number;
  53908. /**
  53909. * Defines the sheen color.
  53910. */
  53911. color: Color3;
  53912. private _texture;
  53913. /**
  53914. * Stores the sheen tint values in a texture.
  53915. * rgb is tint
  53916. * a is a intensity
  53917. */
  53918. texture: Nullable<BaseTexture>;
  53919. private _roughness;
  53920. /**
  53921. * Defines the sheen roughness.
  53922. * It is not taken into account if linkSheenWithAlbedo is true.
  53923. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53924. */
  53925. roughness: Nullable<number>;
  53926. private _albedoScaling;
  53927. /**
  53928. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53929. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53930. * making it easier to setup and tweak the effect
  53931. */
  53932. albedoScaling: boolean;
  53933. /** @hidden */
  53934. private _internalMarkAllSubMeshesAsTexturesDirty;
  53935. /** @hidden */
  53936. _markAllSubMeshesAsTexturesDirty(): void;
  53937. /**
  53938. * Instantiate a new istance of clear coat configuration.
  53939. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53940. */
  53941. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53942. /**
  53943. * Specifies that the submesh is ready to be used.
  53944. * @param defines the list of "defines" to update.
  53945. * @param scene defines the scene the material belongs to.
  53946. * @returns - boolean indicating that the submesh is ready or not.
  53947. */
  53948. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53949. /**
  53950. * Checks to see if a texture is used in the material.
  53951. * @param defines the list of "defines" to update.
  53952. * @param scene defines the scene the material belongs to.
  53953. */
  53954. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53955. /**
  53956. * Binds the material data.
  53957. * @param uniformBuffer defines the Uniform buffer to fill in.
  53958. * @param scene defines the scene the material belongs to.
  53959. * @param isFrozen defines wether the material is frozen or not.
  53960. */
  53961. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53962. /**
  53963. * Checks to see if a texture is used in the material.
  53964. * @param texture - Base texture to use.
  53965. * @returns - Boolean specifying if a texture is used in the material.
  53966. */
  53967. hasTexture(texture: BaseTexture): boolean;
  53968. /**
  53969. * Returns an array of the actively used textures.
  53970. * @param activeTextures Array of BaseTextures
  53971. */
  53972. getActiveTextures(activeTextures: BaseTexture[]): void;
  53973. /**
  53974. * Returns the animatable textures.
  53975. * @param animatables Array of animatable textures.
  53976. */
  53977. getAnimatables(animatables: IAnimatable[]): void;
  53978. /**
  53979. * Disposes the resources of the material.
  53980. * @param forceDisposeTextures - Forces the disposal of all textures.
  53981. */
  53982. dispose(forceDisposeTextures?: boolean): void;
  53983. /**
  53984. * Get the current class name of the texture useful for serialization or dynamic coding.
  53985. * @returns "PBRSheenConfiguration"
  53986. */
  53987. getClassName(): string;
  53988. /**
  53989. * Add fallbacks to the effect fallbacks list.
  53990. * @param defines defines the Base texture to use.
  53991. * @param fallbacks defines the current fallback list.
  53992. * @param currentRank defines the current fallback rank.
  53993. * @returns the new fallback rank.
  53994. */
  53995. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53996. /**
  53997. * Add the required uniforms to the current list.
  53998. * @param uniforms defines the current uniform list.
  53999. */
  54000. static AddUniforms(uniforms: string[]): void;
  54001. /**
  54002. * Add the required uniforms to the current buffer.
  54003. * @param uniformBuffer defines the current uniform buffer.
  54004. */
  54005. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54006. /**
  54007. * Add the required samplers to the current list.
  54008. * @param samplers defines the current sampler list.
  54009. */
  54010. static AddSamplers(samplers: string[]): void;
  54011. /**
  54012. * Makes a duplicate of the current configuration into another one.
  54013. * @param sheenConfiguration define the config where to copy the info
  54014. */
  54015. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54016. /**
  54017. * Serializes this BRDF configuration.
  54018. * @returns - An object with the serialized config.
  54019. */
  54020. serialize(): any;
  54021. /**
  54022. * Parses a anisotropy Configuration from a serialized object.
  54023. * @param source - Serialized object.
  54024. * @param scene Defines the scene we are parsing for
  54025. * @param rootUrl Defines the rootUrl to load from
  54026. */
  54027. parse(source: any, scene: Scene, rootUrl: string): void;
  54028. }
  54029. }
  54030. declare module BABYLON {
  54031. /**
  54032. * @hidden
  54033. */
  54034. export interface IMaterialSubSurfaceDefines {
  54035. SUBSURFACE: boolean;
  54036. SS_REFRACTION: boolean;
  54037. SS_TRANSLUCENCY: boolean;
  54038. SS_SCATERRING: boolean;
  54039. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54040. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54041. SS_REFRACTIONMAP_3D: boolean;
  54042. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54043. SS_LODINREFRACTIONALPHA: boolean;
  54044. SS_GAMMAREFRACTION: boolean;
  54045. SS_RGBDREFRACTION: boolean;
  54046. SS_LINEARSPECULARREFRACTION: boolean;
  54047. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54048. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54049. /** @hidden */
  54050. _areTexturesDirty: boolean;
  54051. }
  54052. /**
  54053. * Define the code related to the sub surface parameters of the pbr material.
  54054. */
  54055. export class PBRSubSurfaceConfiguration {
  54056. private _isRefractionEnabled;
  54057. /**
  54058. * Defines if the refraction is enabled in the material.
  54059. */
  54060. isRefractionEnabled: boolean;
  54061. private _isTranslucencyEnabled;
  54062. /**
  54063. * Defines if the translucency is enabled in the material.
  54064. */
  54065. isTranslucencyEnabled: boolean;
  54066. private _isScatteringEnabled;
  54067. /**
  54068. * Defines the refraction intensity of the material.
  54069. * The refraction when enabled replaces the Diffuse part of the material.
  54070. * The intensity helps transitionning between diffuse and refraction.
  54071. */
  54072. refractionIntensity: number;
  54073. /**
  54074. * Defines the translucency intensity of the material.
  54075. * When translucency has been enabled, this defines how much of the "translucency"
  54076. * is addded to the diffuse part of the material.
  54077. */
  54078. translucencyIntensity: number;
  54079. /**
  54080. * Defines the scattering intensity of the material.
  54081. * When scattering has been enabled, this defines how much of the "scattered light"
  54082. * is addded to the diffuse part of the material.
  54083. */
  54084. scatteringIntensity: number;
  54085. private _thicknessTexture;
  54086. /**
  54087. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54088. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54089. * 0 would mean minimumThickness
  54090. * 1 would mean maximumThickness
  54091. * The other channels might be use as a mask to vary the different effects intensity.
  54092. */
  54093. thicknessTexture: Nullable<BaseTexture>;
  54094. private _refractionTexture;
  54095. /**
  54096. * Defines the texture to use for refraction.
  54097. */
  54098. refractionTexture: Nullable<BaseTexture>;
  54099. private _indexOfRefraction;
  54100. /**
  54101. * Index of refraction of the material base layer.
  54102. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54103. *
  54104. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54105. *
  54106. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54107. */
  54108. indexOfRefraction: number;
  54109. private _invertRefractionY;
  54110. /**
  54111. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54112. */
  54113. invertRefractionY: boolean;
  54114. private _linkRefractionWithTransparency;
  54115. /**
  54116. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54117. * Materials half opaque for instance using refraction could benefit from this control.
  54118. */
  54119. linkRefractionWithTransparency: boolean;
  54120. /**
  54121. * Defines the minimum thickness stored in the thickness map.
  54122. * If no thickness map is defined, this value will be used to simulate thickness.
  54123. */
  54124. minimumThickness: number;
  54125. /**
  54126. * Defines the maximum thickness stored in the thickness map.
  54127. */
  54128. maximumThickness: number;
  54129. /**
  54130. * Defines the volume tint of the material.
  54131. * This is used for both translucency and scattering.
  54132. */
  54133. tintColor: Color3;
  54134. /**
  54135. * Defines the distance at which the tint color should be found in the media.
  54136. * This is used for refraction only.
  54137. */
  54138. tintColorAtDistance: number;
  54139. /**
  54140. * Defines how far each channel transmit through the media.
  54141. * It is defined as a color to simplify it selection.
  54142. */
  54143. diffusionDistance: Color3;
  54144. private _useMaskFromThicknessTexture;
  54145. /**
  54146. * Stores the intensity of the different subsurface effects in the thickness texture.
  54147. * * the green channel is the translucency intensity.
  54148. * * the blue channel is the scattering intensity.
  54149. * * the alpha channel is the refraction intensity.
  54150. */
  54151. useMaskFromThicknessTexture: boolean;
  54152. /** @hidden */
  54153. private _internalMarkAllSubMeshesAsTexturesDirty;
  54154. /** @hidden */
  54155. _markAllSubMeshesAsTexturesDirty(): void;
  54156. /**
  54157. * Instantiate a new istance of sub surface configuration.
  54158. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54159. */
  54160. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54161. /**
  54162. * Gets wehter the submesh is ready to be used or not.
  54163. * @param defines the list of "defines" to update.
  54164. * @param scene defines the scene the material belongs to.
  54165. * @returns - boolean indicating that the submesh is ready or not.
  54166. */
  54167. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54168. /**
  54169. * Checks to see if a texture is used in the material.
  54170. * @param defines the list of "defines" to update.
  54171. * @param scene defines the scene to the material belongs to.
  54172. */
  54173. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54174. /**
  54175. * Binds the material data.
  54176. * @param uniformBuffer defines the Uniform buffer to fill in.
  54177. * @param scene defines the scene the material belongs to.
  54178. * @param engine defines the engine the material belongs to.
  54179. * @param isFrozen defines whether the material is frozen or not.
  54180. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54181. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54182. */
  54183. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54184. /**
  54185. * Unbinds the material from the mesh.
  54186. * @param activeEffect defines the effect that should be unbound from.
  54187. * @returns true if unbound, otherwise false
  54188. */
  54189. unbind(activeEffect: Effect): boolean;
  54190. /**
  54191. * Returns the texture used for refraction or null if none is used.
  54192. * @param scene defines the scene the material belongs to.
  54193. * @returns - Refraction texture if present. If no refraction texture and refraction
  54194. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54195. */
  54196. private _getRefractionTexture;
  54197. /**
  54198. * Returns true if alpha blending should be disabled.
  54199. */
  54200. get disableAlphaBlending(): boolean;
  54201. /**
  54202. * Fills the list of render target textures.
  54203. * @param renderTargets the list of render targets to update
  54204. */
  54205. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54206. /**
  54207. * Checks to see if a texture is used in the material.
  54208. * @param texture - Base texture to use.
  54209. * @returns - Boolean specifying if a texture is used in the material.
  54210. */
  54211. hasTexture(texture: BaseTexture): boolean;
  54212. /**
  54213. * Gets a boolean indicating that current material needs to register RTT
  54214. * @returns true if this uses a render target otherwise false.
  54215. */
  54216. hasRenderTargetTextures(): boolean;
  54217. /**
  54218. * Returns an array of the actively used textures.
  54219. * @param activeTextures Array of BaseTextures
  54220. */
  54221. getActiveTextures(activeTextures: BaseTexture[]): void;
  54222. /**
  54223. * Returns the animatable textures.
  54224. * @param animatables Array of animatable textures.
  54225. */
  54226. getAnimatables(animatables: IAnimatable[]): void;
  54227. /**
  54228. * Disposes the resources of the material.
  54229. * @param forceDisposeTextures - Forces the disposal of all textures.
  54230. */
  54231. dispose(forceDisposeTextures?: boolean): void;
  54232. /**
  54233. * Get the current class name of the texture useful for serialization or dynamic coding.
  54234. * @returns "PBRSubSurfaceConfiguration"
  54235. */
  54236. getClassName(): string;
  54237. /**
  54238. * Add fallbacks to the effect fallbacks list.
  54239. * @param defines defines the Base texture to use.
  54240. * @param fallbacks defines the current fallback list.
  54241. * @param currentRank defines the current fallback rank.
  54242. * @returns the new fallback rank.
  54243. */
  54244. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54245. /**
  54246. * Add the required uniforms to the current list.
  54247. * @param uniforms defines the current uniform list.
  54248. */
  54249. static AddUniforms(uniforms: string[]): void;
  54250. /**
  54251. * Add the required samplers to the current list.
  54252. * @param samplers defines the current sampler list.
  54253. */
  54254. static AddSamplers(samplers: string[]): void;
  54255. /**
  54256. * Add the required uniforms to the current buffer.
  54257. * @param uniformBuffer defines the current uniform buffer.
  54258. */
  54259. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54260. /**
  54261. * Makes a duplicate of the current configuration into another one.
  54262. * @param configuration define the config where to copy the info
  54263. */
  54264. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54265. /**
  54266. * Serializes this Sub Surface configuration.
  54267. * @returns - An object with the serialized config.
  54268. */
  54269. serialize(): any;
  54270. /**
  54271. * Parses a anisotropy Configuration from a serialized object.
  54272. * @param source - Serialized object.
  54273. * @param scene Defines the scene we are parsing for
  54274. * @param rootUrl Defines the rootUrl to load from
  54275. */
  54276. parse(source: any, scene: Scene, rootUrl: string): void;
  54277. }
  54278. }
  54279. declare module BABYLON {
  54280. /** @hidden */
  54281. export var pbrFragmentDeclaration: {
  54282. name: string;
  54283. shader: string;
  54284. };
  54285. }
  54286. declare module BABYLON {
  54287. /** @hidden */
  54288. export var pbrUboDeclaration: {
  54289. name: string;
  54290. shader: string;
  54291. };
  54292. }
  54293. declare module BABYLON {
  54294. /** @hidden */
  54295. export var pbrFragmentExtraDeclaration: {
  54296. name: string;
  54297. shader: string;
  54298. };
  54299. }
  54300. declare module BABYLON {
  54301. /** @hidden */
  54302. export var pbrFragmentSamplersDeclaration: {
  54303. name: string;
  54304. shader: string;
  54305. };
  54306. }
  54307. declare module BABYLON {
  54308. /** @hidden */
  54309. export var importanceSampling: {
  54310. name: string;
  54311. shader: string;
  54312. };
  54313. }
  54314. declare module BABYLON {
  54315. /** @hidden */
  54316. export var pbrHelperFunctions: {
  54317. name: string;
  54318. shader: string;
  54319. };
  54320. }
  54321. declare module BABYLON {
  54322. /** @hidden */
  54323. export var harmonicsFunctions: {
  54324. name: string;
  54325. shader: string;
  54326. };
  54327. }
  54328. declare module BABYLON {
  54329. /** @hidden */
  54330. export var pbrDirectLightingSetupFunctions: {
  54331. name: string;
  54332. shader: string;
  54333. };
  54334. }
  54335. declare module BABYLON {
  54336. /** @hidden */
  54337. export var pbrDirectLightingFalloffFunctions: {
  54338. name: string;
  54339. shader: string;
  54340. };
  54341. }
  54342. declare module BABYLON {
  54343. /** @hidden */
  54344. export var pbrBRDFFunctions: {
  54345. name: string;
  54346. shader: string;
  54347. };
  54348. }
  54349. declare module BABYLON {
  54350. /** @hidden */
  54351. export var hdrFilteringFunctions: {
  54352. name: string;
  54353. shader: string;
  54354. };
  54355. }
  54356. declare module BABYLON {
  54357. /** @hidden */
  54358. export var pbrDirectLightingFunctions: {
  54359. name: string;
  54360. shader: string;
  54361. };
  54362. }
  54363. declare module BABYLON {
  54364. /** @hidden */
  54365. export var pbrIBLFunctions: {
  54366. name: string;
  54367. shader: string;
  54368. };
  54369. }
  54370. declare module BABYLON {
  54371. /** @hidden */
  54372. export var pbrBlockAlbedoOpacity: {
  54373. name: string;
  54374. shader: string;
  54375. };
  54376. }
  54377. declare module BABYLON {
  54378. /** @hidden */
  54379. export var pbrBlockReflectivity: {
  54380. name: string;
  54381. shader: string;
  54382. };
  54383. }
  54384. declare module BABYLON {
  54385. /** @hidden */
  54386. export var pbrBlockAmbientOcclusion: {
  54387. name: string;
  54388. shader: string;
  54389. };
  54390. }
  54391. declare module BABYLON {
  54392. /** @hidden */
  54393. export var pbrBlockAlphaFresnel: {
  54394. name: string;
  54395. shader: string;
  54396. };
  54397. }
  54398. declare module BABYLON {
  54399. /** @hidden */
  54400. export var pbrBlockAnisotropic: {
  54401. name: string;
  54402. shader: string;
  54403. };
  54404. }
  54405. declare module BABYLON {
  54406. /** @hidden */
  54407. export var pbrBlockReflection: {
  54408. name: string;
  54409. shader: string;
  54410. };
  54411. }
  54412. declare module BABYLON {
  54413. /** @hidden */
  54414. export var pbrBlockSheen: {
  54415. name: string;
  54416. shader: string;
  54417. };
  54418. }
  54419. declare module BABYLON {
  54420. /** @hidden */
  54421. export var pbrBlockClearcoat: {
  54422. name: string;
  54423. shader: string;
  54424. };
  54425. }
  54426. declare module BABYLON {
  54427. /** @hidden */
  54428. export var pbrBlockSubSurface: {
  54429. name: string;
  54430. shader: string;
  54431. };
  54432. }
  54433. declare module BABYLON {
  54434. /** @hidden */
  54435. export var pbrBlockNormalGeometric: {
  54436. name: string;
  54437. shader: string;
  54438. };
  54439. }
  54440. declare module BABYLON {
  54441. /** @hidden */
  54442. export var pbrBlockNormalFinal: {
  54443. name: string;
  54444. shader: string;
  54445. };
  54446. }
  54447. declare module BABYLON {
  54448. /** @hidden */
  54449. export var pbrBlockGeometryInfo: {
  54450. name: string;
  54451. shader: string;
  54452. };
  54453. }
  54454. declare module BABYLON {
  54455. /** @hidden */
  54456. export var pbrBlockReflectance0: {
  54457. name: string;
  54458. shader: string;
  54459. };
  54460. }
  54461. declare module BABYLON {
  54462. /** @hidden */
  54463. export var pbrBlockReflectance: {
  54464. name: string;
  54465. shader: string;
  54466. };
  54467. }
  54468. declare module BABYLON {
  54469. /** @hidden */
  54470. export var pbrBlockDirectLighting: {
  54471. name: string;
  54472. shader: string;
  54473. };
  54474. }
  54475. declare module BABYLON {
  54476. /** @hidden */
  54477. export var pbrBlockFinalLitComponents: {
  54478. name: string;
  54479. shader: string;
  54480. };
  54481. }
  54482. declare module BABYLON {
  54483. /** @hidden */
  54484. export var pbrBlockFinalUnlitComponents: {
  54485. name: string;
  54486. shader: string;
  54487. };
  54488. }
  54489. declare module BABYLON {
  54490. /** @hidden */
  54491. export var pbrBlockFinalColorComposition: {
  54492. name: string;
  54493. shader: string;
  54494. };
  54495. }
  54496. declare module BABYLON {
  54497. /** @hidden */
  54498. export var pbrBlockImageProcessing: {
  54499. name: string;
  54500. shader: string;
  54501. };
  54502. }
  54503. declare module BABYLON {
  54504. /** @hidden */
  54505. export var pbrDebug: {
  54506. name: string;
  54507. shader: string;
  54508. };
  54509. }
  54510. declare module BABYLON {
  54511. /** @hidden */
  54512. export var pbrPixelShader: {
  54513. name: string;
  54514. shader: string;
  54515. };
  54516. }
  54517. declare module BABYLON {
  54518. /** @hidden */
  54519. export var pbrVertexDeclaration: {
  54520. name: string;
  54521. shader: string;
  54522. };
  54523. }
  54524. declare module BABYLON {
  54525. /** @hidden */
  54526. export var pbrVertexShader: {
  54527. name: string;
  54528. shader: string;
  54529. };
  54530. }
  54531. declare module BABYLON {
  54532. /**
  54533. * Manages the defines for the PBR Material.
  54534. * @hidden
  54535. */
  54536. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54537. PBR: boolean;
  54538. NUM_SAMPLES: string;
  54539. REALTIME_FILTERING: boolean;
  54540. MAINUV1: boolean;
  54541. MAINUV2: boolean;
  54542. UV1: boolean;
  54543. UV2: boolean;
  54544. ALBEDO: boolean;
  54545. GAMMAALBEDO: boolean;
  54546. ALBEDODIRECTUV: number;
  54547. VERTEXCOLOR: boolean;
  54548. AMBIENT: boolean;
  54549. AMBIENTDIRECTUV: number;
  54550. AMBIENTINGRAYSCALE: boolean;
  54551. OPACITY: boolean;
  54552. VERTEXALPHA: boolean;
  54553. OPACITYDIRECTUV: number;
  54554. OPACITYRGB: boolean;
  54555. ALPHATEST: boolean;
  54556. DEPTHPREPASS: boolean;
  54557. ALPHABLEND: boolean;
  54558. ALPHAFROMALBEDO: boolean;
  54559. ALPHATESTVALUE: string;
  54560. SPECULAROVERALPHA: boolean;
  54561. RADIANCEOVERALPHA: boolean;
  54562. ALPHAFRESNEL: boolean;
  54563. LINEARALPHAFRESNEL: boolean;
  54564. PREMULTIPLYALPHA: boolean;
  54565. EMISSIVE: boolean;
  54566. EMISSIVEDIRECTUV: number;
  54567. REFLECTIVITY: boolean;
  54568. REFLECTIVITYDIRECTUV: number;
  54569. SPECULARTERM: boolean;
  54570. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54571. MICROSURFACEAUTOMATIC: boolean;
  54572. LODBASEDMICROSFURACE: boolean;
  54573. MICROSURFACEMAP: boolean;
  54574. MICROSURFACEMAPDIRECTUV: number;
  54575. METALLICWORKFLOW: boolean;
  54576. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54577. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54578. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54579. AOSTOREINMETALMAPRED: boolean;
  54580. METALLIC_REFLECTANCE: boolean;
  54581. METALLIC_REFLECTANCEDIRECTUV: number;
  54582. ENVIRONMENTBRDF: boolean;
  54583. ENVIRONMENTBRDF_RGBD: boolean;
  54584. NORMAL: boolean;
  54585. TANGENT: boolean;
  54586. BUMP: boolean;
  54587. BUMPDIRECTUV: number;
  54588. OBJECTSPACE_NORMALMAP: boolean;
  54589. PARALLAX: boolean;
  54590. PARALLAXOCCLUSION: boolean;
  54591. NORMALXYSCALE: boolean;
  54592. LIGHTMAP: boolean;
  54593. LIGHTMAPDIRECTUV: number;
  54594. USELIGHTMAPASSHADOWMAP: boolean;
  54595. GAMMALIGHTMAP: boolean;
  54596. RGBDLIGHTMAP: boolean;
  54597. REFLECTION: boolean;
  54598. REFLECTIONMAP_3D: boolean;
  54599. REFLECTIONMAP_SPHERICAL: boolean;
  54600. REFLECTIONMAP_PLANAR: boolean;
  54601. REFLECTIONMAP_CUBIC: boolean;
  54602. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54603. REFLECTIONMAP_PROJECTION: boolean;
  54604. REFLECTIONMAP_SKYBOX: boolean;
  54605. REFLECTIONMAP_EXPLICIT: boolean;
  54606. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54607. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54608. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54609. INVERTCUBICMAP: boolean;
  54610. USESPHERICALFROMREFLECTIONMAP: boolean;
  54611. USEIRRADIANCEMAP: boolean;
  54612. SPHERICAL_HARMONICS: boolean;
  54613. USESPHERICALINVERTEX: boolean;
  54614. REFLECTIONMAP_OPPOSITEZ: boolean;
  54615. LODINREFLECTIONALPHA: boolean;
  54616. GAMMAREFLECTION: boolean;
  54617. RGBDREFLECTION: boolean;
  54618. LINEARSPECULARREFLECTION: boolean;
  54619. RADIANCEOCCLUSION: boolean;
  54620. HORIZONOCCLUSION: boolean;
  54621. INSTANCES: boolean;
  54622. THIN_INSTANCES: boolean;
  54623. NUM_BONE_INFLUENCERS: number;
  54624. BonesPerMesh: number;
  54625. BONETEXTURE: boolean;
  54626. NONUNIFORMSCALING: boolean;
  54627. MORPHTARGETS: boolean;
  54628. MORPHTARGETS_NORMAL: boolean;
  54629. MORPHTARGETS_TANGENT: boolean;
  54630. MORPHTARGETS_UV: boolean;
  54631. NUM_MORPH_INFLUENCERS: number;
  54632. IMAGEPROCESSING: boolean;
  54633. VIGNETTE: boolean;
  54634. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54635. VIGNETTEBLENDMODEOPAQUE: boolean;
  54636. TONEMAPPING: boolean;
  54637. TONEMAPPING_ACES: boolean;
  54638. CONTRAST: boolean;
  54639. COLORCURVES: boolean;
  54640. COLORGRADING: boolean;
  54641. COLORGRADING3D: boolean;
  54642. SAMPLER3DGREENDEPTH: boolean;
  54643. SAMPLER3DBGRMAP: boolean;
  54644. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54645. EXPOSURE: boolean;
  54646. MULTIVIEW: boolean;
  54647. USEPHYSICALLIGHTFALLOFF: boolean;
  54648. USEGLTFLIGHTFALLOFF: boolean;
  54649. TWOSIDEDLIGHTING: boolean;
  54650. SHADOWFLOAT: boolean;
  54651. CLIPPLANE: boolean;
  54652. CLIPPLANE2: boolean;
  54653. CLIPPLANE3: boolean;
  54654. CLIPPLANE4: boolean;
  54655. CLIPPLANE5: boolean;
  54656. CLIPPLANE6: boolean;
  54657. POINTSIZE: boolean;
  54658. FOG: boolean;
  54659. LOGARITHMICDEPTH: boolean;
  54660. FORCENORMALFORWARD: boolean;
  54661. SPECULARAA: boolean;
  54662. CLEARCOAT: boolean;
  54663. CLEARCOAT_DEFAULTIOR: boolean;
  54664. CLEARCOAT_TEXTURE: boolean;
  54665. CLEARCOAT_TEXTUREDIRECTUV: number;
  54666. CLEARCOAT_BUMP: boolean;
  54667. CLEARCOAT_BUMPDIRECTUV: number;
  54668. CLEARCOAT_TINT: boolean;
  54669. CLEARCOAT_TINT_TEXTURE: boolean;
  54670. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54671. ANISOTROPIC: boolean;
  54672. ANISOTROPIC_TEXTURE: boolean;
  54673. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54674. BRDF_V_HEIGHT_CORRELATED: boolean;
  54675. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54676. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54677. SHEEN: boolean;
  54678. SHEEN_TEXTURE: boolean;
  54679. SHEEN_TEXTUREDIRECTUV: number;
  54680. SHEEN_LINKWITHALBEDO: boolean;
  54681. SHEEN_ROUGHNESS: boolean;
  54682. SHEEN_ALBEDOSCALING: boolean;
  54683. SUBSURFACE: boolean;
  54684. SS_REFRACTION: boolean;
  54685. SS_TRANSLUCENCY: boolean;
  54686. SS_SCATERRING: boolean;
  54687. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54688. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54689. SS_REFRACTIONMAP_3D: boolean;
  54690. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54691. SS_LODINREFRACTIONALPHA: boolean;
  54692. SS_GAMMAREFRACTION: boolean;
  54693. SS_RGBDREFRACTION: boolean;
  54694. SS_LINEARSPECULARREFRACTION: boolean;
  54695. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54696. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54697. UNLIT: boolean;
  54698. DEBUGMODE: number;
  54699. /**
  54700. * Initializes the PBR Material defines.
  54701. */
  54702. constructor();
  54703. /**
  54704. * Resets the PBR Material defines.
  54705. */
  54706. reset(): void;
  54707. }
  54708. /**
  54709. * The Physically based material base class of BJS.
  54710. *
  54711. * This offers the main features of a standard PBR material.
  54712. * For more information, please refer to the documentation :
  54713. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54714. */
  54715. export abstract class PBRBaseMaterial extends PushMaterial {
  54716. /**
  54717. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54718. */
  54719. static readonly PBRMATERIAL_OPAQUE: number;
  54720. /**
  54721. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54722. */
  54723. static readonly PBRMATERIAL_ALPHATEST: number;
  54724. /**
  54725. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54726. */
  54727. static readonly PBRMATERIAL_ALPHABLEND: number;
  54728. /**
  54729. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54730. * They are also discarded below the alpha cutoff threshold to improve performances.
  54731. */
  54732. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54733. /**
  54734. * Defines the default value of how much AO map is occluding the analytical lights
  54735. * (point spot...).
  54736. */
  54737. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54738. /**
  54739. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54740. */
  54741. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54742. /**
  54743. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54744. * to enhance interoperability with other engines.
  54745. */
  54746. static readonly LIGHTFALLOFF_GLTF: number;
  54747. /**
  54748. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54749. * to enhance interoperability with other materials.
  54750. */
  54751. static readonly LIGHTFALLOFF_STANDARD: number;
  54752. /**
  54753. * Intensity of the direct lights e.g. the four lights available in your scene.
  54754. * This impacts both the direct diffuse and specular highlights.
  54755. */
  54756. protected _directIntensity: number;
  54757. /**
  54758. * Intensity of the emissive part of the material.
  54759. * This helps controlling the emissive effect without modifying the emissive color.
  54760. */
  54761. protected _emissiveIntensity: number;
  54762. /**
  54763. * Intensity of the environment e.g. how much the environment will light the object
  54764. * either through harmonics for rough material or through the refelction for shiny ones.
  54765. */
  54766. protected _environmentIntensity: number;
  54767. /**
  54768. * This is a special control allowing the reduction of the specular highlights coming from the
  54769. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54770. */
  54771. protected _specularIntensity: number;
  54772. /**
  54773. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54774. */
  54775. private _lightingInfos;
  54776. /**
  54777. * Debug Control allowing disabling the bump map on this material.
  54778. */
  54779. protected _disableBumpMap: boolean;
  54780. /**
  54781. * AKA Diffuse Texture in standard nomenclature.
  54782. */
  54783. protected _albedoTexture: Nullable<BaseTexture>;
  54784. /**
  54785. * AKA Occlusion Texture in other nomenclature.
  54786. */
  54787. protected _ambientTexture: Nullable<BaseTexture>;
  54788. /**
  54789. * AKA Occlusion Texture Intensity in other nomenclature.
  54790. */
  54791. protected _ambientTextureStrength: number;
  54792. /**
  54793. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54794. * 1 means it completely occludes it
  54795. * 0 mean it has no impact
  54796. */
  54797. protected _ambientTextureImpactOnAnalyticalLights: number;
  54798. /**
  54799. * Stores the alpha values in a texture.
  54800. */
  54801. protected _opacityTexture: Nullable<BaseTexture>;
  54802. /**
  54803. * Stores the reflection values in a texture.
  54804. */
  54805. protected _reflectionTexture: Nullable<BaseTexture>;
  54806. /**
  54807. * Stores the emissive values in a texture.
  54808. */
  54809. protected _emissiveTexture: Nullable<BaseTexture>;
  54810. /**
  54811. * AKA Specular texture in other nomenclature.
  54812. */
  54813. protected _reflectivityTexture: Nullable<BaseTexture>;
  54814. /**
  54815. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54816. */
  54817. protected _metallicTexture: Nullable<BaseTexture>;
  54818. /**
  54819. * Specifies the metallic scalar of the metallic/roughness workflow.
  54820. * Can also be used to scale the metalness values of the metallic texture.
  54821. */
  54822. protected _metallic: Nullable<number>;
  54823. /**
  54824. * Specifies the roughness scalar of the metallic/roughness workflow.
  54825. * Can also be used to scale the roughness values of the metallic texture.
  54826. */
  54827. protected _roughness: Nullable<number>;
  54828. /**
  54829. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54830. * By default the indexOfrefraction is used to compute F0;
  54831. *
  54832. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54833. *
  54834. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54835. * F90 = metallicReflectanceColor;
  54836. */
  54837. protected _metallicF0Factor: number;
  54838. /**
  54839. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54840. * By default the F90 is always 1;
  54841. *
  54842. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54843. *
  54844. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54845. * F90 = metallicReflectanceColor;
  54846. */
  54847. protected _metallicReflectanceColor: Color3;
  54848. /**
  54849. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54850. * This is multiply against the scalar values defined in the material.
  54851. */
  54852. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54853. /**
  54854. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54855. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54856. */
  54857. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54858. /**
  54859. * Stores surface normal data used to displace a mesh in a texture.
  54860. */
  54861. protected _bumpTexture: Nullable<BaseTexture>;
  54862. /**
  54863. * Stores the pre-calculated light information of a mesh in a texture.
  54864. */
  54865. protected _lightmapTexture: Nullable<BaseTexture>;
  54866. /**
  54867. * The color of a material in ambient lighting.
  54868. */
  54869. protected _ambientColor: Color3;
  54870. /**
  54871. * AKA Diffuse Color in other nomenclature.
  54872. */
  54873. protected _albedoColor: Color3;
  54874. /**
  54875. * AKA Specular Color in other nomenclature.
  54876. */
  54877. protected _reflectivityColor: Color3;
  54878. /**
  54879. * The color applied when light is reflected from a material.
  54880. */
  54881. protected _reflectionColor: Color3;
  54882. /**
  54883. * The color applied when light is emitted from a material.
  54884. */
  54885. protected _emissiveColor: Color3;
  54886. /**
  54887. * AKA Glossiness in other nomenclature.
  54888. */
  54889. protected _microSurface: number;
  54890. /**
  54891. * Specifies that the material will use the light map as a show map.
  54892. */
  54893. protected _useLightmapAsShadowmap: boolean;
  54894. /**
  54895. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54896. * makes the reflect vector face the model (under horizon).
  54897. */
  54898. protected _useHorizonOcclusion: boolean;
  54899. /**
  54900. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54901. * too much the area relying on ambient texture to define their ambient occlusion.
  54902. */
  54903. protected _useRadianceOcclusion: boolean;
  54904. /**
  54905. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54906. */
  54907. protected _useAlphaFromAlbedoTexture: boolean;
  54908. /**
  54909. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54910. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54911. */
  54912. protected _useSpecularOverAlpha: boolean;
  54913. /**
  54914. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54915. */
  54916. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54917. /**
  54918. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54919. */
  54920. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54921. /**
  54922. * Specifies if the metallic texture contains the roughness information in its green channel.
  54923. */
  54924. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54925. /**
  54926. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54927. */
  54928. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54929. /**
  54930. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54931. */
  54932. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54933. /**
  54934. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54935. */
  54936. protected _useAmbientInGrayScale: boolean;
  54937. /**
  54938. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54939. * The material will try to infer what glossiness each pixel should be.
  54940. */
  54941. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54942. /**
  54943. * Defines the falloff type used in this material.
  54944. * It by default is Physical.
  54945. */
  54946. protected _lightFalloff: number;
  54947. /**
  54948. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54949. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54950. */
  54951. protected _useRadianceOverAlpha: boolean;
  54952. /**
  54953. * Allows using an object space normal map (instead of tangent space).
  54954. */
  54955. protected _useObjectSpaceNormalMap: boolean;
  54956. /**
  54957. * Allows using the bump map in parallax mode.
  54958. */
  54959. protected _useParallax: boolean;
  54960. /**
  54961. * Allows using the bump map in parallax occlusion mode.
  54962. */
  54963. protected _useParallaxOcclusion: boolean;
  54964. /**
  54965. * Controls the scale bias of the parallax mode.
  54966. */
  54967. protected _parallaxScaleBias: number;
  54968. /**
  54969. * If sets to true, disables all the lights affecting the material.
  54970. */
  54971. protected _disableLighting: boolean;
  54972. /**
  54973. * Number of Simultaneous lights allowed on the material.
  54974. */
  54975. protected _maxSimultaneousLights: number;
  54976. /**
  54977. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54978. */
  54979. protected _invertNormalMapX: boolean;
  54980. /**
  54981. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54982. */
  54983. protected _invertNormalMapY: boolean;
  54984. /**
  54985. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54986. */
  54987. protected _twoSidedLighting: boolean;
  54988. /**
  54989. * Defines the alpha limits in alpha test mode.
  54990. */
  54991. protected _alphaCutOff: number;
  54992. /**
  54993. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54994. */
  54995. protected _forceAlphaTest: boolean;
  54996. /**
  54997. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54998. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54999. */
  55000. protected _useAlphaFresnel: boolean;
  55001. /**
  55002. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55003. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55004. */
  55005. protected _useLinearAlphaFresnel: boolean;
  55006. /**
  55007. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55008. * from cos thetav and roughness:
  55009. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55010. */
  55011. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55012. /**
  55013. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55014. */
  55015. protected _forceIrradianceInFragment: boolean;
  55016. private _realTimeFiltering;
  55017. /**
  55018. * Enables realtime filtering on the texture.
  55019. */
  55020. get realTimeFiltering(): boolean;
  55021. set realTimeFiltering(b: boolean);
  55022. private _realTimeFilteringQuality;
  55023. /**
  55024. * Quality switch for realtime filtering
  55025. */
  55026. get realTimeFilteringQuality(): number;
  55027. set realTimeFilteringQuality(n: number);
  55028. /**
  55029. * Force normal to face away from face.
  55030. */
  55031. protected _forceNormalForward: boolean;
  55032. /**
  55033. * Enables specular anti aliasing in the PBR shader.
  55034. * It will both interacts on the Geometry for analytical and IBL lighting.
  55035. * It also prefilter the roughness map based on the bump values.
  55036. */
  55037. protected _enableSpecularAntiAliasing: boolean;
  55038. /**
  55039. * Default configuration related to image processing available in the PBR Material.
  55040. */
  55041. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55042. /**
  55043. * Keep track of the image processing observer to allow dispose and replace.
  55044. */
  55045. private _imageProcessingObserver;
  55046. /**
  55047. * Attaches a new image processing configuration to the PBR Material.
  55048. * @param configuration
  55049. */
  55050. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55051. /**
  55052. * Stores the available render targets.
  55053. */
  55054. private _renderTargets;
  55055. /**
  55056. * Sets the global ambient color for the material used in lighting calculations.
  55057. */
  55058. private _globalAmbientColor;
  55059. /**
  55060. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55061. */
  55062. private _useLogarithmicDepth;
  55063. /**
  55064. * If set to true, no lighting calculations will be applied.
  55065. */
  55066. private _unlit;
  55067. private _debugMode;
  55068. /**
  55069. * @hidden
  55070. * This is reserved for the inspector.
  55071. * Defines the material debug mode.
  55072. * It helps seeing only some components of the material while troubleshooting.
  55073. */
  55074. debugMode: number;
  55075. /**
  55076. * @hidden
  55077. * This is reserved for the inspector.
  55078. * Specify from where on screen the debug mode should start.
  55079. * The value goes from -1 (full screen) to 1 (not visible)
  55080. * It helps with side by side comparison against the final render
  55081. * This defaults to -1
  55082. */
  55083. private debugLimit;
  55084. /**
  55085. * @hidden
  55086. * This is reserved for the inspector.
  55087. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55088. * You can use the factor to better multiply the final value.
  55089. */
  55090. private debugFactor;
  55091. /**
  55092. * Defines the clear coat layer parameters for the material.
  55093. */
  55094. readonly clearCoat: PBRClearCoatConfiguration;
  55095. /**
  55096. * Defines the anisotropic parameters for the material.
  55097. */
  55098. readonly anisotropy: PBRAnisotropicConfiguration;
  55099. /**
  55100. * Defines the BRDF parameters for the material.
  55101. */
  55102. readonly brdf: PBRBRDFConfiguration;
  55103. /**
  55104. * Defines the Sheen parameters for the material.
  55105. */
  55106. readonly sheen: PBRSheenConfiguration;
  55107. /**
  55108. * Defines the SubSurface parameters for the material.
  55109. */
  55110. readonly subSurface: PBRSubSurfaceConfiguration;
  55111. protected _rebuildInParallel: boolean;
  55112. /**
  55113. * Instantiates a new PBRMaterial instance.
  55114. *
  55115. * @param name The material name
  55116. * @param scene The scene the material will be use in.
  55117. */
  55118. constructor(name: string, scene: Scene);
  55119. /**
  55120. * Gets a boolean indicating that current material needs to register RTT
  55121. */
  55122. get hasRenderTargetTextures(): boolean;
  55123. /**
  55124. * Gets the name of the material class.
  55125. */
  55126. getClassName(): string;
  55127. /**
  55128. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55129. */
  55130. get useLogarithmicDepth(): boolean;
  55131. /**
  55132. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55133. */
  55134. set useLogarithmicDepth(value: boolean);
  55135. /**
  55136. * Returns true if alpha blending should be disabled.
  55137. */
  55138. protected get _disableAlphaBlending(): boolean;
  55139. /**
  55140. * Specifies whether or not this material should be rendered in alpha blend mode.
  55141. */
  55142. needAlphaBlending(): boolean;
  55143. /**
  55144. * Specifies whether or not this material should be rendered in alpha test mode.
  55145. */
  55146. needAlphaTesting(): boolean;
  55147. /**
  55148. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55149. */
  55150. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55151. /**
  55152. * Gets the texture used for the alpha test.
  55153. */
  55154. getAlphaTestTexture(): Nullable<BaseTexture>;
  55155. /**
  55156. * Specifies that the submesh is ready to be used.
  55157. * @param mesh - BJS mesh.
  55158. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55159. * @param useInstances - Specifies that instances should be used.
  55160. * @returns - boolean indicating that the submesh is ready or not.
  55161. */
  55162. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55163. /**
  55164. * Specifies if the material uses metallic roughness workflow.
  55165. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55166. */
  55167. isMetallicWorkflow(): boolean;
  55168. private _prepareEffect;
  55169. private _prepareDefines;
  55170. /**
  55171. * Force shader compilation
  55172. */
  55173. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55174. /**
  55175. * Initializes the uniform buffer layout for the shader.
  55176. */
  55177. buildUniformLayout(): void;
  55178. /**
  55179. * Unbinds the material from the mesh
  55180. */
  55181. unbind(): void;
  55182. /**
  55183. * Binds the submesh data.
  55184. * @param world - The world matrix.
  55185. * @param mesh - The BJS mesh.
  55186. * @param subMesh - A submesh of the BJS mesh.
  55187. */
  55188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55189. /**
  55190. * Returns the animatable textures.
  55191. * @returns - Array of animatable textures.
  55192. */
  55193. getAnimatables(): IAnimatable[];
  55194. /**
  55195. * Returns the texture used for reflections.
  55196. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55197. */
  55198. private _getReflectionTexture;
  55199. /**
  55200. * Returns an array of the actively used textures.
  55201. * @returns - Array of BaseTextures
  55202. */
  55203. getActiveTextures(): BaseTexture[];
  55204. /**
  55205. * Checks to see if a texture is used in the material.
  55206. * @param texture - Base texture to use.
  55207. * @returns - Boolean specifying if a texture is used in the material.
  55208. */
  55209. hasTexture(texture: BaseTexture): boolean;
  55210. /**
  55211. * Disposes the resources of the material.
  55212. * @param forceDisposeEffect - Forces the disposal of effects.
  55213. * @param forceDisposeTextures - Forces the disposal of all textures.
  55214. */
  55215. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55216. }
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * The Physically based material of BJS.
  55221. *
  55222. * This offers the main features of a standard PBR material.
  55223. * For more information, please refer to the documentation :
  55224. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55225. */
  55226. export class PBRMaterial extends PBRBaseMaterial {
  55227. /**
  55228. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55229. */
  55230. static readonly PBRMATERIAL_OPAQUE: number;
  55231. /**
  55232. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55233. */
  55234. static readonly PBRMATERIAL_ALPHATEST: number;
  55235. /**
  55236. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55237. */
  55238. static readonly PBRMATERIAL_ALPHABLEND: number;
  55239. /**
  55240. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55241. * They are also discarded below the alpha cutoff threshold to improve performances.
  55242. */
  55243. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55244. /**
  55245. * Defines the default value of how much AO map is occluding the analytical lights
  55246. * (point spot...).
  55247. */
  55248. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55249. /**
  55250. * Intensity of the direct lights e.g. the four lights available in your scene.
  55251. * This impacts both the direct diffuse and specular highlights.
  55252. */
  55253. directIntensity: number;
  55254. /**
  55255. * Intensity of the emissive part of the material.
  55256. * This helps controlling the emissive effect without modifying the emissive color.
  55257. */
  55258. emissiveIntensity: number;
  55259. /**
  55260. * Intensity of the environment e.g. how much the environment will light the object
  55261. * either through harmonics for rough material or through the refelction for shiny ones.
  55262. */
  55263. environmentIntensity: number;
  55264. /**
  55265. * This is a special control allowing the reduction of the specular highlights coming from the
  55266. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55267. */
  55268. specularIntensity: number;
  55269. /**
  55270. * Debug Control allowing disabling the bump map on this material.
  55271. */
  55272. disableBumpMap: boolean;
  55273. /**
  55274. * AKA Diffuse Texture in standard nomenclature.
  55275. */
  55276. albedoTexture: BaseTexture;
  55277. /**
  55278. * AKA Occlusion Texture in other nomenclature.
  55279. */
  55280. ambientTexture: BaseTexture;
  55281. /**
  55282. * AKA Occlusion Texture Intensity in other nomenclature.
  55283. */
  55284. ambientTextureStrength: number;
  55285. /**
  55286. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55287. * 1 means it completely occludes it
  55288. * 0 mean it has no impact
  55289. */
  55290. ambientTextureImpactOnAnalyticalLights: number;
  55291. /**
  55292. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55293. */
  55294. opacityTexture: BaseTexture;
  55295. /**
  55296. * Stores the reflection values in a texture.
  55297. */
  55298. reflectionTexture: Nullable<BaseTexture>;
  55299. /**
  55300. * Stores the emissive values in a texture.
  55301. */
  55302. emissiveTexture: BaseTexture;
  55303. /**
  55304. * AKA Specular texture in other nomenclature.
  55305. */
  55306. reflectivityTexture: BaseTexture;
  55307. /**
  55308. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55309. */
  55310. metallicTexture: BaseTexture;
  55311. /**
  55312. * Specifies the metallic scalar of the metallic/roughness workflow.
  55313. * Can also be used to scale the metalness values of the metallic texture.
  55314. */
  55315. metallic: Nullable<number>;
  55316. /**
  55317. * Specifies the roughness scalar of the metallic/roughness workflow.
  55318. * Can also be used to scale the roughness values of the metallic texture.
  55319. */
  55320. roughness: Nullable<number>;
  55321. /**
  55322. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55323. * By default the indexOfrefraction is used to compute F0;
  55324. *
  55325. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55326. *
  55327. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55328. * F90 = metallicReflectanceColor;
  55329. */
  55330. metallicF0Factor: number;
  55331. /**
  55332. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55333. * By default the F90 is always 1;
  55334. *
  55335. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55336. *
  55337. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55338. * F90 = metallicReflectanceColor;
  55339. */
  55340. metallicReflectanceColor: Color3;
  55341. /**
  55342. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55343. * This is multiply against the scalar values defined in the material.
  55344. */
  55345. metallicReflectanceTexture: Nullable<BaseTexture>;
  55346. /**
  55347. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55348. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55349. */
  55350. microSurfaceTexture: BaseTexture;
  55351. /**
  55352. * Stores surface normal data used to displace a mesh in a texture.
  55353. */
  55354. bumpTexture: BaseTexture;
  55355. /**
  55356. * Stores the pre-calculated light information of a mesh in a texture.
  55357. */
  55358. lightmapTexture: BaseTexture;
  55359. /**
  55360. * Stores the refracted light information in a texture.
  55361. */
  55362. get refractionTexture(): Nullable<BaseTexture>;
  55363. set refractionTexture(value: Nullable<BaseTexture>);
  55364. /**
  55365. * The color of a material in ambient lighting.
  55366. */
  55367. ambientColor: Color3;
  55368. /**
  55369. * AKA Diffuse Color in other nomenclature.
  55370. */
  55371. albedoColor: Color3;
  55372. /**
  55373. * AKA Specular Color in other nomenclature.
  55374. */
  55375. reflectivityColor: Color3;
  55376. /**
  55377. * The color reflected from the material.
  55378. */
  55379. reflectionColor: Color3;
  55380. /**
  55381. * The color emitted from the material.
  55382. */
  55383. emissiveColor: Color3;
  55384. /**
  55385. * AKA Glossiness in other nomenclature.
  55386. */
  55387. microSurface: number;
  55388. /**
  55389. * Index of refraction of the material base layer.
  55390. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55391. *
  55392. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55393. *
  55394. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55395. */
  55396. get indexOfRefraction(): number;
  55397. set indexOfRefraction(value: number);
  55398. /**
  55399. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55400. */
  55401. get invertRefractionY(): boolean;
  55402. set invertRefractionY(value: boolean);
  55403. /**
  55404. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55405. * Materials half opaque for instance using refraction could benefit from this control.
  55406. */
  55407. get linkRefractionWithTransparency(): boolean;
  55408. set linkRefractionWithTransparency(value: boolean);
  55409. /**
  55410. * If true, the light map contains occlusion information instead of lighting info.
  55411. */
  55412. useLightmapAsShadowmap: boolean;
  55413. /**
  55414. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55415. */
  55416. useAlphaFromAlbedoTexture: boolean;
  55417. /**
  55418. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55419. */
  55420. forceAlphaTest: boolean;
  55421. /**
  55422. * Defines the alpha limits in alpha test mode.
  55423. */
  55424. alphaCutOff: number;
  55425. /**
  55426. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55427. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55428. */
  55429. useSpecularOverAlpha: boolean;
  55430. /**
  55431. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55432. */
  55433. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55434. /**
  55435. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55436. */
  55437. useRoughnessFromMetallicTextureAlpha: boolean;
  55438. /**
  55439. * Specifies if the metallic texture contains the roughness information in its green channel.
  55440. */
  55441. useRoughnessFromMetallicTextureGreen: boolean;
  55442. /**
  55443. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55444. */
  55445. useMetallnessFromMetallicTextureBlue: boolean;
  55446. /**
  55447. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55448. */
  55449. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55450. /**
  55451. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55452. */
  55453. useAmbientInGrayScale: boolean;
  55454. /**
  55455. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55456. * The material will try to infer what glossiness each pixel should be.
  55457. */
  55458. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55459. /**
  55460. * BJS is using an harcoded light falloff based on a manually sets up range.
  55461. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55462. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55463. */
  55464. get usePhysicalLightFalloff(): boolean;
  55465. /**
  55466. * BJS is using an harcoded light falloff based on a manually sets up range.
  55467. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55468. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55469. */
  55470. set usePhysicalLightFalloff(value: boolean);
  55471. /**
  55472. * In order to support the falloff compatibility with gltf, a special mode has been added
  55473. * to reproduce the gltf light falloff.
  55474. */
  55475. get useGLTFLightFalloff(): boolean;
  55476. /**
  55477. * In order to support the falloff compatibility with gltf, a special mode has been added
  55478. * to reproduce the gltf light falloff.
  55479. */
  55480. set useGLTFLightFalloff(value: boolean);
  55481. /**
  55482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55484. */
  55485. useRadianceOverAlpha: boolean;
  55486. /**
  55487. * Allows using an object space normal map (instead of tangent space).
  55488. */
  55489. useObjectSpaceNormalMap: boolean;
  55490. /**
  55491. * Allows using the bump map in parallax mode.
  55492. */
  55493. useParallax: boolean;
  55494. /**
  55495. * Allows using the bump map in parallax occlusion mode.
  55496. */
  55497. useParallaxOcclusion: boolean;
  55498. /**
  55499. * Controls the scale bias of the parallax mode.
  55500. */
  55501. parallaxScaleBias: number;
  55502. /**
  55503. * If sets to true, disables all the lights affecting the material.
  55504. */
  55505. disableLighting: boolean;
  55506. /**
  55507. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55508. */
  55509. forceIrradianceInFragment: boolean;
  55510. /**
  55511. * Number of Simultaneous lights allowed on the material.
  55512. */
  55513. maxSimultaneousLights: number;
  55514. /**
  55515. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55516. */
  55517. invertNormalMapX: boolean;
  55518. /**
  55519. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55520. */
  55521. invertNormalMapY: boolean;
  55522. /**
  55523. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55524. */
  55525. twoSidedLighting: boolean;
  55526. /**
  55527. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55528. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55529. */
  55530. useAlphaFresnel: boolean;
  55531. /**
  55532. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55533. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55534. */
  55535. useLinearAlphaFresnel: boolean;
  55536. /**
  55537. * Let user defines the brdf lookup texture used for IBL.
  55538. * A default 8bit version is embedded but you could point at :
  55539. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55540. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55541. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55542. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55543. */
  55544. environmentBRDFTexture: Nullable<BaseTexture>;
  55545. /**
  55546. * Force normal to face away from face.
  55547. */
  55548. forceNormalForward: boolean;
  55549. /**
  55550. * Enables specular anti aliasing in the PBR shader.
  55551. * It will both interacts on the Geometry for analytical and IBL lighting.
  55552. * It also prefilter the roughness map based on the bump values.
  55553. */
  55554. enableSpecularAntiAliasing: boolean;
  55555. /**
  55556. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55557. * makes the reflect vector face the model (under horizon).
  55558. */
  55559. useHorizonOcclusion: boolean;
  55560. /**
  55561. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55562. * too much the area relying on ambient texture to define their ambient occlusion.
  55563. */
  55564. useRadianceOcclusion: boolean;
  55565. /**
  55566. * If set to true, no lighting calculations will be applied.
  55567. */
  55568. unlit: boolean;
  55569. /**
  55570. * Gets the image processing configuration used either in this material.
  55571. */
  55572. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55573. /**
  55574. * Sets the Default image processing configuration used either in the this material.
  55575. *
  55576. * If sets to null, the scene one is in use.
  55577. */
  55578. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55579. /**
  55580. * Gets wether the color curves effect is enabled.
  55581. */
  55582. get cameraColorCurvesEnabled(): boolean;
  55583. /**
  55584. * Sets wether the color curves effect is enabled.
  55585. */
  55586. set cameraColorCurvesEnabled(value: boolean);
  55587. /**
  55588. * Gets wether the color grading effect is enabled.
  55589. */
  55590. get cameraColorGradingEnabled(): boolean;
  55591. /**
  55592. * Gets wether the color grading effect is enabled.
  55593. */
  55594. set cameraColorGradingEnabled(value: boolean);
  55595. /**
  55596. * Gets wether tonemapping is enabled or not.
  55597. */
  55598. get cameraToneMappingEnabled(): boolean;
  55599. /**
  55600. * Sets wether tonemapping is enabled or not
  55601. */
  55602. set cameraToneMappingEnabled(value: boolean);
  55603. /**
  55604. * The camera exposure used on this material.
  55605. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55606. * This corresponds to a photographic exposure.
  55607. */
  55608. get cameraExposure(): number;
  55609. /**
  55610. * The camera exposure used on this material.
  55611. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55612. * This corresponds to a photographic exposure.
  55613. */
  55614. set cameraExposure(value: number);
  55615. /**
  55616. * Gets The camera contrast used on this material.
  55617. */
  55618. get cameraContrast(): number;
  55619. /**
  55620. * Sets The camera contrast used on this material.
  55621. */
  55622. set cameraContrast(value: number);
  55623. /**
  55624. * Gets the Color Grading 2D Lookup Texture.
  55625. */
  55626. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55627. /**
  55628. * Sets the Color Grading 2D Lookup Texture.
  55629. */
  55630. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55631. /**
  55632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55634. * 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;
  55635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55636. */
  55637. get cameraColorCurves(): Nullable<ColorCurves>;
  55638. /**
  55639. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55640. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55641. * 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;
  55642. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55643. */
  55644. set cameraColorCurves(value: Nullable<ColorCurves>);
  55645. /**
  55646. * Instantiates a new PBRMaterial instance.
  55647. *
  55648. * @param name The material name
  55649. * @param scene The scene the material will be use in.
  55650. */
  55651. constructor(name: string, scene: Scene);
  55652. /**
  55653. * Returns the name of this material class.
  55654. */
  55655. getClassName(): string;
  55656. /**
  55657. * Makes a duplicate of the current material.
  55658. * @param name - name to use for the new material.
  55659. */
  55660. clone(name: string): PBRMaterial;
  55661. /**
  55662. * Serializes this PBR Material.
  55663. * @returns - An object with the serialized material.
  55664. */
  55665. serialize(): any;
  55666. /**
  55667. * Parses a PBR Material from a serialized object.
  55668. * @param source - Serialized object.
  55669. * @param scene - BJS scene instance.
  55670. * @param rootUrl - url for the scene object
  55671. * @returns - PBRMaterial
  55672. */
  55673. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55674. }
  55675. }
  55676. declare module BABYLON {
  55677. /**
  55678. * Direct draw surface info
  55679. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55680. */
  55681. export interface DDSInfo {
  55682. /**
  55683. * Width of the texture
  55684. */
  55685. width: number;
  55686. /**
  55687. * Width of the texture
  55688. */
  55689. height: number;
  55690. /**
  55691. * Number of Mipmaps for the texture
  55692. * @see https://en.wikipedia.org/wiki/Mipmap
  55693. */
  55694. mipmapCount: number;
  55695. /**
  55696. * If the textures format is a known fourCC format
  55697. * @see https://www.fourcc.org/
  55698. */
  55699. isFourCC: boolean;
  55700. /**
  55701. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55702. */
  55703. isRGB: boolean;
  55704. /**
  55705. * If the texture is a lumincance format
  55706. */
  55707. isLuminance: boolean;
  55708. /**
  55709. * If this is a cube texture
  55710. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55711. */
  55712. isCube: boolean;
  55713. /**
  55714. * If the texture is a compressed format eg. FOURCC_DXT1
  55715. */
  55716. isCompressed: boolean;
  55717. /**
  55718. * The dxgiFormat of the texture
  55719. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55720. */
  55721. dxgiFormat: number;
  55722. /**
  55723. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55724. */
  55725. textureType: number;
  55726. /**
  55727. * Sphericle polynomial created for the dds texture
  55728. */
  55729. sphericalPolynomial?: SphericalPolynomial;
  55730. }
  55731. /**
  55732. * Class used to provide DDS decompression tools
  55733. */
  55734. export class DDSTools {
  55735. /**
  55736. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55737. */
  55738. static StoreLODInAlphaChannel: boolean;
  55739. /**
  55740. * Gets DDS information from an array buffer
  55741. * @param data defines the array buffer view to read data from
  55742. * @returns the DDS information
  55743. */
  55744. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55745. private static _FloatView;
  55746. private static _Int32View;
  55747. private static _ToHalfFloat;
  55748. private static _FromHalfFloat;
  55749. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55750. private static _GetHalfFloatRGBAArrayBuffer;
  55751. private static _GetFloatRGBAArrayBuffer;
  55752. private static _GetFloatAsUIntRGBAArrayBuffer;
  55753. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55754. private static _GetRGBAArrayBuffer;
  55755. private static _ExtractLongWordOrder;
  55756. private static _GetRGBArrayBuffer;
  55757. private static _GetLuminanceArrayBuffer;
  55758. /**
  55759. * Uploads DDS Levels to a Babylon Texture
  55760. * @hidden
  55761. */
  55762. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55763. }
  55764. interface ThinEngine {
  55765. /**
  55766. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55767. * @param rootUrl defines the url where the file to load is located
  55768. * @param scene defines the current scene
  55769. * @param lodScale defines scale to apply to the mip map selection
  55770. * @param lodOffset defines offset to apply to the mip map selection
  55771. * @param onLoad defines an optional callback raised when the texture is loaded
  55772. * @param onError defines an optional callback raised if there is an issue to load the texture
  55773. * @param format defines the format of the data
  55774. * @param forcedExtension defines the extension to use to pick the right loader
  55775. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55776. * @returns the cube texture as an InternalTexture
  55777. */
  55778. 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;
  55779. }
  55780. }
  55781. declare module BABYLON {
  55782. /**
  55783. * Implementation of the DDS Texture Loader.
  55784. * @hidden
  55785. */
  55786. export class _DDSTextureLoader implements IInternalTextureLoader {
  55787. /**
  55788. * Defines wether the loader supports cascade loading the different faces.
  55789. */
  55790. readonly supportCascades: boolean;
  55791. /**
  55792. * This returns if the loader support the current file information.
  55793. * @param extension defines the file extension of the file being loaded
  55794. * @returns true if the loader can load the specified file
  55795. */
  55796. canLoad(extension: string): boolean;
  55797. /**
  55798. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55799. * @param data contains the texture data
  55800. * @param texture defines the BabylonJS internal texture
  55801. * @param createPolynomials will be true if polynomials have been requested
  55802. * @param onLoad defines the callback to trigger once the texture is ready
  55803. * @param onError defines the callback to trigger in case of error
  55804. */
  55805. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55806. /**
  55807. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55808. * @param data contains the texture data
  55809. * @param texture defines the BabylonJS internal texture
  55810. * @param callback defines the method to call once ready to upload
  55811. */
  55812. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55813. }
  55814. }
  55815. declare module BABYLON {
  55816. /**
  55817. * Implementation of the ENV Texture Loader.
  55818. * @hidden
  55819. */
  55820. export class _ENVTextureLoader implements IInternalTextureLoader {
  55821. /**
  55822. * Defines wether the loader supports cascade loading the different faces.
  55823. */
  55824. readonly supportCascades: boolean;
  55825. /**
  55826. * This returns if the loader support the current file information.
  55827. * @param extension defines the file extension of the file being loaded
  55828. * @returns true if the loader can load the specified file
  55829. */
  55830. canLoad(extension: string): boolean;
  55831. /**
  55832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55833. * @param data contains the texture data
  55834. * @param texture defines the BabylonJS internal texture
  55835. * @param createPolynomials will be true if polynomials have been requested
  55836. * @param onLoad defines the callback to trigger once the texture is ready
  55837. * @param onError defines the callback to trigger in case of error
  55838. */
  55839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55840. /**
  55841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55842. * @param data contains the texture data
  55843. * @param texture defines the BabylonJS internal texture
  55844. * @param callback defines the method to call once ready to upload
  55845. */
  55846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55847. }
  55848. }
  55849. declare module BABYLON {
  55850. /**
  55851. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55852. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55853. */
  55854. export class KhronosTextureContainer {
  55855. /** contents of the KTX container file */
  55856. data: ArrayBufferView;
  55857. private static HEADER_LEN;
  55858. private static COMPRESSED_2D;
  55859. private static COMPRESSED_3D;
  55860. private static TEX_2D;
  55861. private static TEX_3D;
  55862. /**
  55863. * Gets the openGL type
  55864. */
  55865. glType: number;
  55866. /**
  55867. * Gets the openGL type size
  55868. */
  55869. glTypeSize: number;
  55870. /**
  55871. * Gets the openGL format
  55872. */
  55873. glFormat: number;
  55874. /**
  55875. * Gets the openGL internal format
  55876. */
  55877. glInternalFormat: number;
  55878. /**
  55879. * Gets the base internal format
  55880. */
  55881. glBaseInternalFormat: number;
  55882. /**
  55883. * Gets image width in pixel
  55884. */
  55885. pixelWidth: number;
  55886. /**
  55887. * Gets image height in pixel
  55888. */
  55889. pixelHeight: number;
  55890. /**
  55891. * Gets image depth in pixels
  55892. */
  55893. pixelDepth: number;
  55894. /**
  55895. * Gets the number of array elements
  55896. */
  55897. numberOfArrayElements: number;
  55898. /**
  55899. * Gets the number of faces
  55900. */
  55901. numberOfFaces: number;
  55902. /**
  55903. * Gets the number of mipmap levels
  55904. */
  55905. numberOfMipmapLevels: number;
  55906. /**
  55907. * Gets the bytes of key value data
  55908. */
  55909. bytesOfKeyValueData: number;
  55910. /**
  55911. * Gets the load type
  55912. */
  55913. loadType: number;
  55914. /**
  55915. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55916. */
  55917. isInvalid: boolean;
  55918. /**
  55919. * Creates a new KhronosTextureContainer
  55920. * @param data contents of the KTX container file
  55921. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55922. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55923. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55924. */
  55925. constructor(
  55926. /** contents of the KTX container file */
  55927. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55928. /**
  55929. * Uploads KTX content to a Babylon Texture.
  55930. * It is assumed that the texture has already been created & is currently bound
  55931. * @hidden
  55932. */
  55933. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55934. private _upload2DCompressedLevels;
  55935. /**
  55936. * Checks if the given data starts with a KTX file identifier.
  55937. * @param data the data to check
  55938. * @returns true if the data is a KTX file or false otherwise
  55939. */
  55940. static IsValid(data: ArrayBufferView): boolean;
  55941. }
  55942. }
  55943. declare module BABYLON {
  55944. /**
  55945. * Class for loading KTX2 files
  55946. * !!! Experimental Extension Subject to Changes !!!
  55947. * @hidden
  55948. */
  55949. export class KhronosTextureContainer2 {
  55950. private static _ModulePromise;
  55951. private static _TranscodeFormat;
  55952. constructor(engine: ThinEngine);
  55953. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55954. private _determineTranscodeFormat;
  55955. /**
  55956. * Checks if the given data starts with a KTX2 file identifier.
  55957. * @param data the data to check
  55958. * @returns true if the data is a KTX2 file or false otherwise
  55959. */
  55960. static IsValid(data: ArrayBufferView): boolean;
  55961. }
  55962. }
  55963. declare module BABYLON {
  55964. /**
  55965. * Implementation of the KTX Texture Loader.
  55966. * @hidden
  55967. */
  55968. export class _KTXTextureLoader implements IInternalTextureLoader {
  55969. /**
  55970. * Defines wether the loader supports cascade loading the different faces.
  55971. */
  55972. readonly supportCascades: boolean;
  55973. /**
  55974. * This returns if the loader support the current file information.
  55975. * @param extension defines the file extension of the file being loaded
  55976. * @returns true if the loader can load the specified file
  55977. */
  55978. canLoad(extension: string): boolean;
  55979. /**
  55980. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55981. * @param data contains the texture data
  55982. * @param texture defines the BabylonJS internal texture
  55983. * @param createPolynomials will be true if polynomials have been requested
  55984. * @param onLoad defines the callback to trigger once the texture is ready
  55985. * @param onError defines the callback to trigger in case of error
  55986. */
  55987. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55988. /**
  55989. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55990. * @param data contains the texture data
  55991. * @param texture defines the BabylonJS internal texture
  55992. * @param callback defines the method to call once ready to upload
  55993. */
  55994. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55995. }
  55996. }
  55997. declare module BABYLON {
  55998. /** @hidden */
  55999. export var _forceSceneHelpersToBundle: boolean;
  56000. interface Scene {
  56001. /**
  56002. * Creates a default light for the scene.
  56003. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56004. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56005. */
  56006. createDefaultLight(replace?: boolean): void;
  56007. /**
  56008. * Creates a default camera for the scene.
  56009. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56010. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56011. * @param replace has default false, when true replaces the active camera in the scene
  56012. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56013. */
  56014. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56015. /**
  56016. * Creates a default camera and a default light.
  56017. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56018. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56019. * @param replace has the default false, when true replaces the active camera/light in the scene
  56020. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56021. */
  56022. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56023. /**
  56024. * Creates a new sky box
  56025. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56026. * @param environmentTexture defines the texture to use as environment texture
  56027. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56028. * @param scale defines the overall scale of the skybox
  56029. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56030. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56031. * @returns a new mesh holding the sky box
  56032. */
  56033. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56034. /**
  56035. * Creates a new environment
  56036. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56037. * @param options defines the options you can use to configure the environment
  56038. * @returns the new EnvironmentHelper
  56039. */
  56040. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56041. /**
  56042. * Creates a new VREXperienceHelper
  56043. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56044. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56045. * @returns a new VREXperienceHelper
  56046. */
  56047. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56048. /**
  56049. * Creates a new WebXRDefaultExperience
  56050. * @see http://doc.babylonjs.com/how_to/webxr
  56051. * @param options experience options
  56052. * @returns a promise for a new WebXRDefaultExperience
  56053. */
  56054. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56055. }
  56056. }
  56057. declare module BABYLON {
  56058. /**
  56059. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56060. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56061. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56062. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56063. */
  56064. export class VideoDome extends TransformNode {
  56065. /**
  56066. * Define the video source as a Monoscopic panoramic 360 video.
  56067. */
  56068. static readonly MODE_MONOSCOPIC: number;
  56069. /**
  56070. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56071. */
  56072. static readonly MODE_TOPBOTTOM: number;
  56073. /**
  56074. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56075. */
  56076. static readonly MODE_SIDEBYSIDE: number;
  56077. private _halfDome;
  56078. private _useDirectMapping;
  56079. /**
  56080. * The video texture being displayed on the sphere
  56081. */
  56082. protected _videoTexture: VideoTexture;
  56083. /**
  56084. * Gets the video texture being displayed on the sphere
  56085. */
  56086. get videoTexture(): VideoTexture;
  56087. /**
  56088. * The skybox material
  56089. */
  56090. protected _material: BackgroundMaterial;
  56091. /**
  56092. * The surface used for the skybox
  56093. */
  56094. protected _mesh: Mesh;
  56095. /**
  56096. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56097. */
  56098. private _halfDomeMask;
  56099. /**
  56100. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56101. * Also see the options.resolution property.
  56102. */
  56103. get fovMultiplier(): number;
  56104. set fovMultiplier(value: number);
  56105. private _videoMode;
  56106. /**
  56107. * Gets or set the current video mode for the video. It can be:
  56108. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56109. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56110. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56111. */
  56112. get videoMode(): number;
  56113. set videoMode(value: number);
  56114. /**
  56115. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56116. *
  56117. */
  56118. get halfDome(): boolean;
  56119. /**
  56120. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56121. */
  56122. set halfDome(enabled: boolean);
  56123. /**
  56124. * Oberserver used in Stereoscopic VR Mode.
  56125. */
  56126. private _onBeforeCameraRenderObserver;
  56127. /**
  56128. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56129. * @param name Element's name, child elements will append suffixes for their own names.
  56130. * @param urlsOrVideo defines the url(s) or the video element to use
  56131. * @param options An object containing optional or exposed sub element properties
  56132. */
  56133. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56134. resolution?: number;
  56135. clickToPlay?: boolean;
  56136. autoPlay?: boolean;
  56137. loop?: boolean;
  56138. size?: number;
  56139. poster?: string;
  56140. faceForward?: boolean;
  56141. useDirectMapping?: boolean;
  56142. halfDomeMode?: boolean;
  56143. }, scene: Scene);
  56144. private _changeVideoMode;
  56145. /**
  56146. * Releases resources associated with this node.
  56147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56149. */
  56150. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56151. }
  56152. }
  56153. declare module BABYLON {
  56154. /**
  56155. * This class can be used to get instrumentation data from a Babylon engine
  56156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56157. */
  56158. export class EngineInstrumentation implements IDisposable {
  56159. /**
  56160. * Define the instrumented engine.
  56161. */
  56162. engine: Engine;
  56163. private _captureGPUFrameTime;
  56164. private _gpuFrameTimeToken;
  56165. private _gpuFrameTime;
  56166. private _captureShaderCompilationTime;
  56167. private _shaderCompilationTime;
  56168. private _onBeginFrameObserver;
  56169. private _onEndFrameObserver;
  56170. private _onBeforeShaderCompilationObserver;
  56171. private _onAfterShaderCompilationObserver;
  56172. /**
  56173. * Gets the perf counter used for GPU frame time
  56174. */
  56175. get gpuFrameTimeCounter(): PerfCounter;
  56176. /**
  56177. * Gets the GPU frame time capture status
  56178. */
  56179. get captureGPUFrameTime(): boolean;
  56180. /**
  56181. * Enable or disable the GPU frame time capture
  56182. */
  56183. set captureGPUFrameTime(value: boolean);
  56184. /**
  56185. * Gets the perf counter used for shader compilation time
  56186. */
  56187. get shaderCompilationTimeCounter(): PerfCounter;
  56188. /**
  56189. * Gets the shader compilation time capture status
  56190. */
  56191. get captureShaderCompilationTime(): boolean;
  56192. /**
  56193. * Enable or disable the shader compilation time capture
  56194. */
  56195. set captureShaderCompilationTime(value: boolean);
  56196. /**
  56197. * Instantiates a new engine instrumentation.
  56198. * This class can be used to get instrumentation data from a Babylon engine
  56199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56200. * @param engine Defines the engine to instrument
  56201. */
  56202. constructor(
  56203. /**
  56204. * Define the instrumented engine.
  56205. */
  56206. engine: Engine);
  56207. /**
  56208. * Dispose and release associated resources.
  56209. */
  56210. dispose(): void;
  56211. }
  56212. }
  56213. declare module BABYLON {
  56214. /**
  56215. * This class can be used to get instrumentation data from a Babylon engine
  56216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56217. */
  56218. export class SceneInstrumentation implements IDisposable {
  56219. /**
  56220. * Defines the scene to instrument
  56221. */
  56222. scene: Scene;
  56223. private _captureActiveMeshesEvaluationTime;
  56224. private _activeMeshesEvaluationTime;
  56225. private _captureRenderTargetsRenderTime;
  56226. private _renderTargetsRenderTime;
  56227. private _captureFrameTime;
  56228. private _frameTime;
  56229. private _captureRenderTime;
  56230. private _renderTime;
  56231. private _captureInterFrameTime;
  56232. private _interFrameTime;
  56233. private _captureParticlesRenderTime;
  56234. private _particlesRenderTime;
  56235. private _captureSpritesRenderTime;
  56236. private _spritesRenderTime;
  56237. private _capturePhysicsTime;
  56238. private _physicsTime;
  56239. private _captureAnimationsTime;
  56240. private _animationsTime;
  56241. private _captureCameraRenderTime;
  56242. private _cameraRenderTime;
  56243. private _onBeforeActiveMeshesEvaluationObserver;
  56244. private _onAfterActiveMeshesEvaluationObserver;
  56245. private _onBeforeRenderTargetsRenderObserver;
  56246. private _onAfterRenderTargetsRenderObserver;
  56247. private _onAfterRenderObserver;
  56248. private _onBeforeDrawPhaseObserver;
  56249. private _onAfterDrawPhaseObserver;
  56250. private _onBeforeAnimationsObserver;
  56251. private _onBeforeParticlesRenderingObserver;
  56252. private _onAfterParticlesRenderingObserver;
  56253. private _onBeforeSpritesRenderingObserver;
  56254. private _onAfterSpritesRenderingObserver;
  56255. private _onBeforePhysicsObserver;
  56256. private _onAfterPhysicsObserver;
  56257. private _onAfterAnimationsObserver;
  56258. private _onBeforeCameraRenderObserver;
  56259. private _onAfterCameraRenderObserver;
  56260. /**
  56261. * Gets the perf counter used for active meshes evaluation time
  56262. */
  56263. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56264. /**
  56265. * Gets the active meshes evaluation time capture status
  56266. */
  56267. get captureActiveMeshesEvaluationTime(): boolean;
  56268. /**
  56269. * Enable or disable the active meshes evaluation time capture
  56270. */
  56271. set captureActiveMeshesEvaluationTime(value: boolean);
  56272. /**
  56273. * Gets the perf counter used for render targets render time
  56274. */
  56275. get renderTargetsRenderTimeCounter(): PerfCounter;
  56276. /**
  56277. * Gets the render targets render time capture status
  56278. */
  56279. get captureRenderTargetsRenderTime(): boolean;
  56280. /**
  56281. * Enable or disable the render targets render time capture
  56282. */
  56283. set captureRenderTargetsRenderTime(value: boolean);
  56284. /**
  56285. * Gets the perf counter used for particles render time
  56286. */
  56287. get particlesRenderTimeCounter(): PerfCounter;
  56288. /**
  56289. * Gets the particles render time capture status
  56290. */
  56291. get captureParticlesRenderTime(): boolean;
  56292. /**
  56293. * Enable or disable the particles render time capture
  56294. */
  56295. set captureParticlesRenderTime(value: boolean);
  56296. /**
  56297. * Gets the perf counter used for sprites render time
  56298. */
  56299. get spritesRenderTimeCounter(): PerfCounter;
  56300. /**
  56301. * Gets the sprites render time capture status
  56302. */
  56303. get captureSpritesRenderTime(): boolean;
  56304. /**
  56305. * Enable or disable the sprites render time capture
  56306. */
  56307. set captureSpritesRenderTime(value: boolean);
  56308. /**
  56309. * Gets the perf counter used for physics time
  56310. */
  56311. get physicsTimeCounter(): PerfCounter;
  56312. /**
  56313. * Gets the physics time capture status
  56314. */
  56315. get capturePhysicsTime(): boolean;
  56316. /**
  56317. * Enable or disable the physics time capture
  56318. */
  56319. set capturePhysicsTime(value: boolean);
  56320. /**
  56321. * Gets the perf counter used for animations time
  56322. */
  56323. get animationsTimeCounter(): PerfCounter;
  56324. /**
  56325. * Gets the animations time capture status
  56326. */
  56327. get captureAnimationsTime(): boolean;
  56328. /**
  56329. * Enable or disable the animations time capture
  56330. */
  56331. set captureAnimationsTime(value: boolean);
  56332. /**
  56333. * Gets the perf counter used for frame time capture
  56334. */
  56335. get frameTimeCounter(): PerfCounter;
  56336. /**
  56337. * Gets the frame time capture status
  56338. */
  56339. get captureFrameTime(): boolean;
  56340. /**
  56341. * Enable or disable the frame time capture
  56342. */
  56343. set captureFrameTime(value: boolean);
  56344. /**
  56345. * Gets the perf counter used for inter-frames time capture
  56346. */
  56347. get interFrameTimeCounter(): PerfCounter;
  56348. /**
  56349. * Gets the inter-frames time capture status
  56350. */
  56351. get captureInterFrameTime(): boolean;
  56352. /**
  56353. * Enable or disable the inter-frames time capture
  56354. */
  56355. set captureInterFrameTime(value: boolean);
  56356. /**
  56357. * Gets the perf counter used for render time capture
  56358. */
  56359. get renderTimeCounter(): PerfCounter;
  56360. /**
  56361. * Gets the render time capture status
  56362. */
  56363. get captureRenderTime(): boolean;
  56364. /**
  56365. * Enable or disable the render time capture
  56366. */
  56367. set captureRenderTime(value: boolean);
  56368. /**
  56369. * Gets the perf counter used for camera render time capture
  56370. */
  56371. get cameraRenderTimeCounter(): PerfCounter;
  56372. /**
  56373. * Gets the camera render time capture status
  56374. */
  56375. get captureCameraRenderTime(): boolean;
  56376. /**
  56377. * Enable or disable the camera render time capture
  56378. */
  56379. set captureCameraRenderTime(value: boolean);
  56380. /**
  56381. * Gets the perf counter used for draw calls
  56382. */
  56383. get drawCallsCounter(): PerfCounter;
  56384. /**
  56385. * Instantiates a new scene instrumentation.
  56386. * This class can be used to get instrumentation data from a Babylon engine
  56387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56388. * @param scene Defines the scene to instrument
  56389. */
  56390. constructor(
  56391. /**
  56392. * Defines the scene to instrument
  56393. */
  56394. scene: Scene);
  56395. /**
  56396. * Dispose and release associated resources.
  56397. */
  56398. dispose(): void;
  56399. }
  56400. }
  56401. declare module BABYLON {
  56402. /** @hidden */
  56403. export var glowMapGenerationPixelShader: {
  56404. name: string;
  56405. shader: string;
  56406. };
  56407. }
  56408. declare module BABYLON {
  56409. /** @hidden */
  56410. export var glowMapGenerationVertexShader: {
  56411. name: string;
  56412. shader: string;
  56413. };
  56414. }
  56415. declare module BABYLON {
  56416. /**
  56417. * Effect layer options. This helps customizing the behaviour
  56418. * of the effect layer.
  56419. */
  56420. export interface IEffectLayerOptions {
  56421. /**
  56422. * Multiplication factor apply to the canvas size to compute the render target size
  56423. * used to generated the objects (the smaller the faster).
  56424. */
  56425. mainTextureRatio: number;
  56426. /**
  56427. * Enforces a fixed size texture to ensure effect stability across devices.
  56428. */
  56429. mainTextureFixedSize?: number;
  56430. /**
  56431. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56432. */
  56433. alphaBlendingMode: number;
  56434. /**
  56435. * The camera attached to the layer.
  56436. */
  56437. camera: Nullable<Camera>;
  56438. /**
  56439. * The rendering group to draw the layer in.
  56440. */
  56441. renderingGroupId: number;
  56442. }
  56443. /**
  56444. * The effect layer Helps adding post process effect blended with the main pass.
  56445. *
  56446. * This can be for instance use to generate glow or higlight effects on the scene.
  56447. *
  56448. * The effect layer class can not be used directly and is intented to inherited from to be
  56449. * customized per effects.
  56450. */
  56451. export abstract class EffectLayer {
  56452. private _vertexBuffers;
  56453. private _indexBuffer;
  56454. private _cachedDefines;
  56455. private _effectLayerMapGenerationEffect;
  56456. private _effectLayerOptions;
  56457. private _mergeEffect;
  56458. protected _scene: Scene;
  56459. protected _engine: Engine;
  56460. protected _maxSize: number;
  56461. protected _mainTextureDesiredSize: ISize;
  56462. protected _mainTexture: RenderTargetTexture;
  56463. protected _shouldRender: boolean;
  56464. protected _postProcesses: PostProcess[];
  56465. protected _textures: BaseTexture[];
  56466. protected _emissiveTextureAndColor: {
  56467. texture: Nullable<BaseTexture>;
  56468. color: Color4;
  56469. };
  56470. /**
  56471. * The name of the layer
  56472. */
  56473. name: string;
  56474. /**
  56475. * The clear color of the texture used to generate the glow map.
  56476. */
  56477. neutralColor: Color4;
  56478. /**
  56479. * Specifies whether the highlight layer is enabled or not.
  56480. */
  56481. isEnabled: boolean;
  56482. /**
  56483. * Gets the camera attached to the layer.
  56484. */
  56485. get camera(): Nullable<Camera>;
  56486. /**
  56487. * Gets the rendering group id the layer should render in.
  56488. */
  56489. get renderingGroupId(): number;
  56490. set renderingGroupId(renderingGroupId: number);
  56491. /**
  56492. * An event triggered when the effect layer has been disposed.
  56493. */
  56494. onDisposeObservable: Observable<EffectLayer>;
  56495. /**
  56496. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56497. */
  56498. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56499. /**
  56500. * An event triggered when the generated texture is being merged in the scene.
  56501. */
  56502. onBeforeComposeObservable: Observable<EffectLayer>;
  56503. /**
  56504. * An event triggered when the mesh is rendered into the effect render target.
  56505. */
  56506. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56507. /**
  56508. * An event triggered after the mesh has been rendered into the effect render target.
  56509. */
  56510. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56511. /**
  56512. * An event triggered when the generated texture has been merged in the scene.
  56513. */
  56514. onAfterComposeObservable: Observable<EffectLayer>;
  56515. /**
  56516. * An event triggered when the efffect layer changes its size.
  56517. */
  56518. onSizeChangedObservable: Observable<EffectLayer>;
  56519. /** @hidden */
  56520. static _SceneComponentInitialization: (scene: Scene) => void;
  56521. /**
  56522. * Instantiates a new effect Layer and references it in the scene.
  56523. * @param name The name of the layer
  56524. * @param scene The scene to use the layer in
  56525. */
  56526. constructor(
  56527. /** The Friendly of the effect in the scene */
  56528. name: string, scene: Scene);
  56529. /**
  56530. * Get the effect name of the layer.
  56531. * @return The effect name
  56532. */
  56533. abstract getEffectName(): string;
  56534. /**
  56535. * Checks for the readiness of the element composing the layer.
  56536. * @param subMesh the mesh to check for
  56537. * @param useInstances specify whether or not to use instances to render the mesh
  56538. * @return true if ready otherwise, false
  56539. */
  56540. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56541. /**
  56542. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56543. * @returns true if the effect requires stencil during the main canvas render pass.
  56544. */
  56545. abstract needStencil(): boolean;
  56546. /**
  56547. * Create the merge effect. This is the shader use to blit the information back
  56548. * to the main canvas at the end of the scene rendering.
  56549. * @returns The effect containing the shader used to merge the effect on the main canvas
  56550. */
  56551. protected abstract _createMergeEffect(): Effect;
  56552. /**
  56553. * Creates the render target textures and post processes used in the effect layer.
  56554. */
  56555. protected abstract _createTextureAndPostProcesses(): void;
  56556. /**
  56557. * Implementation specific of rendering the generating effect on the main canvas.
  56558. * @param effect The effect used to render through
  56559. */
  56560. protected abstract _internalRender(effect: Effect): void;
  56561. /**
  56562. * Sets the required values for both the emissive texture and and the main color.
  56563. */
  56564. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56565. /**
  56566. * Free any resources and references associated to a mesh.
  56567. * Internal use
  56568. * @param mesh The mesh to free.
  56569. */
  56570. abstract _disposeMesh(mesh: Mesh): void;
  56571. /**
  56572. * Serializes this layer (Glow or Highlight for example)
  56573. * @returns a serialized layer object
  56574. */
  56575. abstract serialize?(): any;
  56576. /**
  56577. * Initializes the effect layer with the required options.
  56578. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56579. */
  56580. protected _init(options: Partial<IEffectLayerOptions>): void;
  56581. /**
  56582. * Generates the index buffer of the full screen quad blending to the main canvas.
  56583. */
  56584. private _generateIndexBuffer;
  56585. /**
  56586. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56587. */
  56588. private _generateVertexBuffer;
  56589. /**
  56590. * Sets the main texture desired size which is the closest power of two
  56591. * of the engine canvas size.
  56592. */
  56593. private _setMainTextureSize;
  56594. /**
  56595. * Creates the main texture for the effect layer.
  56596. */
  56597. protected _createMainTexture(): void;
  56598. /**
  56599. * Adds specific effects defines.
  56600. * @param defines The defines to add specifics to.
  56601. */
  56602. protected _addCustomEffectDefines(defines: string[]): void;
  56603. /**
  56604. * Checks for the readiness of the element composing the layer.
  56605. * @param subMesh the mesh to check for
  56606. * @param useInstances specify whether or not to use instances to render the mesh
  56607. * @param emissiveTexture the associated emissive texture used to generate the glow
  56608. * @return true if ready otherwise, false
  56609. */
  56610. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56611. /**
  56612. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56613. */
  56614. render(): void;
  56615. /**
  56616. * Determine if a given mesh will be used in the current effect.
  56617. * @param mesh mesh to test
  56618. * @returns true if the mesh will be used
  56619. */
  56620. hasMesh(mesh: AbstractMesh): boolean;
  56621. /**
  56622. * Returns true if the layer contains information to display, otherwise false.
  56623. * @returns true if the glow layer should be rendered
  56624. */
  56625. shouldRender(): boolean;
  56626. /**
  56627. * Returns true if the mesh should render, otherwise false.
  56628. * @param mesh The mesh to render
  56629. * @returns true if it should render otherwise false
  56630. */
  56631. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56632. /**
  56633. * Returns true if the mesh can be rendered, otherwise false.
  56634. * @param mesh The mesh to render
  56635. * @param material The material used on the mesh
  56636. * @returns true if it can be rendered otherwise false
  56637. */
  56638. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56639. /**
  56640. * Returns true if the mesh should render, otherwise false.
  56641. * @param mesh The mesh to render
  56642. * @returns true if it should render otherwise false
  56643. */
  56644. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56645. /**
  56646. * Renders the submesh passed in parameter to the generation map.
  56647. */
  56648. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56649. /**
  56650. * Defines whether the current material of the mesh should be use to render the effect.
  56651. * @param mesh defines the current mesh to render
  56652. */
  56653. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56654. /**
  56655. * Rebuild the required buffers.
  56656. * @hidden Internal use only.
  56657. */
  56658. _rebuild(): void;
  56659. /**
  56660. * Dispose only the render target textures and post process.
  56661. */
  56662. private _disposeTextureAndPostProcesses;
  56663. /**
  56664. * Dispose the highlight layer and free resources.
  56665. */
  56666. dispose(): void;
  56667. /**
  56668. * Gets the class name of the effect layer
  56669. * @returns the string with the class name of the effect layer
  56670. */
  56671. getClassName(): string;
  56672. /**
  56673. * Creates an effect layer from parsed effect layer data
  56674. * @param parsedEffectLayer defines effect layer data
  56675. * @param scene defines the current scene
  56676. * @param rootUrl defines the root URL containing the effect layer information
  56677. * @returns a parsed effect Layer
  56678. */
  56679. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. interface AbstractScene {
  56684. /**
  56685. * The list of effect layers (highlights/glow) added to the scene
  56686. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56687. * @see http://doc.babylonjs.com/how_to/glow_layer
  56688. */
  56689. effectLayers: Array<EffectLayer>;
  56690. /**
  56691. * Removes the given effect layer from this scene.
  56692. * @param toRemove defines the effect layer to remove
  56693. * @returns the index of the removed effect layer
  56694. */
  56695. removeEffectLayer(toRemove: EffectLayer): number;
  56696. /**
  56697. * Adds the given effect layer to this scene
  56698. * @param newEffectLayer defines the effect layer to add
  56699. */
  56700. addEffectLayer(newEffectLayer: EffectLayer): void;
  56701. }
  56702. /**
  56703. * Defines the layer scene component responsible to manage any effect layers
  56704. * in a given scene.
  56705. */
  56706. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56707. /**
  56708. * The component name helpfull to identify the component in the list of scene components.
  56709. */
  56710. readonly name: string;
  56711. /**
  56712. * The scene the component belongs to.
  56713. */
  56714. scene: Scene;
  56715. private _engine;
  56716. private _renderEffects;
  56717. private _needStencil;
  56718. private _previousStencilState;
  56719. /**
  56720. * Creates a new instance of the component for the given scene
  56721. * @param scene Defines the scene to register the component in
  56722. */
  56723. constructor(scene: Scene);
  56724. /**
  56725. * Registers the component in a given scene
  56726. */
  56727. register(): void;
  56728. /**
  56729. * Rebuilds the elements related to this component in case of
  56730. * context lost for instance.
  56731. */
  56732. rebuild(): void;
  56733. /**
  56734. * Serializes the component data to the specified json object
  56735. * @param serializationObject The object to serialize to
  56736. */
  56737. serialize(serializationObject: any): void;
  56738. /**
  56739. * Adds all the elements from the container to the scene
  56740. * @param container the container holding the elements
  56741. */
  56742. addFromContainer(container: AbstractScene): void;
  56743. /**
  56744. * Removes all the elements in the container from the scene
  56745. * @param container contains the elements to remove
  56746. * @param dispose if the removed element should be disposed (default: false)
  56747. */
  56748. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56749. /**
  56750. * Disposes the component and the associated ressources.
  56751. */
  56752. dispose(): void;
  56753. private _isReadyForMesh;
  56754. private _renderMainTexture;
  56755. private _setStencil;
  56756. private _setStencilBack;
  56757. private _draw;
  56758. private _drawCamera;
  56759. private _drawRenderingGroup;
  56760. }
  56761. }
  56762. declare module BABYLON {
  56763. /** @hidden */
  56764. export var glowMapMergePixelShader: {
  56765. name: string;
  56766. shader: string;
  56767. };
  56768. }
  56769. declare module BABYLON {
  56770. /** @hidden */
  56771. export var glowMapMergeVertexShader: {
  56772. name: string;
  56773. shader: string;
  56774. };
  56775. }
  56776. declare module BABYLON {
  56777. interface AbstractScene {
  56778. /**
  56779. * Return a the first highlight layer of the scene with a given name.
  56780. * @param name The name of the highlight layer to look for.
  56781. * @return The highlight layer if found otherwise null.
  56782. */
  56783. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56784. }
  56785. /**
  56786. * Glow layer options. This helps customizing the behaviour
  56787. * of the glow layer.
  56788. */
  56789. export interface IGlowLayerOptions {
  56790. /**
  56791. * Multiplication factor apply to the canvas size to compute the render target size
  56792. * used to generated the glowing objects (the smaller the faster).
  56793. */
  56794. mainTextureRatio: number;
  56795. /**
  56796. * Enforces a fixed size texture to ensure resize independant blur.
  56797. */
  56798. mainTextureFixedSize?: number;
  56799. /**
  56800. * How big is the kernel of the blur texture.
  56801. */
  56802. blurKernelSize: number;
  56803. /**
  56804. * The camera attached to the layer.
  56805. */
  56806. camera: Nullable<Camera>;
  56807. /**
  56808. * Enable MSAA by chosing the number of samples.
  56809. */
  56810. mainTextureSamples?: number;
  56811. /**
  56812. * The rendering group to draw the layer in.
  56813. */
  56814. renderingGroupId: number;
  56815. }
  56816. /**
  56817. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56818. *
  56819. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56820. *
  56821. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56822. */
  56823. export class GlowLayer extends EffectLayer {
  56824. /**
  56825. * Effect Name of the layer.
  56826. */
  56827. static readonly EffectName: string;
  56828. /**
  56829. * The default blur kernel size used for the glow.
  56830. */
  56831. static DefaultBlurKernelSize: number;
  56832. /**
  56833. * The default texture size ratio used for the glow.
  56834. */
  56835. static DefaultTextureRatio: number;
  56836. /**
  56837. * Sets the kernel size of the blur.
  56838. */
  56839. set blurKernelSize(value: number);
  56840. /**
  56841. * Gets the kernel size of the blur.
  56842. */
  56843. get blurKernelSize(): number;
  56844. /**
  56845. * Sets the glow intensity.
  56846. */
  56847. set intensity(value: number);
  56848. /**
  56849. * Gets the glow intensity.
  56850. */
  56851. get intensity(): number;
  56852. private _options;
  56853. private _intensity;
  56854. private _horizontalBlurPostprocess1;
  56855. private _verticalBlurPostprocess1;
  56856. private _horizontalBlurPostprocess2;
  56857. private _verticalBlurPostprocess2;
  56858. private _blurTexture1;
  56859. private _blurTexture2;
  56860. private _postProcesses1;
  56861. private _postProcesses2;
  56862. private _includedOnlyMeshes;
  56863. private _excludedMeshes;
  56864. private _meshesUsingTheirOwnMaterials;
  56865. /**
  56866. * Callback used to let the user override the color selection on a per mesh basis
  56867. */
  56868. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56869. /**
  56870. * Callback used to let the user override the texture selection on a per mesh basis
  56871. */
  56872. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56873. /**
  56874. * Instantiates a new glow Layer and references it to the scene.
  56875. * @param name The name of the layer
  56876. * @param scene The scene to use the layer in
  56877. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56878. */
  56879. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56880. /**
  56881. * Get the effect name of the layer.
  56882. * @return The effect name
  56883. */
  56884. getEffectName(): string;
  56885. /**
  56886. * Create the merge effect. This is the shader use to blit the information back
  56887. * to the main canvas at the end of the scene rendering.
  56888. */
  56889. protected _createMergeEffect(): Effect;
  56890. /**
  56891. * Creates the render target textures and post processes used in the glow layer.
  56892. */
  56893. protected _createTextureAndPostProcesses(): void;
  56894. /**
  56895. * Checks for the readiness of the element composing the layer.
  56896. * @param subMesh the mesh to check for
  56897. * @param useInstances specify wether or not to use instances to render the mesh
  56898. * @param emissiveTexture the associated emissive texture used to generate the glow
  56899. * @return true if ready otherwise, false
  56900. */
  56901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56902. /**
  56903. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56904. */
  56905. needStencil(): boolean;
  56906. /**
  56907. * Returns true if the mesh can be rendered, otherwise false.
  56908. * @param mesh The mesh to render
  56909. * @param material The material used on the mesh
  56910. * @returns true if it can be rendered otherwise false
  56911. */
  56912. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56913. /**
  56914. * Implementation specific of rendering the generating effect on the main canvas.
  56915. * @param effect The effect used to render through
  56916. */
  56917. protected _internalRender(effect: Effect): void;
  56918. /**
  56919. * Sets the required values for both the emissive texture and and the main color.
  56920. */
  56921. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56922. /**
  56923. * Returns true if the mesh should render, otherwise false.
  56924. * @param mesh The mesh to render
  56925. * @returns true if it should render otherwise false
  56926. */
  56927. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56928. /**
  56929. * Adds specific effects defines.
  56930. * @param defines The defines to add specifics to.
  56931. */
  56932. protected _addCustomEffectDefines(defines: string[]): void;
  56933. /**
  56934. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56935. * @param mesh The mesh to exclude from the glow layer
  56936. */
  56937. addExcludedMesh(mesh: Mesh): void;
  56938. /**
  56939. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56940. * @param mesh The mesh to remove
  56941. */
  56942. removeExcludedMesh(mesh: Mesh): void;
  56943. /**
  56944. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56945. * @param mesh The mesh to include in the glow layer
  56946. */
  56947. addIncludedOnlyMesh(mesh: Mesh): void;
  56948. /**
  56949. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56950. * @param mesh The mesh to remove
  56951. */
  56952. removeIncludedOnlyMesh(mesh: Mesh): void;
  56953. /**
  56954. * Determine if a given mesh will be used in the glow layer
  56955. * @param mesh The mesh to test
  56956. * @returns true if the mesh will be highlighted by the current glow layer
  56957. */
  56958. hasMesh(mesh: AbstractMesh): boolean;
  56959. /**
  56960. * Defines whether the current material of the mesh should be use to render the effect.
  56961. * @param mesh defines the current mesh to render
  56962. */
  56963. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56964. /**
  56965. * Add a mesh to be rendered through its own material and not with emissive only.
  56966. * @param mesh The mesh for which we need to use its material
  56967. */
  56968. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56969. /**
  56970. * Remove a mesh from being rendered through its own material and not with emissive only.
  56971. * @param mesh The mesh for which we need to not use its material
  56972. */
  56973. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56974. /**
  56975. * Free any resources and references associated to a mesh.
  56976. * Internal use
  56977. * @param mesh The mesh to free.
  56978. * @hidden
  56979. */
  56980. _disposeMesh(mesh: Mesh): void;
  56981. /**
  56982. * Gets the class name of the effect layer
  56983. * @returns the string with the class name of the effect layer
  56984. */
  56985. getClassName(): string;
  56986. /**
  56987. * Serializes this glow layer
  56988. * @returns a serialized glow layer object
  56989. */
  56990. serialize(): any;
  56991. /**
  56992. * Creates a Glow Layer from parsed glow layer data
  56993. * @param parsedGlowLayer defines glow layer data
  56994. * @param scene defines the current scene
  56995. * @param rootUrl defines the root URL containing the glow layer information
  56996. * @returns a parsed Glow Layer
  56997. */
  56998. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56999. }
  57000. }
  57001. declare module BABYLON {
  57002. /** @hidden */
  57003. export var glowBlurPostProcessPixelShader: {
  57004. name: string;
  57005. shader: string;
  57006. };
  57007. }
  57008. declare module BABYLON {
  57009. interface AbstractScene {
  57010. /**
  57011. * Return a the first highlight layer of the scene with a given name.
  57012. * @param name The name of the highlight layer to look for.
  57013. * @return The highlight layer if found otherwise null.
  57014. */
  57015. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57016. }
  57017. /**
  57018. * Highlight layer options. This helps customizing the behaviour
  57019. * of the highlight layer.
  57020. */
  57021. export interface IHighlightLayerOptions {
  57022. /**
  57023. * Multiplication factor apply to the canvas size to compute the render target size
  57024. * used to generated the glowing objects (the smaller the faster).
  57025. */
  57026. mainTextureRatio: number;
  57027. /**
  57028. * Enforces a fixed size texture to ensure resize independant blur.
  57029. */
  57030. mainTextureFixedSize?: number;
  57031. /**
  57032. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57033. * of the picture to blur (the smaller the faster).
  57034. */
  57035. blurTextureSizeRatio: number;
  57036. /**
  57037. * How big in texel of the blur texture is the vertical blur.
  57038. */
  57039. blurVerticalSize: number;
  57040. /**
  57041. * How big in texel of the blur texture is the horizontal blur.
  57042. */
  57043. blurHorizontalSize: number;
  57044. /**
  57045. * Alpha blending mode used to apply the blur. Default is combine.
  57046. */
  57047. alphaBlendingMode: number;
  57048. /**
  57049. * The camera attached to the layer.
  57050. */
  57051. camera: Nullable<Camera>;
  57052. /**
  57053. * Should we display highlight as a solid stroke?
  57054. */
  57055. isStroke?: boolean;
  57056. /**
  57057. * The rendering group to draw the layer in.
  57058. */
  57059. renderingGroupId: number;
  57060. }
  57061. /**
  57062. * The highlight layer Helps adding a glow effect around a mesh.
  57063. *
  57064. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57065. * glowy meshes to your scene.
  57066. *
  57067. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57068. */
  57069. export class HighlightLayer extends EffectLayer {
  57070. name: string;
  57071. /**
  57072. * Effect Name of the highlight layer.
  57073. */
  57074. static readonly EffectName: string;
  57075. /**
  57076. * The neutral color used during the preparation of the glow effect.
  57077. * This is black by default as the blend operation is a blend operation.
  57078. */
  57079. static NeutralColor: Color4;
  57080. /**
  57081. * Stencil value used for glowing meshes.
  57082. */
  57083. static GlowingMeshStencilReference: number;
  57084. /**
  57085. * Stencil value used for the other meshes in the scene.
  57086. */
  57087. static NormalMeshStencilReference: number;
  57088. /**
  57089. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57090. */
  57091. innerGlow: boolean;
  57092. /**
  57093. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57094. */
  57095. outerGlow: boolean;
  57096. /**
  57097. * Specifies the horizontal size of the blur.
  57098. */
  57099. set blurHorizontalSize(value: number);
  57100. /**
  57101. * Specifies the vertical size of the blur.
  57102. */
  57103. set blurVerticalSize(value: number);
  57104. /**
  57105. * Gets the horizontal size of the blur.
  57106. */
  57107. get blurHorizontalSize(): number;
  57108. /**
  57109. * Gets the vertical size of the blur.
  57110. */
  57111. get blurVerticalSize(): number;
  57112. /**
  57113. * An event triggered when the highlight layer is being blurred.
  57114. */
  57115. onBeforeBlurObservable: Observable<HighlightLayer>;
  57116. /**
  57117. * An event triggered when the highlight layer has been blurred.
  57118. */
  57119. onAfterBlurObservable: Observable<HighlightLayer>;
  57120. private _instanceGlowingMeshStencilReference;
  57121. private _options;
  57122. private _downSamplePostprocess;
  57123. private _horizontalBlurPostprocess;
  57124. private _verticalBlurPostprocess;
  57125. private _blurTexture;
  57126. private _meshes;
  57127. private _excludedMeshes;
  57128. /**
  57129. * Instantiates a new highlight Layer and references it to the scene..
  57130. * @param name The name of the layer
  57131. * @param scene The scene to use the layer in
  57132. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57133. */
  57134. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57135. /**
  57136. * Get the effect name of the layer.
  57137. * @return The effect name
  57138. */
  57139. getEffectName(): string;
  57140. /**
  57141. * Create the merge effect. This is the shader use to blit the information back
  57142. * to the main canvas at the end of the scene rendering.
  57143. */
  57144. protected _createMergeEffect(): Effect;
  57145. /**
  57146. * Creates the render target textures and post processes used in the highlight layer.
  57147. */
  57148. protected _createTextureAndPostProcesses(): void;
  57149. /**
  57150. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57151. */
  57152. needStencil(): boolean;
  57153. /**
  57154. * Checks for the readiness of the element composing the layer.
  57155. * @param subMesh the mesh to check for
  57156. * @param useInstances specify wether or not to use instances to render the mesh
  57157. * @param emissiveTexture the associated emissive texture used to generate the glow
  57158. * @return true if ready otherwise, false
  57159. */
  57160. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57161. /**
  57162. * Implementation specific of rendering the generating effect on the main canvas.
  57163. * @param effect The effect used to render through
  57164. */
  57165. protected _internalRender(effect: Effect): void;
  57166. /**
  57167. * Returns true if the layer contains information to display, otherwise false.
  57168. */
  57169. shouldRender(): boolean;
  57170. /**
  57171. * Returns true if the mesh should render, otherwise false.
  57172. * @param mesh The mesh to render
  57173. * @returns true if it should render otherwise false
  57174. */
  57175. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57176. /**
  57177. * Adds specific effects defines.
  57178. * @param defines The defines to add specifics to.
  57179. */
  57180. protected _addCustomEffectDefines(defines: string[]): void;
  57181. /**
  57182. * Sets the required values for both the emissive texture and and the main color.
  57183. */
  57184. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57185. /**
  57186. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57187. * @param mesh The mesh to exclude from the highlight layer
  57188. */
  57189. addExcludedMesh(mesh: Mesh): void;
  57190. /**
  57191. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57192. * @param mesh The mesh to highlight
  57193. */
  57194. removeExcludedMesh(mesh: Mesh): void;
  57195. /**
  57196. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57197. * @param mesh mesh to test
  57198. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57199. */
  57200. hasMesh(mesh: AbstractMesh): boolean;
  57201. /**
  57202. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57203. * @param mesh The mesh to highlight
  57204. * @param color The color of the highlight
  57205. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57206. */
  57207. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57208. /**
  57209. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57210. * @param mesh The mesh to highlight
  57211. */
  57212. removeMesh(mesh: Mesh): void;
  57213. /**
  57214. * Remove all the meshes currently referenced in the highlight layer
  57215. */
  57216. removeAllMeshes(): void;
  57217. /**
  57218. * Force the stencil to the normal expected value for none glowing parts
  57219. */
  57220. private _defaultStencilReference;
  57221. /**
  57222. * Free any resources and references associated to a mesh.
  57223. * Internal use
  57224. * @param mesh The mesh to free.
  57225. * @hidden
  57226. */
  57227. _disposeMesh(mesh: Mesh): void;
  57228. /**
  57229. * Dispose the highlight layer and free resources.
  57230. */
  57231. dispose(): void;
  57232. /**
  57233. * Gets the class name of the effect layer
  57234. * @returns the string with the class name of the effect layer
  57235. */
  57236. getClassName(): string;
  57237. /**
  57238. * Serializes this Highlight layer
  57239. * @returns a serialized Highlight layer object
  57240. */
  57241. serialize(): any;
  57242. /**
  57243. * Creates a Highlight layer from parsed Highlight layer data
  57244. * @param parsedHightlightLayer defines the Highlight layer data
  57245. * @param scene defines the current scene
  57246. * @param rootUrl defines the root URL containing the Highlight layer information
  57247. * @returns a parsed Highlight layer
  57248. */
  57249. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57250. }
  57251. }
  57252. declare module BABYLON {
  57253. interface AbstractScene {
  57254. /**
  57255. * The list of layers (background and foreground) of the scene
  57256. */
  57257. layers: Array<Layer>;
  57258. }
  57259. /**
  57260. * Defines the layer scene component responsible to manage any layers
  57261. * in a given scene.
  57262. */
  57263. export class LayerSceneComponent implements ISceneComponent {
  57264. /**
  57265. * The component name helpfull to identify the component in the list of scene components.
  57266. */
  57267. readonly name: string;
  57268. /**
  57269. * The scene the component belongs to.
  57270. */
  57271. scene: Scene;
  57272. private _engine;
  57273. /**
  57274. * Creates a new instance of the component for the given scene
  57275. * @param scene Defines the scene to register the component in
  57276. */
  57277. constructor(scene: Scene);
  57278. /**
  57279. * Registers the component in a given scene
  57280. */
  57281. register(): void;
  57282. /**
  57283. * Rebuilds the elements related to this component in case of
  57284. * context lost for instance.
  57285. */
  57286. rebuild(): void;
  57287. /**
  57288. * Disposes the component and the associated ressources.
  57289. */
  57290. dispose(): void;
  57291. private _draw;
  57292. private _drawCameraPredicate;
  57293. private _drawCameraBackground;
  57294. private _drawCameraForeground;
  57295. private _drawRenderTargetPredicate;
  57296. private _drawRenderTargetBackground;
  57297. private _drawRenderTargetForeground;
  57298. /**
  57299. * Adds all the elements from the container to the scene
  57300. * @param container the container holding the elements
  57301. */
  57302. addFromContainer(container: AbstractScene): void;
  57303. /**
  57304. * Removes all the elements in the container from the scene
  57305. * @param container contains the elements to remove
  57306. * @param dispose if the removed element should be disposed (default: false)
  57307. */
  57308. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57309. }
  57310. }
  57311. declare module BABYLON {
  57312. /** @hidden */
  57313. export var layerPixelShader: {
  57314. name: string;
  57315. shader: string;
  57316. };
  57317. }
  57318. declare module BABYLON {
  57319. /** @hidden */
  57320. export var layerVertexShader: {
  57321. name: string;
  57322. shader: string;
  57323. };
  57324. }
  57325. declare module BABYLON {
  57326. /**
  57327. * This represents a full screen 2d layer.
  57328. * This can be useful to display a picture in the background of your scene for instance.
  57329. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57330. */
  57331. export class Layer {
  57332. /**
  57333. * Define the name of the layer.
  57334. */
  57335. name: string;
  57336. /**
  57337. * Define the texture the layer should display.
  57338. */
  57339. texture: Nullable<Texture>;
  57340. /**
  57341. * Is the layer in background or foreground.
  57342. */
  57343. isBackground: boolean;
  57344. /**
  57345. * Define the color of the layer (instead of texture).
  57346. */
  57347. color: Color4;
  57348. /**
  57349. * Define the scale of the layer in order to zoom in out of the texture.
  57350. */
  57351. scale: Vector2;
  57352. /**
  57353. * Define an offset for the layer in order to shift the texture.
  57354. */
  57355. offset: Vector2;
  57356. /**
  57357. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57358. */
  57359. alphaBlendingMode: number;
  57360. /**
  57361. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57362. * Alpha test will not mix with the background color in case of transparency.
  57363. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57364. */
  57365. alphaTest: boolean;
  57366. /**
  57367. * Define a mask to restrict the layer to only some of the scene cameras.
  57368. */
  57369. layerMask: number;
  57370. /**
  57371. * Define the list of render target the layer is visible into.
  57372. */
  57373. renderTargetTextures: RenderTargetTexture[];
  57374. /**
  57375. * Define if the layer is only used in renderTarget or if it also
  57376. * renders in the main frame buffer of the canvas.
  57377. */
  57378. renderOnlyInRenderTargetTextures: boolean;
  57379. private _scene;
  57380. private _vertexBuffers;
  57381. private _indexBuffer;
  57382. private _effect;
  57383. private _previousDefines;
  57384. /**
  57385. * An event triggered when the layer is disposed.
  57386. */
  57387. onDisposeObservable: Observable<Layer>;
  57388. private _onDisposeObserver;
  57389. /**
  57390. * Back compatibility with callback before the onDisposeObservable existed.
  57391. * The set callback will be triggered when the layer has been disposed.
  57392. */
  57393. set onDispose(callback: () => void);
  57394. /**
  57395. * An event triggered before rendering the scene
  57396. */
  57397. onBeforeRenderObservable: Observable<Layer>;
  57398. private _onBeforeRenderObserver;
  57399. /**
  57400. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57401. * The set callback will be triggered just before rendering the layer.
  57402. */
  57403. set onBeforeRender(callback: () => void);
  57404. /**
  57405. * An event triggered after rendering the scene
  57406. */
  57407. onAfterRenderObservable: Observable<Layer>;
  57408. private _onAfterRenderObserver;
  57409. /**
  57410. * Back compatibility with callback before the onAfterRenderObservable existed.
  57411. * The set callback will be triggered just after rendering the layer.
  57412. */
  57413. set onAfterRender(callback: () => void);
  57414. /**
  57415. * Instantiates a new layer.
  57416. * This represents a full screen 2d layer.
  57417. * This can be useful to display a picture in the background of your scene for instance.
  57418. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57419. * @param name Define the name of the layer in the scene
  57420. * @param imgUrl Define the url of the texture to display in the layer
  57421. * @param scene Define the scene the layer belongs to
  57422. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57423. * @param color Defines a color for the layer
  57424. */
  57425. constructor(
  57426. /**
  57427. * Define the name of the layer.
  57428. */
  57429. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57430. private _createIndexBuffer;
  57431. /** @hidden */
  57432. _rebuild(): void;
  57433. /**
  57434. * Renders the layer in the scene.
  57435. */
  57436. render(): void;
  57437. /**
  57438. * Disposes and releases the associated ressources.
  57439. */
  57440. dispose(): void;
  57441. }
  57442. }
  57443. declare module BABYLON {
  57444. /** @hidden */
  57445. export var lensFlarePixelShader: {
  57446. name: string;
  57447. shader: string;
  57448. };
  57449. }
  57450. declare module BABYLON {
  57451. /** @hidden */
  57452. export var lensFlareVertexShader: {
  57453. name: string;
  57454. shader: string;
  57455. };
  57456. }
  57457. declare module BABYLON {
  57458. /**
  57459. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57460. * It is usually composed of several `lensFlare`.
  57461. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57462. */
  57463. export class LensFlareSystem {
  57464. /**
  57465. * Define the name of the lens flare system
  57466. */
  57467. name: string;
  57468. /**
  57469. * List of lens flares used in this system.
  57470. */
  57471. lensFlares: LensFlare[];
  57472. /**
  57473. * Define a limit from the border the lens flare can be visible.
  57474. */
  57475. borderLimit: number;
  57476. /**
  57477. * Define a viewport border we do not want to see the lens flare in.
  57478. */
  57479. viewportBorder: number;
  57480. /**
  57481. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57482. */
  57483. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57484. /**
  57485. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57486. */
  57487. layerMask: number;
  57488. /**
  57489. * Define the id of the lens flare system in the scene.
  57490. * (equal to name by default)
  57491. */
  57492. id: string;
  57493. private _scene;
  57494. private _emitter;
  57495. private _vertexBuffers;
  57496. private _indexBuffer;
  57497. private _effect;
  57498. private _positionX;
  57499. private _positionY;
  57500. private _isEnabled;
  57501. /** @hidden */
  57502. static _SceneComponentInitialization: (scene: Scene) => void;
  57503. /**
  57504. * Instantiates a lens flare system.
  57505. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57506. * It is usually composed of several `lensFlare`.
  57507. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57508. * @param name Define the name of the lens flare system in the scene
  57509. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57510. * @param scene Define the scene the lens flare system belongs to
  57511. */
  57512. constructor(
  57513. /**
  57514. * Define the name of the lens flare system
  57515. */
  57516. name: string, emitter: any, scene: Scene);
  57517. /**
  57518. * Define if the lens flare system is enabled.
  57519. */
  57520. get isEnabled(): boolean;
  57521. set isEnabled(value: boolean);
  57522. /**
  57523. * Get the scene the effects belongs to.
  57524. * @returns the scene holding the lens flare system
  57525. */
  57526. getScene(): Scene;
  57527. /**
  57528. * Get the emitter of the lens flare system.
  57529. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57530. * @returns the emitter of the lens flare system
  57531. */
  57532. getEmitter(): any;
  57533. /**
  57534. * Set the emitter of the lens flare system.
  57535. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57536. * @param newEmitter Define the new emitter of the system
  57537. */
  57538. setEmitter(newEmitter: any): void;
  57539. /**
  57540. * Get the lens flare system emitter position.
  57541. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57542. * @returns the position
  57543. */
  57544. getEmitterPosition(): Vector3;
  57545. /**
  57546. * @hidden
  57547. */
  57548. computeEffectivePosition(globalViewport: Viewport): boolean;
  57549. /** @hidden */
  57550. _isVisible(): boolean;
  57551. /**
  57552. * @hidden
  57553. */
  57554. render(): boolean;
  57555. /**
  57556. * Dispose and release the lens flare with its associated resources.
  57557. */
  57558. dispose(): void;
  57559. /**
  57560. * Parse a lens flare system from a JSON repressentation
  57561. * @param parsedLensFlareSystem Define the JSON to parse
  57562. * @param scene Define the scene the parsed system should be instantiated in
  57563. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57564. * @returns the parsed system
  57565. */
  57566. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57567. /**
  57568. * Serialize the current Lens Flare System into a JSON representation.
  57569. * @returns the serialized JSON
  57570. */
  57571. serialize(): any;
  57572. }
  57573. }
  57574. declare module BABYLON {
  57575. /**
  57576. * This represents one of the lens effect in a `lensFlareSystem`.
  57577. * It controls one of the indiviual texture used in the effect.
  57578. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57579. */
  57580. export class LensFlare {
  57581. /**
  57582. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57583. */
  57584. size: number;
  57585. /**
  57586. * 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.
  57587. */
  57588. position: number;
  57589. /**
  57590. * Define the lens color.
  57591. */
  57592. color: Color3;
  57593. /**
  57594. * Define the lens texture.
  57595. */
  57596. texture: Nullable<Texture>;
  57597. /**
  57598. * Define the alpha mode to render this particular lens.
  57599. */
  57600. alphaMode: number;
  57601. private _system;
  57602. /**
  57603. * Creates a new Lens Flare.
  57604. * This represents one of the lens effect in a `lensFlareSystem`.
  57605. * It controls one of the indiviual texture used in the effect.
  57606. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57607. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57608. * @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.
  57609. * @param color Define the lens color
  57610. * @param imgUrl Define the lens texture url
  57611. * @param system Define the `lensFlareSystem` this flare is part of
  57612. * @returns The newly created Lens Flare
  57613. */
  57614. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57615. /**
  57616. * Instantiates a new Lens Flare.
  57617. * This represents one of the lens effect in a `lensFlareSystem`.
  57618. * It controls one of the indiviual texture used in the effect.
  57619. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57620. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57621. * @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.
  57622. * @param color Define the lens color
  57623. * @param imgUrl Define the lens texture url
  57624. * @param system Define the `lensFlareSystem` this flare is part of
  57625. */
  57626. constructor(
  57627. /**
  57628. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57629. */
  57630. size: number,
  57631. /**
  57632. * 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.
  57633. */
  57634. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57635. /**
  57636. * Dispose and release the lens flare with its associated resources.
  57637. */
  57638. dispose(): void;
  57639. }
  57640. }
  57641. declare module BABYLON {
  57642. interface AbstractScene {
  57643. /**
  57644. * The list of lens flare system added to the scene
  57645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57646. */
  57647. lensFlareSystems: Array<LensFlareSystem>;
  57648. /**
  57649. * Removes the given lens flare system from this scene.
  57650. * @param toRemove The lens flare system to remove
  57651. * @returns The index of the removed lens flare system
  57652. */
  57653. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57654. /**
  57655. * Adds the given lens flare system to this scene
  57656. * @param newLensFlareSystem The lens flare system to add
  57657. */
  57658. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57659. /**
  57660. * Gets a lens flare system using its name
  57661. * @param name defines the name to look for
  57662. * @returns the lens flare system or null if not found
  57663. */
  57664. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57665. /**
  57666. * Gets a lens flare system using its id
  57667. * @param id defines the id to look for
  57668. * @returns the lens flare system or null if not found
  57669. */
  57670. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57671. }
  57672. /**
  57673. * Defines the lens flare scene component responsible to manage any lens flares
  57674. * in a given scene.
  57675. */
  57676. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57677. /**
  57678. * The component name helpfull to identify the component in the list of scene components.
  57679. */
  57680. readonly name: string;
  57681. /**
  57682. * The scene the component belongs to.
  57683. */
  57684. scene: Scene;
  57685. /**
  57686. * Creates a new instance of the component for the given scene
  57687. * @param scene Defines the scene to register the component in
  57688. */
  57689. constructor(scene: Scene);
  57690. /**
  57691. * Registers the component in a given scene
  57692. */
  57693. register(): void;
  57694. /**
  57695. * Rebuilds the elements related to this component in case of
  57696. * context lost for instance.
  57697. */
  57698. rebuild(): void;
  57699. /**
  57700. * Adds all the elements from the container to the scene
  57701. * @param container the container holding the elements
  57702. */
  57703. addFromContainer(container: AbstractScene): void;
  57704. /**
  57705. * Removes all the elements in the container from the scene
  57706. * @param container contains the elements to remove
  57707. * @param dispose if the removed element should be disposed (default: false)
  57708. */
  57709. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57710. /**
  57711. * Serializes the component data to the specified json object
  57712. * @param serializationObject The object to serialize to
  57713. */
  57714. serialize(serializationObject: any): void;
  57715. /**
  57716. * Disposes the component and the associated ressources.
  57717. */
  57718. dispose(): void;
  57719. private _draw;
  57720. }
  57721. }
  57722. declare module BABYLON {
  57723. /** @hidden */
  57724. export var depthPixelShader: {
  57725. name: string;
  57726. shader: string;
  57727. };
  57728. }
  57729. declare module BABYLON {
  57730. /** @hidden */
  57731. export var depthVertexShader: {
  57732. name: string;
  57733. shader: string;
  57734. };
  57735. }
  57736. declare module BABYLON {
  57737. /**
  57738. * This represents a depth renderer in Babylon.
  57739. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57740. */
  57741. export class DepthRenderer {
  57742. private _scene;
  57743. private _depthMap;
  57744. private _effect;
  57745. private readonly _storeNonLinearDepth;
  57746. private readonly _clearColor;
  57747. /** Get if the depth renderer is using packed depth or not */
  57748. readonly isPacked: boolean;
  57749. private _cachedDefines;
  57750. private _camera;
  57751. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57752. enabled: boolean;
  57753. /**
  57754. * Specifiess that the depth renderer will only be used within
  57755. * the camera it is created for.
  57756. * This can help forcing its rendering during the camera processing.
  57757. */
  57758. useOnlyInActiveCamera: boolean;
  57759. /** @hidden */
  57760. static _SceneComponentInitialization: (scene: Scene) => void;
  57761. /**
  57762. * Instantiates a depth renderer
  57763. * @param scene The scene the renderer belongs to
  57764. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57765. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57766. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57767. */
  57768. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57769. /**
  57770. * Creates the depth rendering effect and checks if the effect is ready.
  57771. * @param subMesh The submesh to be used to render the depth map of
  57772. * @param useInstances If multiple world instances should be used
  57773. * @returns if the depth renderer is ready to render the depth map
  57774. */
  57775. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57776. /**
  57777. * Gets the texture which the depth map will be written to.
  57778. * @returns The depth map texture
  57779. */
  57780. getDepthMap(): RenderTargetTexture;
  57781. /**
  57782. * Disposes of the depth renderer.
  57783. */
  57784. dispose(): void;
  57785. }
  57786. }
  57787. declare module BABYLON {
  57788. /** @hidden */
  57789. export var minmaxReduxPixelShader: {
  57790. name: string;
  57791. shader: string;
  57792. };
  57793. }
  57794. declare module BABYLON {
  57795. /**
  57796. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57797. * and maximum values from all values of the texture.
  57798. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57799. * The source values are read from the red channel of the texture.
  57800. */
  57801. export class MinMaxReducer {
  57802. /**
  57803. * Observable triggered when the computation has been performed
  57804. */
  57805. onAfterReductionPerformed: Observable<{
  57806. min: number;
  57807. max: number;
  57808. }>;
  57809. protected _camera: Camera;
  57810. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57811. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57812. protected _postProcessManager: PostProcessManager;
  57813. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57814. protected _forceFullscreenViewport: boolean;
  57815. /**
  57816. * Creates a min/max reducer
  57817. * @param camera The camera to use for the post processes
  57818. */
  57819. constructor(camera: Camera);
  57820. /**
  57821. * Gets the texture used to read the values from.
  57822. */
  57823. get sourceTexture(): Nullable<RenderTargetTexture>;
  57824. /**
  57825. * Sets the source texture to read the values from.
  57826. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57827. * because in such textures '1' value must not be taken into account to compute the maximum
  57828. * as this value is used to clear the texture.
  57829. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57830. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57831. * @param depthRedux Indicates if the texture is a depth texture or not
  57832. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57833. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57834. */
  57835. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57836. /**
  57837. * Defines the refresh rate of the computation.
  57838. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57839. */
  57840. get refreshRate(): number;
  57841. set refreshRate(value: number);
  57842. protected _activated: boolean;
  57843. /**
  57844. * Gets the activation status of the reducer
  57845. */
  57846. get activated(): boolean;
  57847. /**
  57848. * Activates the reduction computation.
  57849. * When activated, the observers registered in onAfterReductionPerformed are
  57850. * called after the compuation is performed
  57851. */
  57852. activate(): void;
  57853. /**
  57854. * Deactivates the reduction computation.
  57855. */
  57856. deactivate(): void;
  57857. /**
  57858. * Disposes the min/max reducer
  57859. * @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.
  57860. */
  57861. dispose(disposeAll?: boolean): void;
  57862. }
  57863. }
  57864. declare module BABYLON {
  57865. /**
  57866. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57867. */
  57868. export class DepthReducer extends MinMaxReducer {
  57869. private _depthRenderer;
  57870. private _depthRendererId;
  57871. /**
  57872. * Gets the depth renderer used for the computation.
  57873. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57874. */
  57875. get depthRenderer(): Nullable<DepthRenderer>;
  57876. /**
  57877. * Creates a depth reducer
  57878. * @param camera The camera used to render the depth texture
  57879. */
  57880. constructor(camera: Camera);
  57881. /**
  57882. * Sets the depth renderer to use to generate the depth map
  57883. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57884. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57885. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57886. */
  57887. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57888. /** @hidden */
  57889. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57890. /**
  57891. * Activates the reduction computation.
  57892. * When activated, the observers registered in onAfterReductionPerformed are
  57893. * called after the compuation is performed
  57894. */
  57895. activate(): void;
  57896. /**
  57897. * Deactivates the reduction computation.
  57898. */
  57899. deactivate(): void;
  57900. /**
  57901. * Disposes the depth reducer
  57902. * @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.
  57903. */
  57904. dispose(disposeAll?: boolean): void;
  57905. }
  57906. }
  57907. declare module BABYLON {
  57908. /**
  57909. * A CSM implementation allowing casting shadows on large scenes.
  57910. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57911. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57912. */
  57913. export class CascadedShadowGenerator extends ShadowGenerator {
  57914. private static readonly frustumCornersNDCSpace;
  57915. /**
  57916. * Name of the CSM class
  57917. */
  57918. static CLASSNAME: string;
  57919. /**
  57920. * Defines the default number of cascades used by the CSM.
  57921. */
  57922. static readonly DEFAULT_CASCADES_COUNT: number;
  57923. /**
  57924. * Defines the minimum number of cascades used by the CSM.
  57925. */
  57926. static readonly MIN_CASCADES_COUNT: number;
  57927. /**
  57928. * Defines the maximum number of cascades used by the CSM.
  57929. */
  57930. static readonly MAX_CASCADES_COUNT: number;
  57931. protected _validateFilter(filter: number): number;
  57932. /**
  57933. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57934. */
  57935. penumbraDarkness: number;
  57936. private _numCascades;
  57937. /**
  57938. * Gets or set the number of cascades used by the CSM.
  57939. */
  57940. get numCascades(): number;
  57941. set numCascades(value: number);
  57942. /**
  57943. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57944. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57945. */
  57946. stabilizeCascades: boolean;
  57947. private _freezeShadowCastersBoundingInfo;
  57948. private _freezeShadowCastersBoundingInfoObservable;
  57949. /**
  57950. * Enables or disables the shadow casters bounding info computation.
  57951. * If your shadow casters don't move, you can disable this feature.
  57952. * If it is enabled, the bounding box computation is done every frame.
  57953. */
  57954. get freezeShadowCastersBoundingInfo(): boolean;
  57955. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57956. private _scbiMin;
  57957. private _scbiMax;
  57958. protected _computeShadowCastersBoundingInfo(): void;
  57959. protected _shadowCastersBoundingInfo: BoundingInfo;
  57960. /**
  57961. * Gets or sets the shadow casters bounding info.
  57962. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57963. * so that the system won't overwrite the bounds you provide
  57964. */
  57965. get shadowCastersBoundingInfo(): BoundingInfo;
  57966. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57967. protected _breaksAreDirty: boolean;
  57968. protected _minDistance: number;
  57969. protected _maxDistance: number;
  57970. /**
  57971. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57972. *
  57973. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57974. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57975. * @param min minimal distance for the breaks (default to 0.)
  57976. * @param max maximal distance for the breaks (default to 1.)
  57977. */
  57978. setMinMaxDistance(min: number, max: number): void;
  57979. /** Gets the minimal distance used in the cascade break computation */
  57980. get minDistance(): number;
  57981. /** Gets the maximal distance used in the cascade break computation */
  57982. get maxDistance(): number;
  57983. /**
  57984. * Gets the class name of that object
  57985. * @returns "CascadedShadowGenerator"
  57986. */
  57987. getClassName(): string;
  57988. private _cascadeMinExtents;
  57989. private _cascadeMaxExtents;
  57990. /**
  57991. * Gets a cascade minimum extents
  57992. * @param cascadeIndex index of the cascade
  57993. * @returns the minimum cascade extents
  57994. */
  57995. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57996. /**
  57997. * Gets a cascade maximum extents
  57998. * @param cascadeIndex index of the cascade
  57999. * @returns the maximum cascade extents
  58000. */
  58001. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58002. private _cascades;
  58003. private _currentLayer;
  58004. private _viewSpaceFrustumsZ;
  58005. private _viewMatrices;
  58006. private _projectionMatrices;
  58007. private _transformMatrices;
  58008. private _transformMatricesAsArray;
  58009. private _frustumLengths;
  58010. private _lightSizeUVCorrection;
  58011. private _depthCorrection;
  58012. private _frustumCornersWorldSpace;
  58013. private _frustumCenter;
  58014. private _shadowCameraPos;
  58015. private _shadowMaxZ;
  58016. /**
  58017. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58018. * It defaults to camera.maxZ
  58019. */
  58020. get shadowMaxZ(): number;
  58021. /**
  58022. * Sets the shadow max z distance.
  58023. */
  58024. set shadowMaxZ(value: number);
  58025. protected _debug: boolean;
  58026. /**
  58027. * Gets or sets the debug flag.
  58028. * When enabled, the cascades are materialized by different colors on the screen.
  58029. */
  58030. get debug(): boolean;
  58031. set debug(dbg: boolean);
  58032. private _depthClamp;
  58033. /**
  58034. * Gets or sets the depth clamping value.
  58035. *
  58036. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58037. * to account for the shadow casters far away.
  58038. *
  58039. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58040. */
  58041. get depthClamp(): boolean;
  58042. set depthClamp(value: boolean);
  58043. private _cascadeBlendPercentage;
  58044. /**
  58045. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58046. * It defaults to 0.1 (10% blending).
  58047. */
  58048. get cascadeBlendPercentage(): number;
  58049. set cascadeBlendPercentage(value: number);
  58050. private _lambda;
  58051. /**
  58052. * Gets or set the lambda parameter.
  58053. * This parameter is used to split the camera frustum and create the cascades.
  58054. * 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.
  58055. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58056. */
  58057. get lambda(): number;
  58058. set lambda(value: number);
  58059. /**
  58060. * Gets the view matrix corresponding to a given cascade
  58061. * @param cascadeNum cascade to retrieve the view matrix from
  58062. * @returns the cascade view matrix
  58063. */
  58064. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58065. /**
  58066. * Gets the projection matrix corresponding to a given cascade
  58067. * @param cascadeNum cascade to retrieve the projection matrix from
  58068. * @returns the cascade projection matrix
  58069. */
  58070. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58071. /**
  58072. * Gets the transformation matrix corresponding to a given cascade
  58073. * @param cascadeNum cascade to retrieve the transformation matrix from
  58074. * @returns the cascade transformation matrix
  58075. */
  58076. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58077. private _depthRenderer;
  58078. /**
  58079. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58080. *
  58081. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58082. *
  58083. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58084. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58085. * @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
  58086. */
  58087. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58088. private _depthReducer;
  58089. private _autoCalcDepthBounds;
  58090. /**
  58091. * Gets or sets the autoCalcDepthBounds property.
  58092. *
  58093. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58094. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58095. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58096. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58097. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58098. */
  58099. get autoCalcDepthBounds(): boolean;
  58100. set autoCalcDepthBounds(value: boolean);
  58101. /**
  58102. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58103. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58104. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58105. * for setting the refresh rate on the renderer yourself!
  58106. */
  58107. get autoCalcDepthBoundsRefreshRate(): number;
  58108. set autoCalcDepthBoundsRefreshRate(value: number);
  58109. /**
  58110. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58111. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58112. * you change the camera near/far planes!
  58113. */
  58114. splitFrustum(): void;
  58115. private _splitFrustum;
  58116. private _computeMatrices;
  58117. private _computeFrustumInWorldSpace;
  58118. private _computeCascadeFrustum;
  58119. /**
  58120. * Support test.
  58121. */
  58122. static get IsSupported(): boolean;
  58123. /** @hidden */
  58124. static _SceneComponentInitialization: (scene: Scene) => void;
  58125. /**
  58126. * Creates a Cascaded Shadow Generator object.
  58127. * A ShadowGenerator is the required tool to use the shadows.
  58128. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58129. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58130. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58131. * @param light The directional light object generating the shadows.
  58132. * @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.
  58133. */
  58134. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58135. protected _initializeGenerator(): void;
  58136. protected _createTargetRenderTexture(): void;
  58137. protected _initializeShadowMap(): void;
  58138. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58139. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58140. /**
  58141. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58142. * @param defines Defines of the material we want to update
  58143. * @param lightIndex Index of the light in the enabled light list of the material
  58144. */
  58145. prepareDefines(defines: any, lightIndex: number): void;
  58146. /**
  58147. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58148. * defined in the generator but impacting the effect).
  58149. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58150. * @param effect The effect we are binfing the information for
  58151. */
  58152. bindShadowLight(lightIndex: string, effect: Effect): void;
  58153. /**
  58154. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58155. * (eq to view projection * shadow projection matrices)
  58156. * @returns The transform matrix used to create the shadow map
  58157. */
  58158. getTransformMatrix(): Matrix;
  58159. /**
  58160. * Disposes the ShadowGenerator.
  58161. * Returns nothing.
  58162. */
  58163. dispose(): void;
  58164. /**
  58165. * Serializes the shadow generator setup to a json object.
  58166. * @returns The serialized JSON object
  58167. */
  58168. serialize(): any;
  58169. /**
  58170. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58171. * @param parsedShadowGenerator The JSON object to parse
  58172. * @param scene The scene to create the shadow map for
  58173. * @returns The parsed shadow generator
  58174. */
  58175. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58176. }
  58177. }
  58178. declare module BABYLON {
  58179. /**
  58180. * Defines the shadow generator component responsible to manage any shadow generators
  58181. * in a given scene.
  58182. */
  58183. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58184. /**
  58185. * The component name helpfull to identify the component in the list of scene components.
  58186. */
  58187. readonly name: string;
  58188. /**
  58189. * The scene the component belongs to.
  58190. */
  58191. scene: Scene;
  58192. /**
  58193. * Creates a new instance of the component for the given scene
  58194. * @param scene Defines the scene to register the component in
  58195. */
  58196. constructor(scene: Scene);
  58197. /**
  58198. * Registers the component in a given scene
  58199. */
  58200. register(): void;
  58201. /**
  58202. * Rebuilds the elements related to this component in case of
  58203. * context lost for instance.
  58204. */
  58205. rebuild(): void;
  58206. /**
  58207. * Serializes the component data to the specified json object
  58208. * @param serializationObject The object to serialize to
  58209. */
  58210. serialize(serializationObject: any): void;
  58211. /**
  58212. * Adds all the elements from the container to the scene
  58213. * @param container the container holding the elements
  58214. */
  58215. addFromContainer(container: AbstractScene): void;
  58216. /**
  58217. * Removes all the elements in the container from the scene
  58218. * @param container contains the elements to remove
  58219. * @param dispose if the removed element should be disposed (default: false)
  58220. */
  58221. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58222. /**
  58223. * Rebuilds the elements related to this component in case of
  58224. * context lost for instance.
  58225. */
  58226. dispose(): void;
  58227. private _gatherRenderTargets;
  58228. }
  58229. }
  58230. declare module BABYLON {
  58231. /**
  58232. * A point light is a light defined by an unique point in world space.
  58233. * The light is emitted in every direction from this point.
  58234. * A good example of a point light is a standard light bulb.
  58235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58236. */
  58237. export class PointLight extends ShadowLight {
  58238. private _shadowAngle;
  58239. /**
  58240. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58241. * This specifies what angle the shadow will use to be created.
  58242. *
  58243. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58244. */
  58245. get shadowAngle(): number;
  58246. /**
  58247. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58248. * This specifies what angle the shadow will use to be created.
  58249. *
  58250. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58251. */
  58252. set shadowAngle(value: number);
  58253. /**
  58254. * Gets the direction if it has been set.
  58255. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58256. */
  58257. get direction(): Vector3;
  58258. /**
  58259. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58260. */
  58261. set direction(value: Vector3);
  58262. /**
  58263. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58264. * A PointLight emits the light in every direction.
  58265. * It can cast shadows.
  58266. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58267. * ```javascript
  58268. * var pointLight = new PointLight("pl", camera.position, scene);
  58269. * ```
  58270. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58271. * @param name The light friendly name
  58272. * @param position The position of the point light in the scene
  58273. * @param scene The scene the lights belongs to
  58274. */
  58275. constructor(name: string, position: Vector3, scene: Scene);
  58276. /**
  58277. * Returns the string "PointLight"
  58278. * @returns the class name
  58279. */
  58280. getClassName(): string;
  58281. /**
  58282. * Returns the integer 0.
  58283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58284. */
  58285. getTypeID(): number;
  58286. /**
  58287. * Specifies wether or not the shadowmap should be a cube texture.
  58288. * @returns true if the shadowmap needs to be a cube texture.
  58289. */
  58290. needCube(): boolean;
  58291. /**
  58292. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58293. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58294. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58295. */
  58296. getShadowDirection(faceIndex?: number): Vector3;
  58297. /**
  58298. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58299. * - fov = PI / 2
  58300. * - aspect ratio : 1.0
  58301. * - z-near and far equal to the active camera minZ and maxZ.
  58302. * Returns the PointLight.
  58303. */
  58304. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58305. protected _buildUniformLayout(): void;
  58306. /**
  58307. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58308. * @param effect The effect to update
  58309. * @param lightIndex The index of the light in the effect to update
  58310. * @returns The point light
  58311. */
  58312. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58314. /**
  58315. * Prepares the list of defines specific to the light type.
  58316. * @param defines the list of defines
  58317. * @param lightIndex defines the index of the light for the effect
  58318. */
  58319. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58320. }
  58321. }
  58322. declare module BABYLON {
  58323. /**
  58324. * Header information of HDR texture files.
  58325. */
  58326. export interface HDRInfo {
  58327. /**
  58328. * The height of the texture in pixels.
  58329. */
  58330. height: number;
  58331. /**
  58332. * The width of the texture in pixels.
  58333. */
  58334. width: number;
  58335. /**
  58336. * The index of the beginning of the data in the binary file.
  58337. */
  58338. dataPosition: number;
  58339. }
  58340. /**
  58341. * This groups tools to convert HDR texture to native colors array.
  58342. */
  58343. export class HDRTools {
  58344. private static Ldexp;
  58345. private static Rgbe2float;
  58346. private static readStringLine;
  58347. /**
  58348. * Reads header information from an RGBE texture stored in a native array.
  58349. * More information on this format are available here:
  58350. * https://en.wikipedia.org/wiki/RGBE_image_format
  58351. *
  58352. * @param uint8array The binary file stored in native array.
  58353. * @return The header information.
  58354. */
  58355. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58356. /**
  58357. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58358. * This RGBE texture needs to store the information as a panorama.
  58359. *
  58360. * More information on this format are available here:
  58361. * https://en.wikipedia.org/wiki/RGBE_image_format
  58362. *
  58363. * @param buffer The binary file stored in an array buffer.
  58364. * @param size The expected size of the extracted cubemap.
  58365. * @return The Cube Map information.
  58366. */
  58367. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58368. /**
  58369. * Returns the pixels data extracted from an RGBE texture.
  58370. * This pixels will be stored left to right up to down in the R G B order in one array.
  58371. *
  58372. * More information on this format are available here:
  58373. * https://en.wikipedia.org/wiki/RGBE_image_format
  58374. *
  58375. * @param uint8array The binary file stored in an array buffer.
  58376. * @param hdrInfo The header information of the file.
  58377. * @return The pixels data in RGB right to left up to down order.
  58378. */
  58379. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58380. private static RGBE_ReadPixels_RLE;
  58381. }
  58382. }
  58383. declare module BABYLON {
  58384. /**
  58385. * Effect Render Options
  58386. */
  58387. export interface IEffectRendererOptions {
  58388. /**
  58389. * Defines the vertices positions.
  58390. */
  58391. positions?: number[];
  58392. /**
  58393. * Defines the indices.
  58394. */
  58395. indices?: number[];
  58396. }
  58397. /**
  58398. * Helper class to render one or more effects.
  58399. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58400. */
  58401. export class EffectRenderer {
  58402. private engine;
  58403. private static _DefaultOptions;
  58404. private _vertexBuffers;
  58405. private _indexBuffer;
  58406. private _fullscreenViewport;
  58407. /**
  58408. * Creates an effect renderer
  58409. * @param engine the engine to use for rendering
  58410. * @param options defines the options of the effect renderer
  58411. */
  58412. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58413. /**
  58414. * Sets the current viewport in normalized coordinates 0-1
  58415. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58416. */
  58417. setViewport(viewport?: Viewport): void;
  58418. /**
  58419. * Binds the embedded attributes buffer to the effect.
  58420. * @param effect Defines the effect to bind the attributes for
  58421. */
  58422. bindBuffers(effect: Effect): void;
  58423. /**
  58424. * Sets the current effect wrapper to use during draw.
  58425. * The effect needs to be ready before calling this api.
  58426. * This also sets the default full screen position attribute.
  58427. * @param effectWrapper Defines the effect to draw with
  58428. */
  58429. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58430. /**
  58431. * Restores engine states
  58432. */
  58433. restoreStates(): void;
  58434. /**
  58435. * Draws a full screen quad.
  58436. */
  58437. draw(): void;
  58438. private isRenderTargetTexture;
  58439. /**
  58440. * renders one or more effects to a specified texture
  58441. * @param effectWrapper the effect to renderer
  58442. * @param outputTexture texture to draw to, if null it will render to the screen.
  58443. */
  58444. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58445. /**
  58446. * Disposes of the effect renderer
  58447. */
  58448. dispose(): void;
  58449. }
  58450. /**
  58451. * Options to create an EffectWrapper
  58452. */
  58453. interface EffectWrapperCreationOptions {
  58454. /**
  58455. * Engine to use to create the effect
  58456. */
  58457. engine: ThinEngine;
  58458. /**
  58459. * Fragment shader for the effect
  58460. */
  58461. fragmentShader: string;
  58462. /**
  58463. * Use the shader store instead of direct source code
  58464. */
  58465. useShaderStore?: boolean;
  58466. /**
  58467. * Vertex shader for the effect
  58468. */
  58469. vertexShader?: string;
  58470. /**
  58471. * Attributes to use in the shader
  58472. */
  58473. attributeNames?: Array<string>;
  58474. /**
  58475. * Uniforms to use in the shader
  58476. */
  58477. uniformNames?: Array<string>;
  58478. /**
  58479. * Texture sampler names to use in the shader
  58480. */
  58481. samplerNames?: Array<string>;
  58482. /**
  58483. * Defines to use in the shader
  58484. */
  58485. defines?: Array<string>;
  58486. /**
  58487. * Callback when effect is compiled
  58488. */
  58489. onCompiled?: Nullable<(effect: Effect) => void>;
  58490. /**
  58491. * The friendly name of the effect displayed in Spector.
  58492. */
  58493. name?: string;
  58494. }
  58495. /**
  58496. * Wraps an effect to be used for rendering
  58497. */
  58498. export class EffectWrapper {
  58499. /**
  58500. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58501. */
  58502. onApplyObservable: Observable<{}>;
  58503. /**
  58504. * The underlying effect
  58505. */
  58506. effect: Effect;
  58507. /**
  58508. * Creates an effect to be renderer
  58509. * @param creationOptions options to create the effect
  58510. */
  58511. constructor(creationOptions: EffectWrapperCreationOptions);
  58512. /**
  58513. * Disposes of the effect wrapper
  58514. */
  58515. dispose(): void;
  58516. }
  58517. }
  58518. declare module BABYLON {
  58519. /** @hidden */
  58520. export var hdrFilteringVertexShader: {
  58521. name: string;
  58522. shader: string;
  58523. };
  58524. }
  58525. declare module BABYLON {
  58526. /** @hidden */
  58527. export var hdrFilteringPixelShader: {
  58528. name: string;
  58529. shader: string;
  58530. };
  58531. }
  58532. declare module BABYLON {
  58533. /**
  58534. * Options for texture filtering
  58535. */
  58536. interface IHDRFilteringOptions {
  58537. /**
  58538. * Scales pixel intensity for the input HDR map.
  58539. */
  58540. hdrScale?: number;
  58541. /**
  58542. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58543. */
  58544. quality?: number;
  58545. }
  58546. /**
  58547. * Filters HDR maps to get correct renderings of PBR reflections
  58548. */
  58549. export class HDRFiltering {
  58550. private _engine;
  58551. private _effectRenderer;
  58552. private _effectWrapper;
  58553. private _lodGenerationOffset;
  58554. private _lodGenerationScale;
  58555. /**
  58556. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58557. * you care about baking speed.
  58558. */
  58559. quality: number;
  58560. /**
  58561. * Scales pixel intensity for the input HDR map.
  58562. */
  58563. hdrScale: number;
  58564. /**
  58565. * Instantiates HDR filter for reflection maps
  58566. *
  58567. * @param engine Thin engine
  58568. * @param options Options
  58569. */
  58570. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58571. private _createRenderTarget;
  58572. private _prefilterInternal;
  58573. private _createEffect;
  58574. /**
  58575. * Get a value indicating if the filter is ready to be used
  58576. * @param texture Texture to filter
  58577. * @returns true if the filter is ready
  58578. */
  58579. isReady(texture: BaseTexture): boolean;
  58580. /**
  58581. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58582. * Prefiltering will be invoked at the end of next rendering pass.
  58583. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58584. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58585. * @param texture Texture to filter
  58586. * @param onFinished Callback when filtering is done
  58587. * @return Promise called when prefiltering is done
  58588. */
  58589. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * This represents a texture coming from an HDR input.
  58595. *
  58596. * The only supported format is currently panorama picture stored in RGBE format.
  58597. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58598. */
  58599. export class HDRCubeTexture extends BaseTexture {
  58600. private static _facesMapping;
  58601. private _generateHarmonics;
  58602. private _noMipmap;
  58603. private _prefilterOnLoad;
  58604. private _textureMatrix;
  58605. private _size;
  58606. private _onLoad;
  58607. private _onError;
  58608. /**
  58609. * The texture URL.
  58610. */
  58611. url: string;
  58612. /**
  58613. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58614. */
  58615. coordinatesMode: number;
  58616. protected _isBlocking: boolean;
  58617. /**
  58618. * Sets wether or not the texture is blocking during loading.
  58619. */
  58620. set isBlocking(value: boolean);
  58621. /**
  58622. * Gets wether or not the texture is blocking during loading.
  58623. */
  58624. get isBlocking(): boolean;
  58625. protected _rotationY: number;
  58626. /**
  58627. * Sets texture matrix rotation angle around Y axis in radians.
  58628. */
  58629. set rotationY(value: number);
  58630. /**
  58631. * Gets texture matrix rotation angle around Y axis radians.
  58632. */
  58633. get rotationY(): number;
  58634. /**
  58635. * Gets or sets the center of the bounding box associated with the cube texture
  58636. * It must define where the camera used to render the texture was set
  58637. */
  58638. boundingBoxPosition: Vector3;
  58639. private _boundingBoxSize;
  58640. /**
  58641. * Gets or sets the size of the bounding box associated with the cube texture
  58642. * When defined, the cubemap will switch to local mode
  58643. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58644. * @example https://www.babylonjs-playground.com/#RNASML
  58645. */
  58646. set boundingBoxSize(value: Vector3);
  58647. get boundingBoxSize(): Vector3;
  58648. /**
  58649. * Instantiates an HDRTexture from the following parameters.
  58650. *
  58651. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58652. * @param sceneOrEngine The scene or engine the texture will be used in
  58653. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58654. * @param noMipmap Forces to not generate the mipmap if true
  58655. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58656. * @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)
  58657. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58658. */
  58659. 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>);
  58660. /**
  58661. * Get the current class name of the texture useful for serialization or dynamic coding.
  58662. * @returns "HDRCubeTexture"
  58663. */
  58664. getClassName(): string;
  58665. /**
  58666. * Occurs when the file is raw .hdr file.
  58667. */
  58668. private loadTexture;
  58669. clone(): HDRCubeTexture;
  58670. delayLoad(): void;
  58671. /**
  58672. * Get the texture reflection matrix used to rotate/transform the reflection.
  58673. * @returns the reflection matrix
  58674. */
  58675. getReflectionTextureMatrix(): Matrix;
  58676. /**
  58677. * Set the texture reflection matrix used to rotate/transform the reflection.
  58678. * @param value Define the reflection matrix to set
  58679. */
  58680. setReflectionTextureMatrix(value: Matrix): void;
  58681. /**
  58682. * Parses a JSON representation of an HDR Texture in order to create the texture
  58683. * @param parsedTexture Define the JSON representation
  58684. * @param scene Define the scene the texture should be created in
  58685. * @param rootUrl Define the root url in case we need to load relative dependencies
  58686. * @returns the newly created texture after parsing
  58687. */
  58688. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58689. serialize(): any;
  58690. }
  58691. }
  58692. declare module BABYLON {
  58693. /**
  58694. * Class used to control physics engine
  58695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58696. */
  58697. export class PhysicsEngine implements IPhysicsEngine {
  58698. private _physicsPlugin;
  58699. /**
  58700. * Global value used to control the smallest number supported by the simulation
  58701. */
  58702. static Epsilon: number;
  58703. private _impostors;
  58704. private _joints;
  58705. private _subTimeStep;
  58706. /**
  58707. * Gets the gravity vector used by the simulation
  58708. */
  58709. gravity: Vector3;
  58710. /**
  58711. * Factory used to create the default physics plugin.
  58712. * @returns The default physics plugin
  58713. */
  58714. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58715. /**
  58716. * Creates a new Physics Engine
  58717. * @param gravity defines the gravity vector used by the simulation
  58718. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58719. */
  58720. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58721. /**
  58722. * Sets the gravity vector used by the simulation
  58723. * @param gravity defines the gravity vector to use
  58724. */
  58725. setGravity(gravity: Vector3): void;
  58726. /**
  58727. * Set the time step of the physics engine.
  58728. * Default is 1/60.
  58729. * To slow it down, enter 1/600 for example.
  58730. * To speed it up, 1/30
  58731. * @param newTimeStep defines the new timestep to apply to this world.
  58732. */
  58733. setTimeStep(newTimeStep?: number): void;
  58734. /**
  58735. * Get the time step of the physics engine.
  58736. * @returns the current time step
  58737. */
  58738. getTimeStep(): number;
  58739. /**
  58740. * Set the sub time step of the physics engine.
  58741. * Default is 0 meaning there is no sub steps
  58742. * To increase physics resolution precision, set a small value (like 1 ms)
  58743. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58744. */
  58745. setSubTimeStep(subTimeStep?: number): void;
  58746. /**
  58747. * Get the sub time step of the physics engine.
  58748. * @returns the current sub time step
  58749. */
  58750. getSubTimeStep(): number;
  58751. /**
  58752. * Release all resources
  58753. */
  58754. dispose(): void;
  58755. /**
  58756. * Gets the name of the current physics plugin
  58757. * @returns the name of the plugin
  58758. */
  58759. getPhysicsPluginName(): string;
  58760. /**
  58761. * Adding a new impostor for the impostor tracking.
  58762. * This will be done by the impostor itself.
  58763. * @param impostor the impostor to add
  58764. */
  58765. addImpostor(impostor: PhysicsImpostor): void;
  58766. /**
  58767. * Remove an impostor from the engine.
  58768. * This impostor and its mesh will not longer be updated by the physics engine.
  58769. * @param impostor the impostor to remove
  58770. */
  58771. removeImpostor(impostor: PhysicsImpostor): void;
  58772. /**
  58773. * Add a joint to the physics engine
  58774. * @param mainImpostor defines the main impostor to which the joint is added.
  58775. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58776. * @param joint defines the joint that will connect both impostors.
  58777. */
  58778. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58779. /**
  58780. * Removes a joint from the simulation
  58781. * @param mainImpostor defines the impostor used with the joint
  58782. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58783. * @param joint defines the joint to remove
  58784. */
  58785. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58786. /**
  58787. * Called by the scene. No need to call it.
  58788. * @param delta defines the timespam between frames
  58789. */
  58790. _step(delta: number): void;
  58791. /**
  58792. * Gets the current plugin used to run the simulation
  58793. * @returns current plugin
  58794. */
  58795. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58796. /**
  58797. * Gets the list of physic impostors
  58798. * @returns an array of PhysicsImpostor
  58799. */
  58800. getImpostors(): Array<PhysicsImpostor>;
  58801. /**
  58802. * Gets the impostor for a physics enabled object
  58803. * @param object defines the object impersonated by the impostor
  58804. * @returns the PhysicsImpostor or null if not found
  58805. */
  58806. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58807. /**
  58808. * Gets the impostor for a physics body object
  58809. * @param body defines physics body used by the impostor
  58810. * @returns the PhysicsImpostor or null if not found
  58811. */
  58812. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58813. /**
  58814. * Does a raycast in the physics world
  58815. * @param from when should the ray start?
  58816. * @param to when should the ray end?
  58817. * @returns PhysicsRaycastResult
  58818. */
  58819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58820. }
  58821. }
  58822. declare module BABYLON {
  58823. /** @hidden */
  58824. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58825. private _useDeltaForWorldStep;
  58826. world: any;
  58827. name: string;
  58828. private _physicsMaterials;
  58829. private _fixedTimeStep;
  58830. private _cannonRaycastResult;
  58831. private _raycastResult;
  58832. private _physicsBodysToRemoveAfterStep;
  58833. private _firstFrame;
  58834. BJSCANNON: any;
  58835. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58836. setGravity(gravity: Vector3): void;
  58837. setTimeStep(timeStep: number): void;
  58838. getTimeStep(): number;
  58839. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58840. private _removeMarkedPhysicsBodiesFromWorld;
  58841. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58842. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58843. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58844. private _processChildMeshes;
  58845. removePhysicsBody(impostor: PhysicsImpostor): void;
  58846. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58847. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58848. private _addMaterial;
  58849. private _checkWithEpsilon;
  58850. private _createShape;
  58851. private _createHeightmap;
  58852. private _minus90X;
  58853. private _plus90X;
  58854. private _tmpPosition;
  58855. private _tmpDeltaPosition;
  58856. private _tmpUnityRotation;
  58857. private _updatePhysicsBodyTransformation;
  58858. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58859. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58860. isSupported(): boolean;
  58861. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58862. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58863. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58864. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58865. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58866. getBodyMass(impostor: PhysicsImpostor): number;
  58867. getBodyFriction(impostor: PhysicsImpostor): number;
  58868. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58869. getBodyRestitution(impostor: PhysicsImpostor): number;
  58870. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58871. sleepBody(impostor: PhysicsImpostor): void;
  58872. wakeUpBody(impostor: PhysicsImpostor): void;
  58873. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58874. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58875. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58876. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58877. getRadius(impostor: PhysicsImpostor): number;
  58878. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58879. dispose(): void;
  58880. private _extendNamespace;
  58881. /**
  58882. * Does a raycast in the physics world
  58883. * @param from when should the ray start?
  58884. * @param to when should the ray end?
  58885. * @returns PhysicsRaycastResult
  58886. */
  58887. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58888. }
  58889. }
  58890. declare module BABYLON {
  58891. /** @hidden */
  58892. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58893. private _useDeltaForWorldStep;
  58894. world: any;
  58895. name: string;
  58896. BJSOIMO: any;
  58897. private _raycastResult;
  58898. private _fixedTimeStep;
  58899. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58900. setGravity(gravity: Vector3): void;
  58901. setTimeStep(timeStep: number): void;
  58902. getTimeStep(): number;
  58903. private _tmpImpostorsArray;
  58904. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58905. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58906. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58907. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58908. private _tmpPositionVector;
  58909. removePhysicsBody(impostor: PhysicsImpostor): void;
  58910. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58911. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58912. isSupported(): boolean;
  58913. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58914. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58915. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58916. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58917. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58918. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58919. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58920. getBodyMass(impostor: PhysicsImpostor): number;
  58921. getBodyFriction(impostor: PhysicsImpostor): number;
  58922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58923. getBodyRestitution(impostor: PhysicsImpostor): number;
  58924. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58925. sleepBody(impostor: PhysicsImpostor): void;
  58926. wakeUpBody(impostor: PhysicsImpostor): void;
  58927. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58928. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58929. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58930. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58931. getRadius(impostor: PhysicsImpostor): number;
  58932. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58933. dispose(): void;
  58934. /**
  58935. * Does a raycast in the physics world
  58936. * @param from when should the ray start?
  58937. * @param to when should the ray end?
  58938. * @returns PhysicsRaycastResult
  58939. */
  58940. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58941. }
  58942. }
  58943. declare module BABYLON {
  58944. /**
  58945. * Class containing static functions to help procedurally build meshes
  58946. */
  58947. export class RibbonBuilder {
  58948. /**
  58949. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58950. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58951. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58952. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58953. * * 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
  58954. * * 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
  58955. * * 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
  58956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58957. * * 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
  58958. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58959. * * 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
  58960. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58961. * * 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
  58962. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58964. * @param name defines the name of the mesh
  58965. * @param options defines the options used to create the mesh
  58966. * @param scene defines the hosting scene
  58967. * @returns the ribbon mesh
  58968. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58969. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58970. */
  58971. static CreateRibbon(name: string, options: {
  58972. pathArray: Vector3[][];
  58973. closeArray?: boolean;
  58974. closePath?: boolean;
  58975. offset?: number;
  58976. updatable?: boolean;
  58977. sideOrientation?: number;
  58978. frontUVs?: Vector4;
  58979. backUVs?: Vector4;
  58980. instance?: Mesh;
  58981. invertUV?: boolean;
  58982. uvs?: Vector2[];
  58983. colors?: Color4[];
  58984. }, scene?: Nullable<Scene>): Mesh;
  58985. }
  58986. }
  58987. declare module BABYLON {
  58988. /**
  58989. * Class containing static functions to help procedurally build meshes
  58990. */
  58991. export class ShapeBuilder {
  58992. /**
  58993. * 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.
  58994. * * 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.
  58995. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58996. * * 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.
  58997. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58998. * * 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
  58999. * * 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
  59000. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59002. * * 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
  59003. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59005. * @param name defines the name of the mesh
  59006. * @param options defines the options used to create the mesh
  59007. * @param scene defines the hosting scene
  59008. * @returns the extruded shape mesh
  59009. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59011. */
  59012. static ExtrudeShape(name: string, options: {
  59013. shape: Vector3[];
  59014. path: Vector3[];
  59015. scale?: number;
  59016. rotation?: number;
  59017. cap?: number;
  59018. updatable?: boolean;
  59019. sideOrientation?: number;
  59020. frontUVs?: Vector4;
  59021. backUVs?: Vector4;
  59022. instance?: Mesh;
  59023. invertUV?: boolean;
  59024. }, scene?: Nullable<Scene>): Mesh;
  59025. /**
  59026. * Creates an custom extruded shape mesh.
  59027. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59028. * * 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.
  59029. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59030. * * 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
  59031. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59032. * * 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
  59033. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59034. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59035. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59036. * * 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
  59037. * * 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
  59038. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59040. * * 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
  59041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59043. * @param name defines the name of the mesh
  59044. * @param options defines the options used to create the mesh
  59045. * @param scene defines the hosting scene
  59046. * @returns the custom extruded shape mesh
  59047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59048. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59050. */
  59051. static ExtrudeShapeCustom(name: string, options: {
  59052. shape: Vector3[];
  59053. path: Vector3[];
  59054. scaleFunction?: any;
  59055. rotationFunction?: any;
  59056. ribbonCloseArray?: boolean;
  59057. ribbonClosePath?: boolean;
  59058. cap?: number;
  59059. updatable?: boolean;
  59060. sideOrientation?: number;
  59061. frontUVs?: Vector4;
  59062. backUVs?: Vector4;
  59063. instance?: Mesh;
  59064. invertUV?: boolean;
  59065. }, scene?: Nullable<Scene>): Mesh;
  59066. private static _ExtrudeShapeGeneric;
  59067. }
  59068. }
  59069. declare module BABYLON {
  59070. /**
  59071. * AmmoJS Physics plugin
  59072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59073. * @see https://github.com/kripken/ammo.js/
  59074. */
  59075. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59076. private _useDeltaForWorldStep;
  59077. /**
  59078. * Reference to the Ammo library
  59079. */
  59080. bjsAMMO: any;
  59081. /**
  59082. * Created ammoJS world which physics bodies are added to
  59083. */
  59084. world: any;
  59085. /**
  59086. * Name of the plugin
  59087. */
  59088. name: string;
  59089. private _timeStep;
  59090. private _fixedTimeStep;
  59091. private _maxSteps;
  59092. private _tmpQuaternion;
  59093. private _tmpAmmoTransform;
  59094. private _tmpAmmoQuaternion;
  59095. private _tmpAmmoConcreteContactResultCallback;
  59096. private _collisionConfiguration;
  59097. private _dispatcher;
  59098. private _overlappingPairCache;
  59099. private _solver;
  59100. private _softBodySolver;
  59101. private _tmpAmmoVectorA;
  59102. private _tmpAmmoVectorB;
  59103. private _tmpAmmoVectorC;
  59104. private _tmpAmmoVectorD;
  59105. private _tmpContactCallbackResult;
  59106. private _tmpAmmoVectorRCA;
  59107. private _tmpAmmoVectorRCB;
  59108. private _raycastResult;
  59109. private static readonly DISABLE_COLLISION_FLAG;
  59110. private static readonly KINEMATIC_FLAG;
  59111. private static readonly DISABLE_DEACTIVATION_FLAG;
  59112. /**
  59113. * Initializes the ammoJS plugin
  59114. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59115. * @param ammoInjection can be used to inject your own ammo reference
  59116. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59117. */
  59118. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59119. /**
  59120. * Sets the gravity of the physics world (m/(s^2))
  59121. * @param gravity Gravity to set
  59122. */
  59123. setGravity(gravity: Vector3): void;
  59124. /**
  59125. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59126. * @param timeStep timestep to use in seconds
  59127. */
  59128. setTimeStep(timeStep: number): void;
  59129. /**
  59130. * 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)
  59131. * @param fixedTimeStep fixedTimeStep to use in seconds
  59132. */
  59133. setFixedTimeStep(fixedTimeStep: number): void;
  59134. /**
  59135. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59136. * @param maxSteps the maximum number of steps by the physics engine per frame
  59137. */
  59138. setMaxSteps(maxSteps: number): void;
  59139. /**
  59140. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59141. * @returns the current timestep in seconds
  59142. */
  59143. getTimeStep(): number;
  59144. /**
  59145. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59146. */
  59147. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59148. private _isImpostorInContact;
  59149. private _isImpostorPairInContact;
  59150. private _stepSimulation;
  59151. /**
  59152. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59153. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59154. * After the step the babylon meshes are set to the position of the physics imposters
  59155. * @param delta amount of time to step forward
  59156. * @param impostors array of imposters to update before/after the step
  59157. */
  59158. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59159. /**
  59160. * Update babylon mesh to match physics world object
  59161. * @param impostor imposter to match
  59162. */
  59163. private _afterSoftStep;
  59164. /**
  59165. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59166. * @param impostor imposter to match
  59167. */
  59168. private _ropeStep;
  59169. /**
  59170. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59171. * @param impostor imposter to match
  59172. */
  59173. private _softbodyOrClothStep;
  59174. private _tmpMatrix;
  59175. /**
  59176. * Applies an impulse on the imposter
  59177. * @param impostor imposter to apply impulse to
  59178. * @param force amount of force to be applied to the imposter
  59179. * @param contactPoint the location to apply the impulse on the imposter
  59180. */
  59181. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59182. /**
  59183. * Applies a force on the imposter
  59184. * @param impostor imposter to apply force
  59185. * @param force amount of force to be applied to the imposter
  59186. * @param contactPoint the location to apply the force on the imposter
  59187. */
  59188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59189. /**
  59190. * Creates a physics body using the plugin
  59191. * @param impostor the imposter to create the physics body on
  59192. */
  59193. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59194. /**
  59195. * Removes the physics body from the imposter and disposes of the body's memory
  59196. * @param impostor imposter to remove the physics body from
  59197. */
  59198. removePhysicsBody(impostor: PhysicsImpostor): void;
  59199. /**
  59200. * Generates a joint
  59201. * @param impostorJoint the imposter joint to create the joint with
  59202. */
  59203. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59204. /**
  59205. * Removes a joint
  59206. * @param impostorJoint the imposter joint to remove the joint from
  59207. */
  59208. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59209. private _addMeshVerts;
  59210. /**
  59211. * Initialise the soft body vertices to match its object's (mesh) vertices
  59212. * Softbody vertices (nodes) are in world space and to match this
  59213. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59214. * @param impostor to create the softbody for
  59215. */
  59216. private _softVertexData;
  59217. /**
  59218. * Create an impostor's soft body
  59219. * @param impostor to create the softbody for
  59220. */
  59221. private _createSoftbody;
  59222. /**
  59223. * Create cloth for an impostor
  59224. * @param impostor to create the softbody for
  59225. */
  59226. private _createCloth;
  59227. /**
  59228. * Create rope for an impostor
  59229. * @param impostor to create the softbody for
  59230. */
  59231. private _createRope;
  59232. /**
  59233. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59234. * @param impostor to create the custom physics shape for
  59235. */
  59236. private _createCustom;
  59237. private _addHullVerts;
  59238. private _createShape;
  59239. /**
  59240. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59241. * @param impostor imposter containing the physics body and babylon object
  59242. */
  59243. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59244. /**
  59245. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59246. * @param impostor imposter containing the physics body and babylon object
  59247. * @param newPosition new position
  59248. * @param newRotation new rotation
  59249. */
  59250. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59251. /**
  59252. * If this plugin is supported
  59253. * @returns true if its supported
  59254. */
  59255. isSupported(): boolean;
  59256. /**
  59257. * Sets the linear velocity of the physics body
  59258. * @param impostor imposter to set the velocity on
  59259. * @param velocity velocity to set
  59260. */
  59261. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59262. /**
  59263. * Sets the angular velocity of the physics body
  59264. * @param impostor imposter to set the velocity on
  59265. * @param velocity velocity to set
  59266. */
  59267. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59268. /**
  59269. * gets the linear velocity
  59270. * @param impostor imposter to get linear velocity from
  59271. * @returns linear velocity
  59272. */
  59273. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59274. /**
  59275. * gets the angular velocity
  59276. * @param impostor imposter to get angular velocity from
  59277. * @returns angular velocity
  59278. */
  59279. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59280. /**
  59281. * Sets the mass of physics body
  59282. * @param impostor imposter to set the mass on
  59283. * @param mass mass to set
  59284. */
  59285. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59286. /**
  59287. * Gets the mass of the physics body
  59288. * @param impostor imposter to get the mass from
  59289. * @returns mass
  59290. */
  59291. getBodyMass(impostor: PhysicsImpostor): number;
  59292. /**
  59293. * Gets friction of the impostor
  59294. * @param impostor impostor to get friction from
  59295. * @returns friction value
  59296. */
  59297. getBodyFriction(impostor: PhysicsImpostor): number;
  59298. /**
  59299. * Sets friction of the impostor
  59300. * @param impostor impostor to set friction on
  59301. * @param friction friction value
  59302. */
  59303. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59304. /**
  59305. * Gets restitution of the impostor
  59306. * @param impostor impostor to get restitution from
  59307. * @returns restitution value
  59308. */
  59309. getBodyRestitution(impostor: PhysicsImpostor): number;
  59310. /**
  59311. * Sets resitution of the impostor
  59312. * @param impostor impostor to set resitution on
  59313. * @param restitution resitution value
  59314. */
  59315. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59316. /**
  59317. * Gets pressure inside the impostor
  59318. * @param impostor impostor to get pressure from
  59319. * @returns pressure value
  59320. */
  59321. getBodyPressure(impostor: PhysicsImpostor): number;
  59322. /**
  59323. * Sets pressure inside a soft body impostor
  59324. * Cloth and rope must remain 0 pressure
  59325. * @param impostor impostor to set pressure on
  59326. * @param pressure pressure value
  59327. */
  59328. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59329. /**
  59330. * Gets stiffness of the impostor
  59331. * @param impostor impostor to get stiffness from
  59332. * @returns pressure value
  59333. */
  59334. getBodyStiffness(impostor: PhysicsImpostor): number;
  59335. /**
  59336. * Sets stiffness of the impostor
  59337. * @param impostor impostor to set stiffness on
  59338. * @param stiffness stiffness value from 0 to 1
  59339. */
  59340. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59341. /**
  59342. * Gets velocityIterations of the impostor
  59343. * @param impostor impostor to get velocity iterations from
  59344. * @returns velocityIterations value
  59345. */
  59346. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59347. /**
  59348. * Sets velocityIterations of the impostor
  59349. * @param impostor impostor to set velocity iterations on
  59350. * @param velocityIterations velocityIterations value
  59351. */
  59352. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59353. /**
  59354. * Gets positionIterations of the impostor
  59355. * @param impostor impostor to get position iterations from
  59356. * @returns positionIterations value
  59357. */
  59358. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59359. /**
  59360. * Sets positionIterations of the impostor
  59361. * @param impostor impostor to set position on
  59362. * @param positionIterations positionIterations value
  59363. */
  59364. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59365. /**
  59366. * Append an anchor to a cloth object
  59367. * @param impostor is the cloth impostor to add anchor to
  59368. * @param otherImpostor is the rigid impostor to anchor to
  59369. * @param width ratio across width from 0 to 1
  59370. * @param height ratio up height from 0 to 1
  59371. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59372. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59373. */
  59374. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59375. /**
  59376. * Append an hook to a rope object
  59377. * @param impostor is the rope impostor to add hook to
  59378. * @param otherImpostor is the rigid impostor to hook to
  59379. * @param length ratio along the rope from 0 to 1
  59380. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59381. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59382. */
  59383. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59384. /**
  59385. * Sleeps the physics body and stops it from being active
  59386. * @param impostor impostor to sleep
  59387. */
  59388. sleepBody(impostor: PhysicsImpostor): void;
  59389. /**
  59390. * Activates the physics body
  59391. * @param impostor impostor to activate
  59392. */
  59393. wakeUpBody(impostor: PhysicsImpostor): void;
  59394. /**
  59395. * Updates the distance parameters of the joint
  59396. * @param joint joint to update
  59397. * @param maxDistance maximum distance of the joint
  59398. * @param minDistance minimum distance of the joint
  59399. */
  59400. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59401. /**
  59402. * Sets a motor on the joint
  59403. * @param joint joint to set motor on
  59404. * @param speed speed of the motor
  59405. * @param maxForce maximum force of the motor
  59406. * @param motorIndex index of the motor
  59407. */
  59408. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59409. /**
  59410. * Sets the motors limit
  59411. * @param joint joint to set limit on
  59412. * @param upperLimit upper limit
  59413. * @param lowerLimit lower limit
  59414. */
  59415. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59416. /**
  59417. * Syncs the position and rotation of a mesh with the impostor
  59418. * @param mesh mesh to sync
  59419. * @param impostor impostor to update the mesh with
  59420. */
  59421. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59422. /**
  59423. * Gets the radius of the impostor
  59424. * @param impostor impostor to get radius from
  59425. * @returns the radius
  59426. */
  59427. getRadius(impostor: PhysicsImpostor): number;
  59428. /**
  59429. * Gets the box size of the impostor
  59430. * @param impostor impostor to get box size from
  59431. * @param result the resulting box size
  59432. */
  59433. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59434. /**
  59435. * Disposes of the impostor
  59436. */
  59437. dispose(): void;
  59438. /**
  59439. * Does a raycast in the physics world
  59440. * @param from when should the ray start?
  59441. * @param to when should the ray end?
  59442. * @returns PhysicsRaycastResult
  59443. */
  59444. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59445. }
  59446. }
  59447. declare module BABYLON {
  59448. interface AbstractScene {
  59449. /**
  59450. * The list of reflection probes added to the scene
  59451. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59452. */
  59453. reflectionProbes: Array<ReflectionProbe>;
  59454. /**
  59455. * Removes the given reflection probe from this scene.
  59456. * @param toRemove The reflection probe to remove
  59457. * @returns The index of the removed reflection probe
  59458. */
  59459. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59460. /**
  59461. * Adds the given reflection probe to this scene.
  59462. * @param newReflectionProbe The reflection probe to add
  59463. */
  59464. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59465. }
  59466. /**
  59467. * Class used to generate realtime reflection / refraction cube textures
  59468. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59469. */
  59470. export class ReflectionProbe {
  59471. /** defines the name of the probe */
  59472. name: string;
  59473. private _scene;
  59474. private _renderTargetTexture;
  59475. private _projectionMatrix;
  59476. private _viewMatrix;
  59477. private _target;
  59478. private _add;
  59479. private _attachedMesh;
  59480. private _invertYAxis;
  59481. /** Gets or sets probe position (center of the cube map) */
  59482. position: Vector3;
  59483. /**
  59484. * Creates a new reflection probe
  59485. * @param name defines the name of the probe
  59486. * @param size defines the texture resolution (for each face)
  59487. * @param scene defines the hosting scene
  59488. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59489. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59490. */
  59491. constructor(
  59492. /** defines the name of the probe */
  59493. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59494. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59495. get samples(): number;
  59496. set samples(value: number);
  59497. /** Gets or sets the refresh rate to use (on every frame by default) */
  59498. get refreshRate(): number;
  59499. set refreshRate(value: number);
  59500. /**
  59501. * Gets the hosting scene
  59502. * @returns a Scene
  59503. */
  59504. getScene(): Scene;
  59505. /** Gets the internal CubeTexture used to render to */
  59506. get cubeTexture(): RenderTargetTexture;
  59507. /** Gets the list of meshes to render */
  59508. get renderList(): Nullable<AbstractMesh[]>;
  59509. /**
  59510. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59511. * @param mesh defines the mesh to attach to
  59512. */
  59513. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59514. /**
  59515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59516. * @param renderingGroupId The rendering group id corresponding to its index
  59517. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59518. */
  59519. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59520. /**
  59521. * Clean all associated resources
  59522. */
  59523. dispose(): void;
  59524. /**
  59525. * Converts the reflection probe information to a readable string for debug purpose.
  59526. * @param fullDetails Supports for multiple levels of logging within scene loading
  59527. * @returns the human readable reflection probe info
  59528. */
  59529. toString(fullDetails?: boolean): string;
  59530. /**
  59531. * Get the class name of the relfection probe.
  59532. * @returns "ReflectionProbe"
  59533. */
  59534. getClassName(): string;
  59535. /**
  59536. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59537. * @returns The JSON representation of the texture
  59538. */
  59539. serialize(): any;
  59540. /**
  59541. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59542. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59543. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59544. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59545. * @returns The parsed reflection probe if successful
  59546. */
  59547. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59548. }
  59549. }
  59550. declare module BABYLON {
  59551. /** @hidden */
  59552. export var _BabylonLoaderRegistered: boolean;
  59553. /**
  59554. * Helps setting up some configuration for the babylon file loader.
  59555. */
  59556. export class BabylonFileLoaderConfiguration {
  59557. /**
  59558. * The loader does not allow injecting custom physix engine into the plugins.
  59559. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59560. * So you could set this variable to your engine import to make it work.
  59561. */
  59562. static LoaderInjectedPhysicsEngine: any;
  59563. }
  59564. }
  59565. declare module BABYLON {
  59566. /**
  59567. * The Physically based simple base material of BJS.
  59568. *
  59569. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59570. * It is used as the base class for both the specGloss and metalRough conventions.
  59571. */
  59572. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59573. /**
  59574. * Number of Simultaneous lights allowed on the material.
  59575. */
  59576. maxSimultaneousLights: number;
  59577. /**
  59578. * If sets to true, disables all the lights affecting the material.
  59579. */
  59580. disableLighting: boolean;
  59581. /**
  59582. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59583. */
  59584. environmentTexture: BaseTexture;
  59585. /**
  59586. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59587. */
  59588. invertNormalMapX: boolean;
  59589. /**
  59590. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59591. */
  59592. invertNormalMapY: boolean;
  59593. /**
  59594. * Normal map used in the model.
  59595. */
  59596. normalTexture: BaseTexture;
  59597. /**
  59598. * Emissivie color used to self-illuminate the model.
  59599. */
  59600. emissiveColor: Color3;
  59601. /**
  59602. * Emissivie texture used to self-illuminate the model.
  59603. */
  59604. emissiveTexture: BaseTexture;
  59605. /**
  59606. * Occlusion Channel Strenght.
  59607. */
  59608. occlusionStrength: number;
  59609. /**
  59610. * Occlusion Texture of the material (adding extra occlusion effects).
  59611. */
  59612. occlusionTexture: BaseTexture;
  59613. /**
  59614. * Defines the alpha limits in alpha test mode.
  59615. */
  59616. alphaCutOff: number;
  59617. /**
  59618. * Gets the current double sided mode.
  59619. */
  59620. get doubleSided(): boolean;
  59621. /**
  59622. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59623. */
  59624. set doubleSided(value: boolean);
  59625. /**
  59626. * Stores the pre-calculated light information of a mesh in a texture.
  59627. */
  59628. lightmapTexture: BaseTexture;
  59629. /**
  59630. * If true, the light map contains occlusion information instead of lighting info.
  59631. */
  59632. useLightmapAsShadowmap: boolean;
  59633. /**
  59634. * Instantiates a new PBRMaterial instance.
  59635. *
  59636. * @param name The material name
  59637. * @param scene The scene the material will be use in.
  59638. */
  59639. constructor(name: string, scene: Scene);
  59640. getClassName(): string;
  59641. }
  59642. }
  59643. declare module BABYLON {
  59644. /**
  59645. * The PBR material of BJS following the metal roughness convention.
  59646. *
  59647. * This fits to the PBR convention in the GLTF definition:
  59648. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59649. */
  59650. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59651. /**
  59652. * The base color has two different interpretations depending on the value of metalness.
  59653. * When the material is a metal, the base color is the specific measured reflectance value
  59654. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59655. * of the material.
  59656. */
  59657. baseColor: Color3;
  59658. /**
  59659. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59660. * well as opacity information in the alpha channel.
  59661. */
  59662. baseTexture: BaseTexture;
  59663. /**
  59664. * Specifies the metallic scalar value of the material.
  59665. * Can also be used to scale the metalness values of the metallic texture.
  59666. */
  59667. metallic: number;
  59668. /**
  59669. * Specifies the roughness scalar value of the material.
  59670. * Can also be used to scale the roughness values of the metallic texture.
  59671. */
  59672. roughness: number;
  59673. /**
  59674. * Texture containing both the metallic value in the B channel and the
  59675. * roughness value in the G channel to keep better precision.
  59676. */
  59677. metallicRoughnessTexture: BaseTexture;
  59678. /**
  59679. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59680. *
  59681. * @param name The material name
  59682. * @param scene The scene the material will be use in.
  59683. */
  59684. constructor(name: string, scene: Scene);
  59685. /**
  59686. * Return the currrent class name of the material.
  59687. */
  59688. getClassName(): string;
  59689. /**
  59690. * Makes a duplicate of the current material.
  59691. * @param name - name to use for the new material.
  59692. */
  59693. clone(name: string): PBRMetallicRoughnessMaterial;
  59694. /**
  59695. * Serialize the material to a parsable JSON object.
  59696. */
  59697. serialize(): any;
  59698. /**
  59699. * Parses a JSON object correponding to the serialize function.
  59700. */
  59701. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59702. }
  59703. }
  59704. declare module BABYLON {
  59705. /**
  59706. * The PBR material of BJS following the specular glossiness convention.
  59707. *
  59708. * This fits to the PBR convention in the GLTF definition:
  59709. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59710. */
  59711. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59712. /**
  59713. * Specifies the diffuse color of the material.
  59714. */
  59715. diffuseColor: Color3;
  59716. /**
  59717. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59718. * channel.
  59719. */
  59720. diffuseTexture: BaseTexture;
  59721. /**
  59722. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59723. */
  59724. specularColor: Color3;
  59725. /**
  59726. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59727. */
  59728. glossiness: number;
  59729. /**
  59730. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59731. */
  59732. specularGlossinessTexture: BaseTexture;
  59733. /**
  59734. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59735. *
  59736. * @param name The material name
  59737. * @param scene The scene the material will be use in.
  59738. */
  59739. constructor(name: string, scene: Scene);
  59740. /**
  59741. * Return the currrent class name of the material.
  59742. */
  59743. getClassName(): string;
  59744. /**
  59745. * Makes a duplicate of the current material.
  59746. * @param name - name to use for the new material.
  59747. */
  59748. clone(name: string): PBRSpecularGlossinessMaterial;
  59749. /**
  59750. * Serialize the material to a parsable JSON object.
  59751. */
  59752. serialize(): any;
  59753. /**
  59754. * Parses a JSON object correponding to the serialize function.
  59755. */
  59756. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59757. }
  59758. }
  59759. declare module BABYLON {
  59760. /**
  59761. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59762. * It can help converting any input color in a desired output one. This can then be used to create effects
  59763. * from sepia, black and white to sixties or futuristic rendering...
  59764. *
  59765. * The only supported format is currently 3dl.
  59766. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59767. */
  59768. export class ColorGradingTexture extends BaseTexture {
  59769. /**
  59770. * The texture URL.
  59771. */
  59772. url: string;
  59773. /**
  59774. * Empty line regex stored for GC.
  59775. */
  59776. private static _noneEmptyLineRegex;
  59777. private _textureMatrix;
  59778. private _onLoad;
  59779. /**
  59780. * Instantiates a ColorGradingTexture from the following parameters.
  59781. *
  59782. * @param url The location of the color gradind data (currently only supporting 3dl)
  59783. * @param sceneOrEngine The scene or engine the texture will be used in
  59784. * @param onLoad defines a callback triggered when the texture has been loaded
  59785. */
  59786. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59787. /**
  59788. * Fires the onload event from the constructor if requested.
  59789. */
  59790. private _triggerOnLoad;
  59791. /**
  59792. * Returns the texture matrix used in most of the material.
  59793. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59794. */
  59795. getTextureMatrix(): Matrix;
  59796. /**
  59797. * Occurs when the file being loaded is a .3dl LUT file.
  59798. */
  59799. private load3dlTexture;
  59800. /**
  59801. * Starts the loading process of the texture.
  59802. */
  59803. private loadTexture;
  59804. /**
  59805. * Clones the color gradind texture.
  59806. */
  59807. clone(): ColorGradingTexture;
  59808. /**
  59809. * Called during delayed load for textures.
  59810. */
  59811. delayLoad(): void;
  59812. /**
  59813. * Parses a color grading texture serialized by Babylon.
  59814. * @param parsedTexture The texture information being parsedTexture
  59815. * @param scene The scene to load the texture in
  59816. * @param rootUrl The root url of the data assets to load
  59817. * @return A color gradind texture
  59818. */
  59819. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59820. /**
  59821. * Serializes the LUT texture to json format.
  59822. */
  59823. serialize(): any;
  59824. }
  59825. }
  59826. declare module BABYLON {
  59827. /**
  59828. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59829. */
  59830. export class EquiRectangularCubeTexture extends BaseTexture {
  59831. /** The six faces of the cube. */
  59832. private static _FacesMapping;
  59833. private _noMipmap;
  59834. private _onLoad;
  59835. private _onError;
  59836. /** The size of the cubemap. */
  59837. private _size;
  59838. /** The buffer of the image. */
  59839. private _buffer;
  59840. /** The width of the input image. */
  59841. private _width;
  59842. /** The height of the input image. */
  59843. private _height;
  59844. /** The URL to the image. */
  59845. url: string;
  59846. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59847. coordinatesMode: number;
  59848. /**
  59849. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59850. * @param url The location of the image
  59851. * @param scene The scene the texture will be used in
  59852. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59853. * @param noMipmap Forces to not generate the mipmap if true
  59854. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59855. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59856. * @param onLoad — defines a callback called when texture is loaded
  59857. * @param onError — defines a callback called if there is an error
  59858. */
  59859. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59860. /**
  59861. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59862. */
  59863. private loadImage;
  59864. /**
  59865. * Convert the image buffer into a cubemap and create a CubeTexture.
  59866. */
  59867. private loadTexture;
  59868. /**
  59869. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59870. * @param buffer The ArrayBuffer that should be converted.
  59871. * @returns The buffer as Float32Array.
  59872. */
  59873. private getFloat32ArrayFromArrayBuffer;
  59874. /**
  59875. * Get the current class name of the texture useful for serialization or dynamic coding.
  59876. * @returns "EquiRectangularCubeTexture"
  59877. */
  59878. getClassName(): string;
  59879. /**
  59880. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59881. * @returns A clone of the current EquiRectangularCubeTexture.
  59882. */
  59883. clone(): EquiRectangularCubeTexture;
  59884. }
  59885. }
  59886. declare module BABYLON {
  59887. /**
  59888. * Defines the options related to the creation of an HtmlElementTexture
  59889. */
  59890. export interface IHtmlElementTextureOptions {
  59891. /**
  59892. * Defines wether mip maps should be created or not.
  59893. */
  59894. generateMipMaps?: boolean;
  59895. /**
  59896. * Defines the sampling mode of the texture.
  59897. */
  59898. samplingMode?: number;
  59899. /**
  59900. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59901. */
  59902. engine: Nullable<ThinEngine>;
  59903. /**
  59904. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59905. */
  59906. scene: Nullable<Scene>;
  59907. }
  59908. /**
  59909. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59910. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59911. * is automatically managed.
  59912. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59913. * in your application.
  59914. *
  59915. * As the update is not automatic, you need to call them manually.
  59916. */
  59917. export class HtmlElementTexture extends BaseTexture {
  59918. /**
  59919. * The texture URL.
  59920. */
  59921. element: HTMLVideoElement | HTMLCanvasElement;
  59922. private static readonly DefaultOptions;
  59923. private _textureMatrix;
  59924. private _isVideo;
  59925. private _generateMipMaps;
  59926. private _samplingMode;
  59927. /**
  59928. * Instantiates a HtmlElementTexture from the following parameters.
  59929. *
  59930. * @param name Defines the name of the texture
  59931. * @param element Defines the video or canvas the texture is filled with
  59932. * @param options Defines the other none mandatory texture creation options
  59933. */
  59934. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59935. private _createInternalTexture;
  59936. /**
  59937. * Returns the texture matrix used in most of the material.
  59938. */
  59939. getTextureMatrix(): Matrix;
  59940. /**
  59941. * Updates the content of the texture.
  59942. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59943. */
  59944. update(invertY?: Nullable<boolean>): void;
  59945. }
  59946. }
  59947. declare module BABYLON {
  59948. /**
  59949. * Based on jsTGALoader - Javascript loader for TGA file
  59950. * By Vincent Thibault
  59951. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59952. */
  59953. export class TGATools {
  59954. private static _TYPE_INDEXED;
  59955. private static _TYPE_RGB;
  59956. private static _TYPE_GREY;
  59957. private static _TYPE_RLE_INDEXED;
  59958. private static _TYPE_RLE_RGB;
  59959. private static _TYPE_RLE_GREY;
  59960. private static _ORIGIN_MASK;
  59961. private static _ORIGIN_SHIFT;
  59962. private static _ORIGIN_BL;
  59963. private static _ORIGIN_BR;
  59964. private static _ORIGIN_UL;
  59965. private static _ORIGIN_UR;
  59966. /**
  59967. * Gets the header of a TGA file
  59968. * @param data defines the TGA data
  59969. * @returns the header
  59970. */
  59971. static GetTGAHeader(data: Uint8Array): any;
  59972. /**
  59973. * Uploads TGA content to a Babylon Texture
  59974. * @hidden
  59975. */
  59976. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59977. /** @hidden */
  59978. 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;
  59979. /** @hidden */
  59980. 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;
  59981. /** @hidden */
  59982. 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;
  59983. /** @hidden */
  59984. 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;
  59985. /** @hidden */
  59986. 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;
  59987. /** @hidden */
  59988. 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;
  59989. }
  59990. }
  59991. declare module BABYLON {
  59992. /**
  59993. * Implementation of the TGA Texture Loader.
  59994. * @hidden
  59995. */
  59996. export class _TGATextureLoader implements IInternalTextureLoader {
  59997. /**
  59998. * Defines wether the loader supports cascade loading the different faces.
  59999. */
  60000. readonly supportCascades: boolean;
  60001. /**
  60002. * This returns if the loader support the current file information.
  60003. * @param extension defines the file extension of the file being loaded
  60004. * @returns true if the loader can load the specified file
  60005. */
  60006. canLoad(extension: string): boolean;
  60007. /**
  60008. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60009. * @param data contains the texture data
  60010. * @param texture defines the BabylonJS internal texture
  60011. * @param createPolynomials will be true if polynomials have been requested
  60012. * @param onLoad defines the callback to trigger once the texture is ready
  60013. * @param onError defines the callback to trigger in case of error
  60014. */
  60015. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60016. /**
  60017. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60018. * @param data contains the texture data
  60019. * @param texture defines the BabylonJS internal texture
  60020. * @param callback defines the method to call once ready to upload
  60021. */
  60022. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60023. }
  60024. }
  60025. declare module BABYLON {
  60026. /**
  60027. * Info about the .basis files
  60028. */
  60029. class BasisFileInfo {
  60030. /**
  60031. * If the file has alpha
  60032. */
  60033. hasAlpha: boolean;
  60034. /**
  60035. * Info about each image of the basis file
  60036. */
  60037. images: Array<{
  60038. levels: Array<{
  60039. width: number;
  60040. height: number;
  60041. transcodedPixels: ArrayBufferView;
  60042. }>;
  60043. }>;
  60044. }
  60045. /**
  60046. * Result of transcoding a basis file
  60047. */
  60048. class TranscodeResult {
  60049. /**
  60050. * Info about the .basis file
  60051. */
  60052. fileInfo: BasisFileInfo;
  60053. /**
  60054. * Format to use when loading the file
  60055. */
  60056. format: number;
  60057. }
  60058. /**
  60059. * Configuration options for the Basis transcoder
  60060. */
  60061. export class BasisTranscodeConfiguration {
  60062. /**
  60063. * Supported compression formats used to determine the supported output format of the transcoder
  60064. */
  60065. supportedCompressionFormats?: {
  60066. /**
  60067. * etc1 compression format
  60068. */
  60069. etc1?: boolean;
  60070. /**
  60071. * s3tc compression format
  60072. */
  60073. s3tc?: boolean;
  60074. /**
  60075. * pvrtc compression format
  60076. */
  60077. pvrtc?: boolean;
  60078. /**
  60079. * etc2 compression format
  60080. */
  60081. etc2?: boolean;
  60082. };
  60083. /**
  60084. * If mipmap levels should be loaded for transcoded images (Default: true)
  60085. */
  60086. loadMipmapLevels?: boolean;
  60087. /**
  60088. * Index of a single image to load (Default: all images)
  60089. */
  60090. loadSingleImage?: number;
  60091. }
  60092. /**
  60093. * Used to load .Basis files
  60094. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60095. */
  60096. export class BasisTools {
  60097. private static _IgnoreSupportedFormats;
  60098. /**
  60099. * URL to use when loading the basis transcoder
  60100. */
  60101. static JSModuleURL: string;
  60102. /**
  60103. * URL to use when loading the wasm module for the transcoder
  60104. */
  60105. static WasmModuleURL: string;
  60106. /**
  60107. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60108. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60109. * @returns internal format corresponding to the Basis format
  60110. */
  60111. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60112. private static _WorkerPromise;
  60113. private static _Worker;
  60114. private static _actionId;
  60115. private static _CreateWorkerAsync;
  60116. /**
  60117. * Transcodes a loaded image file to compressed pixel data
  60118. * @param data image data to transcode
  60119. * @param config configuration options for the transcoding
  60120. * @returns a promise resulting in the transcoded image
  60121. */
  60122. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60123. /**
  60124. * Loads a texture from the transcode result
  60125. * @param texture texture load to
  60126. * @param transcodeResult the result of transcoding the basis file to load from
  60127. */
  60128. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60129. }
  60130. }
  60131. declare module BABYLON {
  60132. /**
  60133. * Loader for .basis file format
  60134. */
  60135. export class _BasisTextureLoader implements IInternalTextureLoader {
  60136. /**
  60137. * Defines whether the loader supports cascade loading the different faces.
  60138. */
  60139. readonly supportCascades: boolean;
  60140. /**
  60141. * This returns if the loader support the current file information.
  60142. * @param extension defines the file extension of the file being loaded
  60143. * @returns true if the loader can load the specified file
  60144. */
  60145. canLoad(extension: string): boolean;
  60146. /**
  60147. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60148. * @param data contains the texture data
  60149. * @param texture defines the BabylonJS internal texture
  60150. * @param createPolynomials will be true if polynomials have been requested
  60151. * @param onLoad defines the callback to trigger once the texture is ready
  60152. * @param onError defines the callback to trigger in case of error
  60153. */
  60154. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60155. /**
  60156. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60157. * @param data contains the texture data
  60158. * @param texture defines the BabylonJS internal texture
  60159. * @param callback defines the method to call once ready to upload
  60160. */
  60161. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60162. }
  60163. }
  60164. declare module BABYLON {
  60165. /**
  60166. * Defines the basic options interface of a TexturePacker Frame
  60167. */
  60168. export interface ITexturePackerFrame {
  60169. /**
  60170. * The frame ID
  60171. */
  60172. id: number;
  60173. /**
  60174. * The frames Scale
  60175. */
  60176. scale: Vector2;
  60177. /**
  60178. * The Frames offset
  60179. */
  60180. offset: Vector2;
  60181. }
  60182. /**
  60183. * This is a support class for frame Data on texture packer sets.
  60184. */
  60185. export class TexturePackerFrame implements ITexturePackerFrame {
  60186. /**
  60187. * The frame ID
  60188. */
  60189. id: number;
  60190. /**
  60191. * The frames Scale
  60192. */
  60193. scale: Vector2;
  60194. /**
  60195. * The Frames offset
  60196. */
  60197. offset: Vector2;
  60198. /**
  60199. * Initializes a texture package frame.
  60200. * @param id The numerical frame identifier
  60201. * @param scale Scalar Vector2 for UV frame
  60202. * @param offset Vector2 for the frame position in UV units.
  60203. * @returns TexturePackerFrame
  60204. */
  60205. constructor(id: number, scale: Vector2, offset: Vector2);
  60206. }
  60207. }
  60208. declare module BABYLON {
  60209. /**
  60210. * Defines the basic options interface of a TexturePacker
  60211. */
  60212. export interface ITexturePackerOptions {
  60213. /**
  60214. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60215. */
  60216. map?: string[];
  60217. /**
  60218. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60219. */
  60220. uvsIn?: string;
  60221. /**
  60222. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60223. */
  60224. uvsOut?: string;
  60225. /**
  60226. * number representing the layout style. Defaults to LAYOUT_STRIP
  60227. */
  60228. layout?: number;
  60229. /**
  60230. * number of columns if using custom column count layout(2). This defaults to 4.
  60231. */
  60232. colnum?: number;
  60233. /**
  60234. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60235. */
  60236. updateInputMeshes?: boolean;
  60237. /**
  60238. * boolean flag to dispose all the source textures. Defaults to true.
  60239. */
  60240. disposeSources?: boolean;
  60241. /**
  60242. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60243. */
  60244. fillBlanks?: boolean;
  60245. /**
  60246. * string value representing the context fill style color. Defaults to 'black'.
  60247. */
  60248. customFillColor?: string;
  60249. /**
  60250. * Width and Height Value of each Frame in the TexturePacker Sets
  60251. */
  60252. frameSize?: number;
  60253. /**
  60254. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60255. */
  60256. paddingRatio?: number;
  60257. /**
  60258. * Number that declares the fill method for the padding gutter.
  60259. */
  60260. paddingMode?: number;
  60261. /**
  60262. * If in SUBUV_COLOR padding mode what color to use.
  60263. */
  60264. paddingColor?: Color3 | Color4;
  60265. }
  60266. /**
  60267. * Defines the basic interface of a TexturePacker JSON File
  60268. */
  60269. export interface ITexturePackerJSON {
  60270. /**
  60271. * The frame ID
  60272. */
  60273. name: string;
  60274. /**
  60275. * The base64 channel data
  60276. */
  60277. sets: any;
  60278. /**
  60279. * The options of the Packer
  60280. */
  60281. options: ITexturePackerOptions;
  60282. /**
  60283. * The frame data of the Packer
  60284. */
  60285. frames: Array<number>;
  60286. }
  60287. /**
  60288. * This is a support class that generates a series of packed texture sets.
  60289. * @see https://doc.babylonjs.com/babylon101/materials
  60290. */
  60291. export class TexturePacker {
  60292. /** Packer Layout Constant 0 */
  60293. static readonly LAYOUT_STRIP: number;
  60294. /** Packer Layout Constant 1 */
  60295. static readonly LAYOUT_POWER2: number;
  60296. /** Packer Layout Constant 2 */
  60297. static readonly LAYOUT_COLNUM: number;
  60298. /** Packer Layout Constant 0 */
  60299. static readonly SUBUV_WRAP: number;
  60300. /** Packer Layout Constant 1 */
  60301. static readonly SUBUV_EXTEND: number;
  60302. /** Packer Layout Constant 2 */
  60303. static readonly SUBUV_COLOR: number;
  60304. /** The Name of the Texture Package */
  60305. name: string;
  60306. /** The scene scope of the TexturePacker */
  60307. scene: Scene;
  60308. /** The Meshes to target */
  60309. meshes: AbstractMesh[];
  60310. /** Arguments passed with the Constructor */
  60311. options: ITexturePackerOptions;
  60312. /** The promise that is started upon initialization */
  60313. promise: Nullable<Promise<TexturePacker | string>>;
  60314. /** The Container object for the channel sets that are generated */
  60315. sets: object;
  60316. /** The Container array for the frames that are generated */
  60317. frames: TexturePackerFrame[];
  60318. /** The expected number of textures the system is parsing. */
  60319. private _expecting;
  60320. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60321. private _paddingValue;
  60322. /**
  60323. * Initializes a texture package series from an array of meshes or a single mesh.
  60324. * @param name The name of the package
  60325. * @param meshes The target meshes to compose the package from
  60326. * @param options The arguments that texture packer should follow while building.
  60327. * @param scene The scene which the textures are scoped to.
  60328. * @returns TexturePacker
  60329. */
  60330. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60331. /**
  60332. * Starts the package process
  60333. * @param resolve The promises resolution function
  60334. * @returns TexturePacker
  60335. */
  60336. private _createFrames;
  60337. /**
  60338. * Calculates the Size of the Channel Sets
  60339. * @returns Vector2
  60340. */
  60341. private _calculateSize;
  60342. /**
  60343. * Calculates the UV data for the frames.
  60344. * @param baseSize the base frameSize
  60345. * @param padding the base frame padding
  60346. * @param dtSize size of the Dynamic Texture for that channel
  60347. * @param dtUnits is 1/dtSize
  60348. * @param update flag to update the input meshes
  60349. */
  60350. private _calculateMeshUVFrames;
  60351. /**
  60352. * Calculates the frames Offset.
  60353. * @param index of the frame
  60354. * @returns Vector2
  60355. */
  60356. private _getFrameOffset;
  60357. /**
  60358. * Updates a Mesh to the frame data
  60359. * @param mesh that is the target
  60360. * @param frameID or the frame index
  60361. */
  60362. private _updateMeshUV;
  60363. /**
  60364. * Updates a Meshes materials to use the texture packer channels
  60365. * @param m is the mesh to target
  60366. * @param force all channels on the packer to be set.
  60367. */
  60368. private _updateTextureReferences;
  60369. /**
  60370. * Public method to set a Mesh to a frame
  60371. * @param m that is the target
  60372. * @param frameID or the frame index
  60373. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60374. */
  60375. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60376. /**
  60377. * Starts the async promise to compile the texture packer.
  60378. * @returns Promise<void>
  60379. */
  60380. processAsync(): Promise<void>;
  60381. /**
  60382. * Disposes all textures associated with this packer
  60383. */
  60384. dispose(): void;
  60385. /**
  60386. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60387. * @param imageType is the image type to use.
  60388. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60389. */
  60390. download(imageType?: string, quality?: number): void;
  60391. /**
  60392. * Public method to load a texturePacker JSON file.
  60393. * @param data of the JSON file in string format.
  60394. */
  60395. updateFromJSON(data: string): void;
  60396. }
  60397. }
  60398. declare module BABYLON {
  60399. /**
  60400. * 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.
  60401. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60402. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60403. */
  60404. export class CustomProceduralTexture extends ProceduralTexture {
  60405. private _animate;
  60406. private _time;
  60407. private _config;
  60408. private _texturePath;
  60409. /**
  60410. * Instantiates a new Custom Procedural Texture.
  60411. * 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.
  60412. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60413. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60414. * @param name Define the name of the texture
  60415. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60416. * @param size Define the size of the texture to create
  60417. * @param scene Define the scene the texture belongs to
  60418. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60419. * @param generateMipMaps Define if the texture should creates mip maps or not
  60420. */
  60421. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60422. private _loadJson;
  60423. /**
  60424. * Is the texture ready to be used ? (rendered at least once)
  60425. * @returns true if ready, otherwise, false.
  60426. */
  60427. isReady(): boolean;
  60428. /**
  60429. * Render the texture to its associated render target.
  60430. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60431. */
  60432. render(useCameraPostProcess?: boolean): void;
  60433. /**
  60434. * Update the list of dependant textures samplers in the shader.
  60435. */
  60436. updateTextures(): void;
  60437. /**
  60438. * Update the uniform values of the procedural texture in the shader.
  60439. */
  60440. updateShaderUniforms(): void;
  60441. /**
  60442. * Define if the texture animates or not.
  60443. */
  60444. get animate(): boolean;
  60445. set animate(value: boolean);
  60446. }
  60447. }
  60448. declare module BABYLON {
  60449. /** @hidden */
  60450. export var noisePixelShader: {
  60451. name: string;
  60452. shader: string;
  60453. };
  60454. }
  60455. declare module BABYLON {
  60456. /**
  60457. * Class used to generate noise procedural textures
  60458. */
  60459. export class NoiseProceduralTexture extends ProceduralTexture {
  60460. private _time;
  60461. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60462. brightness: number;
  60463. /** Defines the number of octaves to process */
  60464. octaves: number;
  60465. /** Defines the level of persistence (0.8 by default) */
  60466. persistence: number;
  60467. /** Gets or sets animation speed factor (default is 1) */
  60468. animationSpeedFactor: number;
  60469. /**
  60470. * Creates a new NoiseProceduralTexture
  60471. * @param name defines the name fo the texture
  60472. * @param size defines the size of the texture (default is 256)
  60473. * @param scene defines the hosting scene
  60474. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60475. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60476. */
  60477. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60478. private _updateShaderUniforms;
  60479. protected _getDefines(): string;
  60480. /** Generate the current state of the procedural texture */
  60481. render(useCameraPostProcess?: boolean): void;
  60482. /**
  60483. * Serializes this noise procedural texture
  60484. * @returns a serialized noise procedural texture object
  60485. */
  60486. serialize(): any;
  60487. /**
  60488. * Clone the texture.
  60489. * @returns the cloned texture
  60490. */
  60491. clone(): NoiseProceduralTexture;
  60492. /**
  60493. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60494. * @param parsedTexture defines parsed texture data
  60495. * @param scene defines the current scene
  60496. * @param rootUrl defines the root URL containing noise procedural texture information
  60497. * @returns a parsed NoiseProceduralTexture
  60498. */
  60499. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60500. }
  60501. }
  60502. declare module BABYLON {
  60503. /**
  60504. * Raw cube texture where the raw buffers are passed in
  60505. */
  60506. export class RawCubeTexture extends CubeTexture {
  60507. /**
  60508. * Creates a cube texture where the raw buffers are passed in.
  60509. * @param scene defines the scene the texture is attached to
  60510. * @param data defines the array of data to use to create each face
  60511. * @param size defines the size of the textures
  60512. * @param format defines the format of the data
  60513. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60514. * @param generateMipMaps defines if the engine should generate the mip levels
  60515. * @param invertY defines if data must be stored with Y axis inverted
  60516. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60517. * @param compression defines the compression used (null by default)
  60518. */
  60519. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60520. /**
  60521. * Updates the raw cube texture.
  60522. * @param data defines the data to store
  60523. * @param format defines the data format
  60524. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60525. * @param invertY defines if data must be stored with Y axis inverted
  60526. * @param compression defines the compression used (null by default)
  60527. * @param level defines which level of the texture to update
  60528. */
  60529. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60530. /**
  60531. * Updates a raw cube texture with RGBD encoded data.
  60532. * @param data defines the array of data [mipmap][face] to use to create each face
  60533. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60534. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60535. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60536. * @returns a promsie that resolves when the operation is complete
  60537. */
  60538. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60539. /**
  60540. * Clones the raw cube texture.
  60541. * @return a new cube texture
  60542. */
  60543. clone(): CubeTexture;
  60544. /** @hidden */
  60545. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60546. }
  60547. }
  60548. declare module BABYLON {
  60549. /**
  60550. * Class used to store 2D array textures containing user data
  60551. */
  60552. export class RawTexture2DArray extends Texture {
  60553. /** Gets or sets the texture format to use */
  60554. format: number;
  60555. /**
  60556. * Create a new RawTexture2DArray
  60557. * @param data defines the data of the texture
  60558. * @param width defines the width of the texture
  60559. * @param height defines the height of the texture
  60560. * @param depth defines the number of layers of the texture
  60561. * @param format defines the texture format to use
  60562. * @param scene defines the hosting scene
  60563. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60564. * @param invertY defines if texture must be stored with Y axis inverted
  60565. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60566. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60567. */
  60568. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60569. /** Gets or sets the texture format to use */
  60570. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60571. /**
  60572. * Update the texture with new data
  60573. * @param data defines the data to store in the texture
  60574. */
  60575. update(data: ArrayBufferView): void;
  60576. }
  60577. }
  60578. declare module BABYLON {
  60579. /**
  60580. * Class used to store 3D textures containing user data
  60581. */
  60582. export class RawTexture3D extends Texture {
  60583. /** Gets or sets the texture format to use */
  60584. format: number;
  60585. /**
  60586. * Create a new RawTexture3D
  60587. * @param data defines the data of the texture
  60588. * @param width defines the width of the texture
  60589. * @param height defines the height of the texture
  60590. * @param depth defines the depth of the texture
  60591. * @param format defines the texture format to use
  60592. * @param scene defines the hosting scene
  60593. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60594. * @param invertY defines if texture must be stored with Y axis inverted
  60595. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60596. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60597. */
  60598. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60599. /** Gets or sets the texture format to use */
  60600. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60601. /**
  60602. * Update the texture with new data
  60603. * @param data defines the data to store in the texture
  60604. */
  60605. update(data: ArrayBufferView): void;
  60606. }
  60607. }
  60608. declare module BABYLON {
  60609. /**
  60610. * Creates a refraction texture used by refraction channel of the standard material.
  60611. * It is like a mirror but to see through a material.
  60612. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60613. */
  60614. export class RefractionTexture extends RenderTargetTexture {
  60615. /**
  60616. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60617. * 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.
  60618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60619. */
  60620. refractionPlane: Plane;
  60621. /**
  60622. * Define how deep under the surface we should see.
  60623. */
  60624. depth: number;
  60625. /**
  60626. * Creates a refraction texture used by refraction channel of the standard material.
  60627. * It is like a mirror but to see through a material.
  60628. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60629. * @param name Define the texture name
  60630. * @param size Define the size of the underlying texture
  60631. * @param scene Define the scene the refraction belongs to
  60632. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60633. */
  60634. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60635. /**
  60636. * Clone the refraction texture.
  60637. * @returns the cloned texture
  60638. */
  60639. clone(): RefractionTexture;
  60640. /**
  60641. * Serialize the texture to a JSON representation you could use in Parse later on
  60642. * @returns the serialized JSON representation
  60643. */
  60644. serialize(): any;
  60645. }
  60646. }
  60647. declare module BABYLON {
  60648. /**
  60649. * Block used to add support for vertex skinning (bones)
  60650. */
  60651. export class BonesBlock extends NodeMaterialBlock {
  60652. /**
  60653. * Creates a new BonesBlock
  60654. * @param name defines the block name
  60655. */
  60656. constructor(name: string);
  60657. /**
  60658. * Initialize the block and prepare the context for build
  60659. * @param state defines the state that will be used for the build
  60660. */
  60661. initialize(state: NodeMaterialBuildState): void;
  60662. /**
  60663. * Gets the current class name
  60664. * @returns the class name
  60665. */
  60666. getClassName(): string;
  60667. /**
  60668. * Gets the matrix indices input component
  60669. */
  60670. get matricesIndices(): NodeMaterialConnectionPoint;
  60671. /**
  60672. * Gets the matrix weights input component
  60673. */
  60674. get matricesWeights(): NodeMaterialConnectionPoint;
  60675. /**
  60676. * Gets the extra matrix indices input component
  60677. */
  60678. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60679. /**
  60680. * Gets the extra matrix weights input component
  60681. */
  60682. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60683. /**
  60684. * Gets the world input component
  60685. */
  60686. get world(): NodeMaterialConnectionPoint;
  60687. /**
  60688. * Gets the output component
  60689. */
  60690. get output(): NodeMaterialConnectionPoint;
  60691. autoConfigure(material: NodeMaterial): void;
  60692. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60695. protected _buildBlock(state: NodeMaterialBuildState): this;
  60696. }
  60697. }
  60698. declare module BABYLON {
  60699. /**
  60700. * Block used to add support for instances
  60701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60702. */
  60703. export class InstancesBlock extends NodeMaterialBlock {
  60704. /**
  60705. * Creates a new InstancesBlock
  60706. * @param name defines the block name
  60707. */
  60708. constructor(name: string);
  60709. /**
  60710. * Gets the current class name
  60711. * @returns the class name
  60712. */
  60713. getClassName(): string;
  60714. /**
  60715. * Gets the first world row input component
  60716. */
  60717. get world0(): NodeMaterialConnectionPoint;
  60718. /**
  60719. * Gets the second world row input component
  60720. */
  60721. get world1(): NodeMaterialConnectionPoint;
  60722. /**
  60723. * Gets the third world row input component
  60724. */
  60725. get world2(): NodeMaterialConnectionPoint;
  60726. /**
  60727. * Gets the forth world row input component
  60728. */
  60729. get world3(): NodeMaterialConnectionPoint;
  60730. /**
  60731. * Gets the world input component
  60732. */
  60733. get world(): NodeMaterialConnectionPoint;
  60734. /**
  60735. * Gets the output component
  60736. */
  60737. get output(): NodeMaterialConnectionPoint;
  60738. /**
  60739. * Gets the isntanceID component
  60740. */
  60741. get instanceID(): NodeMaterialConnectionPoint;
  60742. autoConfigure(material: NodeMaterial): void;
  60743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  60744. protected _buildBlock(state: NodeMaterialBuildState): this;
  60745. }
  60746. }
  60747. declare module BABYLON {
  60748. /**
  60749. * Block used to add morph targets support to vertex shader
  60750. */
  60751. export class MorphTargetsBlock extends NodeMaterialBlock {
  60752. private _repeatableContentAnchor;
  60753. /**
  60754. * Create a new MorphTargetsBlock
  60755. * @param name defines the block name
  60756. */
  60757. constructor(name: string);
  60758. /**
  60759. * Gets the current class name
  60760. * @returns the class name
  60761. */
  60762. getClassName(): string;
  60763. /**
  60764. * Gets the position input component
  60765. */
  60766. get position(): NodeMaterialConnectionPoint;
  60767. /**
  60768. * Gets the normal input component
  60769. */
  60770. get normal(): NodeMaterialConnectionPoint;
  60771. /**
  60772. * Gets the tangent input component
  60773. */
  60774. get tangent(): NodeMaterialConnectionPoint;
  60775. /**
  60776. * Gets the tangent input component
  60777. */
  60778. get uv(): NodeMaterialConnectionPoint;
  60779. /**
  60780. * Gets the position output component
  60781. */
  60782. get positionOutput(): NodeMaterialConnectionPoint;
  60783. /**
  60784. * Gets the normal output component
  60785. */
  60786. get normalOutput(): NodeMaterialConnectionPoint;
  60787. /**
  60788. * Gets the tangent output component
  60789. */
  60790. get tangentOutput(): NodeMaterialConnectionPoint;
  60791. /**
  60792. * Gets the tangent output component
  60793. */
  60794. get uvOutput(): NodeMaterialConnectionPoint;
  60795. initialize(state: NodeMaterialBuildState): void;
  60796. autoConfigure(material: NodeMaterial): void;
  60797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60799. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60800. protected _buildBlock(state: NodeMaterialBuildState): this;
  60801. }
  60802. }
  60803. declare module BABYLON {
  60804. /**
  60805. * Block used to get data information from a light
  60806. */
  60807. export class LightInformationBlock extends NodeMaterialBlock {
  60808. private _lightDataUniformName;
  60809. private _lightColorUniformName;
  60810. private _lightTypeDefineName;
  60811. /**
  60812. * Gets or sets the light associated with this block
  60813. */
  60814. light: Nullable<Light>;
  60815. /**
  60816. * Creates a new LightInformationBlock
  60817. * @param name defines the block name
  60818. */
  60819. constructor(name: string);
  60820. /**
  60821. * Gets the current class name
  60822. * @returns the class name
  60823. */
  60824. getClassName(): string;
  60825. /**
  60826. * Gets the world position input component
  60827. */
  60828. get worldPosition(): NodeMaterialConnectionPoint;
  60829. /**
  60830. * Gets the direction output component
  60831. */
  60832. get direction(): NodeMaterialConnectionPoint;
  60833. /**
  60834. * Gets the direction output component
  60835. */
  60836. get color(): NodeMaterialConnectionPoint;
  60837. /**
  60838. * Gets the direction output component
  60839. */
  60840. get intensity(): NodeMaterialConnectionPoint;
  60841. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60843. protected _buildBlock(state: NodeMaterialBuildState): this;
  60844. serialize(): any;
  60845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60846. }
  60847. }
  60848. declare module BABYLON {
  60849. /**
  60850. * Block used to add image processing support to fragment shader
  60851. */
  60852. export class ImageProcessingBlock extends NodeMaterialBlock {
  60853. /**
  60854. * Create a new ImageProcessingBlock
  60855. * @param name defines the block name
  60856. */
  60857. constructor(name: string);
  60858. /**
  60859. * Gets the current class name
  60860. * @returns the class name
  60861. */
  60862. getClassName(): string;
  60863. /**
  60864. * Gets the color input component
  60865. */
  60866. get color(): NodeMaterialConnectionPoint;
  60867. /**
  60868. * Gets the output component
  60869. */
  60870. get output(): NodeMaterialConnectionPoint;
  60871. /**
  60872. * Initialize the block and prepare the context for build
  60873. * @param state defines the state that will be used for the build
  60874. */
  60875. initialize(state: NodeMaterialBuildState): void;
  60876. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60879. protected _buildBlock(state: NodeMaterialBuildState): this;
  60880. }
  60881. }
  60882. declare module BABYLON {
  60883. /**
  60884. * Block used to pertub normals based on a normal map
  60885. */
  60886. export class PerturbNormalBlock extends NodeMaterialBlock {
  60887. private _tangentSpaceParameterName;
  60888. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60889. invertX: boolean;
  60890. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60891. invertY: boolean;
  60892. /**
  60893. * Create a new PerturbNormalBlock
  60894. * @param name defines the block name
  60895. */
  60896. constructor(name: string);
  60897. /**
  60898. * Gets the current class name
  60899. * @returns the class name
  60900. */
  60901. getClassName(): string;
  60902. /**
  60903. * Gets the world position input component
  60904. */
  60905. get worldPosition(): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Gets the world normal input component
  60908. */
  60909. get worldNormal(): NodeMaterialConnectionPoint;
  60910. /**
  60911. * Gets the world tangent input component
  60912. */
  60913. get worldTangent(): NodeMaterialConnectionPoint;
  60914. /**
  60915. * Gets the uv input component
  60916. */
  60917. get uv(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the normal map color input component
  60920. */
  60921. get normalMapColor(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the strength input component
  60924. */
  60925. get strength(): NodeMaterialConnectionPoint;
  60926. /**
  60927. * Gets the output component
  60928. */
  60929. get output(): NodeMaterialConnectionPoint;
  60930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60932. autoConfigure(material: NodeMaterial): void;
  60933. protected _buildBlock(state: NodeMaterialBuildState): this;
  60934. protected _dumpPropertiesCode(): string;
  60935. serialize(): any;
  60936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60937. }
  60938. }
  60939. declare module BABYLON {
  60940. /**
  60941. * Block used to discard a pixel if a value is smaller than a cutoff
  60942. */
  60943. export class DiscardBlock extends NodeMaterialBlock {
  60944. /**
  60945. * Create a new DiscardBlock
  60946. * @param name defines the block name
  60947. */
  60948. constructor(name: string);
  60949. /**
  60950. * Gets the current class name
  60951. * @returns the class name
  60952. */
  60953. getClassName(): string;
  60954. /**
  60955. * Gets the color input component
  60956. */
  60957. get value(): NodeMaterialConnectionPoint;
  60958. /**
  60959. * Gets the cutoff input component
  60960. */
  60961. get cutoff(): NodeMaterialConnectionPoint;
  60962. protected _buildBlock(state: NodeMaterialBuildState): this;
  60963. }
  60964. }
  60965. declare module BABYLON {
  60966. /**
  60967. * Block used to test if the fragment shader is front facing
  60968. */
  60969. export class FrontFacingBlock extends NodeMaterialBlock {
  60970. /**
  60971. * Creates a new FrontFacingBlock
  60972. * @param name defines the block name
  60973. */
  60974. constructor(name: string);
  60975. /**
  60976. * Gets the current class name
  60977. * @returns the class name
  60978. */
  60979. getClassName(): string;
  60980. /**
  60981. * Gets the output component
  60982. */
  60983. get output(): NodeMaterialConnectionPoint;
  60984. protected _buildBlock(state: NodeMaterialBuildState): this;
  60985. }
  60986. }
  60987. declare module BABYLON {
  60988. /**
  60989. * Block used to get the derivative value on x and y of a given input
  60990. */
  60991. export class DerivativeBlock extends NodeMaterialBlock {
  60992. /**
  60993. * Create a new DerivativeBlock
  60994. * @param name defines the block name
  60995. */
  60996. constructor(name: string);
  60997. /**
  60998. * Gets the current class name
  60999. * @returns the class name
  61000. */
  61001. getClassName(): string;
  61002. /**
  61003. * Gets the input component
  61004. */
  61005. get input(): NodeMaterialConnectionPoint;
  61006. /**
  61007. * Gets the derivative output on x
  61008. */
  61009. get dx(): NodeMaterialConnectionPoint;
  61010. /**
  61011. * Gets the derivative output on y
  61012. */
  61013. get dy(): NodeMaterialConnectionPoint;
  61014. protected _buildBlock(state: NodeMaterialBuildState): this;
  61015. }
  61016. }
  61017. declare module BABYLON {
  61018. /**
  61019. * Block used to make gl_FragCoord available
  61020. */
  61021. export class FragCoordBlock extends NodeMaterialBlock {
  61022. /**
  61023. * Creates a new FragCoordBlock
  61024. * @param name defines the block name
  61025. */
  61026. constructor(name: string);
  61027. /**
  61028. * Gets the current class name
  61029. * @returns the class name
  61030. */
  61031. getClassName(): string;
  61032. /**
  61033. * Gets the xy component
  61034. */
  61035. get xy(): NodeMaterialConnectionPoint;
  61036. /**
  61037. * Gets the xyz component
  61038. */
  61039. get xyz(): NodeMaterialConnectionPoint;
  61040. /**
  61041. * Gets the xyzw component
  61042. */
  61043. get xyzw(): NodeMaterialConnectionPoint;
  61044. /**
  61045. * Gets the x component
  61046. */
  61047. get x(): NodeMaterialConnectionPoint;
  61048. /**
  61049. * Gets the y component
  61050. */
  61051. get y(): NodeMaterialConnectionPoint;
  61052. /**
  61053. * Gets the z component
  61054. */
  61055. get z(): NodeMaterialConnectionPoint;
  61056. /**
  61057. * Gets the w component
  61058. */
  61059. get output(): NodeMaterialConnectionPoint;
  61060. protected writeOutputs(state: NodeMaterialBuildState): string;
  61061. protected _buildBlock(state: NodeMaterialBuildState): this;
  61062. }
  61063. }
  61064. declare module BABYLON {
  61065. /**
  61066. * Block used to get the screen sizes
  61067. */
  61068. export class ScreenSizeBlock extends NodeMaterialBlock {
  61069. private _varName;
  61070. private _scene;
  61071. /**
  61072. * Creates a new ScreenSizeBlock
  61073. * @param name defines the block name
  61074. */
  61075. constructor(name: string);
  61076. /**
  61077. * Gets the current class name
  61078. * @returns the class name
  61079. */
  61080. getClassName(): string;
  61081. /**
  61082. * Gets the xy component
  61083. */
  61084. get xy(): NodeMaterialConnectionPoint;
  61085. /**
  61086. * Gets the x component
  61087. */
  61088. get x(): NodeMaterialConnectionPoint;
  61089. /**
  61090. * Gets the y component
  61091. */
  61092. get y(): NodeMaterialConnectionPoint;
  61093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61094. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61095. protected _buildBlock(state: NodeMaterialBuildState): this;
  61096. }
  61097. }
  61098. declare module BABYLON {
  61099. /**
  61100. * Block used to add support for scene fog
  61101. */
  61102. export class FogBlock extends NodeMaterialBlock {
  61103. private _fogDistanceName;
  61104. private _fogParameters;
  61105. /**
  61106. * Create a new FogBlock
  61107. * @param name defines the block name
  61108. */
  61109. constructor(name: string);
  61110. /**
  61111. * Gets the current class name
  61112. * @returns the class name
  61113. */
  61114. getClassName(): string;
  61115. /**
  61116. * Gets the world position input component
  61117. */
  61118. get worldPosition(): NodeMaterialConnectionPoint;
  61119. /**
  61120. * Gets the view input component
  61121. */
  61122. get view(): NodeMaterialConnectionPoint;
  61123. /**
  61124. * Gets the color input component
  61125. */
  61126. get input(): NodeMaterialConnectionPoint;
  61127. /**
  61128. * Gets the fog color input component
  61129. */
  61130. get fogColor(): NodeMaterialConnectionPoint;
  61131. /**
  61132. * Gets the output component
  61133. */
  61134. get output(): NodeMaterialConnectionPoint;
  61135. autoConfigure(material: NodeMaterial): void;
  61136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61138. protected _buildBlock(state: NodeMaterialBuildState): this;
  61139. }
  61140. }
  61141. declare module BABYLON {
  61142. /**
  61143. * Block used to add light in the fragment shader
  61144. */
  61145. export class LightBlock extends NodeMaterialBlock {
  61146. private _lightId;
  61147. /**
  61148. * Gets or sets the light associated with this block
  61149. */
  61150. light: Nullable<Light>;
  61151. /**
  61152. * Create a new LightBlock
  61153. * @param name defines the block name
  61154. */
  61155. constructor(name: string);
  61156. /**
  61157. * Gets the current class name
  61158. * @returns the class name
  61159. */
  61160. getClassName(): string;
  61161. /**
  61162. * Gets the world position input component
  61163. */
  61164. get worldPosition(): NodeMaterialConnectionPoint;
  61165. /**
  61166. * Gets the world normal input component
  61167. */
  61168. get worldNormal(): NodeMaterialConnectionPoint;
  61169. /**
  61170. * Gets the camera (or eye) position component
  61171. */
  61172. get cameraPosition(): NodeMaterialConnectionPoint;
  61173. /**
  61174. * Gets the glossiness component
  61175. */
  61176. get glossiness(): NodeMaterialConnectionPoint;
  61177. /**
  61178. * Gets the glossinness power component
  61179. */
  61180. get glossPower(): NodeMaterialConnectionPoint;
  61181. /**
  61182. * Gets the diffuse color component
  61183. */
  61184. get diffuseColor(): NodeMaterialConnectionPoint;
  61185. /**
  61186. * Gets the specular color component
  61187. */
  61188. get specularColor(): NodeMaterialConnectionPoint;
  61189. /**
  61190. * Gets the diffuse output component
  61191. */
  61192. get diffuseOutput(): NodeMaterialConnectionPoint;
  61193. /**
  61194. * Gets the specular output component
  61195. */
  61196. get specularOutput(): NodeMaterialConnectionPoint;
  61197. /**
  61198. * Gets the shadow output component
  61199. */
  61200. get shadow(): NodeMaterialConnectionPoint;
  61201. autoConfigure(material: NodeMaterial): void;
  61202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61203. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61204. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61205. private _injectVertexCode;
  61206. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61207. serialize(): any;
  61208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61209. }
  61210. }
  61211. declare module BABYLON {
  61212. /**
  61213. * Block used to read a reflection texture from a sampler
  61214. */
  61215. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61216. /**
  61217. * Create a new ReflectionTextureBlock
  61218. * @param name defines the block name
  61219. */
  61220. constructor(name: string);
  61221. /**
  61222. * Gets the current class name
  61223. * @returns the class name
  61224. */
  61225. getClassName(): string;
  61226. /**
  61227. * Gets the world position input component
  61228. */
  61229. get position(): NodeMaterialConnectionPoint;
  61230. /**
  61231. * Gets the world position input component
  61232. */
  61233. get worldPosition(): NodeMaterialConnectionPoint;
  61234. /**
  61235. * Gets the world normal input component
  61236. */
  61237. get worldNormal(): NodeMaterialConnectionPoint;
  61238. /**
  61239. * Gets the world input component
  61240. */
  61241. get world(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the camera (or eye) position component
  61244. */
  61245. get cameraPosition(): NodeMaterialConnectionPoint;
  61246. /**
  61247. * Gets the view input component
  61248. */
  61249. get view(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the rgb output component
  61252. */
  61253. get rgb(): NodeMaterialConnectionPoint;
  61254. /**
  61255. * Gets the r output component
  61256. */
  61257. get r(): NodeMaterialConnectionPoint;
  61258. /**
  61259. * Gets the g output component
  61260. */
  61261. get g(): NodeMaterialConnectionPoint;
  61262. /**
  61263. * Gets the b output component
  61264. */
  61265. get b(): NodeMaterialConnectionPoint;
  61266. autoConfigure(material: NodeMaterial): void;
  61267. protected _buildBlock(state: NodeMaterialBuildState): this;
  61268. }
  61269. }
  61270. declare module BABYLON {
  61271. /**
  61272. * Block used to add 2 vectors
  61273. */
  61274. export class AddBlock extends NodeMaterialBlock {
  61275. /**
  61276. * Creates a new AddBlock
  61277. * @param name defines the block name
  61278. */
  61279. constructor(name: string);
  61280. /**
  61281. * Gets the current class name
  61282. * @returns the class name
  61283. */
  61284. getClassName(): string;
  61285. /**
  61286. * Gets the left operand input component
  61287. */
  61288. get left(): NodeMaterialConnectionPoint;
  61289. /**
  61290. * Gets the right operand input component
  61291. */
  61292. get right(): NodeMaterialConnectionPoint;
  61293. /**
  61294. * Gets the output component
  61295. */
  61296. get output(): NodeMaterialConnectionPoint;
  61297. protected _buildBlock(state: NodeMaterialBuildState): this;
  61298. }
  61299. }
  61300. declare module BABYLON {
  61301. /**
  61302. * Block used to scale a vector by a float
  61303. */
  61304. export class ScaleBlock extends NodeMaterialBlock {
  61305. /**
  61306. * Creates a new ScaleBlock
  61307. * @param name defines the block name
  61308. */
  61309. constructor(name: string);
  61310. /**
  61311. * Gets the current class name
  61312. * @returns the class name
  61313. */
  61314. getClassName(): string;
  61315. /**
  61316. * Gets the input component
  61317. */
  61318. get input(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the factor input component
  61321. */
  61322. get factor(): NodeMaterialConnectionPoint;
  61323. /**
  61324. * Gets the output component
  61325. */
  61326. get output(): NodeMaterialConnectionPoint;
  61327. protected _buildBlock(state: NodeMaterialBuildState): this;
  61328. }
  61329. }
  61330. declare module BABYLON {
  61331. /**
  61332. * Block used to clamp a float
  61333. */
  61334. export class ClampBlock extends NodeMaterialBlock {
  61335. /** Gets or sets the minimum range */
  61336. minimum: number;
  61337. /** Gets or sets the maximum range */
  61338. maximum: number;
  61339. /**
  61340. * Creates a new ClampBlock
  61341. * @param name defines the block name
  61342. */
  61343. constructor(name: string);
  61344. /**
  61345. * Gets the current class name
  61346. * @returns the class name
  61347. */
  61348. getClassName(): string;
  61349. /**
  61350. * Gets the value input component
  61351. */
  61352. get value(): NodeMaterialConnectionPoint;
  61353. /**
  61354. * Gets the output component
  61355. */
  61356. get output(): NodeMaterialConnectionPoint;
  61357. protected _buildBlock(state: NodeMaterialBuildState): this;
  61358. protected _dumpPropertiesCode(): string;
  61359. serialize(): any;
  61360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61361. }
  61362. }
  61363. declare module BABYLON {
  61364. /**
  61365. * Block used to apply a cross product between 2 vectors
  61366. */
  61367. export class CrossBlock extends NodeMaterialBlock {
  61368. /**
  61369. * Creates a new CrossBlock
  61370. * @param name defines the block name
  61371. */
  61372. constructor(name: string);
  61373. /**
  61374. * Gets the current class name
  61375. * @returns the class name
  61376. */
  61377. getClassName(): string;
  61378. /**
  61379. * Gets the left operand input component
  61380. */
  61381. get left(): NodeMaterialConnectionPoint;
  61382. /**
  61383. * Gets the right operand input component
  61384. */
  61385. get right(): NodeMaterialConnectionPoint;
  61386. /**
  61387. * Gets the output component
  61388. */
  61389. get output(): NodeMaterialConnectionPoint;
  61390. protected _buildBlock(state: NodeMaterialBuildState): this;
  61391. }
  61392. }
  61393. declare module BABYLON {
  61394. /**
  61395. * Block used to apply a dot product between 2 vectors
  61396. */
  61397. export class DotBlock extends NodeMaterialBlock {
  61398. /**
  61399. * Creates a new DotBlock
  61400. * @param name defines the block name
  61401. */
  61402. constructor(name: string);
  61403. /**
  61404. * Gets the current class name
  61405. * @returns the class name
  61406. */
  61407. getClassName(): string;
  61408. /**
  61409. * Gets the left operand input component
  61410. */
  61411. get left(): NodeMaterialConnectionPoint;
  61412. /**
  61413. * Gets the right operand input component
  61414. */
  61415. get right(): NodeMaterialConnectionPoint;
  61416. /**
  61417. * Gets the output component
  61418. */
  61419. get output(): NodeMaterialConnectionPoint;
  61420. protected _buildBlock(state: NodeMaterialBuildState): this;
  61421. }
  61422. }
  61423. declare module BABYLON {
  61424. /**
  61425. * Block used to normalize a vector
  61426. */
  61427. export class NormalizeBlock extends NodeMaterialBlock {
  61428. /**
  61429. * Creates a new NormalizeBlock
  61430. * @param name defines the block name
  61431. */
  61432. constructor(name: string);
  61433. /**
  61434. * Gets the current class name
  61435. * @returns the class name
  61436. */
  61437. getClassName(): string;
  61438. /**
  61439. * Gets the input component
  61440. */
  61441. get input(): NodeMaterialConnectionPoint;
  61442. /**
  61443. * Gets the output component
  61444. */
  61445. get output(): NodeMaterialConnectionPoint;
  61446. protected _buildBlock(state: NodeMaterialBuildState): this;
  61447. }
  61448. }
  61449. declare module BABYLON {
  61450. /**
  61451. * Operations supported by the Trigonometry block
  61452. */
  61453. export enum TrigonometryBlockOperations {
  61454. /** Cos */
  61455. Cos = 0,
  61456. /** Sin */
  61457. Sin = 1,
  61458. /** Abs */
  61459. Abs = 2,
  61460. /** Exp */
  61461. Exp = 3,
  61462. /** Exp2 */
  61463. Exp2 = 4,
  61464. /** Round */
  61465. Round = 5,
  61466. /** Floor */
  61467. Floor = 6,
  61468. /** Ceiling */
  61469. Ceiling = 7,
  61470. /** Square root */
  61471. Sqrt = 8,
  61472. /** Log */
  61473. Log = 9,
  61474. /** Tangent */
  61475. Tan = 10,
  61476. /** Arc tangent */
  61477. ArcTan = 11,
  61478. /** Arc cosinus */
  61479. ArcCos = 12,
  61480. /** Arc sinus */
  61481. ArcSin = 13,
  61482. /** Fraction */
  61483. Fract = 14,
  61484. /** Sign */
  61485. Sign = 15,
  61486. /** To radians (from degrees) */
  61487. Radians = 16,
  61488. /** To degrees (from radians) */
  61489. Degrees = 17
  61490. }
  61491. /**
  61492. * Block used to apply trigonometry operation to floats
  61493. */
  61494. export class TrigonometryBlock extends NodeMaterialBlock {
  61495. /**
  61496. * Gets or sets the operation applied by the block
  61497. */
  61498. operation: TrigonometryBlockOperations;
  61499. /**
  61500. * Creates a new TrigonometryBlock
  61501. * @param name defines the block name
  61502. */
  61503. constructor(name: string);
  61504. /**
  61505. * Gets the current class name
  61506. * @returns the class name
  61507. */
  61508. getClassName(): string;
  61509. /**
  61510. * Gets the input component
  61511. */
  61512. get input(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the output component
  61515. */
  61516. get output(): NodeMaterialConnectionPoint;
  61517. protected _buildBlock(state: NodeMaterialBuildState): this;
  61518. serialize(): any;
  61519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61520. protected _dumpPropertiesCode(): string;
  61521. }
  61522. }
  61523. declare module BABYLON {
  61524. /**
  61525. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61526. */
  61527. export class ColorMergerBlock extends NodeMaterialBlock {
  61528. /**
  61529. * Create a new ColorMergerBlock
  61530. * @param name defines the block name
  61531. */
  61532. constructor(name: string);
  61533. /**
  61534. * Gets the current class name
  61535. * @returns the class name
  61536. */
  61537. getClassName(): string;
  61538. /**
  61539. * Gets the rgb component (input)
  61540. */
  61541. get rgbIn(): NodeMaterialConnectionPoint;
  61542. /**
  61543. * Gets the r component (input)
  61544. */
  61545. get r(): NodeMaterialConnectionPoint;
  61546. /**
  61547. * Gets the g component (input)
  61548. */
  61549. get g(): NodeMaterialConnectionPoint;
  61550. /**
  61551. * Gets the b component (input)
  61552. */
  61553. get b(): NodeMaterialConnectionPoint;
  61554. /**
  61555. * Gets the a component (input)
  61556. */
  61557. get a(): NodeMaterialConnectionPoint;
  61558. /**
  61559. * Gets the rgba component (output)
  61560. */
  61561. get rgba(): NodeMaterialConnectionPoint;
  61562. /**
  61563. * Gets the rgb component (output)
  61564. */
  61565. get rgbOut(): NodeMaterialConnectionPoint;
  61566. /**
  61567. * Gets the rgb component (output)
  61568. * @deprecated Please use rgbOut instead.
  61569. */
  61570. get rgb(): NodeMaterialConnectionPoint;
  61571. protected _buildBlock(state: NodeMaterialBuildState): this;
  61572. }
  61573. }
  61574. declare module BABYLON {
  61575. /**
  61576. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61577. */
  61578. export class VectorSplitterBlock extends NodeMaterialBlock {
  61579. /**
  61580. * Create a new VectorSplitterBlock
  61581. * @param name defines the block name
  61582. */
  61583. constructor(name: string);
  61584. /**
  61585. * Gets the current class name
  61586. * @returns the class name
  61587. */
  61588. getClassName(): string;
  61589. /**
  61590. * Gets the xyzw component (input)
  61591. */
  61592. get xyzw(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the xyz component (input)
  61595. */
  61596. get xyzIn(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the xy component (input)
  61599. */
  61600. get xyIn(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the xyz component (output)
  61603. */
  61604. get xyzOut(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the xy component (output)
  61607. */
  61608. get xyOut(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the x component (output)
  61611. */
  61612. get x(): NodeMaterialConnectionPoint;
  61613. /**
  61614. * Gets the y component (output)
  61615. */
  61616. get y(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the z component (output)
  61619. */
  61620. get z(): NodeMaterialConnectionPoint;
  61621. /**
  61622. * Gets the w component (output)
  61623. */
  61624. get w(): NodeMaterialConnectionPoint;
  61625. protected _inputRename(name: string): string;
  61626. protected _outputRename(name: string): string;
  61627. protected _buildBlock(state: NodeMaterialBuildState): this;
  61628. }
  61629. }
  61630. declare module BABYLON {
  61631. /**
  61632. * Block used to lerp between 2 values
  61633. */
  61634. export class LerpBlock extends NodeMaterialBlock {
  61635. /**
  61636. * Creates a new LerpBlock
  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 left operand input component
  61647. */
  61648. get left(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the right operand input component
  61651. */
  61652. get right(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the gradient operand input component
  61655. */
  61656. get gradient(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the output component
  61659. */
  61660. get output(): NodeMaterialConnectionPoint;
  61661. protected _buildBlock(state: NodeMaterialBuildState): this;
  61662. }
  61663. }
  61664. declare module BABYLON {
  61665. /**
  61666. * Block used to divide 2 vectors
  61667. */
  61668. export class DivideBlock extends NodeMaterialBlock {
  61669. /**
  61670. * Creates a new DivideBlock
  61671. * @param name defines the block name
  61672. */
  61673. constructor(name: string);
  61674. /**
  61675. * Gets the current class name
  61676. * @returns the class name
  61677. */
  61678. getClassName(): string;
  61679. /**
  61680. * Gets the left operand input component
  61681. */
  61682. get left(): NodeMaterialConnectionPoint;
  61683. /**
  61684. * Gets the right operand input component
  61685. */
  61686. get right(): NodeMaterialConnectionPoint;
  61687. /**
  61688. * Gets the output component
  61689. */
  61690. get output(): NodeMaterialConnectionPoint;
  61691. protected _buildBlock(state: NodeMaterialBuildState): this;
  61692. }
  61693. }
  61694. declare module BABYLON {
  61695. /**
  61696. * Block used to subtract 2 vectors
  61697. */
  61698. export class SubtractBlock extends NodeMaterialBlock {
  61699. /**
  61700. * Creates a new SubtractBlock
  61701. * @param name defines the block name
  61702. */
  61703. constructor(name: string);
  61704. /**
  61705. * Gets the current class name
  61706. * @returns the class name
  61707. */
  61708. getClassName(): string;
  61709. /**
  61710. * Gets the left operand input component
  61711. */
  61712. get left(): NodeMaterialConnectionPoint;
  61713. /**
  61714. * Gets the right operand input component
  61715. */
  61716. get right(): NodeMaterialConnectionPoint;
  61717. /**
  61718. * Gets the output component
  61719. */
  61720. get output(): NodeMaterialConnectionPoint;
  61721. protected _buildBlock(state: NodeMaterialBuildState): this;
  61722. }
  61723. }
  61724. declare module BABYLON {
  61725. /**
  61726. * Block used to step a value
  61727. */
  61728. export class StepBlock extends NodeMaterialBlock {
  61729. /**
  61730. * Creates a new StepBlock
  61731. * @param name defines the block name
  61732. */
  61733. constructor(name: string);
  61734. /**
  61735. * Gets the current class name
  61736. * @returns the class name
  61737. */
  61738. getClassName(): string;
  61739. /**
  61740. * Gets the value operand input component
  61741. */
  61742. get value(): NodeMaterialConnectionPoint;
  61743. /**
  61744. * Gets the edge operand input component
  61745. */
  61746. get edge(): NodeMaterialConnectionPoint;
  61747. /**
  61748. * Gets the output component
  61749. */
  61750. get output(): NodeMaterialConnectionPoint;
  61751. protected _buildBlock(state: NodeMaterialBuildState): this;
  61752. }
  61753. }
  61754. declare module BABYLON {
  61755. /**
  61756. * Block used to get the opposite (1 - x) of a value
  61757. */
  61758. export class OneMinusBlock extends NodeMaterialBlock {
  61759. /**
  61760. * Creates a new OneMinusBlock
  61761. * @param name defines the block name
  61762. */
  61763. constructor(name: string);
  61764. /**
  61765. * Gets the current class name
  61766. * @returns the class name
  61767. */
  61768. getClassName(): string;
  61769. /**
  61770. * Gets the input component
  61771. */
  61772. get input(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the output component
  61775. */
  61776. get output(): NodeMaterialConnectionPoint;
  61777. protected _buildBlock(state: NodeMaterialBuildState): this;
  61778. }
  61779. }
  61780. declare module BABYLON {
  61781. /**
  61782. * Block used to get the view direction
  61783. */
  61784. export class ViewDirectionBlock extends NodeMaterialBlock {
  61785. /**
  61786. * Creates a new ViewDirectionBlock
  61787. * @param name defines the block name
  61788. */
  61789. constructor(name: string);
  61790. /**
  61791. * Gets the current class name
  61792. * @returns the class name
  61793. */
  61794. getClassName(): string;
  61795. /**
  61796. * Gets the world position component
  61797. */
  61798. get worldPosition(): NodeMaterialConnectionPoint;
  61799. /**
  61800. * Gets the camera position component
  61801. */
  61802. get cameraPosition(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the output component
  61805. */
  61806. get output(): NodeMaterialConnectionPoint;
  61807. autoConfigure(material: NodeMaterial): void;
  61808. protected _buildBlock(state: NodeMaterialBuildState): this;
  61809. }
  61810. }
  61811. declare module BABYLON {
  61812. /**
  61813. * Block used to compute fresnel value
  61814. */
  61815. export class FresnelBlock extends NodeMaterialBlock {
  61816. /**
  61817. * Create a new FresnelBlock
  61818. * @param name defines the block name
  61819. */
  61820. constructor(name: string);
  61821. /**
  61822. * Gets the current class name
  61823. * @returns the class name
  61824. */
  61825. getClassName(): string;
  61826. /**
  61827. * Gets the world normal input component
  61828. */
  61829. get worldNormal(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the view direction input component
  61832. */
  61833. get viewDirection(): NodeMaterialConnectionPoint;
  61834. /**
  61835. * Gets the bias input component
  61836. */
  61837. get bias(): NodeMaterialConnectionPoint;
  61838. /**
  61839. * Gets the camera (or eye) position component
  61840. */
  61841. get power(): NodeMaterialConnectionPoint;
  61842. /**
  61843. * Gets the fresnel output component
  61844. */
  61845. get fresnel(): NodeMaterialConnectionPoint;
  61846. autoConfigure(material: NodeMaterial): void;
  61847. protected _buildBlock(state: NodeMaterialBuildState): this;
  61848. }
  61849. }
  61850. declare module BABYLON {
  61851. /**
  61852. * Block used to get the max of 2 values
  61853. */
  61854. export class MaxBlock extends NodeMaterialBlock {
  61855. /**
  61856. * Creates a new MaxBlock
  61857. * @param name defines the block name
  61858. */
  61859. constructor(name: string);
  61860. /**
  61861. * Gets the current class name
  61862. * @returns the class name
  61863. */
  61864. getClassName(): string;
  61865. /**
  61866. * Gets the left operand input component
  61867. */
  61868. get left(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the right operand input component
  61871. */
  61872. get right(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the output component
  61875. */
  61876. get output(): NodeMaterialConnectionPoint;
  61877. protected _buildBlock(state: NodeMaterialBuildState): this;
  61878. }
  61879. }
  61880. declare module BABYLON {
  61881. /**
  61882. * Block used to get the min of 2 values
  61883. */
  61884. export class MinBlock extends NodeMaterialBlock {
  61885. /**
  61886. * Creates a new MinBlock
  61887. * @param name defines the block name
  61888. */
  61889. constructor(name: string);
  61890. /**
  61891. * Gets the current class name
  61892. * @returns the class name
  61893. */
  61894. getClassName(): string;
  61895. /**
  61896. * Gets the left operand input component
  61897. */
  61898. get left(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the right operand input component
  61901. */
  61902. get right(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the output component
  61905. */
  61906. get output(): NodeMaterialConnectionPoint;
  61907. protected _buildBlock(state: NodeMaterialBuildState): this;
  61908. }
  61909. }
  61910. declare module BABYLON {
  61911. /**
  61912. * Block used to get the distance between 2 values
  61913. */
  61914. export class DistanceBlock extends NodeMaterialBlock {
  61915. /**
  61916. * Creates a new DistanceBlock
  61917. * @param name defines the block name
  61918. */
  61919. constructor(name: string);
  61920. /**
  61921. * Gets the current class name
  61922. * @returns the class name
  61923. */
  61924. getClassName(): string;
  61925. /**
  61926. * Gets the left operand input component
  61927. */
  61928. get left(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the right operand input component
  61931. */
  61932. get right(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the output component
  61935. */
  61936. get output(): NodeMaterialConnectionPoint;
  61937. protected _buildBlock(state: NodeMaterialBuildState): this;
  61938. }
  61939. }
  61940. declare module BABYLON {
  61941. /**
  61942. * Block used to get the length of a vector
  61943. */
  61944. export class LengthBlock extends NodeMaterialBlock {
  61945. /**
  61946. * Creates a new LengthBlock
  61947. * @param name defines the block name
  61948. */
  61949. constructor(name: string);
  61950. /**
  61951. * Gets the current class name
  61952. * @returns the class name
  61953. */
  61954. getClassName(): string;
  61955. /**
  61956. * Gets the value input component
  61957. */
  61958. get value(): NodeMaterialConnectionPoint;
  61959. /**
  61960. * Gets the output component
  61961. */
  61962. get output(): NodeMaterialConnectionPoint;
  61963. protected _buildBlock(state: NodeMaterialBuildState): this;
  61964. }
  61965. }
  61966. declare module BABYLON {
  61967. /**
  61968. * Block used to get negative version of a value (i.e. x * -1)
  61969. */
  61970. export class NegateBlock extends NodeMaterialBlock {
  61971. /**
  61972. * Creates a new NegateBlock
  61973. * @param name defines the block name
  61974. */
  61975. constructor(name: string);
  61976. /**
  61977. * Gets the current class name
  61978. * @returns the class name
  61979. */
  61980. getClassName(): string;
  61981. /**
  61982. * Gets the value input component
  61983. */
  61984. get value(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the output component
  61987. */
  61988. get output(): NodeMaterialConnectionPoint;
  61989. protected _buildBlock(state: NodeMaterialBuildState): this;
  61990. }
  61991. }
  61992. declare module BABYLON {
  61993. /**
  61994. * Block used to get the value of the first parameter raised to the power of the second
  61995. */
  61996. export class PowBlock extends NodeMaterialBlock {
  61997. /**
  61998. * Creates a new PowBlock
  61999. * @param name defines the block name
  62000. */
  62001. constructor(name: string);
  62002. /**
  62003. * Gets the current class name
  62004. * @returns the class name
  62005. */
  62006. getClassName(): string;
  62007. /**
  62008. * Gets the value operand input component
  62009. */
  62010. get value(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the power operand input component
  62013. */
  62014. get power(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the output component
  62017. */
  62018. get output(): NodeMaterialConnectionPoint;
  62019. protected _buildBlock(state: NodeMaterialBuildState): this;
  62020. }
  62021. }
  62022. declare module BABYLON {
  62023. /**
  62024. * Block used to get a random number
  62025. */
  62026. export class RandomNumberBlock extends NodeMaterialBlock {
  62027. /**
  62028. * Creates a new RandomNumberBlock
  62029. * @param name defines the block name
  62030. */
  62031. constructor(name: string);
  62032. /**
  62033. * Gets the current class name
  62034. * @returns the class name
  62035. */
  62036. getClassName(): string;
  62037. /**
  62038. * Gets the seed input component
  62039. */
  62040. get seed(): NodeMaterialConnectionPoint;
  62041. /**
  62042. * Gets the output component
  62043. */
  62044. get output(): NodeMaterialConnectionPoint;
  62045. protected _buildBlock(state: NodeMaterialBuildState): this;
  62046. }
  62047. }
  62048. declare module BABYLON {
  62049. /**
  62050. * Block used to compute arc tangent of 2 values
  62051. */
  62052. export class ArcTan2Block extends NodeMaterialBlock {
  62053. /**
  62054. * Creates a new ArcTan2Block
  62055. * @param name defines the block name
  62056. */
  62057. constructor(name: string);
  62058. /**
  62059. * Gets the current class name
  62060. * @returns the class name
  62061. */
  62062. getClassName(): string;
  62063. /**
  62064. * Gets the x operand input component
  62065. */
  62066. get x(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the y operand input component
  62069. */
  62070. get y(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the output component
  62073. */
  62074. get output(): NodeMaterialConnectionPoint;
  62075. protected _buildBlock(state: NodeMaterialBuildState): this;
  62076. }
  62077. }
  62078. declare module BABYLON {
  62079. /**
  62080. * Block used to smooth step a value
  62081. */
  62082. export class SmoothStepBlock extends NodeMaterialBlock {
  62083. /**
  62084. * Creates a new SmoothStepBlock
  62085. * @param name defines the block name
  62086. */
  62087. constructor(name: string);
  62088. /**
  62089. * Gets the current class name
  62090. * @returns the class name
  62091. */
  62092. getClassName(): string;
  62093. /**
  62094. * Gets the value operand input component
  62095. */
  62096. get value(): NodeMaterialConnectionPoint;
  62097. /**
  62098. * Gets the first edge operand input component
  62099. */
  62100. get edge0(): NodeMaterialConnectionPoint;
  62101. /**
  62102. * Gets the second edge operand input component
  62103. */
  62104. get edge1(): NodeMaterialConnectionPoint;
  62105. /**
  62106. * Gets the output component
  62107. */
  62108. get output(): NodeMaterialConnectionPoint;
  62109. protected _buildBlock(state: NodeMaterialBuildState): this;
  62110. }
  62111. }
  62112. declare module BABYLON {
  62113. /**
  62114. * Block used to get the reciprocal (1 / x) of a value
  62115. */
  62116. export class ReciprocalBlock extends NodeMaterialBlock {
  62117. /**
  62118. * Creates a new ReciprocalBlock
  62119. * @param name defines the block name
  62120. */
  62121. constructor(name: string);
  62122. /**
  62123. * Gets the current class name
  62124. * @returns the class name
  62125. */
  62126. getClassName(): string;
  62127. /**
  62128. * Gets the input component
  62129. */
  62130. get input(): NodeMaterialConnectionPoint;
  62131. /**
  62132. * Gets the output component
  62133. */
  62134. get output(): NodeMaterialConnectionPoint;
  62135. protected _buildBlock(state: NodeMaterialBuildState): this;
  62136. }
  62137. }
  62138. declare module BABYLON {
  62139. /**
  62140. * Block used to replace a color by another one
  62141. */
  62142. export class ReplaceColorBlock extends NodeMaterialBlock {
  62143. /**
  62144. * Creates a new ReplaceColorBlock
  62145. * @param name defines the block name
  62146. */
  62147. constructor(name: string);
  62148. /**
  62149. * Gets the current class name
  62150. * @returns the class name
  62151. */
  62152. getClassName(): string;
  62153. /**
  62154. * Gets the value input component
  62155. */
  62156. get value(): NodeMaterialConnectionPoint;
  62157. /**
  62158. * Gets the reference input component
  62159. */
  62160. get reference(): NodeMaterialConnectionPoint;
  62161. /**
  62162. * Gets the distance input component
  62163. */
  62164. get distance(): NodeMaterialConnectionPoint;
  62165. /**
  62166. * Gets the replacement input component
  62167. */
  62168. get replacement(): NodeMaterialConnectionPoint;
  62169. /**
  62170. * Gets the output component
  62171. */
  62172. get output(): NodeMaterialConnectionPoint;
  62173. protected _buildBlock(state: NodeMaterialBuildState): this;
  62174. }
  62175. }
  62176. declare module BABYLON {
  62177. /**
  62178. * Block used to posterize a value
  62179. * @see https://en.wikipedia.org/wiki/Posterization
  62180. */
  62181. export class PosterizeBlock extends NodeMaterialBlock {
  62182. /**
  62183. * Creates a new PosterizeBlock
  62184. * @param name defines the block name
  62185. */
  62186. constructor(name: string);
  62187. /**
  62188. * Gets the current class name
  62189. * @returns the class name
  62190. */
  62191. getClassName(): string;
  62192. /**
  62193. * Gets the value input component
  62194. */
  62195. get value(): NodeMaterialConnectionPoint;
  62196. /**
  62197. * Gets the steps input component
  62198. */
  62199. get steps(): NodeMaterialConnectionPoint;
  62200. /**
  62201. * Gets the output component
  62202. */
  62203. get output(): NodeMaterialConnectionPoint;
  62204. protected _buildBlock(state: NodeMaterialBuildState): this;
  62205. }
  62206. }
  62207. declare module BABYLON {
  62208. /**
  62209. * Operations supported by the Wave block
  62210. */
  62211. export enum WaveBlockKind {
  62212. /** SawTooth */
  62213. SawTooth = 0,
  62214. /** Square */
  62215. Square = 1,
  62216. /** Triangle */
  62217. Triangle = 2
  62218. }
  62219. /**
  62220. * Block used to apply wave operation to floats
  62221. */
  62222. export class WaveBlock extends NodeMaterialBlock {
  62223. /**
  62224. * Gets or sets the kibnd of wave to be applied by the block
  62225. */
  62226. kind: WaveBlockKind;
  62227. /**
  62228. * Creates a new WaveBlock
  62229. * @param name defines the block name
  62230. */
  62231. constructor(name: string);
  62232. /**
  62233. * Gets the current class name
  62234. * @returns the class name
  62235. */
  62236. getClassName(): string;
  62237. /**
  62238. * Gets the input component
  62239. */
  62240. get input(): NodeMaterialConnectionPoint;
  62241. /**
  62242. * Gets the output component
  62243. */
  62244. get output(): NodeMaterialConnectionPoint;
  62245. protected _buildBlock(state: NodeMaterialBuildState): this;
  62246. serialize(): any;
  62247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62248. }
  62249. }
  62250. declare module BABYLON {
  62251. /**
  62252. * Class used to store a color step for the GradientBlock
  62253. */
  62254. export class GradientBlockColorStep {
  62255. /**
  62256. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62257. */
  62258. step: number;
  62259. /**
  62260. * Gets or sets the color associated with this step
  62261. */
  62262. color: Color3;
  62263. /**
  62264. * Creates a new GradientBlockColorStep
  62265. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62266. * @param color defines the color associated with this step
  62267. */
  62268. constructor(
  62269. /**
  62270. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62271. */
  62272. step: number,
  62273. /**
  62274. * Gets or sets the color associated with this step
  62275. */
  62276. color: Color3);
  62277. }
  62278. /**
  62279. * Block used to return a color from a gradient based on an input value between 0 and 1
  62280. */
  62281. export class GradientBlock extends NodeMaterialBlock {
  62282. /**
  62283. * Gets or sets the list of color steps
  62284. */
  62285. colorSteps: GradientBlockColorStep[];
  62286. /**
  62287. * Creates a new GradientBlock
  62288. * @param name defines the block name
  62289. */
  62290. constructor(name: string);
  62291. /**
  62292. * Gets the current class name
  62293. * @returns the class name
  62294. */
  62295. getClassName(): string;
  62296. /**
  62297. * Gets the gradient input component
  62298. */
  62299. get gradient(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the output component
  62302. */
  62303. get output(): NodeMaterialConnectionPoint;
  62304. private _writeColorConstant;
  62305. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62306. serialize(): any;
  62307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62308. protected _dumpPropertiesCode(): string;
  62309. }
  62310. }
  62311. declare module BABYLON {
  62312. /**
  62313. * Block used to normalize lerp between 2 values
  62314. */
  62315. export class NLerpBlock extends NodeMaterialBlock {
  62316. /**
  62317. * Creates a new NLerpBlock
  62318. * @param name defines the block name
  62319. */
  62320. constructor(name: string);
  62321. /**
  62322. * Gets the current class name
  62323. * @returns the class name
  62324. */
  62325. getClassName(): string;
  62326. /**
  62327. * Gets the left operand input component
  62328. */
  62329. get left(): NodeMaterialConnectionPoint;
  62330. /**
  62331. * Gets the right operand input component
  62332. */
  62333. get right(): NodeMaterialConnectionPoint;
  62334. /**
  62335. * Gets the gradient operand input component
  62336. */
  62337. get gradient(): NodeMaterialConnectionPoint;
  62338. /**
  62339. * Gets the output component
  62340. */
  62341. get output(): NodeMaterialConnectionPoint;
  62342. protected _buildBlock(state: NodeMaterialBuildState): this;
  62343. }
  62344. }
  62345. declare module BABYLON {
  62346. /**
  62347. * block used to Generate a Worley Noise 3D Noise Pattern
  62348. */
  62349. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62350. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62351. manhattanDistance: boolean;
  62352. /**
  62353. * Creates a new WorleyNoise3DBlock
  62354. * @param name defines the block name
  62355. */
  62356. constructor(name: string);
  62357. /**
  62358. * Gets the current class name
  62359. * @returns the class name
  62360. */
  62361. getClassName(): string;
  62362. /**
  62363. * Gets the seed input component
  62364. */
  62365. get seed(): NodeMaterialConnectionPoint;
  62366. /**
  62367. * Gets the jitter input component
  62368. */
  62369. get jitter(): NodeMaterialConnectionPoint;
  62370. /**
  62371. * Gets the output component
  62372. */
  62373. get output(): NodeMaterialConnectionPoint;
  62374. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62375. /**
  62376. * Exposes the properties to the UI?
  62377. */
  62378. protected _dumpPropertiesCode(): string;
  62379. /**
  62380. * Exposes the properties to the Seralize?
  62381. */
  62382. serialize(): any;
  62383. /**
  62384. * Exposes the properties to the deseralize?
  62385. */
  62386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62387. }
  62388. }
  62389. declare module BABYLON {
  62390. /**
  62391. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62392. */
  62393. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62394. /**
  62395. * Creates a new SimplexPerlin3DBlock
  62396. * @param name defines the block name
  62397. */
  62398. constructor(name: string);
  62399. /**
  62400. * Gets the current class name
  62401. * @returns the class name
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the seed operand input component
  62406. */
  62407. get seed(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the output component
  62410. */
  62411. get output(): NodeMaterialConnectionPoint;
  62412. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62413. }
  62414. }
  62415. declare module BABYLON {
  62416. /**
  62417. * Block used to blend normals
  62418. */
  62419. export class NormalBlendBlock extends NodeMaterialBlock {
  62420. /**
  62421. * Creates a new NormalBlendBlock
  62422. * @param name defines the block name
  62423. */
  62424. constructor(name: string);
  62425. /**
  62426. * Gets the current class name
  62427. * @returns the class name
  62428. */
  62429. getClassName(): string;
  62430. /**
  62431. * Gets the first input component
  62432. */
  62433. get normalMap0(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the second input component
  62436. */
  62437. get normalMap1(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the output component
  62440. */
  62441. get output(): NodeMaterialConnectionPoint;
  62442. protected _buildBlock(state: NodeMaterialBuildState): this;
  62443. }
  62444. }
  62445. declare module BABYLON {
  62446. /**
  62447. * Block used to rotate a 2d vector by a given angle
  62448. */
  62449. export class Rotate2dBlock extends NodeMaterialBlock {
  62450. /**
  62451. * Creates a new Rotate2dBlock
  62452. * @param name defines the block name
  62453. */
  62454. constructor(name: string);
  62455. /**
  62456. * Gets the current class name
  62457. * @returns the class name
  62458. */
  62459. getClassName(): string;
  62460. /**
  62461. * Gets the input vector
  62462. */
  62463. get input(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the input angle
  62466. */
  62467. get angle(): NodeMaterialConnectionPoint;
  62468. /**
  62469. * Gets the output component
  62470. */
  62471. get output(): NodeMaterialConnectionPoint;
  62472. autoConfigure(material: NodeMaterial): void;
  62473. protected _buildBlock(state: NodeMaterialBuildState): this;
  62474. }
  62475. }
  62476. declare module BABYLON {
  62477. /**
  62478. * Block used to get the reflected vector from a direction and a normal
  62479. */
  62480. export class ReflectBlock extends NodeMaterialBlock {
  62481. /**
  62482. * Creates a new ReflectBlock
  62483. * @param name defines the block name
  62484. */
  62485. constructor(name: string);
  62486. /**
  62487. * Gets the current class name
  62488. * @returns the class name
  62489. */
  62490. getClassName(): string;
  62491. /**
  62492. * Gets the incident component
  62493. */
  62494. get incident(): NodeMaterialConnectionPoint;
  62495. /**
  62496. * Gets the normal component
  62497. */
  62498. get normal(): NodeMaterialConnectionPoint;
  62499. /**
  62500. * Gets the output component
  62501. */
  62502. get output(): NodeMaterialConnectionPoint;
  62503. protected _buildBlock(state: NodeMaterialBuildState): this;
  62504. }
  62505. }
  62506. declare module BABYLON {
  62507. /**
  62508. * Block used to get the refracted vector from a direction and a normal
  62509. */
  62510. export class RefractBlock extends NodeMaterialBlock {
  62511. /**
  62512. * Creates a new RefractBlock
  62513. * @param name defines the block name
  62514. */
  62515. constructor(name: string);
  62516. /**
  62517. * Gets the current class name
  62518. * @returns the class name
  62519. */
  62520. getClassName(): string;
  62521. /**
  62522. * Gets the incident component
  62523. */
  62524. get incident(): NodeMaterialConnectionPoint;
  62525. /**
  62526. * Gets the normal component
  62527. */
  62528. get normal(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the index of refraction component
  62531. */
  62532. get ior(): NodeMaterialConnectionPoint;
  62533. /**
  62534. * Gets the output component
  62535. */
  62536. get output(): NodeMaterialConnectionPoint;
  62537. protected _buildBlock(state: NodeMaterialBuildState): this;
  62538. }
  62539. }
  62540. declare module BABYLON {
  62541. /**
  62542. * Block used to desaturate a color
  62543. */
  62544. export class DesaturateBlock extends NodeMaterialBlock {
  62545. /**
  62546. * Creates a new DesaturateBlock
  62547. * @param name defines the block name
  62548. */
  62549. constructor(name: string);
  62550. /**
  62551. * Gets the current class name
  62552. * @returns the class name
  62553. */
  62554. getClassName(): string;
  62555. /**
  62556. * Gets the color operand input component
  62557. */
  62558. get color(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the level operand input component
  62561. */
  62562. get level(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the output component
  62565. */
  62566. get output(): NodeMaterialConnectionPoint;
  62567. protected _buildBlock(state: NodeMaterialBuildState): this;
  62568. }
  62569. }
  62570. declare module BABYLON {
  62571. /**
  62572. * Block used to implement the ambient occlusion module of the PBR material
  62573. */
  62574. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62575. /**
  62576. * Create a new AmbientOcclusionBlock
  62577. * @param name defines the block name
  62578. */
  62579. constructor(name: string);
  62580. /**
  62581. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62582. */
  62583. useAmbientInGrayScale: boolean;
  62584. /**
  62585. * Initialize the block and prepare the context for build
  62586. * @param state defines the state that will be used for the build
  62587. */
  62588. initialize(state: NodeMaterialBuildState): void;
  62589. /**
  62590. * Gets the current class name
  62591. * @returns the class name
  62592. */
  62593. getClassName(): string;
  62594. /**
  62595. * Gets the texture input component
  62596. */
  62597. get texture(): NodeMaterialConnectionPoint;
  62598. /**
  62599. * Gets the texture intensity component
  62600. */
  62601. get intensity(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the direct light intensity input component
  62604. */
  62605. get directLightIntensity(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the ambient occlusion object output component
  62608. */
  62609. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the main code of the block (fragment side)
  62612. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62613. * @returns the shader code
  62614. */
  62615. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62617. protected _buildBlock(state: NodeMaterialBuildState): this;
  62618. protected _dumpPropertiesCode(): string;
  62619. serialize(): any;
  62620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62621. }
  62622. }
  62623. declare module BABYLON {
  62624. /**
  62625. * Block used to implement the reflection module of the PBR material
  62626. */
  62627. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62628. /** @hidden */
  62629. _defineLODReflectionAlpha: string;
  62630. /** @hidden */
  62631. _defineLinearSpecularReflection: string;
  62632. private _vEnvironmentIrradianceName;
  62633. /** @hidden */
  62634. _vReflectionMicrosurfaceInfosName: string;
  62635. /** @hidden */
  62636. _vReflectionInfosName: string;
  62637. private _scene;
  62638. /**
  62639. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62640. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62641. * It's less burden on the user side in the editor part.
  62642. */
  62643. /** @hidden */
  62644. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62645. /** @hidden */
  62646. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62647. /** @hidden */
  62648. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62649. /**
  62650. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62651. * diffuse part of the IBL.
  62652. */
  62653. useSphericalHarmonics: boolean;
  62654. /**
  62655. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62656. */
  62657. forceIrradianceInFragment: boolean;
  62658. /**
  62659. * Create a new ReflectionBlock
  62660. * @param name defines the block name
  62661. */
  62662. constructor(name: string);
  62663. /**
  62664. * Gets the current class name
  62665. * @returns the class name
  62666. */
  62667. getClassName(): string;
  62668. /**
  62669. * Gets the position input component
  62670. */
  62671. get position(): NodeMaterialConnectionPoint;
  62672. /**
  62673. * Gets the world position input component
  62674. */
  62675. get worldPosition(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the world normal input component
  62678. */
  62679. get worldNormal(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the world input component
  62682. */
  62683. get world(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the camera (or eye) position component
  62686. */
  62687. get cameraPosition(): NodeMaterialConnectionPoint;
  62688. /**
  62689. * Gets the view input component
  62690. */
  62691. get view(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the color input component
  62694. */
  62695. get color(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the reflection object output component
  62698. */
  62699. get reflection(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62702. */
  62703. get hasTexture(): boolean;
  62704. /**
  62705. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62706. */
  62707. get reflectionColor(): string;
  62708. protected _getTexture(): Nullable<BaseTexture>;
  62709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62711. /**
  62712. * Gets the code to inject in the vertex shader
  62713. * @param state current state of the node material building
  62714. * @returns the shader code
  62715. */
  62716. handleVertexSide(state: NodeMaterialBuildState): string;
  62717. /**
  62718. * Gets the main code of the block (fragment side)
  62719. * @param state current state of the node material building
  62720. * @param normalVarName name of the existing variable corresponding to the normal
  62721. * @returns the shader code
  62722. */
  62723. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62724. protected _buildBlock(state: NodeMaterialBuildState): this;
  62725. protected _dumpPropertiesCode(): string;
  62726. serialize(): any;
  62727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62728. }
  62729. }
  62730. declare module BABYLON {
  62731. /**
  62732. * Block used to implement the sheen module of the PBR material
  62733. */
  62734. export class SheenBlock extends NodeMaterialBlock {
  62735. /**
  62736. * Create a new SheenBlock
  62737. * @param name defines the block name
  62738. */
  62739. constructor(name: string);
  62740. /**
  62741. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62742. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62743. * making it easier to setup and tweak the effect
  62744. */
  62745. albedoScaling: boolean;
  62746. /**
  62747. * Defines if the sheen is linked to the sheen color.
  62748. */
  62749. linkSheenWithAlbedo: boolean;
  62750. /**
  62751. * Initialize the block and prepare the context for build
  62752. * @param state defines the state that will be used for the build
  62753. */
  62754. initialize(state: NodeMaterialBuildState): void;
  62755. /**
  62756. * Gets the current class name
  62757. * @returns the class name
  62758. */
  62759. getClassName(): string;
  62760. /**
  62761. * Gets the intensity input component
  62762. */
  62763. get intensity(): NodeMaterialConnectionPoint;
  62764. /**
  62765. * Gets the color input component
  62766. */
  62767. get color(): NodeMaterialConnectionPoint;
  62768. /**
  62769. * Gets the roughness input component
  62770. */
  62771. get roughness(): NodeMaterialConnectionPoint;
  62772. /**
  62773. * Gets the texture input component
  62774. */
  62775. get texture(): NodeMaterialConnectionPoint;
  62776. /**
  62777. * Gets the sheen object output component
  62778. */
  62779. get sheen(): NodeMaterialConnectionPoint;
  62780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62781. /**
  62782. * Gets the main code of the block (fragment side)
  62783. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62784. * @returns the shader code
  62785. */
  62786. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. protected _dumpPropertiesCode(): string;
  62789. serialize(): any;
  62790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62791. }
  62792. }
  62793. declare module BABYLON {
  62794. /**
  62795. * Block used to implement the reflectivity module of the PBR material
  62796. */
  62797. export class ReflectivityBlock extends NodeMaterialBlock {
  62798. /**
  62799. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62800. */
  62801. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62802. /**
  62803. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62804. */
  62805. useMetallnessFromMetallicTextureBlue: boolean;
  62806. /**
  62807. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62808. */
  62809. useRoughnessFromMetallicTextureAlpha: boolean;
  62810. /**
  62811. * Specifies if the metallic texture contains the roughness information in its green channel.
  62812. */
  62813. useRoughnessFromMetallicTextureGreen: boolean;
  62814. /**
  62815. * Create a new ReflectivityBlock
  62816. * @param name defines the block name
  62817. */
  62818. constructor(name: string);
  62819. /**
  62820. * Initialize the block and prepare the context for build
  62821. * @param state defines the state that will be used for the build
  62822. */
  62823. initialize(state: NodeMaterialBuildState): void;
  62824. /**
  62825. * Gets the current class name
  62826. * @returns the class name
  62827. */
  62828. getClassName(): string;
  62829. /**
  62830. * Gets the metallic input component
  62831. */
  62832. get metallic(): NodeMaterialConnectionPoint;
  62833. /**
  62834. * Gets the roughness input component
  62835. */
  62836. get roughness(): NodeMaterialConnectionPoint;
  62837. /**
  62838. * Gets the texture input component
  62839. */
  62840. get texture(): NodeMaterialConnectionPoint;
  62841. /**
  62842. * Gets the reflectivity object output component
  62843. */
  62844. get reflectivity(): NodeMaterialConnectionPoint;
  62845. /**
  62846. * Gets the main code of the block (fragment side)
  62847. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62848. * @returns the shader code
  62849. */
  62850. getCode(aoIntensityVarName: string): string;
  62851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62852. protected _buildBlock(state: NodeMaterialBuildState): this;
  62853. protected _dumpPropertiesCode(): string;
  62854. serialize(): any;
  62855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62856. }
  62857. }
  62858. declare module BABYLON {
  62859. /**
  62860. * Block used to implement the anisotropy module of the PBR material
  62861. */
  62862. export class AnisotropyBlock extends NodeMaterialBlock {
  62863. /**
  62864. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62865. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62866. * It's less burden on the user side in the editor part.
  62867. */
  62868. /** @hidden */
  62869. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62870. /** @hidden */
  62871. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62872. /**
  62873. * Create a new AnisotropyBlock
  62874. * @param name defines the block name
  62875. */
  62876. constructor(name: string);
  62877. /**
  62878. * Initialize the block and prepare the context for build
  62879. * @param state defines the state that will be used for the build
  62880. */
  62881. initialize(state: NodeMaterialBuildState): void;
  62882. /**
  62883. * Gets the current class name
  62884. * @returns the class name
  62885. */
  62886. getClassName(): string;
  62887. /**
  62888. * Gets the intensity input component
  62889. */
  62890. get intensity(): NodeMaterialConnectionPoint;
  62891. /**
  62892. * Gets the direction input component
  62893. */
  62894. get direction(): NodeMaterialConnectionPoint;
  62895. /**
  62896. * Gets the texture input component
  62897. */
  62898. get texture(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the uv input component
  62901. */
  62902. get uv(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the worldTangent input component
  62905. */
  62906. get worldTangent(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the anisotropy object output component
  62909. */
  62910. get anisotropy(): NodeMaterialConnectionPoint;
  62911. private _generateTBNSpace;
  62912. /**
  62913. * Gets the main code of the block (fragment side)
  62914. * @param state current state of the node material building
  62915. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62916. * @returns the shader code
  62917. */
  62918. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62920. protected _buildBlock(state: NodeMaterialBuildState): this;
  62921. }
  62922. }
  62923. declare module BABYLON {
  62924. /**
  62925. * Block used to implement the clear coat module of the PBR material
  62926. */
  62927. export class ClearCoatBlock extends NodeMaterialBlock {
  62928. private _scene;
  62929. /**
  62930. * Create a new ClearCoatBlock
  62931. * @param name defines the block name
  62932. */
  62933. constructor(name: string);
  62934. /**
  62935. * Initialize the block and prepare the context for build
  62936. * @param state defines the state that will be used for the build
  62937. */
  62938. initialize(state: NodeMaterialBuildState): void;
  62939. /**
  62940. * Gets the current class name
  62941. * @returns the class name
  62942. */
  62943. getClassName(): string;
  62944. /**
  62945. * Gets the intensity input component
  62946. */
  62947. get intensity(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the roughness input component
  62950. */
  62951. get roughness(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the ior input component
  62954. */
  62955. get ior(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the texture input component
  62958. */
  62959. get texture(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the bump texture input component
  62962. */
  62963. get bumpTexture(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the uv input component
  62966. */
  62967. get uv(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the tint color input component
  62970. */
  62971. get tintColor(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the tint "at distance" input component
  62974. */
  62975. get tintAtDistance(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the tint thickness input component
  62978. */
  62979. get tintThickness(): NodeMaterialConnectionPoint;
  62980. /**
  62981. * Gets the tint texture input component
  62982. */
  62983. get tintTexture(): NodeMaterialConnectionPoint;
  62984. /**
  62985. * Gets the world tangent input component
  62986. */
  62987. get worldTangent(): NodeMaterialConnectionPoint;
  62988. /**
  62989. * Gets the clear coat object output component
  62990. */
  62991. get clearcoat(): NodeMaterialConnectionPoint;
  62992. autoConfigure(material: NodeMaterial): void;
  62993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62995. private _generateTBNSpace;
  62996. /**
  62997. * Gets the main code of the block (fragment side)
  62998. * @param state current state of the node material building
  62999. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63000. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63001. * @param worldPosVarName name of the variable holding the world position
  63002. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63003. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63004. * @param worldNormalVarName name of the variable holding the world normal
  63005. * @returns the shader code
  63006. */
  63007. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63008. protected _buildBlock(state: NodeMaterialBuildState): this;
  63009. }
  63010. }
  63011. declare module BABYLON {
  63012. /**
  63013. * Block used to implement the sub surface module of the PBR material
  63014. */
  63015. export class SubSurfaceBlock extends NodeMaterialBlock {
  63016. /**
  63017. * Create a new SubSurfaceBlock
  63018. * @param name defines the block name
  63019. */
  63020. constructor(name: string);
  63021. /**
  63022. * Stores the intensity of the different subsurface effects in the thickness texture.
  63023. * * the green channel is the translucency intensity.
  63024. * * the blue channel is the scattering intensity.
  63025. * * the alpha channel is the refraction intensity.
  63026. */
  63027. useMaskFromThicknessTexture: boolean;
  63028. /**
  63029. * Initialize the block and prepare the context for build
  63030. * @param state defines the state that will be used for the build
  63031. */
  63032. initialize(state: NodeMaterialBuildState): void;
  63033. /**
  63034. * Gets the current class name
  63035. * @returns the class name
  63036. */
  63037. getClassName(): string;
  63038. /**
  63039. * Gets the min thickness input component
  63040. */
  63041. get minThickness(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the max thickness input component
  63044. */
  63045. get maxThickness(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the thickness texture component
  63048. */
  63049. get thicknessTexture(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the tint color input component
  63052. */
  63053. get tintColor(): NodeMaterialConnectionPoint;
  63054. /**
  63055. * Gets the translucency intensity input component
  63056. */
  63057. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63058. /**
  63059. * Gets the translucency diffusion distance input component
  63060. */
  63061. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the refraction object parameters
  63064. */
  63065. get refraction(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the sub surface object output component
  63068. */
  63069. get subsurface(): NodeMaterialConnectionPoint;
  63070. autoConfigure(material: NodeMaterial): void;
  63071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63072. /**
  63073. * Gets the main code of the block (fragment side)
  63074. * @param state current state of the node material building
  63075. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63076. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63077. * @param worldPosVarName name of the variable holding the world position
  63078. * @returns the shader code
  63079. */
  63080. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63081. protected _buildBlock(state: NodeMaterialBuildState): this;
  63082. }
  63083. }
  63084. declare module BABYLON {
  63085. /**
  63086. * Block used to implement the PBR metallic/roughness model
  63087. */
  63088. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63089. /**
  63090. * Gets or sets the light associated with this block
  63091. */
  63092. light: Nullable<Light>;
  63093. private _lightId;
  63094. private _scene;
  63095. private _environmentBRDFTexture;
  63096. private _environmentBrdfSamplerName;
  63097. private _vNormalWName;
  63098. private _invertNormalName;
  63099. /**
  63100. * Create a new ReflectionBlock
  63101. * @param name defines the block name
  63102. */
  63103. constructor(name: string);
  63104. /**
  63105. * Intensity of the direct lights e.g. the four lights available in your scene.
  63106. * This impacts both the direct diffuse and specular highlights.
  63107. */
  63108. directIntensity: number;
  63109. /**
  63110. * Intensity of the environment e.g. how much the environment will light the object
  63111. * either through harmonics for rough material or through the refelction for shiny ones.
  63112. */
  63113. environmentIntensity: number;
  63114. /**
  63115. * This is a special control allowing the reduction of the specular highlights coming from the
  63116. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63117. */
  63118. specularIntensity: number;
  63119. /**
  63120. * Defines the falloff type used in this material.
  63121. * It by default is Physical.
  63122. */
  63123. lightFalloff: number;
  63124. /**
  63125. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63126. */
  63127. useAlphaFromAlbedoTexture: boolean;
  63128. /**
  63129. * Specifies that alpha test should be used
  63130. */
  63131. useAlphaTest: boolean;
  63132. /**
  63133. * Defines the alpha limits in alpha test mode.
  63134. */
  63135. alphaTestCutoff: number;
  63136. /**
  63137. * Specifies that alpha blending should be used
  63138. */
  63139. useAlphaBlending: boolean;
  63140. /**
  63141. * Defines if the alpha value should be determined via the rgb values.
  63142. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63143. */
  63144. opacityRGB: boolean;
  63145. /**
  63146. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63147. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63148. */
  63149. useRadianceOverAlpha: boolean;
  63150. /**
  63151. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63152. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63153. */
  63154. useSpecularOverAlpha: boolean;
  63155. /**
  63156. * Enables specular anti aliasing in the PBR shader.
  63157. * It will both interacts on the Geometry for analytical and IBL lighting.
  63158. * It also prefilter the roughness map based on the bump values.
  63159. */
  63160. enableSpecularAntiAliasing: boolean;
  63161. /**
  63162. * Defines if the material uses energy conservation.
  63163. */
  63164. useEnergyConservation: boolean;
  63165. /**
  63166. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63167. * too much the area relying on ambient texture to define their ambient occlusion.
  63168. */
  63169. useRadianceOcclusion: boolean;
  63170. /**
  63171. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63172. * makes the reflect vector face the model (under horizon).
  63173. */
  63174. useHorizonOcclusion: boolean;
  63175. /**
  63176. * If set to true, no lighting calculations will be applied.
  63177. */
  63178. unlit: boolean;
  63179. /**
  63180. * Force normal to face away from face.
  63181. */
  63182. forceNormalForward: boolean;
  63183. /**
  63184. * Defines the material debug mode.
  63185. * It helps seeing only some components of the material while troubleshooting.
  63186. */
  63187. debugMode: number;
  63188. /**
  63189. * Specify from where on screen the debug mode should start.
  63190. * The value goes from -1 (full screen) to 1 (not visible)
  63191. * It helps with side by side comparison against the final render
  63192. * This defaults to 0
  63193. */
  63194. debugLimit: number;
  63195. /**
  63196. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63197. * You can use the factor to better multiply the final value.
  63198. */
  63199. debugFactor: number;
  63200. /**
  63201. * Initialize the block and prepare the context for build
  63202. * @param state defines the state that will be used for the build
  63203. */
  63204. initialize(state: NodeMaterialBuildState): void;
  63205. /**
  63206. * Gets the current class name
  63207. * @returns the class name
  63208. */
  63209. getClassName(): string;
  63210. /**
  63211. * Gets the world position input component
  63212. */
  63213. get worldPosition(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the world normal input component
  63216. */
  63217. get worldNormal(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the perturbed normal input component
  63220. */
  63221. get perturbedNormal(): NodeMaterialConnectionPoint;
  63222. /**
  63223. * Gets the camera position input component
  63224. */
  63225. get cameraPosition(): NodeMaterialConnectionPoint;
  63226. /**
  63227. * Gets the base color input component
  63228. */
  63229. get baseColor(): NodeMaterialConnectionPoint;
  63230. /**
  63231. * Gets the base texture input component
  63232. */
  63233. get baseTexture(): NodeMaterialConnectionPoint;
  63234. /**
  63235. * Gets the opacity texture input component
  63236. */
  63237. get opacityTexture(): NodeMaterialConnectionPoint;
  63238. /**
  63239. * Gets the ambient color input component
  63240. */
  63241. get ambientColor(): NodeMaterialConnectionPoint;
  63242. /**
  63243. * Gets the reflectivity object parameters
  63244. */
  63245. get reflectivity(): NodeMaterialConnectionPoint;
  63246. /**
  63247. * Gets the ambient occlusion object parameters
  63248. */
  63249. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63250. /**
  63251. * Gets the reflection object parameters
  63252. */
  63253. get reflection(): NodeMaterialConnectionPoint;
  63254. /**
  63255. * Gets the sheen object parameters
  63256. */
  63257. get sheen(): NodeMaterialConnectionPoint;
  63258. /**
  63259. * Gets the clear coat object parameters
  63260. */
  63261. get clearcoat(): NodeMaterialConnectionPoint;
  63262. /**
  63263. * Gets the sub surface object parameters
  63264. */
  63265. get subsurface(): NodeMaterialConnectionPoint;
  63266. /**
  63267. * Gets the anisotropy object parameters
  63268. */
  63269. get anisotropy(): NodeMaterialConnectionPoint;
  63270. /**
  63271. * Gets the ambient output component
  63272. */
  63273. get ambient(): NodeMaterialConnectionPoint;
  63274. /**
  63275. * Gets the diffuse output component
  63276. */
  63277. get diffuse(): NodeMaterialConnectionPoint;
  63278. /**
  63279. * Gets the specular output component
  63280. */
  63281. get specular(): NodeMaterialConnectionPoint;
  63282. /**
  63283. * Gets the sheen output component
  63284. */
  63285. get sheenDir(): NodeMaterialConnectionPoint;
  63286. /**
  63287. * Gets the clear coat output component
  63288. */
  63289. get clearcoatDir(): NodeMaterialConnectionPoint;
  63290. /**
  63291. * Gets the indirect diffuse output component
  63292. */
  63293. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63294. /**
  63295. * Gets the indirect specular output component
  63296. */
  63297. get specularIndirect(): NodeMaterialConnectionPoint;
  63298. /**
  63299. * Gets the indirect sheen output component
  63300. */
  63301. get sheenIndirect(): NodeMaterialConnectionPoint;
  63302. /**
  63303. * Gets the indirect clear coat output component
  63304. */
  63305. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63306. /**
  63307. * Gets the refraction output component
  63308. */
  63309. get refraction(): NodeMaterialConnectionPoint;
  63310. /**
  63311. * Gets the global lighting output component
  63312. */
  63313. get lighting(): NodeMaterialConnectionPoint;
  63314. /**
  63315. * Gets the shadow output component
  63316. */
  63317. get shadow(): NodeMaterialConnectionPoint;
  63318. /**
  63319. * Gets the alpha output component
  63320. */
  63321. get alpha(): NodeMaterialConnectionPoint;
  63322. autoConfigure(material: NodeMaterial): void;
  63323. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63324. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63326. private _injectVertexCode;
  63327. /**
  63328. * Gets the code corresponding to the albedo/opacity module
  63329. * @returns the shader code
  63330. */
  63331. getAlbedoOpacityCode(): string;
  63332. protected _buildBlock(state: NodeMaterialBuildState): this;
  63333. protected _dumpPropertiesCode(): string;
  63334. serialize(): any;
  63335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63336. }
  63337. }
  63338. declare module BABYLON {
  63339. /**
  63340. * Block used to compute value of one parameter modulo another
  63341. */
  63342. export class ModBlock extends NodeMaterialBlock {
  63343. /**
  63344. * Creates a new ModBlock
  63345. * @param name defines the block name
  63346. */
  63347. constructor(name: string);
  63348. /**
  63349. * Gets the current class name
  63350. * @returns the class name
  63351. */
  63352. getClassName(): string;
  63353. /**
  63354. * Gets the left operand input component
  63355. */
  63356. get left(): NodeMaterialConnectionPoint;
  63357. /**
  63358. * Gets the right operand input component
  63359. */
  63360. get right(): NodeMaterialConnectionPoint;
  63361. /**
  63362. * Gets the output component
  63363. */
  63364. get output(): NodeMaterialConnectionPoint;
  63365. protected _buildBlock(state: NodeMaterialBuildState): this;
  63366. }
  63367. }
  63368. declare module BABYLON {
  63369. /**
  63370. * Helper class to push actions to a pool of workers.
  63371. */
  63372. export class WorkerPool implements IDisposable {
  63373. private _workerInfos;
  63374. private _pendingActions;
  63375. /**
  63376. * Constructor
  63377. * @param workers Array of workers to use for actions
  63378. */
  63379. constructor(workers: Array<Worker>);
  63380. /**
  63381. * Terminates all workers and clears any pending actions.
  63382. */
  63383. dispose(): void;
  63384. /**
  63385. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63386. * pended until a worker has completed its action.
  63387. * @param action The action to perform. Call onComplete when the action is complete.
  63388. */
  63389. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63390. private _execute;
  63391. }
  63392. }
  63393. declare module BABYLON {
  63394. /**
  63395. * Configuration for Draco compression
  63396. */
  63397. export interface IDracoCompressionConfiguration {
  63398. /**
  63399. * Configuration for the decoder.
  63400. */
  63401. decoder: {
  63402. /**
  63403. * The url to the WebAssembly module.
  63404. */
  63405. wasmUrl?: string;
  63406. /**
  63407. * The url to the WebAssembly binary.
  63408. */
  63409. wasmBinaryUrl?: string;
  63410. /**
  63411. * The url to the fallback JavaScript module.
  63412. */
  63413. fallbackUrl?: string;
  63414. };
  63415. }
  63416. /**
  63417. * Draco compression (https://google.github.io/draco/)
  63418. *
  63419. * This class wraps the Draco module.
  63420. *
  63421. * **Encoder**
  63422. *
  63423. * The encoder is not currently implemented.
  63424. *
  63425. * **Decoder**
  63426. *
  63427. * 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.
  63428. *
  63429. * To update the configuration, use the following code:
  63430. * ```javascript
  63431. * DracoCompression.Configuration = {
  63432. * decoder: {
  63433. * wasmUrl: "<url to the WebAssembly library>",
  63434. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63435. * fallbackUrl: "<url to the fallback JavaScript library>",
  63436. * }
  63437. * };
  63438. * ```
  63439. *
  63440. * 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.
  63441. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63442. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63443. *
  63444. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63445. * ```javascript
  63446. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63447. * ```
  63448. *
  63449. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63450. */
  63451. export class DracoCompression implements IDisposable {
  63452. private _workerPoolPromise?;
  63453. private _decoderModulePromise?;
  63454. /**
  63455. * The configuration. Defaults to the following urls:
  63456. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63457. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63458. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63459. */
  63460. static Configuration: IDracoCompressionConfiguration;
  63461. /**
  63462. * Returns true if the decoder configuration is available.
  63463. */
  63464. static get DecoderAvailable(): boolean;
  63465. /**
  63466. * Default number of workers to create when creating the draco compression object.
  63467. */
  63468. static DefaultNumWorkers: number;
  63469. private static GetDefaultNumWorkers;
  63470. private static _Default;
  63471. /**
  63472. * Default instance for the draco compression object.
  63473. */
  63474. static get Default(): DracoCompression;
  63475. /**
  63476. * Constructor
  63477. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63478. */
  63479. constructor(numWorkers?: number);
  63480. /**
  63481. * Stop all async operations and release resources.
  63482. */
  63483. dispose(): void;
  63484. /**
  63485. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63486. * @returns a promise that resolves when ready
  63487. */
  63488. whenReadyAsync(): Promise<void>;
  63489. /**
  63490. * Decode Draco compressed mesh data to vertex data.
  63491. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63492. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63493. * @returns A promise that resolves with the decoded vertex data
  63494. */
  63495. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63496. [kind: string]: number;
  63497. }): Promise<VertexData>;
  63498. }
  63499. }
  63500. declare module BABYLON {
  63501. /**
  63502. * Class for building Constructive Solid Geometry
  63503. */
  63504. export class CSG {
  63505. private polygons;
  63506. /**
  63507. * The world matrix
  63508. */
  63509. matrix: Matrix;
  63510. /**
  63511. * Stores the position
  63512. */
  63513. position: Vector3;
  63514. /**
  63515. * Stores the rotation
  63516. */
  63517. rotation: Vector3;
  63518. /**
  63519. * Stores the rotation quaternion
  63520. */
  63521. rotationQuaternion: Nullable<Quaternion>;
  63522. /**
  63523. * Stores the scaling vector
  63524. */
  63525. scaling: Vector3;
  63526. /**
  63527. * Convert the Mesh to CSG
  63528. * @param mesh The Mesh to convert to CSG
  63529. * @returns A new CSG from the Mesh
  63530. */
  63531. static FromMesh(mesh: Mesh): CSG;
  63532. /**
  63533. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63534. * @param polygons Polygons used to construct a CSG solid
  63535. */
  63536. private static FromPolygons;
  63537. /**
  63538. * Clones, or makes a deep copy, of the CSG
  63539. * @returns A new CSG
  63540. */
  63541. clone(): CSG;
  63542. /**
  63543. * Unions this CSG with another CSG
  63544. * @param csg The CSG to union against this CSG
  63545. * @returns The unioned CSG
  63546. */
  63547. union(csg: CSG): CSG;
  63548. /**
  63549. * Unions this CSG with another CSG in place
  63550. * @param csg The CSG to union against this CSG
  63551. */
  63552. unionInPlace(csg: CSG): void;
  63553. /**
  63554. * Subtracts this CSG with another CSG
  63555. * @param csg The CSG to subtract against this CSG
  63556. * @returns A new CSG
  63557. */
  63558. subtract(csg: CSG): CSG;
  63559. /**
  63560. * Subtracts this CSG with another CSG in place
  63561. * @param csg The CSG to subtact against this CSG
  63562. */
  63563. subtractInPlace(csg: CSG): void;
  63564. /**
  63565. * Intersect this CSG with another CSG
  63566. * @param csg The CSG to intersect against this CSG
  63567. * @returns A new CSG
  63568. */
  63569. intersect(csg: CSG): CSG;
  63570. /**
  63571. * Intersects this CSG with another CSG in place
  63572. * @param csg The CSG to intersect against this CSG
  63573. */
  63574. intersectInPlace(csg: CSG): void;
  63575. /**
  63576. * Return a new CSG solid with solid and empty space switched. This solid is
  63577. * not modified.
  63578. * @returns A new CSG solid with solid and empty space switched
  63579. */
  63580. inverse(): CSG;
  63581. /**
  63582. * Inverses the CSG in place
  63583. */
  63584. inverseInPlace(): void;
  63585. /**
  63586. * This is used to keep meshes transformations so they can be restored
  63587. * when we build back a Babylon Mesh
  63588. * NB : All CSG operations are performed in world coordinates
  63589. * @param csg The CSG to copy the transform attributes from
  63590. * @returns This CSG
  63591. */
  63592. copyTransformAttributes(csg: CSG): CSG;
  63593. /**
  63594. * Build Raw mesh from CSG
  63595. * Coordinates here are in world space
  63596. * @param name The name of the mesh geometry
  63597. * @param scene The Scene
  63598. * @param keepSubMeshes Specifies if the submeshes should be kept
  63599. * @returns A new Mesh
  63600. */
  63601. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63602. /**
  63603. * Build Mesh from CSG taking material and transforms into account
  63604. * @param name The name of the Mesh
  63605. * @param material The material of the Mesh
  63606. * @param scene The Scene
  63607. * @param keepSubMeshes Specifies if submeshes should be kept
  63608. * @returns The new Mesh
  63609. */
  63610. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63611. }
  63612. }
  63613. declare module BABYLON {
  63614. /**
  63615. * Class used to create a trail following a mesh
  63616. */
  63617. export class TrailMesh extends Mesh {
  63618. private _generator;
  63619. private _autoStart;
  63620. private _running;
  63621. private _diameter;
  63622. private _length;
  63623. private _sectionPolygonPointsCount;
  63624. private _sectionVectors;
  63625. private _sectionNormalVectors;
  63626. private _beforeRenderObserver;
  63627. /**
  63628. * @constructor
  63629. * @param name The value used by scene.getMeshByName() to do a lookup.
  63630. * @param generator The mesh or transform node to generate a trail.
  63631. * @param scene The scene to add this mesh to.
  63632. * @param diameter Diameter of trailing mesh. Default is 1.
  63633. * @param length Length of trailing mesh. Default is 60.
  63634. * @param autoStart Automatically start trailing mesh. Default true.
  63635. */
  63636. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63637. /**
  63638. * "TrailMesh"
  63639. * @returns "TrailMesh"
  63640. */
  63641. getClassName(): string;
  63642. private _createMesh;
  63643. /**
  63644. * Start trailing mesh.
  63645. */
  63646. start(): void;
  63647. /**
  63648. * Stop trailing mesh.
  63649. */
  63650. stop(): void;
  63651. /**
  63652. * Update trailing mesh geometry.
  63653. */
  63654. update(): void;
  63655. /**
  63656. * Returns a new TrailMesh object.
  63657. * @param name is a string, the name given to the new mesh
  63658. * @param newGenerator use new generator object for cloned trail mesh
  63659. * @returns a new mesh
  63660. */
  63661. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63662. /**
  63663. * Serializes this trail mesh
  63664. * @param serializationObject object to write serialization to
  63665. */
  63666. serialize(serializationObject: any): void;
  63667. /**
  63668. * Parses a serialized trail mesh
  63669. * @param parsedMesh the serialized mesh
  63670. * @param scene the scene to create the trail mesh in
  63671. * @returns the created trail mesh
  63672. */
  63673. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63674. }
  63675. }
  63676. declare module BABYLON {
  63677. /**
  63678. * Class containing static functions to help procedurally build meshes
  63679. */
  63680. export class TiledBoxBuilder {
  63681. /**
  63682. * Creates a box mesh
  63683. * 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)
  63684. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63686. * * 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
  63687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63688. * @param name defines the name of the mesh
  63689. * @param options defines the options used to create the mesh
  63690. * @param scene defines the hosting scene
  63691. * @returns the box mesh
  63692. */
  63693. static CreateTiledBox(name: string, options: {
  63694. pattern?: number;
  63695. width?: number;
  63696. height?: number;
  63697. depth?: number;
  63698. tileSize?: number;
  63699. tileWidth?: number;
  63700. tileHeight?: number;
  63701. alignHorizontal?: number;
  63702. alignVertical?: number;
  63703. faceUV?: Vector4[];
  63704. faceColors?: Color4[];
  63705. sideOrientation?: number;
  63706. updatable?: boolean;
  63707. }, scene?: Nullable<Scene>): Mesh;
  63708. }
  63709. }
  63710. declare module BABYLON {
  63711. /**
  63712. * Class containing static functions to help procedurally build meshes
  63713. */
  63714. export class TorusKnotBuilder {
  63715. /**
  63716. * Creates a torus knot mesh
  63717. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63718. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63719. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63720. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63722. * * 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
  63723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63724. * @param name defines the name of the mesh
  63725. * @param options defines the options used to create the mesh
  63726. * @param scene defines the hosting scene
  63727. * @returns the torus knot mesh
  63728. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63729. */
  63730. static CreateTorusKnot(name: string, options: {
  63731. radius?: number;
  63732. tube?: number;
  63733. radialSegments?: number;
  63734. tubularSegments?: number;
  63735. p?: number;
  63736. q?: number;
  63737. updatable?: boolean;
  63738. sideOrientation?: number;
  63739. frontUVs?: Vector4;
  63740. backUVs?: Vector4;
  63741. }, scene: any): Mesh;
  63742. }
  63743. }
  63744. declare module BABYLON {
  63745. /**
  63746. * Polygon
  63747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63748. */
  63749. export class Polygon {
  63750. /**
  63751. * Creates a rectangle
  63752. * @param xmin bottom X coord
  63753. * @param ymin bottom Y coord
  63754. * @param xmax top X coord
  63755. * @param ymax top Y coord
  63756. * @returns points that make the resulting rectation
  63757. */
  63758. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63759. /**
  63760. * Creates a circle
  63761. * @param radius radius of circle
  63762. * @param cx scale in x
  63763. * @param cy scale in y
  63764. * @param numberOfSides number of sides that make up the circle
  63765. * @returns points that make the resulting circle
  63766. */
  63767. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63768. /**
  63769. * Creates a polygon from input string
  63770. * @param input Input polygon data
  63771. * @returns the parsed points
  63772. */
  63773. static Parse(input: string): Vector2[];
  63774. /**
  63775. * Starts building a polygon from x and y coordinates
  63776. * @param x x coordinate
  63777. * @param y y coordinate
  63778. * @returns the started path2
  63779. */
  63780. static StartingAt(x: number, y: number): Path2;
  63781. }
  63782. /**
  63783. * Builds a polygon
  63784. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63785. */
  63786. export class PolygonMeshBuilder {
  63787. private _points;
  63788. private _outlinepoints;
  63789. private _holes;
  63790. private _name;
  63791. private _scene;
  63792. private _epoints;
  63793. private _eholes;
  63794. private _addToepoint;
  63795. /**
  63796. * Babylon reference to the earcut plugin.
  63797. */
  63798. bjsEarcut: any;
  63799. /**
  63800. * Creates a PolygonMeshBuilder
  63801. * @param name name of the builder
  63802. * @param contours Path of the polygon
  63803. * @param scene scene to add to when creating the mesh
  63804. * @param earcutInjection can be used to inject your own earcut reference
  63805. */
  63806. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63807. /**
  63808. * Adds a whole within the polygon
  63809. * @param hole Array of points defining the hole
  63810. * @returns this
  63811. */
  63812. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63813. /**
  63814. * Creates the polygon
  63815. * @param updatable If the mesh should be updatable
  63816. * @param depth The depth of the mesh created
  63817. * @returns the created mesh
  63818. */
  63819. build(updatable?: boolean, depth?: number): Mesh;
  63820. /**
  63821. * Creates the polygon
  63822. * @param depth The depth of the mesh created
  63823. * @returns the created VertexData
  63824. */
  63825. buildVertexData(depth?: number): VertexData;
  63826. /**
  63827. * Adds a side to the polygon
  63828. * @param positions points that make the polygon
  63829. * @param normals normals of the polygon
  63830. * @param uvs uvs of the polygon
  63831. * @param indices indices of the polygon
  63832. * @param bounds bounds of the polygon
  63833. * @param points points of the polygon
  63834. * @param depth depth of the polygon
  63835. * @param flip flip of the polygon
  63836. */
  63837. private addSide;
  63838. }
  63839. }
  63840. declare module BABYLON {
  63841. /**
  63842. * Class containing static functions to help procedurally build meshes
  63843. */
  63844. export class PolygonBuilder {
  63845. /**
  63846. * Creates a polygon mesh
  63847. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63848. * * 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
  63849. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63851. * * 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)
  63852. * * Remember you can only change the shape positions, not their number when updating a polygon
  63853. * @param name defines the name of the mesh
  63854. * @param options defines the options used to create the mesh
  63855. * @param scene defines the hosting scene
  63856. * @param earcutInjection can be used to inject your own earcut reference
  63857. * @returns the polygon mesh
  63858. */
  63859. static CreatePolygon(name: string, options: {
  63860. shape: Vector3[];
  63861. holes?: Vector3[][];
  63862. depth?: number;
  63863. faceUV?: Vector4[];
  63864. faceColors?: Color4[];
  63865. updatable?: boolean;
  63866. sideOrientation?: number;
  63867. frontUVs?: Vector4;
  63868. backUVs?: Vector4;
  63869. wrap?: boolean;
  63870. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63871. /**
  63872. * Creates an extruded polygon mesh, with depth in the Y direction.
  63873. * * 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)
  63874. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63875. * @param name defines the name of the mesh
  63876. * @param options defines the options used to create the mesh
  63877. * @param scene defines the hosting scene
  63878. * @param earcutInjection can be used to inject your own earcut reference
  63879. * @returns the polygon mesh
  63880. */
  63881. static ExtrudePolygon(name: string, options: {
  63882. shape: Vector3[];
  63883. holes?: Vector3[][];
  63884. depth?: number;
  63885. faceUV?: Vector4[];
  63886. faceColors?: Color4[];
  63887. updatable?: boolean;
  63888. sideOrientation?: number;
  63889. frontUVs?: Vector4;
  63890. backUVs?: Vector4;
  63891. wrap?: boolean;
  63892. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63893. }
  63894. }
  63895. declare module BABYLON {
  63896. /**
  63897. * Class containing static functions to help procedurally build meshes
  63898. */
  63899. export class LatheBuilder {
  63900. /**
  63901. * Creates lathe mesh.
  63902. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63903. * * 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
  63904. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63905. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63906. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63907. * * 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
  63908. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63909. * * 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
  63910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63911. * * 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
  63912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63914. * @param name defines the name of the mesh
  63915. * @param options defines the options used to create the mesh
  63916. * @param scene defines the hosting scene
  63917. * @returns the lathe mesh
  63918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63919. */
  63920. static CreateLathe(name: string, options: {
  63921. shape: Vector3[];
  63922. radius?: number;
  63923. tessellation?: number;
  63924. clip?: number;
  63925. arc?: number;
  63926. closed?: boolean;
  63927. updatable?: boolean;
  63928. sideOrientation?: number;
  63929. frontUVs?: Vector4;
  63930. backUVs?: Vector4;
  63931. cap?: number;
  63932. invertUV?: boolean;
  63933. }, scene?: Nullable<Scene>): Mesh;
  63934. }
  63935. }
  63936. declare module BABYLON {
  63937. /**
  63938. * Class containing static functions to help procedurally build meshes
  63939. */
  63940. export class TiledPlaneBuilder {
  63941. /**
  63942. * Creates a tiled plane mesh
  63943. * * The parameter `pattern` will, depending on value, do nothing or
  63944. * * * flip (reflect about central vertical) alternate tiles across and up
  63945. * * * flip every tile on alternate rows
  63946. * * * rotate (180 degs) alternate tiles across and up
  63947. * * * rotate every tile on alternate rows
  63948. * * * flip and rotate alternate tiles across and up
  63949. * * * flip and rotate every tile on alternate rows
  63950. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63951. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63952. * * 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
  63953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63954. * * 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)
  63955. * * 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)
  63956. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63957. * @param name defines the name of the mesh
  63958. * @param options defines the options used to create the mesh
  63959. * @param scene defines the hosting scene
  63960. * @returns the box mesh
  63961. */
  63962. static CreateTiledPlane(name: string, options: {
  63963. pattern?: number;
  63964. tileSize?: number;
  63965. tileWidth?: number;
  63966. tileHeight?: number;
  63967. size?: number;
  63968. width?: number;
  63969. height?: number;
  63970. alignHorizontal?: number;
  63971. alignVertical?: number;
  63972. sideOrientation?: number;
  63973. frontUVs?: Vector4;
  63974. backUVs?: Vector4;
  63975. updatable?: boolean;
  63976. }, scene?: Nullable<Scene>): Mesh;
  63977. }
  63978. }
  63979. declare module BABYLON {
  63980. /**
  63981. * Class containing static functions to help procedurally build meshes
  63982. */
  63983. export class TubeBuilder {
  63984. /**
  63985. * Creates a tube mesh.
  63986. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63987. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63988. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63989. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63990. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63991. * * 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)
  63992. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63993. * * 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
  63994. * * 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
  63995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63996. * * 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
  63997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63999. * @param name defines the name of the mesh
  64000. * @param options defines the options used to create the mesh
  64001. * @param scene defines the hosting scene
  64002. * @returns the tube mesh
  64003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64004. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64005. */
  64006. static CreateTube(name: string, options: {
  64007. path: Vector3[];
  64008. radius?: number;
  64009. tessellation?: number;
  64010. radiusFunction?: {
  64011. (i: number, distance: number): number;
  64012. };
  64013. cap?: number;
  64014. arc?: number;
  64015. updatable?: boolean;
  64016. sideOrientation?: number;
  64017. frontUVs?: Vector4;
  64018. backUVs?: Vector4;
  64019. instance?: Mesh;
  64020. invertUV?: boolean;
  64021. }, scene?: Nullable<Scene>): Mesh;
  64022. }
  64023. }
  64024. declare module BABYLON {
  64025. /**
  64026. * Class containing static functions to help procedurally build meshes
  64027. */
  64028. export class IcoSphereBuilder {
  64029. /**
  64030. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64031. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64032. * * 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`)
  64033. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64034. * * 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
  64035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64036. * * 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
  64037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64038. * @param name defines the name of the mesh
  64039. * @param options defines the options used to create the mesh
  64040. * @param scene defines the hosting scene
  64041. * @returns the icosahedron mesh
  64042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64043. */
  64044. static CreateIcoSphere(name: string, options: {
  64045. radius?: number;
  64046. radiusX?: number;
  64047. radiusY?: number;
  64048. radiusZ?: number;
  64049. flat?: boolean;
  64050. subdivisions?: number;
  64051. sideOrientation?: number;
  64052. frontUVs?: Vector4;
  64053. backUVs?: Vector4;
  64054. updatable?: boolean;
  64055. }, scene?: Nullable<Scene>): Mesh;
  64056. }
  64057. }
  64058. declare module BABYLON {
  64059. /**
  64060. * Class containing static functions to help procedurally build meshes
  64061. */
  64062. export class DecalBuilder {
  64063. /**
  64064. * Creates a decal mesh.
  64065. * 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
  64066. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64067. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64068. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64069. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64070. * @param name defines the name of the mesh
  64071. * @param sourceMesh defines the mesh where the decal must be applied
  64072. * @param options defines the options used to create the mesh
  64073. * @param scene defines the hosting scene
  64074. * @returns the decal mesh
  64075. * @see https://doc.babylonjs.com/how_to/decals
  64076. */
  64077. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64078. position?: Vector3;
  64079. normal?: Vector3;
  64080. size?: Vector3;
  64081. angle?: number;
  64082. }): Mesh;
  64083. }
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * Class containing static functions to help procedurally build meshes
  64088. */
  64089. export class MeshBuilder {
  64090. /**
  64091. * Creates a box mesh
  64092. * * The parameter `size` sets the size (float) of each box side (default 1)
  64093. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64094. * * 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)
  64095. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64097. * * 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
  64098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64099. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64100. * @param name defines the name of the mesh
  64101. * @param options defines the options used to create the mesh
  64102. * @param scene defines the hosting scene
  64103. * @returns the box mesh
  64104. */
  64105. static CreateBox(name: string, options: {
  64106. size?: number;
  64107. width?: number;
  64108. height?: number;
  64109. depth?: number;
  64110. faceUV?: Vector4[];
  64111. faceColors?: Color4[];
  64112. sideOrientation?: number;
  64113. frontUVs?: Vector4;
  64114. backUVs?: Vector4;
  64115. wrap?: boolean;
  64116. topBaseAt?: number;
  64117. bottomBaseAt?: number;
  64118. updatable?: boolean;
  64119. }, scene?: Nullable<Scene>): Mesh;
  64120. /**
  64121. * Creates a tiled box mesh
  64122. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64124. * @param name defines the name of the mesh
  64125. * @param options defines the options used to create the mesh
  64126. * @param scene defines the hosting scene
  64127. * @returns the tiled box mesh
  64128. */
  64129. static CreateTiledBox(name: string, options: {
  64130. pattern?: number;
  64131. size?: number;
  64132. width?: number;
  64133. height?: number;
  64134. depth: number;
  64135. tileSize?: number;
  64136. tileWidth?: number;
  64137. tileHeight?: number;
  64138. faceUV?: Vector4[];
  64139. faceColors?: Color4[];
  64140. alignHorizontal?: number;
  64141. alignVertical?: number;
  64142. sideOrientation?: number;
  64143. updatable?: boolean;
  64144. }, scene?: Nullable<Scene>): Mesh;
  64145. /**
  64146. * Creates a sphere mesh
  64147. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64148. * * 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`)
  64149. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64150. * * 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
  64151. * * 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)
  64152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64153. * * 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
  64154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64155. * @param name defines the name of the mesh
  64156. * @param options defines the options used to create the mesh
  64157. * @param scene defines the hosting scene
  64158. * @returns the sphere mesh
  64159. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64160. */
  64161. static CreateSphere(name: string, options: {
  64162. segments?: number;
  64163. diameter?: number;
  64164. diameterX?: number;
  64165. diameterY?: number;
  64166. diameterZ?: number;
  64167. arc?: number;
  64168. slice?: number;
  64169. sideOrientation?: number;
  64170. frontUVs?: Vector4;
  64171. backUVs?: Vector4;
  64172. updatable?: boolean;
  64173. }, scene?: Nullable<Scene>): Mesh;
  64174. /**
  64175. * Creates a plane polygonal mesh. By default, this is a disc
  64176. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64177. * * 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
  64178. * * 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
  64179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64180. * * 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
  64181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64182. * @param name defines the name of the mesh
  64183. * @param options defines the options used to create the mesh
  64184. * @param scene defines the hosting scene
  64185. * @returns the plane polygonal mesh
  64186. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64187. */
  64188. static CreateDisc(name: string, options: {
  64189. radius?: number;
  64190. tessellation?: number;
  64191. arc?: number;
  64192. updatable?: boolean;
  64193. sideOrientation?: number;
  64194. frontUVs?: Vector4;
  64195. backUVs?: Vector4;
  64196. }, scene?: Nullable<Scene>): Mesh;
  64197. /**
  64198. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64199. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64200. * * 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`)
  64201. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64202. * * 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
  64203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64204. * * 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
  64205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64206. * @param name defines the name of the mesh
  64207. * @param options defines the options used to create the mesh
  64208. * @param scene defines the hosting scene
  64209. * @returns the icosahedron mesh
  64210. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64211. */
  64212. static CreateIcoSphere(name: string, options: {
  64213. radius?: number;
  64214. radiusX?: number;
  64215. radiusY?: number;
  64216. radiusZ?: number;
  64217. flat?: boolean;
  64218. subdivisions?: number;
  64219. sideOrientation?: number;
  64220. frontUVs?: Vector4;
  64221. backUVs?: Vector4;
  64222. updatable?: boolean;
  64223. }, scene?: Nullable<Scene>): Mesh;
  64224. /**
  64225. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64226. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64227. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64228. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64229. * * 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
  64230. * * 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
  64231. * * 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
  64232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64233. * * 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
  64234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64235. * * 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
  64236. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64237. * * 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
  64238. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64240. * @param name defines the name of the mesh
  64241. * @param options defines the options used to create the mesh
  64242. * @param scene defines the hosting scene
  64243. * @returns the ribbon mesh
  64244. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64246. */
  64247. static CreateRibbon(name: string, options: {
  64248. pathArray: Vector3[][];
  64249. closeArray?: boolean;
  64250. closePath?: boolean;
  64251. offset?: number;
  64252. updatable?: boolean;
  64253. sideOrientation?: number;
  64254. frontUVs?: Vector4;
  64255. backUVs?: Vector4;
  64256. instance?: Mesh;
  64257. invertUV?: boolean;
  64258. uvs?: Vector2[];
  64259. colors?: Color4[];
  64260. }, scene?: Nullable<Scene>): Mesh;
  64261. /**
  64262. * Creates a cylinder or a cone mesh
  64263. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64264. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64265. * * 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.
  64266. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64267. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64268. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64269. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64270. * * 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).
  64271. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64272. * * 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).
  64273. * * 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
  64274. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64275. * * 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
  64276. * * 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.
  64277. * * If `enclose` is false, a ring surface is one element.
  64278. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64279. * * 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
  64280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64281. * * 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
  64282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64283. * @param name defines the name of the mesh
  64284. * @param options defines the options used to create the mesh
  64285. * @param scene defines the hosting scene
  64286. * @returns the cylinder mesh
  64287. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64288. */
  64289. static CreateCylinder(name: string, options: {
  64290. height?: number;
  64291. diameterTop?: number;
  64292. diameterBottom?: number;
  64293. diameter?: number;
  64294. tessellation?: number;
  64295. subdivisions?: number;
  64296. arc?: number;
  64297. faceColors?: Color4[];
  64298. faceUV?: Vector4[];
  64299. updatable?: boolean;
  64300. hasRings?: boolean;
  64301. enclose?: boolean;
  64302. cap?: number;
  64303. sideOrientation?: number;
  64304. frontUVs?: Vector4;
  64305. backUVs?: Vector4;
  64306. }, scene?: Nullable<Scene>): Mesh;
  64307. /**
  64308. * Creates a torus mesh
  64309. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64310. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64311. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64313. * * 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
  64314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64315. * @param name defines the name of the mesh
  64316. * @param options defines the options used to create the mesh
  64317. * @param scene defines the hosting scene
  64318. * @returns the torus mesh
  64319. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64320. */
  64321. static CreateTorus(name: string, options: {
  64322. diameter?: number;
  64323. thickness?: number;
  64324. tessellation?: number;
  64325. updatable?: boolean;
  64326. sideOrientation?: number;
  64327. frontUVs?: Vector4;
  64328. backUVs?: Vector4;
  64329. }, scene?: Nullable<Scene>): Mesh;
  64330. /**
  64331. * Creates a torus knot mesh
  64332. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64333. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64334. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64335. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64337. * * 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
  64338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64339. * @param name defines the name of the mesh
  64340. * @param options defines the options used to create the mesh
  64341. * @param scene defines the hosting scene
  64342. * @returns the torus knot mesh
  64343. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64344. */
  64345. static CreateTorusKnot(name: string, options: {
  64346. radius?: number;
  64347. tube?: number;
  64348. radialSegments?: number;
  64349. tubularSegments?: number;
  64350. p?: number;
  64351. q?: number;
  64352. updatable?: boolean;
  64353. sideOrientation?: number;
  64354. frontUVs?: Vector4;
  64355. backUVs?: Vector4;
  64356. }, scene?: Nullable<Scene>): Mesh;
  64357. /**
  64358. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64359. * * 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
  64360. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64361. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64362. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64363. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64364. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64365. * * 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
  64366. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64369. * @param name defines the name of the new line system
  64370. * @param options defines the options used to create the line system
  64371. * @param scene defines the hosting scene
  64372. * @returns a new line system mesh
  64373. */
  64374. static CreateLineSystem(name: string, options: {
  64375. lines: Vector3[][];
  64376. updatable?: boolean;
  64377. instance?: Nullable<LinesMesh>;
  64378. colors?: Nullable<Color4[][]>;
  64379. useVertexAlpha?: boolean;
  64380. }, scene: Nullable<Scene>): LinesMesh;
  64381. /**
  64382. * Creates a line mesh
  64383. * 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
  64384. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64385. * * The parameter `points` is an array successive Vector3
  64386. * * 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
  64387. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64388. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64389. * * When updating an instance, remember that only point positions can change, not the number of points
  64390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64392. * @param name defines the name of the new line system
  64393. * @param options defines the options used to create the line system
  64394. * @param scene defines the hosting scene
  64395. * @returns a new line mesh
  64396. */
  64397. static CreateLines(name: string, options: {
  64398. points: Vector3[];
  64399. updatable?: boolean;
  64400. instance?: Nullable<LinesMesh>;
  64401. colors?: Color4[];
  64402. useVertexAlpha?: boolean;
  64403. }, scene?: Nullable<Scene>): LinesMesh;
  64404. /**
  64405. * Creates a dashed line mesh
  64406. * * 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
  64407. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64408. * * The parameter `points` is an array successive Vector3
  64409. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64410. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64411. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64412. * * 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
  64413. * * When updating an instance, remember that only point positions can change, not the number of points
  64414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64415. * @param name defines the name of the mesh
  64416. * @param options defines the options used to create the mesh
  64417. * @param scene defines the hosting scene
  64418. * @returns the dashed line mesh
  64419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64420. */
  64421. static CreateDashedLines(name: string, options: {
  64422. points: Vector3[];
  64423. dashSize?: number;
  64424. gapSize?: number;
  64425. dashNb?: number;
  64426. updatable?: boolean;
  64427. instance?: LinesMesh;
  64428. }, scene?: Nullable<Scene>): LinesMesh;
  64429. /**
  64430. * 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.
  64431. * * 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.
  64432. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64433. * * 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.
  64434. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64435. * * 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
  64436. * * 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
  64437. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64439. * * 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
  64440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64442. * @param name defines the name of the mesh
  64443. * @param options defines the options used to create the mesh
  64444. * @param scene defines the hosting scene
  64445. * @returns the extruded shape mesh
  64446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64448. */
  64449. static ExtrudeShape(name: string, options: {
  64450. shape: Vector3[];
  64451. path: Vector3[];
  64452. scale?: number;
  64453. rotation?: number;
  64454. cap?: number;
  64455. updatable?: boolean;
  64456. sideOrientation?: number;
  64457. frontUVs?: Vector4;
  64458. backUVs?: Vector4;
  64459. instance?: Mesh;
  64460. invertUV?: boolean;
  64461. }, scene?: Nullable<Scene>): Mesh;
  64462. /**
  64463. * Creates an custom extruded shape mesh.
  64464. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64465. * * 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.
  64466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64467. * * 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
  64468. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64469. * * 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
  64470. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64471. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64472. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64473. * * 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
  64474. * * 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
  64475. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64477. * * 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
  64478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64480. * @param name defines the name of the mesh
  64481. * @param options defines the options used to create the mesh
  64482. * @param scene defines the hosting scene
  64483. * @returns the custom extruded shape mesh
  64484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64487. */
  64488. static ExtrudeShapeCustom(name: string, options: {
  64489. shape: Vector3[];
  64490. path: Vector3[];
  64491. scaleFunction?: any;
  64492. rotationFunction?: any;
  64493. ribbonCloseArray?: boolean;
  64494. ribbonClosePath?: boolean;
  64495. cap?: number;
  64496. updatable?: boolean;
  64497. sideOrientation?: number;
  64498. frontUVs?: Vector4;
  64499. backUVs?: Vector4;
  64500. instance?: Mesh;
  64501. invertUV?: boolean;
  64502. }, scene?: Nullable<Scene>): Mesh;
  64503. /**
  64504. * Creates lathe mesh.
  64505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64506. * * 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
  64507. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64508. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64509. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64510. * * 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
  64511. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64512. * * 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
  64513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64514. * * 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
  64515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64517. * @param name defines the name of the mesh
  64518. * @param options defines the options used to create the mesh
  64519. * @param scene defines the hosting scene
  64520. * @returns the lathe mesh
  64521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64522. */
  64523. static CreateLathe(name: string, options: {
  64524. shape: Vector3[];
  64525. radius?: number;
  64526. tessellation?: number;
  64527. clip?: number;
  64528. arc?: number;
  64529. closed?: boolean;
  64530. updatable?: boolean;
  64531. sideOrientation?: number;
  64532. frontUVs?: Vector4;
  64533. backUVs?: Vector4;
  64534. cap?: number;
  64535. invertUV?: boolean;
  64536. }, scene?: Nullable<Scene>): Mesh;
  64537. /**
  64538. * Creates a tiled plane mesh
  64539. * * You can set a limited pattern arrangement with the tiles
  64540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64541. * * 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
  64542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64543. * @param name defines the name of the mesh
  64544. * @param options defines the options used to create the mesh
  64545. * @param scene defines the hosting scene
  64546. * @returns the plane mesh
  64547. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64548. */
  64549. static CreateTiledPlane(name: string, options: {
  64550. pattern?: number;
  64551. tileSize?: number;
  64552. tileWidth?: number;
  64553. tileHeight?: number;
  64554. size?: number;
  64555. width?: number;
  64556. height?: number;
  64557. alignHorizontal?: number;
  64558. alignVertical?: number;
  64559. sideOrientation?: number;
  64560. frontUVs?: Vector4;
  64561. backUVs?: Vector4;
  64562. updatable?: boolean;
  64563. }, scene?: Nullable<Scene>): Mesh;
  64564. /**
  64565. * Creates a plane mesh
  64566. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64567. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64568. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64570. * * 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
  64571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64572. * @param name defines the name of the mesh
  64573. * @param options defines the options used to create the mesh
  64574. * @param scene defines the hosting scene
  64575. * @returns the plane mesh
  64576. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64577. */
  64578. static CreatePlane(name: string, options: {
  64579. size?: number;
  64580. width?: number;
  64581. height?: number;
  64582. sideOrientation?: number;
  64583. frontUVs?: Vector4;
  64584. backUVs?: Vector4;
  64585. updatable?: boolean;
  64586. sourcePlane?: Plane;
  64587. }, scene?: Nullable<Scene>): Mesh;
  64588. /**
  64589. * Creates a ground mesh
  64590. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64591. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64593. * @param name defines the name of the mesh
  64594. * @param options defines the options used to create the mesh
  64595. * @param scene defines the hosting scene
  64596. * @returns the ground mesh
  64597. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64598. */
  64599. static CreateGround(name: string, options: {
  64600. width?: number;
  64601. height?: number;
  64602. subdivisions?: number;
  64603. subdivisionsX?: number;
  64604. subdivisionsY?: number;
  64605. updatable?: boolean;
  64606. }, scene?: Nullable<Scene>): Mesh;
  64607. /**
  64608. * Creates a tiled ground mesh
  64609. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64610. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64611. * * 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
  64612. * * 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
  64613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64614. * @param name defines the name of the mesh
  64615. * @param options defines the options used to create the mesh
  64616. * @param scene defines the hosting scene
  64617. * @returns the tiled ground mesh
  64618. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64619. */
  64620. static CreateTiledGround(name: string, options: {
  64621. xmin: number;
  64622. zmin: number;
  64623. xmax: number;
  64624. zmax: number;
  64625. subdivisions?: {
  64626. w: number;
  64627. h: number;
  64628. };
  64629. precision?: {
  64630. w: number;
  64631. h: number;
  64632. };
  64633. updatable?: boolean;
  64634. }, scene?: Nullable<Scene>): Mesh;
  64635. /**
  64636. * Creates a ground mesh from a height map
  64637. * * The parameter `url` sets the URL of the height map image resource.
  64638. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64639. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64640. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64641. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64642. * * 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.
  64643. * * 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).
  64644. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64646. * @param name defines the name of the mesh
  64647. * @param url defines the url to the height map
  64648. * @param options defines the options used to create the mesh
  64649. * @param scene defines the hosting scene
  64650. * @returns the ground mesh
  64651. * @see https://doc.babylonjs.com/babylon101/height_map
  64652. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64653. */
  64654. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64655. width?: number;
  64656. height?: number;
  64657. subdivisions?: number;
  64658. minHeight?: number;
  64659. maxHeight?: number;
  64660. colorFilter?: Color3;
  64661. alphaFilter?: number;
  64662. updatable?: boolean;
  64663. onReady?: (mesh: GroundMesh) => void;
  64664. }, scene?: Nullable<Scene>): GroundMesh;
  64665. /**
  64666. * Creates a polygon mesh
  64667. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64668. * * 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
  64669. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64671. * * 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)
  64672. * * Remember you can only change the shape positions, not their number when updating a polygon
  64673. * @param name defines the name of the mesh
  64674. * @param options defines the options used to create the mesh
  64675. * @param scene defines the hosting scene
  64676. * @param earcutInjection can be used to inject your own earcut reference
  64677. * @returns the polygon mesh
  64678. */
  64679. static CreatePolygon(name: string, options: {
  64680. shape: Vector3[];
  64681. holes?: Vector3[][];
  64682. depth?: number;
  64683. faceUV?: Vector4[];
  64684. faceColors?: Color4[];
  64685. updatable?: boolean;
  64686. sideOrientation?: number;
  64687. frontUVs?: Vector4;
  64688. backUVs?: Vector4;
  64689. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64690. /**
  64691. * Creates an extruded polygon mesh, with depth in the Y direction.
  64692. * * 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)
  64693. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64694. * @param name defines the name of the mesh
  64695. * @param options defines the options used to create the mesh
  64696. * @param scene defines the hosting scene
  64697. * @param earcutInjection can be used to inject your own earcut reference
  64698. * @returns the polygon mesh
  64699. */
  64700. static ExtrudePolygon(name: string, options: {
  64701. shape: Vector3[];
  64702. holes?: Vector3[][];
  64703. depth?: number;
  64704. faceUV?: Vector4[];
  64705. faceColors?: Color4[];
  64706. updatable?: boolean;
  64707. sideOrientation?: number;
  64708. frontUVs?: Vector4;
  64709. backUVs?: Vector4;
  64710. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64711. /**
  64712. * Creates a tube mesh.
  64713. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64714. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64715. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64716. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64717. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64718. * * 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)
  64719. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64720. * * 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
  64721. * * 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
  64722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64723. * * 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
  64724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64726. * @param name defines the name of the mesh
  64727. * @param options defines the options used to create the mesh
  64728. * @param scene defines the hosting scene
  64729. * @returns the tube mesh
  64730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64731. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64732. */
  64733. static CreateTube(name: string, options: {
  64734. path: Vector3[];
  64735. radius?: number;
  64736. tessellation?: number;
  64737. radiusFunction?: {
  64738. (i: number, distance: number): number;
  64739. };
  64740. cap?: number;
  64741. arc?: number;
  64742. updatable?: boolean;
  64743. sideOrientation?: number;
  64744. frontUVs?: Vector4;
  64745. backUVs?: Vector4;
  64746. instance?: Mesh;
  64747. invertUV?: boolean;
  64748. }, scene?: Nullable<Scene>): Mesh;
  64749. /**
  64750. * Creates a polyhedron mesh
  64751. * * 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
  64752. * * The parameter `size` (positive float, default 1) sets the polygon size
  64753. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64754. * * 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`
  64755. * * 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
  64756. * * 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)`)
  64757. * * 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
  64758. * * 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
  64759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64760. * * 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
  64761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64762. * @param name defines the name of the mesh
  64763. * @param options defines the options used to create the mesh
  64764. * @param scene defines the hosting scene
  64765. * @returns the polyhedron mesh
  64766. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64767. */
  64768. static CreatePolyhedron(name: string, options: {
  64769. type?: number;
  64770. size?: number;
  64771. sizeX?: number;
  64772. sizeY?: number;
  64773. sizeZ?: number;
  64774. custom?: any;
  64775. faceUV?: Vector4[];
  64776. faceColors?: Color4[];
  64777. flat?: boolean;
  64778. updatable?: boolean;
  64779. sideOrientation?: number;
  64780. frontUVs?: Vector4;
  64781. backUVs?: Vector4;
  64782. }, scene?: Nullable<Scene>): Mesh;
  64783. /**
  64784. * Creates a decal mesh.
  64785. * 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
  64786. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64787. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64788. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64789. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64790. * @param name defines the name of the mesh
  64791. * @param sourceMesh defines the mesh where the decal must be applied
  64792. * @param options defines the options used to create the mesh
  64793. * @param scene defines the hosting scene
  64794. * @returns the decal mesh
  64795. * @see https://doc.babylonjs.com/how_to/decals
  64796. */
  64797. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64798. position?: Vector3;
  64799. normal?: Vector3;
  64800. size?: Vector3;
  64801. angle?: number;
  64802. }): Mesh;
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /**
  64807. * A simplifier interface for future simplification implementations
  64808. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64809. */
  64810. export interface ISimplifier {
  64811. /**
  64812. * Simplification of a given mesh according to the given settings.
  64813. * Since this requires computation, it is assumed that the function runs async.
  64814. * @param settings The settings of the simplification, including quality and distance
  64815. * @param successCallback A callback that will be called after the mesh was simplified.
  64816. * @param errorCallback in case of an error, this callback will be called. optional.
  64817. */
  64818. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64819. }
  64820. /**
  64821. * Expected simplification settings.
  64822. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64823. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64824. */
  64825. export interface ISimplificationSettings {
  64826. /**
  64827. * Gets or sets the expected quality
  64828. */
  64829. quality: number;
  64830. /**
  64831. * Gets or sets the distance when this optimized version should be used
  64832. */
  64833. distance: number;
  64834. /**
  64835. * Gets an already optimized mesh
  64836. */
  64837. optimizeMesh?: boolean;
  64838. }
  64839. /**
  64840. * Class used to specify simplification options
  64841. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64842. */
  64843. export class SimplificationSettings implements ISimplificationSettings {
  64844. /** expected quality */
  64845. quality: number;
  64846. /** distance when this optimized version should be used */
  64847. distance: number;
  64848. /** already optimized mesh */
  64849. optimizeMesh?: boolean | undefined;
  64850. /**
  64851. * Creates a SimplificationSettings
  64852. * @param quality expected quality
  64853. * @param distance distance when this optimized version should be used
  64854. * @param optimizeMesh already optimized mesh
  64855. */
  64856. constructor(
  64857. /** expected quality */
  64858. quality: number,
  64859. /** distance when this optimized version should be used */
  64860. distance: number,
  64861. /** already optimized mesh */
  64862. optimizeMesh?: boolean | undefined);
  64863. }
  64864. /**
  64865. * Interface used to define a simplification task
  64866. */
  64867. export interface ISimplificationTask {
  64868. /**
  64869. * Array of settings
  64870. */
  64871. settings: Array<ISimplificationSettings>;
  64872. /**
  64873. * Simplification type
  64874. */
  64875. simplificationType: SimplificationType;
  64876. /**
  64877. * Mesh to simplify
  64878. */
  64879. mesh: Mesh;
  64880. /**
  64881. * Callback called on success
  64882. */
  64883. successCallback?: () => void;
  64884. /**
  64885. * Defines if parallel processing can be used
  64886. */
  64887. parallelProcessing: boolean;
  64888. }
  64889. /**
  64890. * Queue used to order the simplification tasks
  64891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64892. */
  64893. export class SimplificationQueue {
  64894. private _simplificationArray;
  64895. /**
  64896. * Gets a boolean indicating that the process is still running
  64897. */
  64898. running: boolean;
  64899. /**
  64900. * Creates a new queue
  64901. */
  64902. constructor();
  64903. /**
  64904. * Adds a new simplification task
  64905. * @param task defines a task to add
  64906. */
  64907. addTask(task: ISimplificationTask): void;
  64908. /**
  64909. * Execute next task
  64910. */
  64911. executeNext(): void;
  64912. /**
  64913. * Execute a simplification task
  64914. * @param task defines the task to run
  64915. */
  64916. runSimplification(task: ISimplificationTask): void;
  64917. private getSimplifier;
  64918. }
  64919. /**
  64920. * The implemented types of simplification
  64921. * At the moment only Quadratic Error Decimation is implemented
  64922. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64923. */
  64924. export enum SimplificationType {
  64925. /** Quadratic error decimation */
  64926. QUADRATIC = 0
  64927. }
  64928. /**
  64929. * An implementation of the Quadratic Error simplification algorithm.
  64930. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64931. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64932. * @author RaananW
  64933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64934. */
  64935. export class QuadraticErrorSimplification implements ISimplifier {
  64936. private _mesh;
  64937. private triangles;
  64938. private vertices;
  64939. private references;
  64940. private _reconstructedMesh;
  64941. /** Gets or sets the number pf sync interations */
  64942. syncIterations: number;
  64943. /** Gets or sets the aggressiveness of the simplifier */
  64944. aggressiveness: number;
  64945. /** Gets or sets the number of allowed iterations for decimation */
  64946. decimationIterations: number;
  64947. /** Gets or sets the espilon to use for bounding box computation */
  64948. boundingBoxEpsilon: number;
  64949. /**
  64950. * Creates a new QuadraticErrorSimplification
  64951. * @param _mesh defines the target mesh
  64952. */
  64953. constructor(_mesh: Mesh);
  64954. /**
  64955. * Simplification of a given mesh according to the given settings.
  64956. * Since this requires computation, it is assumed that the function runs async.
  64957. * @param settings The settings of the simplification, including quality and distance
  64958. * @param successCallback A callback that will be called after the mesh was simplified.
  64959. */
  64960. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64961. private runDecimation;
  64962. private initWithMesh;
  64963. private init;
  64964. private reconstructMesh;
  64965. private initDecimatedMesh;
  64966. private isFlipped;
  64967. private updateTriangles;
  64968. private identifyBorder;
  64969. private updateMesh;
  64970. private vertexError;
  64971. private calculateError;
  64972. }
  64973. }
  64974. declare module BABYLON {
  64975. interface Scene {
  64976. /** @hidden (Backing field) */
  64977. _simplificationQueue: SimplificationQueue;
  64978. /**
  64979. * Gets or sets the simplification queue attached to the scene
  64980. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64981. */
  64982. simplificationQueue: SimplificationQueue;
  64983. }
  64984. interface Mesh {
  64985. /**
  64986. * Simplify the mesh according to the given array of settings.
  64987. * Function will return immediately and will simplify async
  64988. * @param settings a collection of simplification settings
  64989. * @param parallelProcessing should all levels calculate parallel or one after the other
  64990. * @param simplificationType the type of simplification to run
  64991. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64992. * @returns the current mesh
  64993. */
  64994. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64995. }
  64996. /**
  64997. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64998. * created in a scene
  64999. */
  65000. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65001. /**
  65002. * The component name helpfull to identify the component in the list of scene components.
  65003. */
  65004. readonly name: string;
  65005. /**
  65006. * The scene the component belongs to.
  65007. */
  65008. scene: Scene;
  65009. /**
  65010. * Creates a new instance of the component for the given scene
  65011. * @param scene Defines the scene to register the component in
  65012. */
  65013. constructor(scene: Scene);
  65014. /**
  65015. * Registers the component in a given scene
  65016. */
  65017. register(): void;
  65018. /**
  65019. * Rebuilds the elements related to this component in case of
  65020. * context lost for instance.
  65021. */
  65022. rebuild(): void;
  65023. /**
  65024. * Disposes the component and the associated ressources
  65025. */
  65026. dispose(): void;
  65027. private _beforeCameraUpdate;
  65028. }
  65029. }
  65030. declare module BABYLON {
  65031. interface Mesh {
  65032. /**
  65033. * Creates a new thin instance
  65034. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65035. * @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
  65036. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65037. */
  65038. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65039. /**
  65040. * Adds the transformation (matrix) of the current mesh as a thin instance
  65041. * @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
  65042. * @returns the thin instance index number
  65043. */
  65044. thinInstanceAddSelf(refresh: boolean): number;
  65045. /**
  65046. * Registers a custom attribute to be used with thin instances
  65047. * @param kind name of the attribute
  65048. * @param stride size in floats of the attribute
  65049. */
  65050. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65051. /**
  65052. * Sets the matrix of a thin instance
  65053. * @param index index of the thin instance
  65054. * @param matrix matrix to set
  65055. * @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
  65056. */
  65057. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65058. /**
  65059. * Sets the value of a custom attribute for a thin instance
  65060. * @param kind name of the attribute
  65061. * @param index index of the thin instance
  65062. * @param value value to set
  65063. * @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
  65064. */
  65065. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65066. /**
  65067. * 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.
  65068. */
  65069. thinInstanceCount: number;
  65070. /**
  65071. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65072. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65073. * @param buffer buffer to set
  65074. * @param stride size in floats of each value of the buffer
  65075. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65076. */
  65077. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65078. /**
  65079. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65080. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65081. */
  65082. thinInstanceBufferUpdated(kind: string): void;
  65083. /**
  65084. * Refreshes the bounding info, taking into account all the thin instances defined
  65085. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65086. */
  65087. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65088. /** @hidden */
  65089. _thinInstanceInitializeUserStorage(): void;
  65090. /** @hidden */
  65091. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65092. /** @hidden */
  65093. _userThinInstanceBuffersStorage: {
  65094. data: {
  65095. [key: string]: Float32Array;
  65096. };
  65097. sizes: {
  65098. [key: string]: number;
  65099. };
  65100. vertexBuffers: {
  65101. [key: string]: Nullable<VertexBuffer>;
  65102. };
  65103. strides: {
  65104. [key: string]: number;
  65105. };
  65106. };
  65107. }
  65108. }
  65109. declare module BABYLON {
  65110. /**
  65111. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65112. */
  65113. export interface INavigationEnginePlugin {
  65114. /**
  65115. * plugin name
  65116. */
  65117. name: string;
  65118. /**
  65119. * Creates a navigation mesh
  65120. * @param meshes array of all the geometry used to compute the navigatio mesh
  65121. * @param parameters bunch of parameters used to filter geometry
  65122. */
  65123. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65124. /**
  65125. * Create a navigation mesh debug mesh
  65126. * @param scene is where the mesh will be added
  65127. * @returns debug display mesh
  65128. */
  65129. createDebugNavMesh(scene: Scene): Mesh;
  65130. /**
  65131. * Get a navigation mesh constrained position, closest to the parameter position
  65132. * @param position world position
  65133. * @returns the closest point to position constrained by the navigation mesh
  65134. */
  65135. getClosestPoint(position: Vector3): Vector3;
  65136. /**
  65137. * Get a navigation mesh constrained position, closest to the parameter position
  65138. * @param position world position
  65139. * @param result output the closest point to position constrained by the navigation mesh
  65140. */
  65141. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65142. /**
  65143. * Get a navigation mesh constrained position, within a particular radius
  65144. * @param position world position
  65145. * @param maxRadius the maximum distance to the constrained world position
  65146. * @returns the closest point to position constrained by the navigation mesh
  65147. */
  65148. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65149. /**
  65150. * Get a navigation mesh constrained position, within a particular radius
  65151. * @param position world position
  65152. * @param maxRadius the maximum distance to the constrained world position
  65153. * @param result output the closest point to position constrained by the navigation mesh
  65154. */
  65155. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65156. /**
  65157. * Compute the final position from a segment made of destination-position
  65158. * @param position world position
  65159. * @param destination world position
  65160. * @returns the resulting point along the navmesh
  65161. */
  65162. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65163. /**
  65164. * Compute the final position from a segment made of destination-position
  65165. * @param position world position
  65166. * @param destination world position
  65167. * @param result output the resulting point along the navmesh
  65168. */
  65169. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65170. /**
  65171. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65172. * @param start world position
  65173. * @param end world position
  65174. * @returns array containing world position composing the path
  65175. */
  65176. computePath(start: Vector3, end: Vector3): Vector3[];
  65177. /**
  65178. * If this plugin is supported
  65179. * @returns true if plugin is supported
  65180. */
  65181. isSupported(): boolean;
  65182. /**
  65183. * Create a new Crowd so you can add agents
  65184. * @param maxAgents the maximum agent count in the crowd
  65185. * @param maxAgentRadius the maximum radius an agent can have
  65186. * @param scene to attach the crowd to
  65187. * @returns the crowd you can add agents to
  65188. */
  65189. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65190. /**
  65191. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65192. * The queries will try to find a solution within those bounds
  65193. * default is (1,1,1)
  65194. * @param extent x,y,z value that define the extent around the queries point of reference
  65195. */
  65196. setDefaultQueryExtent(extent: Vector3): void;
  65197. /**
  65198. * Get the Bounding box extent specified by setDefaultQueryExtent
  65199. * @returns the box extent values
  65200. */
  65201. getDefaultQueryExtent(): Vector3;
  65202. /**
  65203. * build the navmesh from a previously saved state using getNavmeshData
  65204. * @param data the Uint8Array returned by getNavmeshData
  65205. */
  65206. buildFromNavmeshData(data: Uint8Array): void;
  65207. /**
  65208. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65209. * @returns data the Uint8Array that can be saved and reused
  65210. */
  65211. getNavmeshData(): Uint8Array;
  65212. /**
  65213. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65214. * @param result output the box extent values
  65215. */
  65216. getDefaultQueryExtentToRef(result: Vector3): void;
  65217. /**
  65218. * Release all resources
  65219. */
  65220. dispose(): void;
  65221. }
  65222. /**
  65223. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65224. */
  65225. export interface ICrowd {
  65226. /**
  65227. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65228. * You can attach anything to that node. The node position is updated in the scene update tick.
  65229. * @param pos world position that will be constrained by the navigation mesh
  65230. * @param parameters agent parameters
  65231. * @param transform hooked to the agent that will be update by the scene
  65232. * @returns agent index
  65233. */
  65234. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65235. /**
  65236. * Returns the agent position in world space
  65237. * @param index agent index returned by addAgent
  65238. * @returns world space position
  65239. */
  65240. getAgentPosition(index: number): Vector3;
  65241. /**
  65242. * Gets the agent position result in world space
  65243. * @param index agent index returned by addAgent
  65244. * @param result output world space position
  65245. */
  65246. getAgentPositionToRef(index: number, result: Vector3): void;
  65247. /**
  65248. * Gets the agent velocity in world space
  65249. * @param index agent index returned by addAgent
  65250. * @returns world space velocity
  65251. */
  65252. getAgentVelocity(index: number): Vector3;
  65253. /**
  65254. * Gets the agent velocity result in world space
  65255. * @param index agent index returned by addAgent
  65256. * @param result output world space velocity
  65257. */
  65258. getAgentVelocityToRef(index: number, result: Vector3): void;
  65259. /**
  65260. * remove a particular agent previously created
  65261. * @param index agent index returned by addAgent
  65262. */
  65263. removeAgent(index: number): void;
  65264. /**
  65265. * get the list of all agents attached to this crowd
  65266. * @returns list of agent indices
  65267. */
  65268. getAgents(): number[];
  65269. /**
  65270. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65271. * @param deltaTime in seconds
  65272. */
  65273. update(deltaTime: number): void;
  65274. /**
  65275. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65276. * @param index agent index returned by addAgent
  65277. * @param destination targeted world position
  65278. */
  65279. agentGoto(index: number, destination: Vector3): void;
  65280. /**
  65281. * Teleport the agent to a new position
  65282. * @param index agent index returned by addAgent
  65283. * @param destination targeted world position
  65284. */
  65285. agentTeleport(index: number, destination: Vector3): void;
  65286. /**
  65287. * Update agent parameters
  65288. * @param index agent index returned by addAgent
  65289. * @param parameters agent parameters
  65290. */
  65291. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65292. /**
  65293. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65294. * The queries will try to find a solution within those bounds
  65295. * default is (1,1,1)
  65296. * @param extent x,y,z value that define the extent around the queries point of reference
  65297. */
  65298. setDefaultQueryExtent(extent: Vector3): void;
  65299. /**
  65300. * Get the Bounding box extent specified by setDefaultQueryExtent
  65301. * @returns the box extent values
  65302. */
  65303. getDefaultQueryExtent(): Vector3;
  65304. /**
  65305. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65306. * @param result output the box extent values
  65307. */
  65308. getDefaultQueryExtentToRef(result: Vector3): void;
  65309. /**
  65310. * Release all resources
  65311. */
  65312. dispose(): void;
  65313. }
  65314. /**
  65315. * Configures an agent
  65316. */
  65317. export interface IAgentParameters {
  65318. /**
  65319. * Agent radius. [Limit: >= 0]
  65320. */
  65321. radius: number;
  65322. /**
  65323. * Agent height. [Limit: > 0]
  65324. */
  65325. height: number;
  65326. /**
  65327. * Maximum allowed acceleration. [Limit: >= 0]
  65328. */
  65329. maxAcceleration: number;
  65330. /**
  65331. * Maximum allowed speed. [Limit: >= 0]
  65332. */
  65333. maxSpeed: number;
  65334. /**
  65335. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65336. */
  65337. collisionQueryRange: number;
  65338. /**
  65339. * The path visibility optimization range. [Limit: > 0]
  65340. */
  65341. pathOptimizationRange: number;
  65342. /**
  65343. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65344. */
  65345. separationWeight: number;
  65346. }
  65347. /**
  65348. * Configures the navigation mesh creation
  65349. */
  65350. export interface INavMeshParameters {
  65351. /**
  65352. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65353. */
  65354. cs: number;
  65355. /**
  65356. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65357. */
  65358. ch: number;
  65359. /**
  65360. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65361. */
  65362. walkableSlopeAngle: number;
  65363. /**
  65364. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65365. * be considered walkable. [Limit: >= 3] [Units: vx]
  65366. */
  65367. walkableHeight: number;
  65368. /**
  65369. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65370. */
  65371. walkableClimb: number;
  65372. /**
  65373. * The distance to erode/shrink the walkable area of the heightfield away from
  65374. * obstructions. [Limit: >=0] [Units: vx]
  65375. */
  65376. walkableRadius: number;
  65377. /**
  65378. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65379. */
  65380. maxEdgeLen: number;
  65381. /**
  65382. * The maximum distance a simplfied contour's border edges should deviate
  65383. * the original raw contour. [Limit: >=0] [Units: vx]
  65384. */
  65385. maxSimplificationError: number;
  65386. /**
  65387. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65388. */
  65389. minRegionArea: number;
  65390. /**
  65391. * Any regions with a span count smaller than this value will, if possible,
  65392. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65393. */
  65394. mergeRegionArea: number;
  65395. /**
  65396. * The maximum number of vertices allowed for polygons generated during the
  65397. * contour to polygon conversion process. [Limit: >= 3]
  65398. */
  65399. maxVertsPerPoly: number;
  65400. /**
  65401. * Sets the sampling distance to use when generating the detail mesh.
  65402. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65403. */
  65404. detailSampleDist: number;
  65405. /**
  65406. * The maximum distance the detail mesh surface should deviate from heightfield
  65407. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65408. */
  65409. detailSampleMaxError: number;
  65410. }
  65411. }
  65412. declare module BABYLON {
  65413. /**
  65414. * RecastJS navigation plugin
  65415. */
  65416. export class RecastJSPlugin implements INavigationEnginePlugin {
  65417. /**
  65418. * Reference to the Recast library
  65419. */
  65420. bjsRECAST: any;
  65421. /**
  65422. * plugin name
  65423. */
  65424. name: string;
  65425. /**
  65426. * the first navmesh created. We might extend this to support multiple navmeshes
  65427. */
  65428. navMesh: any;
  65429. /**
  65430. * Initializes the recastJS plugin
  65431. * @param recastInjection can be used to inject your own recast reference
  65432. */
  65433. constructor(recastInjection?: any);
  65434. /**
  65435. * Creates a navigation mesh
  65436. * @param meshes array of all the geometry used to compute the navigatio mesh
  65437. * @param parameters bunch of parameters used to filter geometry
  65438. */
  65439. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65440. /**
  65441. * Create a navigation mesh debug mesh
  65442. * @param scene is where the mesh will be added
  65443. * @returns debug display mesh
  65444. */
  65445. createDebugNavMesh(scene: Scene): Mesh;
  65446. /**
  65447. * Get a navigation mesh constrained position, closest to the parameter position
  65448. * @param position world position
  65449. * @returns the closest point to position constrained by the navigation mesh
  65450. */
  65451. getClosestPoint(position: Vector3): Vector3;
  65452. /**
  65453. * Get a navigation mesh constrained position, closest to the parameter position
  65454. * @param position world position
  65455. * @param result output the closest point to position constrained by the navigation mesh
  65456. */
  65457. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65458. /**
  65459. * Get a navigation mesh constrained position, within a particular radius
  65460. * @param position world position
  65461. * @param maxRadius the maximum distance to the constrained world position
  65462. * @returns the closest point to position constrained by the navigation mesh
  65463. */
  65464. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65465. /**
  65466. * Get a navigation mesh constrained position, within a particular radius
  65467. * @param position world position
  65468. * @param maxRadius the maximum distance to the constrained world position
  65469. * @param result output the closest point to position constrained by the navigation mesh
  65470. */
  65471. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65472. /**
  65473. * Compute the final position from a segment made of destination-position
  65474. * @param position world position
  65475. * @param destination world position
  65476. * @returns the resulting point along the navmesh
  65477. */
  65478. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65479. /**
  65480. * Compute the final position from a segment made of destination-position
  65481. * @param position world position
  65482. * @param destination world position
  65483. * @param result output the resulting point along the navmesh
  65484. */
  65485. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65486. /**
  65487. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65488. * @param start world position
  65489. * @param end world position
  65490. * @returns array containing world position composing the path
  65491. */
  65492. computePath(start: Vector3, end: Vector3): Vector3[];
  65493. /**
  65494. * Create a new Crowd so you can add agents
  65495. * @param maxAgents the maximum agent count in the crowd
  65496. * @param maxAgentRadius the maximum radius an agent can have
  65497. * @param scene to attach the crowd to
  65498. * @returns the crowd you can add agents to
  65499. */
  65500. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65501. /**
  65502. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65503. * The queries will try to find a solution within those bounds
  65504. * default is (1,1,1)
  65505. * @param extent x,y,z value that define the extent around the queries point of reference
  65506. */
  65507. setDefaultQueryExtent(extent: Vector3): void;
  65508. /**
  65509. * Get the Bounding box extent specified by setDefaultQueryExtent
  65510. * @returns the box extent values
  65511. */
  65512. getDefaultQueryExtent(): Vector3;
  65513. /**
  65514. * build the navmesh from a previously saved state using getNavmeshData
  65515. * @param data the Uint8Array returned by getNavmeshData
  65516. */
  65517. buildFromNavmeshData(data: Uint8Array): void;
  65518. /**
  65519. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65520. * @returns data the Uint8Array that can be saved and reused
  65521. */
  65522. getNavmeshData(): Uint8Array;
  65523. /**
  65524. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65525. * @param result output the box extent values
  65526. */
  65527. getDefaultQueryExtentToRef(result: Vector3): void;
  65528. /**
  65529. * Disposes
  65530. */
  65531. dispose(): void;
  65532. /**
  65533. * If this plugin is supported
  65534. * @returns true if plugin is supported
  65535. */
  65536. isSupported(): boolean;
  65537. }
  65538. /**
  65539. * Recast detour crowd implementation
  65540. */
  65541. export class RecastJSCrowd implements ICrowd {
  65542. /**
  65543. * Recast/detour plugin
  65544. */
  65545. bjsRECASTPlugin: RecastJSPlugin;
  65546. /**
  65547. * Link to the detour crowd
  65548. */
  65549. recastCrowd: any;
  65550. /**
  65551. * One transform per agent
  65552. */
  65553. transforms: TransformNode[];
  65554. /**
  65555. * All agents created
  65556. */
  65557. agents: number[];
  65558. /**
  65559. * Link to the scene is kept to unregister the crowd from the scene
  65560. */
  65561. private _scene;
  65562. /**
  65563. * Observer for crowd updates
  65564. */
  65565. private _onBeforeAnimationsObserver;
  65566. /**
  65567. * Constructor
  65568. * @param plugin recastJS plugin
  65569. * @param maxAgents the maximum agent count in the crowd
  65570. * @param maxAgentRadius the maximum radius an agent can have
  65571. * @param scene to attach the crowd to
  65572. * @returns the crowd you can add agents to
  65573. */
  65574. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65575. /**
  65576. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65577. * You can attach anything to that node. The node position is updated in the scene update tick.
  65578. * @param pos world position that will be constrained by the navigation mesh
  65579. * @param parameters agent parameters
  65580. * @param transform hooked to the agent that will be update by the scene
  65581. * @returns agent index
  65582. */
  65583. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65584. /**
  65585. * Returns the agent position in world space
  65586. * @param index agent index returned by addAgent
  65587. * @returns world space position
  65588. */
  65589. getAgentPosition(index: number): Vector3;
  65590. /**
  65591. * Returns the agent position result in world space
  65592. * @param index agent index returned by addAgent
  65593. * @param result output world space position
  65594. */
  65595. getAgentPositionToRef(index: number, result: Vector3): void;
  65596. /**
  65597. * Returns the agent velocity in world space
  65598. * @param index agent index returned by addAgent
  65599. * @returns world space velocity
  65600. */
  65601. getAgentVelocity(index: number): Vector3;
  65602. /**
  65603. * Returns the agent velocity result in world space
  65604. * @param index agent index returned by addAgent
  65605. * @param result output world space velocity
  65606. */
  65607. getAgentVelocityToRef(index: number, result: Vector3): void;
  65608. /**
  65609. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65610. * @param index agent index returned by addAgent
  65611. * @param destination targeted world position
  65612. */
  65613. agentGoto(index: number, destination: Vector3): void;
  65614. /**
  65615. * Teleport the agent to a new position
  65616. * @param index agent index returned by addAgent
  65617. * @param destination targeted world position
  65618. */
  65619. agentTeleport(index: number, destination: Vector3): void;
  65620. /**
  65621. * Update agent parameters
  65622. * @param index agent index returned by addAgent
  65623. * @param parameters agent parameters
  65624. */
  65625. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65626. /**
  65627. * remove a particular agent previously created
  65628. * @param index agent index returned by addAgent
  65629. */
  65630. removeAgent(index: number): void;
  65631. /**
  65632. * get the list of all agents attached to this crowd
  65633. * @returns list of agent indices
  65634. */
  65635. getAgents(): number[];
  65636. /**
  65637. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65638. * @param deltaTime in seconds
  65639. */
  65640. update(deltaTime: number): void;
  65641. /**
  65642. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65643. * The queries will try to find a solution within those bounds
  65644. * default is (1,1,1)
  65645. * @param extent x,y,z value that define the extent around the queries point of reference
  65646. */
  65647. setDefaultQueryExtent(extent: Vector3): void;
  65648. /**
  65649. * Get the Bounding box extent specified by setDefaultQueryExtent
  65650. * @returns the box extent values
  65651. */
  65652. getDefaultQueryExtent(): Vector3;
  65653. /**
  65654. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65655. * @param result output the box extent values
  65656. */
  65657. getDefaultQueryExtentToRef(result: Vector3): void;
  65658. /**
  65659. * Release all resources
  65660. */
  65661. dispose(): void;
  65662. }
  65663. }
  65664. declare module BABYLON {
  65665. /**
  65666. * Class used to enable access to IndexedDB
  65667. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65668. */
  65669. export class Database implements IOfflineProvider {
  65670. private _callbackManifestChecked;
  65671. private _currentSceneUrl;
  65672. private _db;
  65673. private _enableSceneOffline;
  65674. private _enableTexturesOffline;
  65675. private _manifestVersionFound;
  65676. private _mustUpdateRessources;
  65677. private _hasReachedQuota;
  65678. private _isSupported;
  65679. private _idbFactory;
  65680. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65681. private static IsUASupportingBlobStorage;
  65682. /**
  65683. * Gets a boolean indicating if Database storate is enabled (off by default)
  65684. */
  65685. static IDBStorageEnabled: boolean;
  65686. /**
  65687. * Gets a boolean indicating if scene must be saved in the database
  65688. */
  65689. get enableSceneOffline(): boolean;
  65690. /**
  65691. * Gets a boolean indicating if textures must be saved in the database
  65692. */
  65693. get enableTexturesOffline(): boolean;
  65694. /**
  65695. * Creates a new Database
  65696. * @param urlToScene defines the url to load the scene
  65697. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65698. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65699. */
  65700. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65701. private static _ParseURL;
  65702. private static _ReturnFullUrlLocation;
  65703. private _checkManifestFile;
  65704. /**
  65705. * Open the database and make it available
  65706. * @param successCallback defines the callback to call on success
  65707. * @param errorCallback defines the callback to call on error
  65708. */
  65709. open(successCallback: () => void, errorCallback: () => void): void;
  65710. /**
  65711. * Loads an image from the database
  65712. * @param url defines the url to load from
  65713. * @param image defines the target DOM image
  65714. */
  65715. loadImage(url: string, image: HTMLImageElement): void;
  65716. private _loadImageFromDBAsync;
  65717. private _saveImageIntoDBAsync;
  65718. private _checkVersionFromDB;
  65719. private _loadVersionFromDBAsync;
  65720. private _saveVersionIntoDBAsync;
  65721. /**
  65722. * Loads a file from database
  65723. * @param url defines the URL to load from
  65724. * @param sceneLoaded defines a callback to call on success
  65725. * @param progressCallBack defines a callback to call when progress changed
  65726. * @param errorCallback defines a callback to call on error
  65727. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65728. */
  65729. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65730. private _loadFileAsync;
  65731. private _saveFileAsync;
  65732. /**
  65733. * Validates if xhr data is correct
  65734. * @param xhr defines the request to validate
  65735. * @param dataType defines the expected data type
  65736. * @returns true if data is correct
  65737. */
  65738. private static _ValidateXHRData;
  65739. }
  65740. }
  65741. declare module BABYLON {
  65742. /** @hidden */
  65743. export var gpuUpdateParticlesPixelShader: {
  65744. name: string;
  65745. shader: string;
  65746. };
  65747. }
  65748. declare module BABYLON {
  65749. /** @hidden */
  65750. export var gpuUpdateParticlesVertexShader: {
  65751. name: string;
  65752. shader: string;
  65753. };
  65754. }
  65755. declare module BABYLON {
  65756. /** @hidden */
  65757. export var clipPlaneFragmentDeclaration2: {
  65758. name: string;
  65759. shader: string;
  65760. };
  65761. }
  65762. declare module BABYLON {
  65763. /** @hidden */
  65764. export var gpuRenderParticlesPixelShader: {
  65765. name: string;
  65766. shader: string;
  65767. };
  65768. }
  65769. declare module BABYLON {
  65770. /** @hidden */
  65771. export var clipPlaneVertexDeclaration2: {
  65772. name: string;
  65773. shader: string;
  65774. };
  65775. }
  65776. declare module BABYLON {
  65777. /** @hidden */
  65778. export var gpuRenderParticlesVertexShader: {
  65779. name: string;
  65780. shader: string;
  65781. };
  65782. }
  65783. declare module BABYLON {
  65784. /**
  65785. * This represents a GPU particle system in Babylon
  65786. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65787. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65788. */
  65789. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65790. /**
  65791. * The layer mask we are rendering the particles through.
  65792. */
  65793. layerMask: number;
  65794. private _capacity;
  65795. private _activeCount;
  65796. private _currentActiveCount;
  65797. private _accumulatedCount;
  65798. private _renderEffect;
  65799. private _updateEffect;
  65800. private _buffer0;
  65801. private _buffer1;
  65802. private _spriteBuffer;
  65803. private _updateVAO;
  65804. private _renderVAO;
  65805. private _targetIndex;
  65806. private _sourceBuffer;
  65807. private _targetBuffer;
  65808. private _engine;
  65809. private _currentRenderId;
  65810. private _started;
  65811. private _stopped;
  65812. private _timeDelta;
  65813. private _randomTexture;
  65814. private _randomTexture2;
  65815. private _attributesStrideSize;
  65816. private _updateEffectOptions;
  65817. private _randomTextureSize;
  65818. private _actualFrame;
  65819. private _customEffect;
  65820. private readonly _rawTextureWidth;
  65821. /**
  65822. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65823. */
  65824. static get IsSupported(): boolean;
  65825. /**
  65826. * An event triggered when the system is disposed.
  65827. */
  65828. onDisposeObservable: Observable<IParticleSystem>;
  65829. /**
  65830. * Gets the maximum number of particles active at the same time.
  65831. * @returns The max number of active particles.
  65832. */
  65833. getCapacity(): number;
  65834. /**
  65835. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65836. * to override the particles.
  65837. */
  65838. forceDepthWrite: boolean;
  65839. /**
  65840. * Gets or set the number of active particles
  65841. */
  65842. get activeParticleCount(): number;
  65843. set activeParticleCount(value: number);
  65844. private _preWarmDone;
  65845. /**
  65846. * Specifies if the particles are updated in emitter local space or world space.
  65847. */
  65848. isLocal: boolean;
  65849. /**
  65850. * Is this system ready to be used/rendered
  65851. * @return true if the system is ready
  65852. */
  65853. isReady(): boolean;
  65854. /**
  65855. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65856. * @returns True if it has been started, otherwise false.
  65857. */
  65858. isStarted(): boolean;
  65859. /**
  65860. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65861. * @returns True if it has been stopped, otherwise false.
  65862. */
  65863. isStopped(): boolean;
  65864. /**
  65865. * Gets a boolean indicating that the system is stopping
  65866. * @returns true if the system is currently stopping
  65867. */
  65868. isStopping(): boolean;
  65869. /**
  65870. * Gets the number of particles active at the same time.
  65871. * @returns The number of active particles.
  65872. */
  65873. getActiveCount(): number;
  65874. /**
  65875. * Starts the particle system and begins to emit
  65876. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65877. */
  65878. start(delay?: number): void;
  65879. /**
  65880. * Stops the particle system.
  65881. */
  65882. stop(): void;
  65883. /**
  65884. * Remove all active particles
  65885. */
  65886. reset(): void;
  65887. /**
  65888. * Returns the string "GPUParticleSystem"
  65889. * @returns a string containing the class name
  65890. */
  65891. getClassName(): string;
  65892. /**
  65893. * Gets the custom effect used to render the particles
  65894. * @param blendMode Blend mode for which the effect should be retrieved
  65895. * @returns The effect
  65896. */
  65897. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65898. /**
  65899. * Sets the custom effect used to render the particles
  65900. * @param effect The effect to set
  65901. * @param blendMode Blend mode for which the effect should be set
  65902. */
  65903. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65904. /** @hidden */
  65905. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65906. /**
  65907. * Observable that will be called just before the particles are drawn
  65908. */
  65909. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65910. /**
  65911. * Gets the name of the particle vertex shader
  65912. */
  65913. get vertexShaderName(): string;
  65914. private _colorGradientsTexture;
  65915. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65916. /**
  65917. * Adds a new color gradient
  65918. * @param gradient defines the gradient to use (between 0 and 1)
  65919. * @param color1 defines the color to affect to the specified gradient
  65920. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65921. * @returns the current particle system
  65922. */
  65923. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65924. private _refreshColorGradient;
  65925. /** Force the system to rebuild all gradients that need to be resync */
  65926. forceRefreshGradients(): void;
  65927. /**
  65928. * Remove a specific color gradient
  65929. * @param gradient defines the gradient to remove
  65930. * @returns the current particle system
  65931. */
  65932. removeColorGradient(gradient: number): GPUParticleSystem;
  65933. private _angularSpeedGradientsTexture;
  65934. private _sizeGradientsTexture;
  65935. private _velocityGradientsTexture;
  65936. private _limitVelocityGradientsTexture;
  65937. private _dragGradientsTexture;
  65938. private _addFactorGradient;
  65939. /**
  65940. * Adds a new size gradient
  65941. * @param gradient defines the gradient to use (between 0 and 1)
  65942. * @param factor defines the size factor to affect to the specified gradient
  65943. * @returns the current particle system
  65944. */
  65945. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65946. /**
  65947. * Remove a specific size gradient
  65948. * @param gradient defines the gradient to remove
  65949. * @returns the current particle system
  65950. */
  65951. removeSizeGradient(gradient: number): GPUParticleSystem;
  65952. private _refreshFactorGradient;
  65953. /**
  65954. * Adds a new angular speed gradient
  65955. * @param gradient defines the gradient to use (between 0 and 1)
  65956. * @param factor defines the angular speed to affect to the specified gradient
  65957. * @returns the current particle system
  65958. */
  65959. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65960. /**
  65961. * Remove a specific angular speed gradient
  65962. * @param gradient defines the gradient to remove
  65963. * @returns the current particle system
  65964. */
  65965. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65966. /**
  65967. * Adds a new velocity gradient
  65968. * @param gradient defines the gradient to use (between 0 and 1)
  65969. * @param factor defines the velocity to affect to the specified gradient
  65970. * @returns the current particle system
  65971. */
  65972. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65973. /**
  65974. * Remove a specific velocity gradient
  65975. * @param gradient defines the gradient to remove
  65976. * @returns the current particle system
  65977. */
  65978. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65979. /**
  65980. * Adds a new limit velocity gradient
  65981. * @param gradient defines the gradient to use (between 0 and 1)
  65982. * @param factor defines the limit velocity value to affect to the specified gradient
  65983. * @returns the current particle system
  65984. */
  65985. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65986. /**
  65987. * Remove a specific limit velocity gradient
  65988. * @param gradient defines the gradient to remove
  65989. * @returns the current particle system
  65990. */
  65991. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65992. /**
  65993. * Adds a new drag gradient
  65994. * @param gradient defines the gradient to use (between 0 and 1)
  65995. * @param factor defines the drag value to affect to the specified gradient
  65996. * @returns the current particle system
  65997. */
  65998. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65999. /**
  66000. * Remove a specific drag gradient
  66001. * @param gradient defines the gradient to remove
  66002. * @returns the current particle system
  66003. */
  66004. removeDragGradient(gradient: number): GPUParticleSystem;
  66005. /**
  66006. * Not supported by GPUParticleSystem
  66007. * @param gradient defines the gradient to use (between 0 and 1)
  66008. * @param factor defines the emit rate value to affect to the specified gradient
  66009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66010. * @returns the current particle system
  66011. */
  66012. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66013. /**
  66014. * Not supported by GPUParticleSystem
  66015. * @param gradient defines the gradient to remove
  66016. * @returns the current particle system
  66017. */
  66018. removeEmitRateGradient(gradient: number): IParticleSystem;
  66019. /**
  66020. * Not supported by GPUParticleSystem
  66021. * @param gradient defines the gradient to use (between 0 and 1)
  66022. * @param factor defines the start size value to affect to the specified gradient
  66023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66024. * @returns the current particle system
  66025. */
  66026. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66027. /**
  66028. * Not supported by GPUParticleSystem
  66029. * @param gradient defines the gradient to remove
  66030. * @returns the current particle system
  66031. */
  66032. removeStartSizeGradient(gradient: number): IParticleSystem;
  66033. /**
  66034. * Not supported by GPUParticleSystem
  66035. * @param gradient defines the gradient to use (between 0 and 1)
  66036. * @param min defines the color remap minimal range
  66037. * @param max defines the color remap maximal range
  66038. * @returns the current particle system
  66039. */
  66040. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66041. /**
  66042. * Not supported by GPUParticleSystem
  66043. * @param gradient defines the gradient to remove
  66044. * @returns the current particle system
  66045. */
  66046. removeColorRemapGradient(): IParticleSystem;
  66047. /**
  66048. * Not supported by GPUParticleSystem
  66049. * @param gradient defines the gradient to use (between 0 and 1)
  66050. * @param min defines the alpha remap minimal range
  66051. * @param max defines the alpha remap maximal range
  66052. * @returns the current particle system
  66053. */
  66054. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66055. /**
  66056. * Not supported by GPUParticleSystem
  66057. * @param gradient defines the gradient to remove
  66058. * @returns the current particle system
  66059. */
  66060. removeAlphaRemapGradient(): IParticleSystem;
  66061. /**
  66062. * Not supported by GPUParticleSystem
  66063. * @param gradient defines the gradient to use (between 0 and 1)
  66064. * @param color defines the color to affect to the specified gradient
  66065. * @returns the current particle system
  66066. */
  66067. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66068. /**
  66069. * Not supported by GPUParticleSystem
  66070. * @param gradient defines the gradient to remove
  66071. * @returns the current particle system
  66072. */
  66073. removeRampGradient(): IParticleSystem;
  66074. /**
  66075. * Not supported by GPUParticleSystem
  66076. * @returns the list of ramp gradients
  66077. */
  66078. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66079. /**
  66080. * Not supported by GPUParticleSystem
  66081. * Gets or sets a boolean indicating that ramp gradients must be used
  66082. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66083. */
  66084. get useRampGradients(): boolean;
  66085. set useRampGradients(value: boolean);
  66086. /**
  66087. * Not supported by GPUParticleSystem
  66088. * @param gradient defines the gradient to use (between 0 and 1)
  66089. * @param factor defines the life time factor to affect to the specified gradient
  66090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66091. * @returns the current particle system
  66092. */
  66093. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66094. /**
  66095. * Not supported by GPUParticleSystem
  66096. * @param gradient defines the gradient to remove
  66097. * @returns the current particle system
  66098. */
  66099. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66100. /**
  66101. * Instantiates a GPU particle system.
  66102. * 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.
  66103. * @param name The name of the particle system
  66104. * @param options The options used to create the system
  66105. * @param scene The scene the particle system belongs to
  66106. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66107. * @param customEffect a custom effect used to change the way particles are rendered by default
  66108. */
  66109. constructor(name: string, options: Partial<{
  66110. capacity: number;
  66111. randomTextureSize: number;
  66112. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66113. protected _reset(): void;
  66114. private _createUpdateVAO;
  66115. private _createRenderVAO;
  66116. private _initialize;
  66117. /** @hidden */
  66118. _recreateUpdateEffect(): void;
  66119. private _getEffect;
  66120. /**
  66121. * Fill the defines array according to the current settings of the particle system
  66122. * @param defines Array to be updated
  66123. * @param blendMode blend mode to take into account when updating the array
  66124. */
  66125. fillDefines(defines: Array<string>, blendMode?: number): void;
  66126. /**
  66127. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66128. * @param uniforms Uniforms array to fill
  66129. * @param attributes Attributes array to fill
  66130. * @param samplers Samplers array to fill
  66131. */
  66132. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66133. /** @hidden */
  66134. _recreateRenderEffect(): Effect;
  66135. /**
  66136. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66137. * @param preWarm defines if we are in the pre-warmimg phase
  66138. */
  66139. animate(preWarm?: boolean): void;
  66140. private _createFactorGradientTexture;
  66141. private _createSizeGradientTexture;
  66142. private _createAngularSpeedGradientTexture;
  66143. private _createVelocityGradientTexture;
  66144. private _createLimitVelocityGradientTexture;
  66145. private _createDragGradientTexture;
  66146. private _createColorGradientTexture;
  66147. /**
  66148. * Renders the particle system in its current state
  66149. * @param preWarm defines if the system should only update the particles but not render them
  66150. * @returns the current number of particles
  66151. */
  66152. render(preWarm?: boolean): number;
  66153. /**
  66154. * Rebuilds the particle system
  66155. */
  66156. rebuild(): void;
  66157. private _releaseBuffers;
  66158. private _releaseVAOs;
  66159. /**
  66160. * Disposes the particle system and free the associated resources
  66161. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66162. */
  66163. dispose(disposeTexture?: boolean): void;
  66164. /**
  66165. * Clones the particle system.
  66166. * @param name The name of the cloned object
  66167. * @param newEmitter The new emitter to use
  66168. * @returns the cloned particle system
  66169. */
  66170. clone(name: string, newEmitter: any): GPUParticleSystem;
  66171. /**
  66172. * Serializes the particle system to a JSON object
  66173. * @param serializeTexture defines if the texture must be serialized as well
  66174. * @returns the JSON object
  66175. */
  66176. serialize(serializeTexture?: boolean): any;
  66177. /**
  66178. * Parses a JSON object to create a GPU particle system.
  66179. * @param parsedParticleSystem The JSON object to parse
  66180. * @param scene The scene to create the particle system in
  66181. * @param rootUrl The root url to use to load external dependencies like texture
  66182. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66183. * @returns the parsed GPU particle system
  66184. */
  66185. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66186. }
  66187. }
  66188. declare module BABYLON {
  66189. /**
  66190. * Represents a set of particle systems working together to create a specific effect
  66191. */
  66192. export class ParticleSystemSet implements IDisposable {
  66193. /**
  66194. * Gets or sets base Assets URL
  66195. */
  66196. static BaseAssetsUrl: string;
  66197. private _emitterCreationOptions;
  66198. private _emitterNode;
  66199. /**
  66200. * Gets the particle system list
  66201. */
  66202. systems: IParticleSystem[];
  66203. /**
  66204. * Gets the emitter node used with this set
  66205. */
  66206. get emitterNode(): Nullable<TransformNode>;
  66207. /**
  66208. * Creates a new emitter mesh as a sphere
  66209. * @param options defines the options used to create the sphere
  66210. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66211. * @param scene defines the hosting scene
  66212. */
  66213. setEmitterAsSphere(options: {
  66214. diameter: number;
  66215. segments: number;
  66216. color: Color3;
  66217. }, renderingGroupId: number, scene: Scene): void;
  66218. /**
  66219. * Starts all particle systems of the set
  66220. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66221. */
  66222. start(emitter?: AbstractMesh): void;
  66223. /**
  66224. * Release all associated resources
  66225. */
  66226. dispose(): void;
  66227. /**
  66228. * Serialize the set into a JSON compatible object
  66229. * @param serializeTexture defines if the texture must be serialized as well
  66230. * @returns a JSON compatible representation of the set
  66231. */
  66232. serialize(serializeTexture?: boolean): any;
  66233. /**
  66234. * Parse a new ParticleSystemSet from a serialized source
  66235. * @param data defines a JSON compatible representation of the set
  66236. * @param scene defines the hosting scene
  66237. * @param gpu defines if we want GPU particles or CPU particles
  66238. * @returns a new ParticleSystemSet
  66239. */
  66240. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66241. }
  66242. }
  66243. declare module BABYLON {
  66244. /**
  66245. * This class is made for on one-liner static method to help creating particle system set.
  66246. */
  66247. export class ParticleHelper {
  66248. /**
  66249. * Gets or sets base Assets URL
  66250. */
  66251. static BaseAssetsUrl: string;
  66252. /** Define the Url to load snippets */
  66253. static SnippetUrl: string;
  66254. /**
  66255. * Create a default particle system that you can tweak
  66256. * @param emitter defines the emitter to use
  66257. * @param capacity defines the system capacity (default is 500 particles)
  66258. * @param scene defines the hosting scene
  66259. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66260. * @returns the new Particle system
  66261. */
  66262. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66263. /**
  66264. * This is the main static method (one-liner) of this helper to create different particle systems
  66265. * @param type This string represents the type to the particle system to create
  66266. * @param scene The scene where the particle system should live
  66267. * @param gpu If the system will use gpu
  66268. * @returns the ParticleSystemSet created
  66269. */
  66270. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66271. /**
  66272. * Static function used to export a particle system to a ParticleSystemSet variable.
  66273. * Please note that the emitter shape is not exported
  66274. * @param systems defines the particle systems to export
  66275. * @returns the created particle system set
  66276. */
  66277. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66278. /**
  66279. * Creates a particle system from a snippet saved in a remote file
  66280. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66281. * @param url defines the url to load from
  66282. * @param scene defines the hosting scene
  66283. * @param gpu If the system will use gpu
  66284. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66285. * @returns a promise that will resolve to the new particle system
  66286. */
  66287. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66288. /**
  66289. * Creates a particle system from a snippet saved by the particle system editor
  66290. * @param snippetId defines the snippet to load
  66291. * @param scene defines the hosting scene
  66292. * @param gpu If the system will use gpu
  66293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66294. * @returns a promise that will resolve to the new particle system
  66295. */
  66296. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66297. }
  66298. }
  66299. declare module BABYLON {
  66300. interface Engine {
  66301. /**
  66302. * Create an effect to use with particle systems.
  66303. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66304. * the particle system for which you want to create a custom effect in the last parameter
  66305. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66306. * @param uniformsNames defines a list of attribute names
  66307. * @param samplers defines an array of string used to represent textures
  66308. * @param defines defines the string containing the defines to use to compile the shaders
  66309. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66310. * @param onCompiled defines a function to call when the effect creation is successful
  66311. * @param onError defines a function to call when the effect creation has failed
  66312. * @param particleSystem the particle system you want to create the effect for
  66313. * @returns the new Effect
  66314. */
  66315. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66316. }
  66317. interface Mesh {
  66318. /**
  66319. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66320. * @returns an array of IParticleSystem
  66321. */
  66322. getEmittedParticleSystems(): IParticleSystem[];
  66323. /**
  66324. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66325. * @returns an array of IParticleSystem
  66326. */
  66327. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66328. }
  66329. }
  66330. declare module BABYLON {
  66331. /** Defines the 4 color options */
  66332. export enum PointColor {
  66333. /** color value */
  66334. Color = 2,
  66335. /** uv value */
  66336. UV = 1,
  66337. /** random value */
  66338. Random = 0,
  66339. /** stated value */
  66340. Stated = 3
  66341. }
  66342. /**
  66343. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66344. * 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.
  66345. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66346. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66347. *
  66348. * Full documentation here : TO BE ENTERED
  66349. */
  66350. export class PointsCloudSystem implements IDisposable {
  66351. /**
  66352. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66353. * Example : var p = SPS.particles[i];
  66354. */
  66355. particles: CloudPoint[];
  66356. /**
  66357. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66358. */
  66359. nbParticles: number;
  66360. /**
  66361. * This a counter for your own usage. It's not set by any SPS functions.
  66362. */
  66363. counter: number;
  66364. /**
  66365. * The PCS name. This name is also given to the underlying mesh.
  66366. */
  66367. name: string;
  66368. /**
  66369. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66370. */
  66371. mesh: Mesh;
  66372. /**
  66373. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66374. * Please read :
  66375. */
  66376. vars: any;
  66377. /**
  66378. * @hidden
  66379. */
  66380. _size: number;
  66381. private _scene;
  66382. private _promises;
  66383. private _positions;
  66384. private _indices;
  66385. private _normals;
  66386. private _colors;
  66387. private _uvs;
  66388. private _indices32;
  66389. private _positions32;
  66390. private _colors32;
  66391. private _uvs32;
  66392. private _updatable;
  66393. private _isVisibilityBoxLocked;
  66394. private _alwaysVisible;
  66395. private _groups;
  66396. private _groupCounter;
  66397. private _computeParticleColor;
  66398. private _computeParticleTexture;
  66399. private _computeParticleRotation;
  66400. private _computeBoundingBox;
  66401. private _isReady;
  66402. /**
  66403. * Creates a PCS (Points Cloud System) object
  66404. * @param name (String) is the PCS name, this will be the underlying mesh name
  66405. * @param pointSize (number) is the size for each point
  66406. * @param scene (Scene) is the scene in which the PCS is added
  66407. * @param options defines the options of the PCS e.g.
  66408. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66409. */
  66410. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66411. updatable?: boolean;
  66412. });
  66413. /**
  66414. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66415. * If no points were added to the PCS, the returned mesh is just a single point.
  66416. * @returns a promise for the created mesh
  66417. */
  66418. buildMeshAsync(): Promise<Mesh>;
  66419. /**
  66420. * @hidden
  66421. */
  66422. private _buildMesh;
  66423. private _addParticle;
  66424. private _randomUnitVector;
  66425. private _getColorIndicesForCoord;
  66426. private _setPointsColorOrUV;
  66427. private _colorFromTexture;
  66428. private _calculateDensity;
  66429. /**
  66430. * Adds points to the PCS in random positions within a unit sphere
  66431. * @param nb (positive integer) the number of particles to be created from this model
  66432. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66433. * @returns the number of groups in the system
  66434. */
  66435. addPoints(nb: number, pointFunction?: any): number;
  66436. /**
  66437. * Adds points to the PCS from the surface of the model shape
  66438. * @param mesh is any Mesh object that will be used as a surface model for the points
  66439. * @param nb (positive integer) the number of particles to be created from this model
  66440. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66441. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66442. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66443. * @returns the number of groups in the system
  66444. */
  66445. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66446. /**
  66447. * Adds points to the PCS inside the model shape
  66448. * @param mesh is any Mesh object that will be used as a surface model for the points
  66449. * @param nb (positive integer) the number of particles to be created from this model
  66450. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66451. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66452. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66453. * @returns the number of groups in the system
  66454. */
  66455. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66456. /**
  66457. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66458. * This method calls `updateParticle()` for each particle of the SPS.
  66459. * For an animated SPS, it is usually called within the render loop.
  66460. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66461. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66462. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66463. * @returns the PCS.
  66464. */
  66465. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66466. /**
  66467. * Disposes the PCS.
  66468. */
  66469. dispose(): void;
  66470. /**
  66471. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66472. * doc :
  66473. * @returns the PCS.
  66474. */
  66475. refreshVisibleSize(): PointsCloudSystem;
  66476. /**
  66477. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66478. * @param size the size (float) of the visibility box
  66479. * note : this doesn't lock the PCS mesh bounding box.
  66480. * doc :
  66481. */
  66482. setVisibilityBox(size: number): void;
  66483. /**
  66484. * Gets whether the PCS is always visible or not
  66485. * doc :
  66486. */
  66487. get isAlwaysVisible(): boolean;
  66488. /**
  66489. * Sets the PCS as always visible or not
  66490. * doc :
  66491. */
  66492. set isAlwaysVisible(val: boolean);
  66493. /**
  66494. * Tells to `setParticles()` to compute the particle rotations or not
  66495. * Default value : false. The PCS is faster when it's set to false
  66496. * Note : particle rotations are only applied to parent particles
  66497. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66498. */
  66499. set computeParticleRotation(val: boolean);
  66500. /**
  66501. * Tells to `setParticles()` to compute the particle colors or not.
  66502. * Default value : true. The PCS is faster when it's set to false.
  66503. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66504. */
  66505. set computeParticleColor(val: boolean);
  66506. set computeParticleTexture(val: boolean);
  66507. /**
  66508. * Gets if `setParticles()` computes the particle colors or not.
  66509. * Default value : false. The PCS is faster when it's set to false.
  66510. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66511. */
  66512. get computeParticleColor(): boolean;
  66513. /**
  66514. * Gets if `setParticles()` computes the particle textures or not.
  66515. * Default value : false. The PCS is faster when it's set to false.
  66516. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66517. */
  66518. get computeParticleTexture(): boolean;
  66519. /**
  66520. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66521. */
  66522. set computeBoundingBox(val: boolean);
  66523. /**
  66524. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66525. */
  66526. get computeBoundingBox(): boolean;
  66527. /**
  66528. * This function does nothing. It may be overwritten to set all the particle first values.
  66529. * The PCS doesn't call this function, you may have to call it by your own.
  66530. * doc :
  66531. */
  66532. initParticles(): void;
  66533. /**
  66534. * This function does nothing. It may be overwritten to recycle a particle
  66535. * The PCS doesn't call this function, you can to call it
  66536. * doc :
  66537. * @param particle The particle to recycle
  66538. * @returns the recycled particle
  66539. */
  66540. recycleParticle(particle: CloudPoint): CloudPoint;
  66541. /**
  66542. * Updates a particle : this function should be overwritten by the user.
  66543. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66544. * doc :
  66545. * @example : just set a particle position or velocity and recycle conditions
  66546. * @param particle The particle to update
  66547. * @returns the updated particle
  66548. */
  66549. updateParticle(particle: CloudPoint): CloudPoint;
  66550. /**
  66551. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66552. * This does nothing and may be overwritten by the user.
  66553. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66554. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66555. * @param update the boolean update value actually passed to setParticles()
  66556. */
  66557. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66558. /**
  66559. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66560. * This will be passed three parameters.
  66561. * This does nothing and may be overwritten by the user.
  66562. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66563. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66564. * @param update the boolean update value actually passed to setParticles()
  66565. */
  66566. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66567. }
  66568. }
  66569. declare module BABYLON {
  66570. /**
  66571. * Represents one particle of a points cloud system.
  66572. */
  66573. export class CloudPoint {
  66574. /**
  66575. * particle global index
  66576. */
  66577. idx: number;
  66578. /**
  66579. * The color of the particle
  66580. */
  66581. color: Nullable<Color4>;
  66582. /**
  66583. * The world space position of the particle.
  66584. */
  66585. position: Vector3;
  66586. /**
  66587. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66588. */
  66589. rotation: Vector3;
  66590. /**
  66591. * The world space rotation quaternion of the particle.
  66592. */
  66593. rotationQuaternion: Nullable<Quaternion>;
  66594. /**
  66595. * The uv of the particle.
  66596. */
  66597. uv: Nullable<Vector2>;
  66598. /**
  66599. * The current speed of the particle.
  66600. */
  66601. velocity: Vector3;
  66602. /**
  66603. * The pivot point in the particle local space.
  66604. */
  66605. pivot: Vector3;
  66606. /**
  66607. * Must the particle be translated from its pivot point in its local space ?
  66608. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66609. * Default : false
  66610. */
  66611. translateFromPivot: boolean;
  66612. /**
  66613. * Index of this particle in the global "positions" array (Internal use)
  66614. * @hidden
  66615. */
  66616. _pos: number;
  66617. /**
  66618. * @hidden Index of this particle in the global "indices" array (Internal use)
  66619. */
  66620. _ind: number;
  66621. /**
  66622. * Group this particle belongs to
  66623. */
  66624. _group: PointsGroup;
  66625. /**
  66626. * Group id of this particle
  66627. */
  66628. groupId: number;
  66629. /**
  66630. * Index of the particle in its group id (Internal use)
  66631. */
  66632. idxInGroup: number;
  66633. /**
  66634. * @hidden Particle BoundingInfo object (Internal use)
  66635. */
  66636. _boundingInfo: BoundingInfo;
  66637. /**
  66638. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66639. */
  66640. _pcs: PointsCloudSystem;
  66641. /**
  66642. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66643. */
  66644. _stillInvisible: boolean;
  66645. /**
  66646. * @hidden Last computed particle rotation matrix
  66647. */
  66648. _rotationMatrix: number[];
  66649. /**
  66650. * Parent particle Id, if any.
  66651. * Default null.
  66652. */
  66653. parentId: Nullable<number>;
  66654. /**
  66655. * @hidden Internal global position in the PCS.
  66656. */
  66657. _globalPosition: Vector3;
  66658. /**
  66659. * Creates a Point Cloud object.
  66660. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66661. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66662. * @param group (PointsGroup) is the group the particle belongs to
  66663. * @param groupId (integer) is the group identifier in the PCS.
  66664. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66665. * @param pcs defines the PCS it is associated to
  66666. */
  66667. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66668. /**
  66669. * get point size
  66670. */
  66671. get size(): Vector3;
  66672. /**
  66673. * Set point size
  66674. */
  66675. set size(scale: Vector3);
  66676. /**
  66677. * Legacy support, changed quaternion to rotationQuaternion
  66678. */
  66679. get quaternion(): Nullable<Quaternion>;
  66680. /**
  66681. * Legacy support, changed quaternion to rotationQuaternion
  66682. */
  66683. set quaternion(q: Nullable<Quaternion>);
  66684. /**
  66685. * Returns a boolean. True if the particle intersects a mesh, else false
  66686. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66687. * @param target is the object (point or mesh) what the intersection is computed against
  66688. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66689. * @returns true if it intersects
  66690. */
  66691. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66692. /**
  66693. * get the rotation matrix of the particle
  66694. * @hidden
  66695. */
  66696. getRotationMatrix(m: Matrix): void;
  66697. }
  66698. /**
  66699. * Represents a group of points in a points cloud system
  66700. * * PCS internal tool, don't use it manually.
  66701. */
  66702. export class PointsGroup {
  66703. /**
  66704. * The group id
  66705. * @hidden
  66706. */
  66707. groupID: number;
  66708. /**
  66709. * image data for group (internal use)
  66710. * @hidden
  66711. */
  66712. _groupImageData: Nullable<ArrayBufferView>;
  66713. /**
  66714. * Image Width (internal use)
  66715. * @hidden
  66716. */
  66717. _groupImgWidth: number;
  66718. /**
  66719. * Image Height (internal use)
  66720. * @hidden
  66721. */
  66722. _groupImgHeight: number;
  66723. /**
  66724. * Custom position function (internal use)
  66725. * @hidden
  66726. */
  66727. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66728. /**
  66729. * density per facet for surface points
  66730. * @hidden
  66731. */
  66732. _groupDensity: number[];
  66733. /**
  66734. * Only when points are colored by texture carries pointer to texture list array
  66735. * @hidden
  66736. */
  66737. _textureNb: number;
  66738. /**
  66739. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66740. * PCS internal tool, don't use it manually.
  66741. * @hidden
  66742. */
  66743. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66744. }
  66745. }
  66746. declare module BABYLON {
  66747. interface Scene {
  66748. /** @hidden (Backing field) */
  66749. _physicsEngine: Nullable<IPhysicsEngine>;
  66750. /** @hidden */
  66751. _physicsTimeAccumulator: number;
  66752. /**
  66753. * Gets the current physics engine
  66754. * @returns a IPhysicsEngine or null if none attached
  66755. */
  66756. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66757. /**
  66758. * Enables physics to the current scene
  66759. * @param gravity defines the scene's gravity for the physics engine
  66760. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66761. * @return a boolean indicating if the physics engine was initialized
  66762. */
  66763. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66764. /**
  66765. * Disables and disposes the physics engine associated with the scene
  66766. */
  66767. disablePhysicsEngine(): void;
  66768. /**
  66769. * Gets a boolean indicating if there is an active physics engine
  66770. * @returns a boolean indicating if there is an active physics engine
  66771. */
  66772. isPhysicsEnabled(): boolean;
  66773. /**
  66774. * Deletes a physics compound impostor
  66775. * @param compound defines the compound to delete
  66776. */
  66777. deleteCompoundImpostor(compound: any): void;
  66778. /**
  66779. * An event triggered when physic simulation is about to be run
  66780. */
  66781. onBeforePhysicsObservable: Observable<Scene>;
  66782. /**
  66783. * An event triggered when physic simulation has been done
  66784. */
  66785. onAfterPhysicsObservable: Observable<Scene>;
  66786. }
  66787. interface AbstractMesh {
  66788. /** @hidden */
  66789. _physicsImpostor: Nullable<PhysicsImpostor>;
  66790. /**
  66791. * Gets or sets impostor used for physic simulation
  66792. * @see http://doc.babylonjs.com/features/physics_engine
  66793. */
  66794. physicsImpostor: Nullable<PhysicsImpostor>;
  66795. /**
  66796. * Gets the current physics impostor
  66797. * @see http://doc.babylonjs.com/features/physics_engine
  66798. * @returns a physics impostor or null
  66799. */
  66800. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66801. /** Apply a physic impulse to the mesh
  66802. * @param force defines the force to apply
  66803. * @param contactPoint defines where to apply the force
  66804. * @returns the current mesh
  66805. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66806. */
  66807. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66808. /**
  66809. * Creates a physic joint between two meshes
  66810. * @param otherMesh defines the other mesh to use
  66811. * @param pivot1 defines the pivot to use on this mesh
  66812. * @param pivot2 defines the pivot to use on the other mesh
  66813. * @param options defines additional options (can be plugin dependent)
  66814. * @returns the current mesh
  66815. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66816. */
  66817. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66818. /** @hidden */
  66819. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66820. }
  66821. /**
  66822. * Defines the physics engine scene component responsible to manage a physics engine
  66823. */
  66824. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66825. /**
  66826. * The component name helpful to identify the component in the list of scene components.
  66827. */
  66828. readonly name: string;
  66829. /**
  66830. * The scene the component belongs to.
  66831. */
  66832. scene: Scene;
  66833. /**
  66834. * Creates a new instance of the component for the given scene
  66835. * @param scene Defines the scene to register the component in
  66836. */
  66837. constructor(scene: Scene);
  66838. /**
  66839. * Registers the component in a given scene
  66840. */
  66841. register(): void;
  66842. /**
  66843. * Rebuilds the elements related to this component in case of
  66844. * context lost for instance.
  66845. */
  66846. rebuild(): void;
  66847. /**
  66848. * Disposes the component and the associated ressources
  66849. */
  66850. dispose(): void;
  66851. }
  66852. }
  66853. declare module BABYLON {
  66854. /**
  66855. * A helper for physics simulations
  66856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66857. */
  66858. export class PhysicsHelper {
  66859. private _scene;
  66860. private _physicsEngine;
  66861. /**
  66862. * Initializes the Physics helper
  66863. * @param scene Babylon.js scene
  66864. */
  66865. constructor(scene: Scene);
  66866. /**
  66867. * Applies a radial explosion impulse
  66868. * @param origin the origin of the explosion
  66869. * @param radiusOrEventOptions the radius or the options of radial explosion
  66870. * @param strength the explosion strength
  66871. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66872. * @returns A physics radial explosion event, or null
  66873. */
  66874. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66875. /**
  66876. * Applies a radial explosion force
  66877. * @param origin the origin of the explosion
  66878. * @param radiusOrEventOptions the radius or the options of radial explosion
  66879. * @param strength the explosion strength
  66880. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66881. * @returns A physics radial explosion event, or null
  66882. */
  66883. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66884. /**
  66885. * Creates a gravitational field
  66886. * @param origin the origin of the explosion
  66887. * @param radiusOrEventOptions the radius or the options of radial explosion
  66888. * @param strength the explosion strength
  66889. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66890. * @returns A physics gravitational field event, or null
  66891. */
  66892. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66893. /**
  66894. * Creates a physics updraft event
  66895. * @param origin the origin of the updraft
  66896. * @param radiusOrEventOptions the radius or the options of the updraft
  66897. * @param strength the strength of the updraft
  66898. * @param height the height of the updraft
  66899. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66900. * @returns A physics updraft event, or null
  66901. */
  66902. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66903. /**
  66904. * Creates a physics vortex event
  66905. * @param origin the of the vortex
  66906. * @param radiusOrEventOptions the radius or the options of the vortex
  66907. * @param strength the strength of the vortex
  66908. * @param height the height of the vortex
  66909. * @returns a Physics vortex event, or null
  66910. * A physics vortex event or null
  66911. */
  66912. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66913. }
  66914. /**
  66915. * Represents a physics radial explosion event
  66916. */
  66917. class PhysicsRadialExplosionEvent {
  66918. private _scene;
  66919. private _options;
  66920. private _sphere;
  66921. private _dataFetched;
  66922. /**
  66923. * Initializes a radial explosioin event
  66924. * @param _scene BabylonJS scene
  66925. * @param _options The options for the vortex event
  66926. */
  66927. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66928. /**
  66929. * Returns the data related to the radial explosion event (sphere).
  66930. * @returns The radial explosion event data
  66931. */
  66932. getData(): PhysicsRadialExplosionEventData;
  66933. /**
  66934. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66935. * @param impostor A physics imposter
  66936. * @param origin the origin of the explosion
  66937. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66938. */
  66939. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66940. /**
  66941. * Triggers affecterd impostors callbacks
  66942. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66943. */
  66944. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66945. /**
  66946. * Disposes the sphere.
  66947. * @param force Specifies if the sphere should be disposed by force
  66948. */
  66949. dispose(force?: boolean): void;
  66950. /*** Helpers ***/
  66951. private _prepareSphere;
  66952. private _intersectsWithSphere;
  66953. }
  66954. /**
  66955. * Represents a gravitational field event
  66956. */
  66957. class PhysicsGravitationalFieldEvent {
  66958. private _physicsHelper;
  66959. private _scene;
  66960. private _origin;
  66961. private _options;
  66962. private _tickCallback;
  66963. private _sphere;
  66964. private _dataFetched;
  66965. /**
  66966. * Initializes the physics gravitational field event
  66967. * @param _physicsHelper A physics helper
  66968. * @param _scene BabylonJS scene
  66969. * @param _origin The origin position of the gravitational field event
  66970. * @param _options The options for the vortex event
  66971. */
  66972. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66973. /**
  66974. * Returns the data related to the gravitational field event (sphere).
  66975. * @returns A gravitational field event
  66976. */
  66977. getData(): PhysicsGravitationalFieldEventData;
  66978. /**
  66979. * Enables the gravitational field.
  66980. */
  66981. enable(): void;
  66982. /**
  66983. * Disables the gravitational field.
  66984. */
  66985. disable(): void;
  66986. /**
  66987. * Disposes the sphere.
  66988. * @param force The force to dispose from the gravitational field event
  66989. */
  66990. dispose(force?: boolean): void;
  66991. private _tick;
  66992. }
  66993. /**
  66994. * Represents a physics updraft event
  66995. */
  66996. class PhysicsUpdraftEvent {
  66997. private _scene;
  66998. private _origin;
  66999. private _options;
  67000. private _physicsEngine;
  67001. private _originTop;
  67002. private _originDirection;
  67003. private _tickCallback;
  67004. private _cylinder;
  67005. private _cylinderPosition;
  67006. private _dataFetched;
  67007. /**
  67008. * Initializes the physics updraft event
  67009. * @param _scene BabylonJS scene
  67010. * @param _origin The origin position of the updraft
  67011. * @param _options The options for the updraft event
  67012. */
  67013. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67014. /**
  67015. * Returns the data related to the updraft event (cylinder).
  67016. * @returns A physics updraft event
  67017. */
  67018. getData(): PhysicsUpdraftEventData;
  67019. /**
  67020. * Enables the updraft.
  67021. */
  67022. enable(): void;
  67023. /**
  67024. * Disables the updraft.
  67025. */
  67026. disable(): void;
  67027. /**
  67028. * Disposes the cylinder.
  67029. * @param force Specifies if the updraft should be disposed by force
  67030. */
  67031. dispose(force?: boolean): void;
  67032. private getImpostorHitData;
  67033. private _tick;
  67034. /*** Helpers ***/
  67035. private _prepareCylinder;
  67036. private _intersectsWithCylinder;
  67037. }
  67038. /**
  67039. * Represents a physics vortex event
  67040. */
  67041. class PhysicsVortexEvent {
  67042. private _scene;
  67043. private _origin;
  67044. private _options;
  67045. private _physicsEngine;
  67046. private _originTop;
  67047. private _tickCallback;
  67048. private _cylinder;
  67049. private _cylinderPosition;
  67050. private _dataFetched;
  67051. /**
  67052. * Initializes the physics vortex event
  67053. * @param _scene The BabylonJS scene
  67054. * @param _origin The origin position of the vortex
  67055. * @param _options The options for the vortex event
  67056. */
  67057. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67058. /**
  67059. * Returns the data related to the vortex event (cylinder).
  67060. * @returns The physics vortex event data
  67061. */
  67062. getData(): PhysicsVortexEventData;
  67063. /**
  67064. * Enables the vortex.
  67065. */
  67066. enable(): void;
  67067. /**
  67068. * Disables the cortex.
  67069. */
  67070. disable(): void;
  67071. /**
  67072. * Disposes the sphere.
  67073. * @param force
  67074. */
  67075. dispose(force?: boolean): void;
  67076. private getImpostorHitData;
  67077. private _tick;
  67078. /*** Helpers ***/
  67079. private _prepareCylinder;
  67080. private _intersectsWithCylinder;
  67081. }
  67082. /**
  67083. * Options fot the radial explosion event
  67084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67085. */
  67086. export class PhysicsRadialExplosionEventOptions {
  67087. /**
  67088. * The radius of the sphere for the radial explosion.
  67089. */
  67090. radius: number;
  67091. /**
  67092. * The strenth of the explosion.
  67093. */
  67094. strength: number;
  67095. /**
  67096. * The strenght of the force in correspondence to the distance of the affected object
  67097. */
  67098. falloff: PhysicsRadialImpulseFalloff;
  67099. /**
  67100. * Sphere options for the radial explosion.
  67101. */
  67102. sphere: {
  67103. segments: number;
  67104. diameter: number;
  67105. };
  67106. /**
  67107. * Sphere options for the radial explosion.
  67108. */
  67109. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67110. }
  67111. /**
  67112. * Options fot the updraft event
  67113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67114. */
  67115. export class PhysicsUpdraftEventOptions {
  67116. /**
  67117. * The radius of the cylinder for the vortex
  67118. */
  67119. radius: number;
  67120. /**
  67121. * The strenth of the updraft.
  67122. */
  67123. strength: number;
  67124. /**
  67125. * The height of the cylinder for the updraft.
  67126. */
  67127. height: number;
  67128. /**
  67129. * The mode for the the updraft.
  67130. */
  67131. updraftMode: PhysicsUpdraftMode;
  67132. }
  67133. /**
  67134. * Options fot the vortex event
  67135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67136. */
  67137. export class PhysicsVortexEventOptions {
  67138. /**
  67139. * The radius of the cylinder for the vortex
  67140. */
  67141. radius: number;
  67142. /**
  67143. * The strenth of the vortex.
  67144. */
  67145. strength: number;
  67146. /**
  67147. * The height of the cylinder for the vortex.
  67148. */
  67149. height: number;
  67150. /**
  67151. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67152. */
  67153. centripetalForceThreshold: number;
  67154. /**
  67155. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67156. */
  67157. centripetalForceMultiplier: number;
  67158. /**
  67159. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67160. */
  67161. centrifugalForceMultiplier: number;
  67162. /**
  67163. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67164. */
  67165. updraftForceMultiplier: number;
  67166. }
  67167. /**
  67168. * The strenght of the force in correspondence to the distance of the affected object
  67169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67170. */
  67171. export enum PhysicsRadialImpulseFalloff {
  67172. /** Defines that impulse is constant in strength across it's whole radius */
  67173. Constant = 0,
  67174. /** Defines that impulse gets weaker if it's further from the origin */
  67175. Linear = 1
  67176. }
  67177. /**
  67178. * The strength of the force in correspondence to the distance of the affected object
  67179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67180. */
  67181. export enum PhysicsUpdraftMode {
  67182. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67183. Center = 0,
  67184. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67185. Perpendicular = 1
  67186. }
  67187. /**
  67188. * Interface for a physics hit data
  67189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67190. */
  67191. export interface PhysicsHitData {
  67192. /**
  67193. * The force applied at the contact point
  67194. */
  67195. force: Vector3;
  67196. /**
  67197. * The contact point
  67198. */
  67199. contactPoint: Vector3;
  67200. /**
  67201. * The distance from the origin to the contact point
  67202. */
  67203. distanceFromOrigin: number;
  67204. }
  67205. /**
  67206. * Interface for radial explosion event data
  67207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67208. */
  67209. export interface PhysicsRadialExplosionEventData {
  67210. /**
  67211. * A sphere used for the radial explosion event
  67212. */
  67213. sphere: Mesh;
  67214. }
  67215. /**
  67216. * Interface for gravitational field event data
  67217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67218. */
  67219. export interface PhysicsGravitationalFieldEventData {
  67220. /**
  67221. * A sphere mesh used for the gravitational field event
  67222. */
  67223. sphere: Mesh;
  67224. }
  67225. /**
  67226. * Interface for updraft event data
  67227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67228. */
  67229. export interface PhysicsUpdraftEventData {
  67230. /**
  67231. * A cylinder used for the updraft event
  67232. */
  67233. cylinder: Mesh;
  67234. }
  67235. /**
  67236. * Interface for vortex event data
  67237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67238. */
  67239. export interface PhysicsVortexEventData {
  67240. /**
  67241. * A cylinder used for the vortex event
  67242. */
  67243. cylinder: Mesh;
  67244. }
  67245. /**
  67246. * Interface for an affected physics impostor
  67247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67248. */
  67249. export interface PhysicsAffectedImpostorWithData {
  67250. /**
  67251. * The impostor affected by the effect
  67252. */
  67253. impostor: PhysicsImpostor;
  67254. /**
  67255. * The data about the hit/horce from the explosion
  67256. */
  67257. hitData: PhysicsHitData;
  67258. }
  67259. }
  67260. declare module BABYLON {
  67261. /** @hidden */
  67262. export var blackAndWhitePixelShader: {
  67263. name: string;
  67264. shader: string;
  67265. };
  67266. }
  67267. declare module BABYLON {
  67268. /**
  67269. * Post process used to render in black and white
  67270. */
  67271. export class BlackAndWhitePostProcess extends PostProcess {
  67272. /**
  67273. * Linear about to convert he result to black and white (default: 1)
  67274. */
  67275. degree: number;
  67276. /**
  67277. * Creates a black and white post process
  67278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67279. * @param name The name of the effect.
  67280. * @param options The required width/height ratio to downsize to before computing the render pass.
  67281. * @param camera The camera to apply the render pass to.
  67282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67283. * @param engine The engine which the post process will be applied. (default: current engine)
  67284. * @param reusable If the post process can be reused on the same frame. (default: false)
  67285. */
  67286. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67287. }
  67288. }
  67289. declare module BABYLON {
  67290. /**
  67291. * This represents a set of one or more post processes in Babylon.
  67292. * A post process can be used to apply a shader to a texture after it is rendered.
  67293. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67294. */
  67295. export class PostProcessRenderEffect {
  67296. private _postProcesses;
  67297. private _getPostProcesses;
  67298. private _singleInstance;
  67299. private _cameras;
  67300. private _indicesForCamera;
  67301. /**
  67302. * Name of the effect
  67303. * @hidden
  67304. */
  67305. _name: string;
  67306. /**
  67307. * Instantiates a post process render effect.
  67308. * A post process can be used to apply a shader to a texture after it is rendered.
  67309. * @param engine The engine the effect is tied to
  67310. * @param name The name of the effect
  67311. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67312. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67313. */
  67314. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67315. /**
  67316. * Checks if all the post processes in the effect are supported.
  67317. */
  67318. get isSupported(): boolean;
  67319. /**
  67320. * Updates the current state of the effect
  67321. * @hidden
  67322. */
  67323. _update(): void;
  67324. /**
  67325. * Attaches the effect on cameras
  67326. * @param cameras The camera to attach to.
  67327. * @hidden
  67328. */
  67329. _attachCameras(cameras: Camera): void;
  67330. /**
  67331. * Attaches the effect on cameras
  67332. * @param cameras The camera to attach to.
  67333. * @hidden
  67334. */
  67335. _attachCameras(cameras: Camera[]): void;
  67336. /**
  67337. * Detaches the effect on cameras
  67338. * @param cameras The camera to detatch from.
  67339. * @hidden
  67340. */
  67341. _detachCameras(cameras: Camera): void;
  67342. /**
  67343. * Detatches the effect on cameras
  67344. * @param cameras The camera to detatch from.
  67345. * @hidden
  67346. */
  67347. _detachCameras(cameras: Camera[]): void;
  67348. /**
  67349. * Enables the effect on given cameras
  67350. * @param cameras The camera to enable.
  67351. * @hidden
  67352. */
  67353. _enable(cameras: Camera): void;
  67354. /**
  67355. * Enables the effect on given cameras
  67356. * @param cameras The camera to enable.
  67357. * @hidden
  67358. */
  67359. _enable(cameras: Nullable<Camera[]>): void;
  67360. /**
  67361. * Disables the effect on the given cameras
  67362. * @param cameras The camera to disable.
  67363. * @hidden
  67364. */
  67365. _disable(cameras: Camera): void;
  67366. /**
  67367. * Disables the effect on the given cameras
  67368. * @param cameras The camera to disable.
  67369. * @hidden
  67370. */
  67371. _disable(cameras: Nullable<Camera[]>): void;
  67372. /**
  67373. * Gets a list of the post processes contained in the effect.
  67374. * @param camera The camera to get the post processes on.
  67375. * @returns The list of the post processes in the effect.
  67376. */
  67377. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67378. }
  67379. }
  67380. declare module BABYLON {
  67381. /** @hidden */
  67382. export var extractHighlightsPixelShader: {
  67383. name: string;
  67384. shader: string;
  67385. };
  67386. }
  67387. declare module BABYLON {
  67388. /**
  67389. * 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.
  67390. */
  67391. export class ExtractHighlightsPostProcess extends PostProcess {
  67392. /**
  67393. * The luminance threshold, pixels below this value will be set to black.
  67394. */
  67395. threshold: number;
  67396. /** @hidden */
  67397. _exposure: number;
  67398. /**
  67399. * Post process which has the input texture to be used when performing highlight extraction
  67400. * @hidden
  67401. */
  67402. _inputPostProcess: Nullable<PostProcess>;
  67403. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67404. }
  67405. }
  67406. declare module BABYLON {
  67407. /** @hidden */
  67408. export var bloomMergePixelShader: {
  67409. name: string;
  67410. shader: string;
  67411. };
  67412. }
  67413. declare module BABYLON {
  67414. /**
  67415. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67416. */
  67417. export class BloomMergePostProcess extends PostProcess {
  67418. /** Weight of the bloom to be added to the original input. */
  67419. weight: number;
  67420. /**
  67421. * Creates a new instance of @see BloomMergePostProcess
  67422. * @param name The name of the effect.
  67423. * @param originalFromInput Post process which's input will be used for the merge.
  67424. * @param blurred Blurred highlights post process which's output will be used.
  67425. * @param weight Weight of the bloom to be added to the original input.
  67426. * @param options The required width/height ratio to downsize to before computing the render pass.
  67427. * @param camera The camera to apply the render pass to.
  67428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67429. * @param engine The engine which the post process will be applied. (default: current engine)
  67430. * @param reusable If the post process can be reused on the same frame. (default: false)
  67431. * @param textureType Type of textures used when performing the post process. (default: 0)
  67432. * @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)
  67433. */
  67434. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67435. /** Weight of the bloom to be added to the original input. */
  67436. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67437. }
  67438. }
  67439. declare module BABYLON {
  67440. /**
  67441. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67442. */
  67443. export class BloomEffect extends PostProcessRenderEffect {
  67444. private bloomScale;
  67445. /**
  67446. * @hidden Internal
  67447. */
  67448. _effects: Array<PostProcess>;
  67449. /**
  67450. * @hidden Internal
  67451. */
  67452. _downscale: ExtractHighlightsPostProcess;
  67453. private _blurX;
  67454. private _blurY;
  67455. private _merge;
  67456. /**
  67457. * The luminance threshold to find bright areas of the image to bloom.
  67458. */
  67459. get threshold(): number;
  67460. set threshold(value: number);
  67461. /**
  67462. * The strength of the bloom.
  67463. */
  67464. get weight(): number;
  67465. set weight(value: number);
  67466. /**
  67467. * Specifies the size of the bloom blur kernel, relative to the final output size
  67468. */
  67469. get kernel(): number;
  67470. set kernel(value: number);
  67471. /**
  67472. * Creates a new instance of @see BloomEffect
  67473. * @param scene The scene the effect belongs to.
  67474. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67475. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67476. * @param bloomWeight The the strength of bloom.
  67477. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67478. * @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)
  67479. */
  67480. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67481. /**
  67482. * Disposes each of the internal effects for a given camera.
  67483. * @param camera The camera to dispose the effect on.
  67484. */
  67485. disposeEffects(camera: Camera): void;
  67486. /**
  67487. * @hidden Internal
  67488. */
  67489. _updateEffects(): void;
  67490. /**
  67491. * Internal
  67492. * @returns if all the contained post processes are ready.
  67493. * @hidden
  67494. */
  67495. _isReady(): boolean;
  67496. }
  67497. }
  67498. declare module BABYLON {
  67499. /** @hidden */
  67500. export var chromaticAberrationPixelShader: {
  67501. name: string;
  67502. shader: string;
  67503. };
  67504. }
  67505. declare module BABYLON {
  67506. /**
  67507. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67508. */
  67509. export class ChromaticAberrationPostProcess extends PostProcess {
  67510. /**
  67511. * The amount of seperation of rgb channels (default: 30)
  67512. */
  67513. aberrationAmount: number;
  67514. /**
  67515. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67516. */
  67517. radialIntensity: number;
  67518. /**
  67519. * 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))
  67520. */
  67521. direction: Vector2;
  67522. /**
  67523. * 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))
  67524. */
  67525. centerPosition: Vector2;
  67526. /**
  67527. * Creates a new instance ChromaticAberrationPostProcess
  67528. * @param name The name of the effect.
  67529. * @param screenWidth The width of the screen to apply the effect on.
  67530. * @param screenHeight The height of the screen to apply the effect on.
  67531. * @param options The required width/height ratio to downsize to before computing the render pass.
  67532. * @param camera The camera to apply the render pass to.
  67533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67534. * @param engine The engine which the post process will be applied. (default: current engine)
  67535. * @param reusable If the post process can be reused on the same frame. (default: false)
  67536. * @param textureType Type of textures used when performing the post process. (default: 0)
  67537. * @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)
  67538. */
  67539. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67540. }
  67541. }
  67542. declare module BABYLON {
  67543. /** @hidden */
  67544. export var circleOfConfusionPixelShader: {
  67545. name: string;
  67546. shader: string;
  67547. };
  67548. }
  67549. declare module BABYLON {
  67550. /**
  67551. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67552. */
  67553. export class CircleOfConfusionPostProcess extends PostProcess {
  67554. /**
  67555. * 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.
  67556. */
  67557. lensSize: number;
  67558. /**
  67559. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67560. */
  67561. fStop: number;
  67562. /**
  67563. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67564. */
  67565. focusDistance: number;
  67566. /**
  67567. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67568. */
  67569. focalLength: number;
  67570. private _depthTexture;
  67571. /**
  67572. * Creates a new instance CircleOfConfusionPostProcess
  67573. * @param name The name of the effect.
  67574. * @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.
  67575. * @param options The required width/height ratio to downsize to before computing the render pass.
  67576. * @param camera The camera to apply the render pass to.
  67577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67578. * @param engine The engine which the post process will be applied. (default: current engine)
  67579. * @param reusable If the post process can be reused on the same frame. (default: false)
  67580. * @param textureType Type of textures used when performing the post process. (default: 0)
  67581. * @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)
  67582. */
  67583. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67584. /**
  67585. * 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.
  67586. */
  67587. set depthTexture(value: RenderTargetTexture);
  67588. }
  67589. }
  67590. declare module BABYLON {
  67591. /** @hidden */
  67592. export var colorCorrectionPixelShader: {
  67593. name: string;
  67594. shader: string;
  67595. };
  67596. }
  67597. declare module BABYLON {
  67598. /**
  67599. *
  67600. * This post-process allows the modification of rendered colors by using
  67601. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67602. *
  67603. * The object needs to be provided an url to a texture containing the color
  67604. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67605. * Use an image editing software to tweak the LUT to match your needs.
  67606. *
  67607. * For an example of a color LUT, see here:
  67608. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67609. * For explanations on color grading, see here:
  67610. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67611. *
  67612. */
  67613. export class ColorCorrectionPostProcess extends PostProcess {
  67614. private _colorTableTexture;
  67615. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67616. }
  67617. }
  67618. declare module BABYLON {
  67619. /** @hidden */
  67620. export var convolutionPixelShader: {
  67621. name: string;
  67622. shader: string;
  67623. };
  67624. }
  67625. declare module BABYLON {
  67626. /**
  67627. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67628. * input texture to perform effects such as edge detection or sharpening
  67629. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67630. */
  67631. export class ConvolutionPostProcess extends PostProcess {
  67632. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67633. kernel: number[];
  67634. /**
  67635. * Creates a new instance ConvolutionPostProcess
  67636. * @param name The name of the effect.
  67637. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67638. * @param options The required width/height ratio to downsize to before computing the render pass.
  67639. * @param camera The camera to apply the render pass to.
  67640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67641. * @param engine The engine which the post process will be applied. (default: current engine)
  67642. * @param reusable If the post process can be reused on the same frame. (default: false)
  67643. * @param textureType Type of textures used when performing the post process. (default: 0)
  67644. */
  67645. constructor(name: string,
  67646. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67647. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67648. /**
  67649. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67650. */
  67651. static EdgeDetect0Kernel: number[];
  67652. /**
  67653. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67654. */
  67655. static EdgeDetect1Kernel: number[];
  67656. /**
  67657. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67658. */
  67659. static EdgeDetect2Kernel: number[];
  67660. /**
  67661. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67662. */
  67663. static SharpenKernel: number[];
  67664. /**
  67665. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67666. */
  67667. static EmbossKernel: number[];
  67668. /**
  67669. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67670. */
  67671. static GaussianKernel: number[];
  67672. }
  67673. }
  67674. declare module BABYLON {
  67675. /**
  67676. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67677. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67678. * based on samples that have a large difference in distance than the center pixel.
  67679. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67680. */
  67681. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67682. direction: Vector2;
  67683. /**
  67684. * Creates a new instance CircleOfConfusionPostProcess
  67685. * @param name The name of the effect.
  67686. * @param scene The scene the effect belongs to.
  67687. * @param direction The direction the blur should be applied.
  67688. * @param kernel The size of the kernel used to blur.
  67689. * @param options The required width/height ratio to downsize to before computing the render pass.
  67690. * @param camera The camera to apply the render pass to.
  67691. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67692. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67694. * @param engine The engine which the post process will be applied. (default: current engine)
  67695. * @param reusable If the post process can be reused on the same frame. (default: false)
  67696. * @param textureType Type of textures used when performing the post process. (default: 0)
  67697. * @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)
  67698. */
  67699. 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);
  67700. }
  67701. }
  67702. declare module BABYLON {
  67703. /** @hidden */
  67704. export var depthOfFieldMergePixelShader: {
  67705. name: string;
  67706. shader: string;
  67707. };
  67708. }
  67709. declare module BABYLON {
  67710. /**
  67711. * Options to be set when merging outputs from the default pipeline.
  67712. */
  67713. export class DepthOfFieldMergePostProcessOptions {
  67714. /**
  67715. * The original image to merge on top of
  67716. */
  67717. originalFromInput: PostProcess;
  67718. /**
  67719. * Parameters to perform the merge of the depth of field effect
  67720. */
  67721. depthOfField?: {
  67722. circleOfConfusion: PostProcess;
  67723. blurSteps: Array<PostProcess>;
  67724. };
  67725. /**
  67726. * Parameters to perform the merge of bloom effect
  67727. */
  67728. bloom?: {
  67729. blurred: PostProcess;
  67730. weight: number;
  67731. };
  67732. }
  67733. /**
  67734. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67735. */
  67736. export class DepthOfFieldMergePostProcess extends PostProcess {
  67737. private blurSteps;
  67738. /**
  67739. * Creates a new instance of DepthOfFieldMergePostProcess
  67740. * @param name The name of the effect.
  67741. * @param originalFromInput Post process which's input will be used for the merge.
  67742. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67743. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67744. * @param options The required width/height ratio to downsize to before computing the render pass.
  67745. * @param camera The camera to apply the render pass to.
  67746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67747. * @param engine The engine which the post process will be applied. (default: current engine)
  67748. * @param reusable If the post process can be reused on the same frame. (default: false)
  67749. * @param textureType Type of textures used when performing the post process. (default: 0)
  67750. * @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)
  67751. */
  67752. 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);
  67753. /**
  67754. * Updates the effect with the current post process compile time values and recompiles the shader.
  67755. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67756. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67757. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67758. * @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
  67759. * @param onCompiled Called when the shader has been compiled.
  67760. * @param onError Called if there is an error when compiling a shader.
  67761. */
  67762. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67763. }
  67764. }
  67765. declare module BABYLON {
  67766. /**
  67767. * Specifies the level of max blur that should be applied when using the depth of field effect
  67768. */
  67769. export enum DepthOfFieldEffectBlurLevel {
  67770. /**
  67771. * Subtle blur
  67772. */
  67773. Low = 0,
  67774. /**
  67775. * Medium blur
  67776. */
  67777. Medium = 1,
  67778. /**
  67779. * Large blur
  67780. */
  67781. High = 2
  67782. }
  67783. /**
  67784. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67785. */
  67786. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67787. private _circleOfConfusion;
  67788. /**
  67789. * @hidden Internal, blurs from high to low
  67790. */
  67791. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67792. private _depthOfFieldBlurY;
  67793. private _dofMerge;
  67794. /**
  67795. * @hidden Internal post processes in depth of field effect
  67796. */
  67797. _effects: Array<PostProcess>;
  67798. /**
  67799. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67800. */
  67801. set focalLength(value: number);
  67802. get focalLength(): number;
  67803. /**
  67804. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67805. */
  67806. set fStop(value: number);
  67807. get fStop(): number;
  67808. /**
  67809. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67810. */
  67811. set focusDistance(value: number);
  67812. get focusDistance(): number;
  67813. /**
  67814. * 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.
  67815. */
  67816. set lensSize(value: number);
  67817. get lensSize(): number;
  67818. /**
  67819. * Creates a new instance DepthOfFieldEffect
  67820. * @param scene The scene the effect belongs to.
  67821. * @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.
  67822. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67823. * @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)
  67824. */
  67825. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67826. /**
  67827. * Get the current class name of the current effet
  67828. * @returns "DepthOfFieldEffect"
  67829. */
  67830. getClassName(): string;
  67831. /**
  67832. * 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.
  67833. */
  67834. set depthTexture(value: RenderTargetTexture);
  67835. /**
  67836. * Disposes each of the internal effects for a given camera.
  67837. * @param camera The camera to dispose the effect on.
  67838. */
  67839. disposeEffects(camera: Camera): void;
  67840. /**
  67841. * @hidden Internal
  67842. */
  67843. _updateEffects(): void;
  67844. /**
  67845. * Internal
  67846. * @returns if all the contained post processes are ready.
  67847. * @hidden
  67848. */
  67849. _isReady(): boolean;
  67850. }
  67851. }
  67852. declare module BABYLON {
  67853. /** @hidden */
  67854. export var displayPassPixelShader: {
  67855. name: string;
  67856. shader: string;
  67857. };
  67858. }
  67859. declare module BABYLON {
  67860. /**
  67861. * DisplayPassPostProcess which produces an output the same as it's input
  67862. */
  67863. export class DisplayPassPostProcess extends PostProcess {
  67864. /**
  67865. * Creates the DisplayPassPostProcess
  67866. * @param name The name of the effect.
  67867. * @param options The required width/height ratio to downsize to before computing the render pass.
  67868. * @param camera The camera to apply the render pass to.
  67869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67870. * @param engine The engine which the post process will be applied. (default: current engine)
  67871. * @param reusable If the post process can be reused on the same frame. (default: false)
  67872. */
  67873. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67874. }
  67875. }
  67876. declare module BABYLON {
  67877. /** @hidden */
  67878. export var filterPixelShader: {
  67879. name: string;
  67880. shader: string;
  67881. };
  67882. }
  67883. declare module BABYLON {
  67884. /**
  67885. * Applies a kernel filter to the image
  67886. */
  67887. export class FilterPostProcess extends PostProcess {
  67888. /** The matrix to be applied to the image */
  67889. kernelMatrix: Matrix;
  67890. /**
  67891. *
  67892. * @param name The name of the effect.
  67893. * @param kernelMatrix The matrix to be applied to the image
  67894. * @param options The required width/height ratio to downsize to before computing the render pass.
  67895. * @param camera The camera to apply the render pass to.
  67896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67897. * @param engine The engine which the post process will be applied. (default: current engine)
  67898. * @param reusable If the post process can be reused on the same frame. (default: false)
  67899. */
  67900. constructor(name: string,
  67901. /** The matrix to be applied to the image */
  67902. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67903. }
  67904. }
  67905. declare module BABYLON {
  67906. /** @hidden */
  67907. export var fxaaPixelShader: {
  67908. name: string;
  67909. shader: string;
  67910. };
  67911. }
  67912. declare module BABYLON {
  67913. /** @hidden */
  67914. export var fxaaVertexShader: {
  67915. name: string;
  67916. shader: string;
  67917. };
  67918. }
  67919. declare module BABYLON {
  67920. /**
  67921. * Fxaa post process
  67922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67923. */
  67924. export class FxaaPostProcess extends PostProcess {
  67925. /** @hidden */
  67926. texelWidth: number;
  67927. /** @hidden */
  67928. texelHeight: number;
  67929. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67930. private _getDefines;
  67931. }
  67932. }
  67933. declare module BABYLON {
  67934. /** @hidden */
  67935. export var grainPixelShader: {
  67936. name: string;
  67937. shader: string;
  67938. };
  67939. }
  67940. declare module BABYLON {
  67941. /**
  67942. * The GrainPostProcess adds noise to the image at mid luminance levels
  67943. */
  67944. export class GrainPostProcess extends PostProcess {
  67945. /**
  67946. * The intensity of the grain added (default: 30)
  67947. */
  67948. intensity: number;
  67949. /**
  67950. * If the grain should be randomized on every frame
  67951. */
  67952. animated: boolean;
  67953. /**
  67954. * Creates a new instance of @see GrainPostProcess
  67955. * @param name The name of the effect.
  67956. * @param options The required width/height ratio to downsize to before computing the render pass.
  67957. * @param camera The camera to apply the render pass to.
  67958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67959. * @param engine The engine which the post process will be applied. (default: current engine)
  67960. * @param reusable If the post process can be reused on the same frame. (default: false)
  67961. * @param textureType Type of textures used when performing the post process. (default: 0)
  67962. * @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)
  67963. */
  67964. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67965. }
  67966. }
  67967. declare module BABYLON {
  67968. /** @hidden */
  67969. export var highlightsPixelShader: {
  67970. name: string;
  67971. shader: string;
  67972. };
  67973. }
  67974. declare module BABYLON {
  67975. /**
  67976. * Extracts highlights from the image
  67977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67978. */
  67979. export class HighlightsPostProcess extends PostProcess {
  67980. /**
  67981. * Extracts highlights from the image
  67982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67983. * @param name The name of the effect.
  67984. * @param options The required width/height ratio to downsize to before computing the render pass.
  67985. * @param camera The camera to apply the render pass to.
  67986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67987. * @param engine The engine which the post process will be applied. (default: current engine)
  67988. * @param reusable If the post process can be reused on the same frame. (default: false)
  67989. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67990. */
  67991. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. /** @hidden */
  67996. export var mrtFragmentDeclaration: {
  67997. name: string;
  67998. shader: string;
  67999. };
  68000. }
  68001. declare module BABYLON {
  68002. /** @hidden */
  68003. export var geometryPixelShader: {
  68004. name: string;
  68005. shader: string;
  68006. };
  68007. }
  68008. declare module BABYLON {
  68009. /** @hidden */
  68010. export var geometryVertexShader: {
  68011. name: string;
  68012. shader: string;
  68013. };
  68014. }
  68015. declare module BABYLON {
  68016. /** @hidden */
  68017. interface ISavedTransformationMatrix {
  68018. world: Matrix;
  68019. viewProjection: Matrix;
  68020. }
  68021. /**
  68022. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68023. */
  68024. export class GeometryBufferRenderer {
  68025. /**
  68026. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68027. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68028. */
  68029. static readonly POSITION_TEXTURE_TYPE: number;
  68030. /**
  68031. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68032. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68033. */
  68034. static readonly VELOCITY_TEXTURE_TYPE: number;
  68035. /**
  68036. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68037. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68038. */
  68039. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68040. /**
  68041. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68042. * in order to compute objects velocities when enableVelocity is set to "true"
  68043. * @hidden
  68044. */
  68045. _previousTransformationMatrices: {
  68046. [index: number]: ISavedTransformationMatrix;
  68047. };
  68048. /**
  68049. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68050. * in order to compute objects velocities when enableVelocity is set to "true"
  68051. * @hidden
  68052. */
  68053. _previousBonesTransformationMatrices: {
  68054. [index: number]: Float32Array;
  68055. };
  68056. /**
  68057. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68058. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68059. */
  68060. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68061. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68062. renderTransparentMeshes: boolean;
  68063. private _scene;
  68064. private _multiRenderTarget;
  68065. private _ratio;
  68066. private _enablePosition;
  68067. private _enableVelocity;
  68068. private _enableReflectivity;
  68069. private _positionIndex;
  68070. private _velocityIndex;
  68071. private _reflectivityIndex;
  68072. protected _effect: Effect;
  68073. protected _cachedDefines: string;
  68074. /**
  68075. * Set the render list (meshes to be rendered) used in the G buffer.
  68076. */
  68077. set renderList(meshes: Mesh[]);
  68078. /**
  68079. * Gets wether or not G buffer are supported by the running hardware.
  68080. * This requires draw buffer supports
  68081. */
  68082. get isSupported(): boolean;
  68083. /**
  68084. * Returns the index of the given texture type in the G-Buffer textures array
  68085. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68086. * @returns the index of the given texture type in the G-Buffer textures array
  68087. */
  68088. getTextureIndex(textureType: number): number;
  68089. /**
  68090. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68091. */
  68092. get enablePosition(): boolean;
  68093. /**
  68094. * Sets whether or not objects positions are enabled for the G buffer.
  68095. */
  68096. set enablePosition(enable: boolean);
  68097. /**
  68098. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68099. */
  68100. get enableVelocity(): boolean;
  68101. /**
  68102. * Sets wether or not objects velocities are enabled for the G buffer.
  68103. */
  68104. set enableVelocity(enable: boolean);
  68105. /**
  68106. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68107. */
  68108. get enableReflectivity(): boolean;
  68109. /**
  68110. * Sets wether or not objects roughness are enabled for the G buffer.
  68111. */
  68112. set enableReflectivity(enable: boolean);
  68113. /**
  68114. * Gets the scene associated with the buffer.
  68115. */
  68116. get scene(): Scene;
  68117. /**
  68118. * Gets the ratio used by the buffer during its creation.
  68119. * How big is the buffer related to the main canvas.
  68120. */
  68121. get ratio(): number;
  68122. /** @hidden */
  68123. static _SceneComponentInitialization: (scene: Scene) => void;
  68124. /**
  68125. * Creates a new G Buffer for the scene
  68126. * @param scene The scene the buffer belongs to
  68127. * @param ratio How big is the buffer related to the main canvas.
  68128. */
  68129. constructor(scene: Scene, ratio?: number);
  68130. /**
  68131. * Checks wether everything is ready to render a submesh to the G buffer.
  68132. * @param subMesh the submesh to check readiness for
  68133. * @param useInstances is the mesh drawn using instance or not
  68134. * @returns true if ready otherwise false
  68135. */
  68136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68137. /**
  68138. * Gets the current underlying G Buffer.
  68139. * @returns the buffer
  68140. */
  68141. getGBuffer(): MultiRenderTarget;
  68142. /**
  68143. * Gets the number of samples used to render the buffer (anti aliasing).
  68144. */
  68145. get samples(): number;
  68146. /**
  68147. * Sets the number of samples used to render the buffer (anti aliasing).
  68148. */
  68149. set samples(value: number);
  68150. /**
  68151. * Disposes the renderer and frees up associated resources.
  68152. */
  68153. dispose(): void;
  68154. protected _createRenderTargets(): void;
  68155. private _copyBonesTransformationMatrices;
  68156. }
  68157. }
  68158. declare module BABYLON {
  68159. interface Scene {
  68160. /** @hidden (Backing field) */
  68161. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68162. /**
  68163. * Gets or Sets the current geometry buffer associated to the scene.
  68164. */
  68165. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68166. /**
  68167. * Enables a GeometryBufferRender and associates it with the scene
  68168. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68169. * @returns the GeometryBufferRenderer
  68170. */
  68171. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68172. /**
  68173. * Disables the GeometryBufferRender associated with the scene
  68174. */
  68175. disableGeometryBufferRenderer(): void;
  68176. }
  68177. /**
  68178. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68179. * in several rendering techniques.
  68180. */
  68181. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68182. /**
  68183. * The component name helpful to identify the component in the list of scene components.
  68184. */
  68185. readonly name: string;
  68186. /**
  68187. * The scene the component belongs to.
  68188. */
  68189. scene: Scene;
  68190. /**
  68191. * Creates a new instance of the component for the given scene
  68192. * @param scene Defines the scene to register the component in
  68193. */
  68194. constructor(scene: Scene);
  68195. /**
  68196. * Registers the component in a given scene
  68197. */
  68198. register(): void;
  68199. /**
  68200. * Rebuilds the elements related to this component in case of
  68201. * context lost for instance.
  68202. */
  68203. rebuild(): void;
  68204. /**
  68205. * Disposes the component and the associated ressources
  68206. */
  68207. dispose(): void;
  68208. private _gatherRenderTargets;
  68209. }
  68210. }
  68211. declare module BABYLON {
  68212. /** @hidden */
  68213. export var motionBlurPixelShader: {
  68214. name: string;
  68215. shader: string;
  68216. };
  68217. }
  68218. declare module BABYLON {
  68219. /**
  68220. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68221. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68222. * As an example, all you have to do is to create the post-process:
  68223. * var mb = new BABYLON.MotionBlurPostProcess(
  68224. * 'mb', // The name of the effect.
  68225. * scene, // The scene containing the objects to blur according to their velocity.
  68226. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68227. * camera // The camera to apply the render pass to.
  68228. * );
  68229. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68230. */
  68231. export class MotionBlurPostProcess extends PostProcess {
  68232. /**
  68233. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68234. */
  68235. motionStrength: number;
  68236. /**
  68237. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68238. */
  68239. get motionBlurSamples(): number;
  68240. /**
  68241. * Sets the number of iterations to be used for motion blur quality
  68242. */
  68243. set motionBlurSamples(samples: number);
  68244. private _motionBlurSamples;
  68245. private _geometryBufferRenderer;
  68246. /**
  68247. * Creates a new instance MotionBlurPostProcess
  68248. * @param name The name of the effect.
  68249. * @param scene The scene containing the objects to blur according to their velocity.
  68250. * @param options The required width/height ratio to downsize to before computing the render pass.
  68251. * @param camera The camera to apply the render pass to.
  68252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68253. * @param engine The engine which the post process will be applied. (default: current engine)
  68254. * @param reusable If the post process can be reused on the same frame. (default: false)
  68255. * @param textureType Type of textures used when performing the post process. (default: 0)
  68256. * @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)
  68257. */
  68258. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68259. /**
  68260. * Excludes the given skinned mesh from computing bones velocities.
  68261. * 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.
  68262. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68263. */
  68264. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68265. /**
  68266. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68267. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68268. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68269. */
  68270. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68271. /**
  68272. * Disposes the post process.
  68273. * @param camera The camera to dispose the post process on.
  68274. */
  68275. dispose(camera?: Camera): void;
  68276. }
  68277. }
  68278. declare module BABYLON {
  68279. /** @hidden */
  68280. export var refractionPixelShader: {
  68281. name: string;
  68282. shader: string;
  68283. };
  68284. }
  68285. declare module BABYLON {
  68286. /**
  68287. * Post process which applies a refractin texture
  68288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68289. */
  68290. export class RefractionPostProcess extends PostProcess {
  68291. /** the base color of the refraction (used to taint the rendering) */
  68292. color: Color3;
  68293. /** simulated refraction depth */
  68294. depth: number;
  68295. /** the coefficient of the base color (0 to remove base color tainting) */
  68296. colorLevel: number;
  68297. private _refTexture;
  68298. private _ownRefractionTexture;
  68299. /**
  68300. * Gets or sets the refraction texture
  68301. * Please note that you are responsible for disposing the texture if you set it manually
  68302. */
  68303. get refractionTexture(): Texture;
  68304. set refractionTexture(value: Texture);
  68305. /**
  68306. * Initializes the RefractionPostProcess
  68307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68308. * @param name The name of the effect.
  68309. * @param refractionTextureUrl Url of the refraction texture to use
  68310. * @param color the base color of the refraction (used to taint the rendering)
  68311. * @param depth simulated refraction depth
  68312. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68313. * @param camera The camera to apply the render pass to.
  68314. * @param options The required width/height ratio to downsize to before computing the render pass.
  68315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68316. * @param engine The engine which the post process will be applied. (default: current engine)
  68317. * @param reusable If the post process can be reused on the same frame. (default: false)
  68318. */
  68319. constructor(name: string, refractionTextureUrl: string,
  68320. /** the base color of the refraction (used to taint the rendering) */
  68321. color: Color3,
  68322. /** simulated refraction depth */
  68323. depth: number,
  68324. /** the coefficient of the base color (0 to remove base color tainting) */
  68325. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68326. /**
  68327. * Disposes of the post process
  68328. * @param camera Camera to dispose post process on
  68329. */
  68330. dispose(camera: Camera): void;
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /** @hidden */
  68335. export var sharpenPixelShader: {
  68336. name: string;
  68337. shader: string;
  68338. };
  68339. }
  68340. declare module BABYLON {
  68341. /**
  68342. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68343. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68344. */
  68345. export class SharpenPostProcess extends PostProcess {
  68346. /**
  68347. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68348. */
  68349. colorAmount: number;
  68350. /**
  68351. * How much sharpness should be applied (default: 0.3)
  68352. */
  68353. edgeAmount: number;
  68354. /**
  68355. * Creates a new instance ConvolutionPostProcess
  68356. * @param name The name of the effect.
  68357. * @param options The required width/height ratio to downsize to before computing the render pass.
  68358. * @param camera The camera to apply the render pass to.
  68359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68360. * @param engine The engine which the post process will be applied. (default: current engine)
  68361. * @param reusable If the post process can be reused on the same frame. (default: false)
  68362. * @param textureType Type of textures used when performing the post process. (default: 0)
  68363. * @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)
  68364. */
  68365. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68366. }
  68367. }
  68368. declare module BABYLON {
  68369. /**
  68370. * PostProcessRenderPipeline
  68371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68372. */
  68373. export class PostProcessRenderPipeline {
  68374. private engine;
  68375. private _renderEffects;
  68376. private _renderEffectsForIsolatedPass;
  68377. /**
  68378. * List of inspectable custom properties (used by the Inspector)
  68379. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68380. */
  68381. inspectableCustomProperties: IInspectable[];
  68382. /**
  68383. * @hidden
  68384. */
  68385. protected _cameras: Camera[];
  68386. /** @hidden */
  68387. _name: string;
  68388. /**
  68389. * Gets pipeline name
  68390. */
  68391. get name(): string;
  68392. /** Gets the list of attached cameras */
  68393. get cameras(): Camera[];
  68394. /**
  68395. * Initializes a PostProcessRenderPipeline
  68396. * @param engine engine to add the pipeline to
  68397. * @param name name of the pipeline
  68398. */
  68399. constructor(engine: Engine, name: string);
  68400. /**
  68401. * Gets the class name
  68402. * @returns "PostProcessRenderPipeline"
  68403. */
  68404. getClassName(): string;
  68405. /**
  68406. * If all the render effects in the pipeline are supported
  68407. */
  68408. get isSupported(): boolean;
  68409. /**
  68410. * Adds an effect to the pipeline
  68411. * @param renderEffect the effect to add
  68412. */
  68413. addEffect(renderEffect: PostProcessRenderEffect): void;
  68414. /** @hidden */
  68415. _rebuild(): void;
  68416. /** @hidden */
  68417. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68418. /** @hidden */
  68419. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68420. /** @hidden */
  68421. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68422. /** @hidden */
  68423. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68424. /** @hidden */
  68425. _attachCameras(cameras: Camera, unique: boolean): void;
  68426. /** @hidden */
  68427. _attachCameras(cameras: Camera[], unique: boolean): void;
  68428. /** @hidden */
  68429. _detachCameras(cameras: Camera): void;
  68430. /** @hidden */
  68431. _detachCameras(cameras: Nullable<Camera[]>): void;
  68432. /** @hidden */
  68433. _update(): void;
  68434. /** @hidden */
  68435. _reset(): void;
  68436. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68437. /**
  68438. * Disposes of the pipeline
  68439. */
  68440. dispose(): void;
  68441. }
  68442. }
  68443. declare module BABYLON {
  68444. /**
  68445. * PostProcessRenderPipelineManager class
  68446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68447. */
  68448. export class PostProcessRenderPipelineManager {
  68449. private _renderPipelines;
  68450. /**
  68451. * Initializes a PostProcessRenderPipelineManager
  68452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68453. */
  68454. constructor();
  68455. /**
  68456. * Gets the list of supported render pipelines
  68457. */
  68458. get supportedPipelines(): PostProcessRenderPipeline[];
  68459. /**
  68460. * Adds a pipeline to the manager
  68461. * @param renderPipeline The pipeline to add
  68462. */
  68463. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68464. /**
  68465. * Attaches a camera to the pipeline
  68466. * @param renderPipelineName The name of the pipeline to attach to
  68467. * @param cameras the camera to attach
  68468. * @param unique if the camera can be attached multiple times to the pipeline
  68469. */
  68470. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68471. /**
  68472. * Detaches a camera from the pipeline
  68473. * @param renderPipelineName The name of the pipeline to detach from
  68474. * @param cameras the camera to detach
  68475. */
  68476. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68477. /**
  68478. * Enables an effect by name on a pipeline
  68479. * @param renderPipelineName the name of the pipeline to enable the effect in
  68480. * @param renderEffectName the name of the effect to enable
  68481. * @param cameras the cameras that the effect should be enabled on
  68482. */
  68483. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68484. /**
  68485. * Disables an effect by name on a pipeline
  68486. * @param renderPipelineName the name of the pipeline to disable the effect in
  68487. * @param renderEffectName the name of the effect to disable
  68488. * @param cameras the cameras that the effect should be disabled on
  68489. */
  68490. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68491. /**
  68492. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68493. */
  68494. update(): void;
  68495. /** @hidden */
  68496. _rebuild(): void;
  68497. /**
  68498. * Disposes of the manager and pipelines
  68499. */
  68500. dispose(): void;
  68501. }
  68502. }
  68503. declare module BABYLON {
  68504. interface Scene {
  68505. /** @hidden (Backing field) */
  68506. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68507. /**
  68508. * Gets the postprocess render pipeline manager
  68509. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68510. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68511. */
  68512. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68513. }
  68514. /**
  68515. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68516. */
  68517. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68518. /**
  68519. * The component name helpfull to identify the component in the list of scene components.
  68520. */
  68521. readonly name: string;
  68522. /**
  68523. * The scene the component belongs to.
  68524. */
  68525. scene: Scene;
  68526. /**
  68527. * Creates a new instance of the component for the given scene
  68528. * @param scene Defines the scene to register the component in
  68529. */
  68530. constructor(scene: Scene);
  68531. /**
  68532. * Registers the component in a given scene
  68533. */
  68534. register(): void;
  68535. /**
  68536. * Rebuilds the elements related to this component in case of
  68537. * context lost for instance.
  68538. */
  68539. rebuild(): void;
  68540. /**
  68541. * Disposes the component and the associated ressources
  68542. */
  68543. dispose(): void;
  68544. private _gatherRenderTargets;
  68545. }
  68546. }
  68547. declare module BABYLON {
  68548. /**
  68549. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68550. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68551. */
  68552. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68553. private _scene;
  68554. private _camerasToBeAttached;
  68555. /**
  68556. * ID of the sharpen post process,
  68557. */
  68558. private readonly SharpenPostProcessId;
  68559. /**
  68560. * @ignore
  68561. * ID of the image processing post process;
  68562. */
  68563. readonly ImageProcessingPostProcessId: string;
  68564. /**
  68565. * @ignore
  68566. * ID of the Fast Approximate Anti-Aliasing post process;
  68567. */
  68568. readonly FxaaPostProcessId: string;
  68569. /**
  68570. * ID of the chromatic aberration post process,
  68571. */
  68572. private readonly ChromaticAberrationPostProcessId;
  68573. /**
  68574. * ID of the grain post process
  68575. */
  68576. private readonly GrainPostProcessId;
  68577. /**
  68578. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68579. */
  68580. sharpen: SharpenPostProcess;
  68581. private _sharpenEffect;
  68582. private bloom;
  68583. /**
  68584. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68585. */
  68586. depthOfField: DepthOfFieldEffect;
  68587. /**
  68588. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68589. */
  68590. fxaa: FxaaPostProcess;
  68591. /**
  68592. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68593. */
  68594. imageProcessing: ImageProcessingPostProcess;
  68595. /**
  68596. * Chromatic aberration post process which will shift rgb colors in the image
  68597. */
  68598. chromaticAberration: ChromaticAberrationPostProcess;
  68599. private _chromaticAberrationEffect;
  68600. /**
  68601. * Grain post process which add noise to the image
  68602. */
  68603. grain: GrainPostProcess;
  68604. private _grainEffect;
  68605. /**
  68606. * Glow post process which adds a glow to emissive areas of the image
  68607. */
  68608. private _glowLayer;
  68609. /**
  68610. * Animations which can be used to tweak settings over a period of time
  68611. */
  68612. animations: Animation[];
  68613. private _imageProcessingConfigurationObserver;
  68614. private _sharpenEnabled;
  68615. private _bloomEnabled;
  68616. private _depthOfFieldEnabled;
  68617. private _depthOfFieldBlurLevel;
  68618. private _fxaaEnabled;
  68619. private _imageProcessingEnabled;
  68620. private _defaultPipelineTextureType;
  68621. private _bloomScale;
  68622. private _chromaticAberrationEnabled;
  68623. private _grainEnabled;
  68624. private _buildAllowed;
  68625. /**
  68626. * Gets active scene
  68627. */
  68628. get scene(): Scene;
  68629. /**
  68630. * Enable or disable the sharpen process from the pipeline
  68631. */
  68632. set sharpenEnabled(enabled: boolean);
  68633. get sharpenEnabled(): boolean;
  68634. private _resizeObserver;
  68635. private _hardwareScaleLevel;
  68636. private _bloomKernel;
  68637. /**
  68638. * Specifies the size of the bloom blur kernel, relative to the final output size
  68639. */
  68640. get bloomKernel(): number;
  68641. set bloomKernel(value: number);
  68642. /**
  68643. * Specifies the weight of the bloom in the final rendering
  68644. */
  68645. private _bloomWeight;
  68646. /**
  68647. * Specifies the luma threshold for the area that will be blurred by the bloom
  68648. */
  68649. private _bloomThreshold;
  68650. private _hdr;
  68651. /**
  68652. * The strength of the bloom.
  68653. */
  68654. set bloomWeight(value: number);
  68655. get bloomWeight(): number;
  68656. /**
  68657. * The strength of the bloom.
  68658. */
  68659. set bloomThreshold(value: number);
  68660. get bloomThreshold(): number;
  68661. /**
  68662. * The scale of the bloom, lower value will provide better performance.
  68663. */
  68664. set bloomScale(value: number);
  68665. get bloomScale(): number;
  68666. /**
  68667. * Enable or disable the bloom from the pipeline
  68668. */
  68669. set bloomEnabled(enabled: boolean);
  68670. get bloomEnabled(): boolean;
  68671. private _rebuildBloom;
  68672. /**
  68673. * If the depth of field is enabled.
  68674. */
  68675. get depthOfFieldEnabled(): boolean;
  68676. set depthOfFieldEnabled(enabled: boolean);
  68677. /**
  68678. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68679. */
  68680. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68681. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68682. /**
  68683. * If the anti aliasing is enabled.
  68684. */
  68685. set fxaaEnabled(enabled: boolean);
  68686. get fxaaEnabled(): boolean;
  68687. private _samples;
  68688. /**
  68689. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68690. */
  68691. set samples(sampleCount: number);
  68692. get samples(): number;
  68693. /**
  68694. * If image processing is enabled.
  68695. */
  68696. set imageProcessingEnabled(enabled: boolean);
  68697. get imageProcessingEnabled(): boolean;
  68698. /**
  68699. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68700. */
  68701. set glowLayerEnabled(enabled: boolean);
  68702. get glowLayerEnabled(): boolean;
  68703. /**
  68704. * Gets the glow layer (or null if not defined)
  68705. */
  68706. get glowLayer(): Nullable<GlowLayer>;
  68707. /**
  68708. * Enable or disable the chromaticAberration process from the pipeline
  68709. */
  68710. set chromaticAberrationEnabled(enabled: boolean);
  68711. get chromaticAberrationEnabled(): boolean;
  68712. /**
  68713. * Enable or disable the grain process from the pipeline
  68714. */
  68715. set grainEnabled(enabled: boolean);
  68716. get grainEnabled(): boolean;
  68717. /**
  68718. * @constructor
  68719. * @param name - The rendering pipeline name (default: "")
  68720. * @param hdr - If high dynamic range textures should be used (default: true)
  68721. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68722. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68723. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68724. */
  68725. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68726. /**
  68727. * Get the class name
  68728. * @returns "DefaultRenderingPipeline"
  68729. */
  68730. getClassName(): string;
  68731. /**
  68732. * Force the compilation of the entire pipeline.
  68733. */
  68734. prepare(): void;
  68735. private _hasCleared;
  68736. private _prevPostProcess;
  68737. private _prevPrevPostProcess;
  68738. private _setAutoClearAndTextureSharing;
  68739. private _depthOfFieldSceneObserver;
  68740. private _buildPipeline;
  68741. private _disposePostProcesses;
  68742. /**
  68743. * Adds a camera to the pipeline
  68744. * @param camera the camera to be added
  68745. */
  68746. addCamera(camera: Camera): void;
  68747. /**
  68748. * Removes a camera from the pipeline
  68749. * @param camera the camera to remove
  68750. */
  68751. removeCamera(camera: Camera): void;
  68752. /**
  68753. * Dispose of the pipeline and stop all post processes
  68754. */
  68755. dispose(): void;
  68756. /**
  68757. * Serialize the rendering pipeline (Used when exporting)
  68758. * @returns the serialized object
  68759. */
  68760. serialize(): any;
  68761. /**
  68762. * Parse the serialized pipeline
  68763. * @param source Source pipeline.
  68764. * @param scene The scene to load the pipeline to.
  68765. * @param rootUrl The URL of the serialized pipeline.
  68766. * @returns An instantiated pipeline from the serialized object.
  68767. */
  68768. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68769. }
  68770. }
  68771. declare module BABYLON {
  68772. /** @hidden */
  68773. export var lensHighlightsPixelShader: {
  68774. name: string;
  68775. shader: string;
  68776. };
  68777. }
  68778. declare module BABYLON {
  68779. /** @hidden */
  68780. export var depthOfFieldPixelShader: {
  68781. name: string;
  68782. shader: string;
  68783. };
  68784. }
  68785. declare module BABYLON {
  68786. /**
  68787. * BABYLON.JS Chromatic Aberration GLSL Shader
  68788. * Author: Olivier Guyot
  68789. * Separates very slightly R, G and B colors on the edges of the screen
  68790. * Inspired by Francois Tarlier & Martins Upitis
  68791. */
  68792. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68793. /**
  68794. * @ignore
  68795. * The chromatic aberration PostProcess id in the pipeline
  68796. */
  68797. LensChromaticAberrationEffect: string;
  68798. /**
  68799. * @ignore
  68800. * The highlights enhancing PostProcess id in the pipeline
  68801. */
  68802. HighlightsEnhancingEffect: string;
  68803. /**
  68804. * @ignore
  68805. * The depth-of-field PostProcess id in the pipeline
  68806. */
  68807. LensDepthOfFieldEffect: string;
  68808. private _scene;
  68809. private _depthTexture;
  68810. private _grainTexture;
  68811. private _chromaticAberrationPostProcess;
  68812. private _highlightsPostProcess;
  68813. private _depthOfFieldPostProcess;
  68814. private _edgeBlur;
  68815. private _grainAmount;
  68816. private _chromaticAberration;
  68817. private _distortion;
  68818. private _highlightsGain;
  68819. private _highlightsThreshold;
  68820. private _dofDistance;
  68821. private _dofAperture;
  68822. private _dofDarken;
  68823. private _dofPentagon;
  68824. private _blurNoise;
  68825. /**
  68826. * @constructor
  68827. *
  68828. * Effect parameters are as follow:
  68829. * {
  68830. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68831. * edge_blur: number; // from 0 to x (1 for realism)
  68832. * distortion: number; // from 0 to x (1 for realism)
  68833. * grain_amount: number; // from 0 to 1
  68834. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68835. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68836. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68837. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68838. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68839. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68840. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68841. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68842. * }
  68843. * Note: if an effect parameter is unset, effect is disabled
  68844. *
  68845. * @param name The rendering pipeline name
  68846. * @param parameters - An object containing all parameters (see above)
  68847. * @param scene The scene linked to this pipeline
  68848. * @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)
  68849. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68850. */
  68851. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68852. /**
  68853. * Get the class name
  68854. * @returns "LensRenderingPipeline"
  68855. */
  68856. getClassName(): string;
  68857. /**
  68858. * Gets associated scene
  68859. */
  68860. get scene(): Scene;
  68861. /**
  68862. * Gets or sets the edge blur
  68863. */
  68864. get edgeBlur(): number;
  68865. set edgeBlur(value: number);
  68866. /**
  68867. * Gets or sets the grain amount
  68868. */
  68869. get grainAmount(): number;
  68870. set grainAmount(value: number);
  68871. /**
  68872. * Gets or sets the chromatic aberration amount
  68873. */
  68874. get chromaticAberration(): number;
  68875. set chromaticAberration(value: number);
  68876. /**
  68877. * Gets or sets the depth of field aperture
  68878. */
  68879. get dofAperture(): number;
  68880. set dofAperture(value: number);
  68881. /**
  68882. * Gets or sets the edge distortion
  68883. */
  68884. get edgeDistortion(): number;
  68885. set edgeDistortion(value: number);
  68886. /**
  68887. * Gets or sets the depth of field distortion
  68888. */
  68889. get dofDistortion(): number;
  68890. set dofDistortion(value: number);
  68891. /**
  68892. * Gets or sets the darken out of focus amount
  68893. */
  68894. get darkenOutOfFocus(): number;
  68895. set darkenOutOfFocus(value: number);
  68896. /**
  68897. * Gets or sets a boolean indicating if blur noise is enabled
  68898. */
  68899. get blurNoise(): boolean;
  68900. set blurNoise(value: boolean);
  68901. /**
  68902. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68903. */
  68904. get pentagonBokeh(): boolean;
  68905. set pentagonBokeh(value: boolean);
  68906. /**
  68907. * Gets or sets the highlight grain amount
  68908. */
  68909. get highlightsGain(): number;
  68910. set highlightsGain(value: number);
  68911. /**
  68912. * Gets or sets the highlight threshold
  68913. */
  68914. get highlightsThreshold(): number;
  68915. set highlightsThreshold(value: number);
  68916. /**
  68917. * Sets the amount of blur at the edges
  68918. * @param amount blur amount
  68919. */
  68920. setEdgeBlur(amount: number): void;
  68921. /**
  68922. * Sets edge blur to 0
  68923. */
  68924. disableEdgeBlur(): void;
  68925. /**
  68926. * Sets the amout of grain
  68927. * @param amount Amount of grain
  68928. */
  68929. setGrainAmount(amount: number): void;
  68930. /**
  68931. * Set grain amount to 0
  68932. */
  68933. disableGrain(): void;
  68934. /**
  68935. * Sets the chromatic aberration amount
  68936. * @param amount amount of chromatic aberration
  68937. */
  68938. setChromaticAberration(amount: number): void;
  68939. /**
  68940. * Sets chromatic aberration amount to 0
  68941. */
  68942. disableChromaticAberration(): void;
  68943. /**
  68944. * Sets the EdgeDistortion amount
  68945. * @param amount amount of EdgeDistortion
  68946. */
  68947. setEdgeDistortion(amount: number): void;
  68948. /**
  68949. * Sets edge distortion to 0
  68950. */
  68951. disableEdgeDistortion(): void;
  68952. /**
  68953. * Sets the FocusDistance amount
  68954. * @param amount amount of FocusDistance
  68955. */
  68956. setFocusDistance(amount: number): void;
  68957. /**
  68958. * Disables depth of field
  68959. */
  68960. disableDepthOfField(): void;
  68961. /**
  68962. * Sets the Aperture amount
  68963. * @param amount amount of Aperture
  68964. */
  68965. setAperture(amount: number): void;
  68966. /**
  68967. * Sets the DarkenOutOfFocus amount
  68968. * @param amount amount of DarkenOutOfFocus
  68969. */
  68970. setDarkenOutOfFocus(amount: number): void;
  68971. private _pentagonBokehIsEnabled;
  68972. /**
  68973. * Creates a pentagon bokeh effect
  68974. */
  68975. enablePentagonBokeh(): void;
  68976. /**
  68977. * Disables the pentagon bokeh effect
  68978. */
  68979. disablePentagonBokeh(): void;
  68980. /**
  68981. * Enables noise blur
  68982. */
  68983. enableNoiseBlur(): void;
  68984. /**
  68985. * Disables noise blur
  68986. */
  68987. disableNoiseBlur(): void;
  68988. /**
  68989. * Sets the HighlightsGain amount
  68990. * @param amount amount of HighlightsGain
  68991. */
  68992. setHighlightsGain(amount: number): void;
  68993. /**
  68994. * Sets the HighlightsThreshold amount
  68995. * @param amount amount of HighlightsThreshold
  68996. */
  68997. setHighlightsThreshold(amount: number): void;
  68998. /**
  68999. * Disables highlights
  69000. */
  69001. disableHighlights(): void;
  69002. /**
  69003. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69004. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69005. */
  69006. dispose(disableDepthRender?: boolean): void;
  69007. private _createChromaticAberrationPostProcess;
  69008. private _createHighlightsPostProcess;
  69009. private _createDepthOfFieldPostProcess;
  69010. private _createGrainTexture;
  69011. }
  69012. }
  69013. declare module BABYLON {
  69014. /** @hidden */
  69015. export var ssao2PixelShader: {
  69016. name: string;
  69017. shader: string;
  69018. };
  69019. }
  69020. declare module BABYLON {
  69021. /** @hidden */
  69022. export var ssaoCombinePixelShader: {
  69023. name: string;
  69024. shader: string;
  69025. };
  69026. }
  69027. declare module BABYLON {
  69028. /**
  69029. * Render pipeline to produce ssao effect
  69030. */
  69031. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69032. /**
  69033. * @ignore
  69034. * The PassPostProcess id in the pipeline that contains the original scene color
  69035. */
  69036. SSAOOriginalSceneColorEffect: string;
  69037. /**
  69038. * @ignore
  69039. * The SSAO PostProcess id in the pipeline
  69040. */
  69041. SSAORenderEffect: string;
  69042. /**
  69043. * @ignore
  69044. * The horizontal blur PostProcess id in the pipeline
  69045. */
  69046. SSAOBlurHRenderEffect: string;
  69047. /**
  69048. * @ignore
  69049. * The vertical blur PostProcess id in the pipeline
  69050. */
  69051. SSAOBlurVRenderEffect: string;
  69052. /**
  69053. * @ignore
  69054. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69055. */
  69056. SSAOCombineRenderEffect: string;
  69057. /**
  69058. * The output strength of the SSAO post-process. Default value is 1.0.
  69059. */
  69060. totalStrength: number;
  69061. /**
  69062. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69063. */
  69064. maxZ: number;
  69065. /**
  69066. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69067. */
  69068. minZAspect: number;
  69069. private _samples;
  69070. /**
  69071. * Number of samples used for the SSAO calculations. Default value is 8
  69072. */
  69073. set samples(n: number);
  69074. get samples(): number;
  69075. private _textureSamples;
  69076. /**
  69077. * Number of samples to use for antialiasing
  69078. */
  69079. set textureSamples(n: number);
  69080. get textureSamples(): number;
  69081. /**
  69082. * Ratio object used for SSAO ratio and blur ratio
  69083. */
  69084. private _ratio;
  69085. /**
  69086. * Dynamically generated sphere sampler.
  69087. */
  69088. private _sampleSphere;
  69089. /**
  69090. * Blur filter offsets
  69091. */
  69092. private _samplerOffsets;
  69093. private _expensiveBlur;
  69094. /**
  69095. * If bilateral blur should be used
  69096. */
  69097. set expensiveBlur(b: boolean);
  69098. get expensiveBlur(): boolean;
  69099. /**
  69100. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69101. */
  69102. radius: number;
  69103. /**
  69104. * The base color of the SSAO post-process
  69105. * The final result is "base + ssao" between [0, 1]
  69106. */
  69107. base: number;
  69108. /**
  69109. * Support test.
  69110. */
  69111. static get IsSupported(): boolean;
  69112. private _scene;
  69113. private _depthTexture;
  69114. private _normalTexture;
  69115. private _randomTexture;
  69116. private _originalColorPostProcess;
  69117. private _ssaoPostProcess;
  69118. private _blurHPostProcess;
  69119. private _blurVPostProcess;
  69120. private _ssaoCombinePostProcess;
  69121. /**
  69122. * Gets active scene
  69123. */
  69124. get scene(): Scene;
  69125. /**
  69126. * @constructor
  69127. * @param name The rendering pipeline name
  69128. * @param scene The scene linked to this pipeline
  69129. * @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 }
  69130. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69131. */
  69132. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69133. /**
  69134. * Get the class name
  69135. * @returns "SSAO2RenderingPipeline"
  69136. */
  69137. getClassName(): string;
  69138. /**
  69139. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69140. */
  69141. dispose(disableGeometryBufferRenderer?: boolean): void;
  69142. private _createBlurPostProcess;
  69143. /** @hidden */
  69144. _rebuild(): void;
  69145. private _bits;
  69146. private _radicalInverse_VdC;
  69147. private _hammersley;
  69148. private _hemisphereSample_uniform;
  69149. private _generateHemisphere;
  69150. private _createSSAOPostProcess;
  69151. private _createSSAOCombinePostProcess;
  69152. private _createRandomTexture;
  69153. /**
  69154. * Serialize the rendering pipeline (Used when exporting)
  69155. * @returns the serialized object
  69156. */
  69157. serialize(): any;
  69158. /**
  69159. * Parse the serialized pipeline
  69160. * @param source Source pipeline.
  69161. * @param scene The scene to load the pipeline to.
  69162. * @param rootUrl The URL of the serialized pipeline.
  69163. * @returns An instantiated pipeline from the serialized object.
  69164. */
  69165. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69166. }
  69167. }
  69168. declare module BABYLON {
  69169. /** @hidden */
  69170. export var ssaoPixelShader: {
  69171. name: string;
  69172. shader: string;
  69173. };
  69174. }
  69175. declare module BABYLON {
  69176. /**
  69177. * Render pipeline to produce ssao effect
  69178. */
  69179. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69180. /**
  69181. * @ignore
  69182. * The PassPostProcess id in the pipeline that contains the original scene color
  69183. */
  69184. SSAOOriginalSceneColorEffect: string;
  69185. /**
  69186. * @ignore
  69187. * The SSAO PostProcess id in the pipeline
  69188. */
  69189. SSAORenderEffect: string;
  69190. /**
  69191. * @ignore
  69192. * The horizontal blur PostProcess id in the pipeline
  69193. */
  69194. SSAOBlurHRenderEffect: string;
  69195. /**
  69196. * @ignore
  69197. * The vertical blur PostProcess id in the pipeline
  69198. */
  69199. SSAOBlurVRenderEffect: string;
  69200. /**
  69201. * @ignore
  69202. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69203. */
  69204. SSAOCombineRenderEffect: string;
  69205. /**
  69206. * The output strength of the SSAO post-process. Default value is 1.0.
  69207. */
  69208. totalStrength: number;
  69209. /**
  69210. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69211. */
  69212. radius: number;
  69213. /**
  69214. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69215. * Must not be equal to fallOff and superior to fallOff.
  69216. * Default value is 0.0075
  69217. */
  69218. area: number;
  69219. /**
  69220. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69221. * Must not be equal to area and inferior to area.
  69222. * Default value is 0.000001
  69223. */
  69224. fallOff: number;
  69225. /**
  69226. * The base color of the SSAO post-process
  69227. * The final result is "base + ssao" between [0, 1]
  69228. */
  69229. base: number;
  69230. private _scene;
  69231. private _depthTexture;
  69232. private _randomTexture;
  69233. private _originalColorPostProcess;
  69234. private _ssaoPostProcess;
  69235. private _blurHPostProcess;
  69236. private _blurVPostProcess;
  69237. private _ssaoCombinePostProcess;
  69238. private _firstUpdate;
  69239. /**
  69240. * Gets active scene
  69241. */
  69242. get scene(): Scene;
  69243. /**
  69244. * @constructor
  69245. * @param name - The rendering pipeline name
  69246. * @param scene - The scene linked to this pipeline
  69247. * @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 }
  69248. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69249. */
  69250. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69251. /**
  69252. * Get the class name
  69253. * @returns "SSAORenderingPipeline"
  69254. */
  69255. getClassName(): string;
  69256. /**
  69257. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69258. */
  69259. dispose(disableDepthRender?: boolean): void;
  69260. private _createBlurPostProcess;
  69261. /** @hidden */
  69262. _rebuild(): void;
  69263. private _createSSAOPostProcess;
  69264. private _createSSAOCombinePostProcess;
  69265. private _createRandomTexture;
  69266. }
  69267. }
  69268. declare module BABYLON {
  69269. /** @hidden */
  69270. export var screenSpaceReflectionPixelShader: {
  69271. name: string;
  69272. shader: string;
  69273. };
  69274. }
  69275. declare module BABYLON {
  69276. /**
  69277. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69278. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69279. */
  69280. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69281. /**
  69282. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69283. */
  69284. threshold: number;
  69285. /**
  69286. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69287. */
  69288. strength: number;
  69289. /**
  69290. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69291. */
  69292. reflectionSpecularFalloffExponent: number;
  69293. /**
  69294. * 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]
  69295. */
  69296. step: number;
  69297. /**
  69298. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69299. */
  69300. roughnessFactor: number;
  69301. private _geometryBufferRenderer;
  69302. private _enableSmoothReflections;
  69303. private _reflectionSamples;
  69304. private _smoothSteps;
  69305. /**
  69306. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69307. * @param name The name of the effect.
  69308. * @param scene The scene containing the objects to calculate reflections.
  69309. * @param options The required width/height ratio to downsize to before computing the render pass.
  69310. * @param camera The camera to apply the render pass to.
  69311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69312. * @param engine The engine which the post process will be applied. (default: current engine)
  69313. * @param reusable If the post process can be reused on the same frame. (default: false)
  69314. * @param textureType Type of textures used when performing the post process. (default: 0)
  69315. * @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)
  69316. */
  69317. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69318. /**
  69319. * Gets wether or not smoothing reflections is enabled.
  69320. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69321. */
  69322. get enableSmoothReflections(): boolean;
  69323. /**
  69324. * Sets wether or not smoothing reflections is enabled.
  69325. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69326. */
  69327. set enableSmoothReflections(enabled: boolean);
  69328. /**
  69329. * Gets the number of samples taken while computing reflections. More samples count is high,
  69330. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69331. */
  69332. get reflectionSamples(): number;
  69333. /**
  69334. * Sets the number of samples taken while computing reflections. More samples count is high,
  69335. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69336. */
  69337. set reflectionSamples(samples: number);
  69338. /**
  69339. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69340. * more the post-process will require GPU power and can generate a drop in FPS.
  69341. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69342. */
  69343. get smoothSteps(): number;
  69344. set smoothSteps(steps: number);
  69345. private _updateEffectDefines;
  69346. }
  69347. }
  69348. declare module BABYLON {
  69349. /** @hidden */
  69350. export var standardPixelShader: {
  69351. name: string;
  69352. shader: string;
  69353. };
  69354. }
  69355. declare module BABYLON {
  69356. /**
  69357. * Standard rendering pipeline
  69358. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69359. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69360. */
  69361. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69362. /**
  69363. * Public members
  69364. */
  69365. /**
  69366. * Post-process which contains the original scene color before the pipeline applies all the effects
  69367. */
  69368. originalPostProcess: Nullable<PostProcess>;
  69369. /**
  69370. * Post-process used to down scale an image x4
  69371. */
  69372. downSampleX4PostProcess: Nullable<PostProcess>;
  69373. /**
  69374. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69375. */
  69376. brightPassPostProcess: Nullable<PostProcess>;
  69377. /**
  69378. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69379. */
  69380. blurHPostProcesses: PostProcess[];
  69381. /**
  69382. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69383. */
  69384. blurVPostProcesses: PostProcess[];
  69385. /**
  69386. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69387. */
  69388. textureAdderPostProcess: Nullable<PostProcess>;
  69389. /**
  69390. * Post-process used to create volumetric lighting effect
  69391. */
  69392. volumetricLightPostProcess: Nullable<PostProcess>;
  69393. /**
  69394. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69395. */
  69396. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69397. /**
  69398. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69399. */
  69400. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69401. /**
  69402. * Post-process used to merge the volumetric light effect and the real scene color
  69403. */
  69404. volumetricLightMergePostProces: Nullable<PostProcess>;
  69405. /**
  69406. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69407. */
  69408. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69409. /**
  69410. * Base post-process used to calculate the average luminance of the final image for HDR
  69411. */
  69412. luminancePostProcess: Nullable<PostProcess>;
  69413. /**
  69414. * Post-processes used to create down sample post-processes in order to get
  69415. * the average luminance of the final image for HDR
  69416. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69417. */
  69418. luminanceDownSamplePostProcesses: PostProcess[];
  69419. /**
  69420. * Post-process used to create a HDR effect (light adaptation)
  69421. */
  69422. hdrPostProcess: Nullable<PostProcess>;
  69423. /**
  69424. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69425. */
  69426. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69427. /**
  69428. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69429. */
  69430. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69431. /**
  69432. * Post-process used to merge the final HDR post-process and the real scene color
  69433. */
  69434. hdrFinalPostProcess: Nullable<PostProcess>;
  69435. /**
  69436. * Post-process used to create a lens flare effect
  69437. */
  69438. lensFlarePostProcess: Nullable<PostProcess>;
  69439. /**
  69440. * Post-process that merges the result of the lens flare post-process and the real scene color
  69441. */
  69442. lensFlareComposePostProcess: Nullable<PostProcess>;
  69443. /**
  69444. * Post-process used to create a motion blur effect
  69445. */
  69446. motionBlurPostProcess: Nullable<PostProcess>;
  69447. /**
  69448. * Post-process used to create a depth of field effect
  69449. */
  69450. depthOfFieldPostProcess: Nullable<PostProcess>;
  69451. /**
  69452. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69453. */
  69454. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69455. /**
  69456. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69457. */
  69458. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69459. /**
  69460. * Represents the brightness threshold in order to configure the illuminated surfaces
  69461. */
  69462. brightThreshold: number;
  69463. /**
  69464. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69465. */
  69466. blurWidth: number;
  69467. /**
  69468. * Sets if the blur for highlighted surfaces must be only horizontal
  69469. */
  69470. horizontalBlur: boolean;
  69471. /**
  69472. * Gets the overall exposure used by the pipeline
  69473. */
  69474. get exposure(): number;
  69475. /**
  69476. * Sets the overall exposure used by the pipeline
  69477. */
  69478. set exposure(value: number);
  69479. /**
  69480. * Texture used typically to simulate "dirty" on camera lens
  69481. */
  69482. lensTexture: Nullable<Texture>;
  69483. /**
  69484. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69485. */
  69486. volumetricLightCoefficient: number;
  69487. /**
  69488. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69489. */
  69490. volumetricLightPower: number;
  69491. /**
  69492. * Used the set the blur intensity to smooth the volumetric lights
  69493. */
  69494. volumetricLightBlurScale: number;
  69495. /**
  69496. * Light (spot or directional) used to generate the volumetric lights rays
  69497. * The source light must have a shadow generate so the pipeline can get its
  69498. * depth map
  69499. */
  69500. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69501. /**
  69502. * For eye adaptation, represents the minimum luminance the eye can see
  69503. */
  69504. hdrMinimumLuminance: number;
  69505. /**
  69506. * For eye adaptation, represents the decrease luminance speed
  69507. */
  69508. hdrDecreaseRate: number;
  69509. /**
  69510. * For eye adaptation, represents the increase luminance speed
  69511. */
  69512. hdrIncreaseRate: number;
  69513. /**
  69514. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69515. */
  69516. get hdrAutoExposure(): boolean;
  69517. /**
  69518. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69519. */
  69520. set hdrAutoExposure(value: boolean);
  69521. /**
  69522. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69523. */
  69524. lensColorTexture: Nullable<Texture>;
  69525. /**
  69526. * The overall strengh for the lens flare effect
  69527. */
  69528. lensFlareStrength: number;
  69529. /**
  69530. * Dispersion coefficient for lens flare ghosts
  69531. */
  69532. lensFlareGhostDispersal: number;
  69533. /**
  69534. * Main lens flare halo width
  69535. */
  69536. lensFlareHaloWidth: number;
  69537. /**
  69538. * Based on the lens distortion effect, defines how much the lens flare result
  69539. * is distorted
  69540. */
  69541. lensFlareDistortionStrength: number;
  69542. /**
  69543. * Configures the blur intensity used for for lens flare (halo)
  69544. */
  69545. lensFlareBlurWidth: number;
  69546. /**
  69547. * Lens star texture must be used to simulate rays on the flares and is available
  69548. * in the documentation
  69549. */
  69550. lensStarTexture: Nullable<Texture>;
  69551. /**
  69552. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69553. * flare effect by taking account of the dirt texture
  69554. */
  69555. lensFlareDirtTexture: Nullable<Texture>;
  69556. /**
  69557. * Represents the focal length for the depth of field effect
  69558. */
  69559. depthOfFieldDistance: number;
  69560. /**
  69561. * Represents the blur intensity for the blurred part of the depth of field effect
  69562. */
  69563. depthOfFieldBlurWidth: number;
  69564. /**
  69565. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69566. */
  69567. get motionStrength(): number;
  69568. /**
  69569. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69570. */
  69571. set motionStrength(strength: number);
  69572. /**
  69573. * Gets wether or not the motion blur post-process is object based or screen based.
  69574. */
  69575. get objectBasedMotionBlur(): boolean;
  69576. /**
  69577. * Sets wether or not the motion blur post-process should be object based or screen based
  69578. */
  69579. set objectBasedMotionBlur(value: boolean);
  69580. /**
  69581. * List of animations for the pipeline (IAnimatable implementation)
  69582. */
  69583. animations: Animation[];
  69584. /**
  69585. * Private members
  69586. */
  69587. private _scene;
  69588. private _currentDepthOfFieldSource;
  69589. private _basePostProcess;
  69590. private _fixedExposure;
  69591. private _currentExposure;
  69592. private _hdrAutoExposure;
  69593. private _hdrCurrentLuminance;
  69594. private _motionStrength;
  69595. private _isObjectBasedMotionBlur;
  69596. private _floatTextureType;
  69597. private _camerasToBeAttached;
  69598. private _ratio;
  69599. private _bloomEnabled;
  69600. private _depthOfFieldEnabled;
  69601. private _vlsEnabled;
  69602. private _lensFlareEnabled;
  69603. private _hdrEnabled;
  69604. private _motionBlurEnabled;
  69605. private _fxaaEnabled;
  69606. private _screenSpaceReflectionsEnabled;
  69607. private _motionBlurSamples;
  69608. private _volumetricLightStepsCount;
  69609. private _samples;
  69610. /**
  69611. * @ignore
  69612. * Specifies if the bloom pipeline is enabled
  69613. */
  69614. get BloomEnabled(): boolean;
  69615. set BloomEnabled(enabled: boolean);
  69616. /**
  69617. * @ignore
  69618. * Specifies if the depth of field pipeline is enabed
  69619. */
  69620. get DepthOfFieldEnabled(): boolean;
  69621. set DepthOfFieldEnabled(enabled: boolean);
  69622. /**
  69623. * @ignore
  69624. * Specifies if the lens flare pipeline is enabed
  69625. */
  69626. get LensFlareEnabled(): boolean;
  69627. set LensFlareEnabled(enabled: boolean);
  69628. /**
  69629. * @ignore
  69630. * Specifies if the HDR pipeline is enabled
  69631. */
  69632. get HDREnabled(): boolean;
  69633. set HDREnabled(enabled: boolean);
  69634. /**
  69635. * @ignore
  69636. * Specifies if the volumetric lights scattering effect is enabled
  69637. */
  69638. get VLSEnabled(): boolean;
  69639. set VLSEnabled(enabled: boolean);
  69640. /**
  69641. * @ignore
  69642. * Specifies if the motion blur effect is enabled
  69643. */
  69644. get MotionBlurEnabled(): boolean;
  69645. set MotionBlurEnabled(enabled: boolean);
  69646. /**
  69647. * Specifies if anti-aliasing is enabled
  69648. */
  69649. get fxaaEnabled(): boolean;
  69650. set fxaaEnabled(enabled: boolean);
  69651. /**
  69652. * Specifies if screen space reflections are enabled.
  69653. */
  69654. get screenSpaceReflectionsEnabled(): boolean;
  69655. set screenSpaceReflectionsEnabled(enabled: boolean);
  69656. /**
  69657. * Specifies the number of steps used to calculate the volumetric lights
  69658. * Typically in interval [50, 200]
  69659. */
  69660. get volumetricLightStepsCount(): number;
  69661. set volumetricLightStepsCount(count: number);
  69662. /**
  69663. * Specifies the number of samples used for the motion blur effect
  69664. * Typically in interval [16, 64]
  69665. */
  69666. get motionBlurSamples(): number;
  69667. set motionBlurSamples(samples: number);
  69668. /**
  69669. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69670. */
  69671. get samples(): number;
  69672. set samples(sampleCount: number);
  69673. /**
  69674. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69675. * @constructor
  69676. * @param name The rendering pipeline name
  69677. * @param scene The scene linked to this pipeline
  69678. * @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)
  69679. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69680. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69681. */
  69682. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69683. private _buildPipeline;
  69684. private _createDownSampleX4PostProcess;
  69685. private _createBrightPassPostProcess;
  69686. private _createBlurPostProcesses;
  69687. private _createTextureAdderPostProcess;
  69688. private _createVolumetricLightPostProcess;
  69689. private _createLuminancePostProcesses;
  69690. private _createHdrPostProcess;
  69691. private _createLensFlarePostProcess;
  69692. private _createDepthOfFieldPostProcess;
  69693. private _createMotionBlurPostProcess;
  69694. private _getDepthTexture;
  69695. private _disposePostProcesses;
  69696. /**
  69697. * Dispose of the pipeline and stop all post processes
  69698. */
  69699. dispose(): void;
  69700. /**
  69701. * Serialize the rendering pipeline (Used when exporting)
  69702. * @returns the serialized object
  69703. */
  69704. serialize(): any;
  69705. /**
  69706. * Parse the serialized pipeline
  69707. * @param source Source pipeline.
  69708. * @param scene The scene to load the pipeline to.
  69709. * @param rootUrl The URL of the serialized pipeline.
  69710. * @returns An instantiated pipeline from the serialized object.
  69711. */
  69712. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69713. /**
  69714. * Luminance steps
  69715. */
  69716. static LuminanceSteps: number;
  69717. }
  69718. }
  69719. declare module BABYLON {
  69720. /** @hidden */
  69721. export var stereoscopicInterlacePixelShader: {
  69722. name: string;
  69723. shader: string;
  69724. };
  69725. }
  69726. declare module BABYLON {
  69727. /**
  69728. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69729. */
  69730. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69731. private _stepSize;
  69732. private _passedProcess;
  69733. /**
  69734. * Initializes a StereoscopicInterlacePostProcessI
  69735. * @param name The name of the effect.
  69736. * @param rigCameras The rig cameras to be appled to the post process
  69737. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69738. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  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. */
  69743. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69744. }
  69745. /**
  69746. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69747. */
  69748. export class StereoscopicInterlacePostProcess extends PostProcess {
  69749. private _stepSize;
  69750. private _passedProcess;
  69751. /**
  69752. * Initializes a StereoscopicInterlacePostProcess
  69753. * @param name The name of the effect.
  69754. * @param rigCameras The rig cameras to be appled to the post process
  69755. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69757. * @param engine The engine which the post process will be applied. (default: current engine)
  69758. * @param reusable If the post process can be reused on the same frame. (default: false)
  69759. */
  69760. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69761. }
  69762. }
  69763. declare module BABYLON {
  69764. /** @hidden */
  69765. export var tonemapPixelShader: {
  69766. name: string;
  69767. shader: string;
  69768. };
  69769. }
  69770. declare module BABYLON {
  69771. /** Defines operator used for tonemapping */
  69772. export enum TonemappingOperator {
  69773. /** Hable */
  69774. Hable = 0,
  69775. /** Reinhard */
  69776. Reinhard = 1,
  69777. /** HejiDawson */
  69778. HejiDawson = 2,
  69779. /** Photographic */
  69780. Photographic = 3
  69781. }
  69782. /**
  69783. * Defines a post process to apply tone mapping
  69784. */
  69785. export class TonemapPostProcess extends PostProcess {
  69786. private _operator;
  69787. /** Defines the required exposure adjustement */
  69788. exposureAdjustment: number;
  69789. /**
  69790. * Creates a new TonemapPostProcess
  69791. * @param name defines the name of the postprocess
  69792. * @param _operator defines the operator to use
  69793. * @param exposureAdjustment defines the required exposure adjustement
  69794. * @param camera defines the camera to use (can be null)
  69795. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69796. * @param engine defines the hosting engine (can be ignore if camera is set)
  69797. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69798. */
  69799. constructor(name: string, _operator: TonemappingOperator,
  69800. /** Defines the required exposure adjustement */
  69801. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69802. }
  69803. }
  69804. declare module BABYLON {
  69805. /** @hidden */
  69806. export var volumetricLightScatteringPixelShader: {
  69807. name: string;
  69808. shader: string;
  69809. };
  69810. }
  69811. declare module BABYLON {
  69812. /** @hidden */
  69813. export var volumetricLightScatteringPassVertexShader: {
  69814. name: string;
  69815. shader: string;
  69816. };
  69817. }
  69818. declare module BABYLON {
  69819. /** @hidden */
  69820. export var volumetricLightScatteringPassPixelShader: {
  69821. name: string;
  69822. shader: string;
  69823. };
  69824. }
  69825. declare module BABYLON {
  69826. /**
  69827. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69828. */
  69829. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69830. private _volumetricLightScatteringPass;
  69831. private _volumetricLightScatteringRTT;
  69832. private _viewPort;
  69833. private _screenCoordinates;
  69834. private _cachedDefines;
  69835. /**
  69836. * If not undefined, the mesh position is computed from the attached node position
  69837. */
  69838. attachedNode: {
  69839. position: Vector3;
  69840. };
  69841. /**
  69842. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69843. */
  69844. customMeshPosition: Vector3;
  69845. /**
  69846. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69847. */
  69848. useCustomMeshPosition: boolean;
  69849. /**
  69850. * If the post-process should inverse the light scattering direction
  69851. */
  69852. invert: boolean;
  69853. /**
  69854. * The internal mesh used by the post-process
  69855. */
  69856. mesh: Mesh;
  69857. /**
  69858. * @hidden
  69859. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69860. */
  69861. get useDiffuseColor(): boolean;
  69862. set useDiffuseColor(useDiffuseColor: boolean);
  69863. /**
  69864. * Array containing the excluded meshes not rendered in the internal pass
  69865. */
  69866. excludedMeshes: AbstractMesh[];
  69867. /**
  69868. * Controls the overall intensity of the post-process
  69869. */
  69870. exposure: number;
  69871. /**
  69872. * Dissipates each sample's contribution in range [0, 1]
  69873. */
  69874. decay: number;
  69875. /**
  69876. * Controls the overall intensity of each sample
  69877. */
  69878. weight: number;
  69879. /**
  69880. * Controls the density of each sample
  69881. */
  69882. density: number;
  69883. /**
  69884. * @constructor
  69885. * @param name The post-process name
  69886. * @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)
  69887. * @param camera The camera that the post-process will be attached to
  69888. * @param mesh The mesh used to create the light scattering
  69889. * @param samples The post-process quality, default 100
  69890. * @param samplingModeThe post-process filtering mode
  69891. * @param engine The babylon engine
  69892. * @param reusable If the post-process is reusable
  69893. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69894. */
  69895. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69896. /**
  69897. * Returns the string "VolumetricLightScatteringPostProcess"
  69898. * @returns "VolumetricLightScatteringPostProcess"
  69899. */
  69900. getClassName(): string;
  69901. private _isReady;
  69902. /**
  69903. * Sets the new light position for light scattering effect
  69904. * @param position The new custom light position
  69905. */
  69906. setCustomMeshPosition(position: Vector3): void;
  69907. /**
  69908. * Returns the light position for light scattering effect
  69909. * @return Vector3 The custom light position
  69910. */
  69911. getCustomMeshPosition(): Vector3;
  69912. /**
  69913. * Disposes the internal assets and detaches the post-process from the camera
  69914. */
  69915. dispose(camera: Camera): void;
  69916. /**
  69917. * Returns the render target texture used by the post-process
  69918. * @return the render target texture used by the post-process
  69919. */
  69920. getPass(): RenderTargetTexture;
  69921. private _meshExcluded;
  69922. private _createPass;
  69923. private _updateMeshScreenCoordinates;
  69924. /**
  69925. * Creates a default mesh for the Volumeric Light Scattering post-process
  69926. * @param name The mesh name
  69927. * @param scene The scene where to create the mesh
  69928. * @return the default mesh
  69929. */
  69930. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69931. }
  69932. }
  69933. declare module BABYLON {
  69934. interface Scene {
  69935. /** @hidden (Backing field) */
  69936. _boundingBoxRenderer: BoundingBoxRenderer;
  69937. /** @hidden (Backing field) */
  69938. _forceShowBoundingBoxes: boolean;
  69939. /**
  69940. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69941. */
  69942. forceShowBoundingBoxes: boolean;
  69943. /**
  69944. * Gets the bounding box renderer associated with the scene
  69945. * @returns a BoundingBoxRenderer
  69946. */
  69947. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69948. }
  69949. interface AbstractMesh {
  69950. /** @hidden (Backing field) */
  69951. _showBoundingBox: boolean;
  69952. /**
  69953. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69954. */
  69955. showBoundingBox: boolean;
  69956. }
  69957. /**
  69958. * Component responsible of rendering the bounding box of the meshes in a scene.
  69959. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69960. */
  69961. export class BoundingBoxRenderer implements ISceneComponent {
  69962. /**
  69963. * The component name helpfull to identify the component in the list of scene components.
  69964. */
  69965. readonly name: string;
  69966. /**
  69967. * The scene the component belongs to.
  69968. */
  69969. scene: Scene;
  69970. /**
  69971. * Color of the bounding box lines placed in front of an object
  69972. */
  69973. frontColor: Color3;
  69974. /**
  69975. * Color of the bounding box lines placed behind an object
  69976. */
  69977. backColor: Color3;
  69978. /**
  69979. * Defines if the renderer should show the back lines or not
  69980. */
  69981. showBackLines: boolean;
  69982. /**
  69983. * Observable raised before rendering a bounding box
  69984. */
  69985. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69986. /**
  69987. * Observable raised after rendering a bounding box
  69988. */
  69989. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69990. /**
  69991. * @hidden
  69992. */
  69993. renderList: SmartArray<BoundingBox>;
  69994. private _colorShader;
  69995. private _vertexBuffers;
  69996. private _indexBuffer;
  69997. private _fillIndexBuffer;
  69998. private _fillIndexData;
  69999. /**
  70000. * Instantiates a new bounding box renderer in a scene.
  70001. * @param scene the scene the renderer renders in
  70002. */
  70003. constructor(scene: Scene);
  70004. /**
  70005. * Registers the component in a given scene
  70006. */
  70007. register(): void;
  70008. private _evaluateSubMesh;
  70009. private _activeMesh;
  70010. private _prepareRessources;
  70011. private _createIndexBuffer;
  70012. /**
  70013. * Rebuilds the elements related to this component in case of
  70014. * context lost for instance.
  70015. */
  70016. rebuild(): void;
  70017. /**
  70018. * @hidden
  70019. */
  70020. reset(): void;
  70021. /**
  70022. * Render the bounding boxes of a specific rendering group
  70023. * @param renderingGroupId defines the rendering group to render
  70024. */
  70025. render(renderingGroupId: number): void;
  70026. /**
  70027. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70028. * @param mesh Define the mesh to render the occlusion bounding box for
  70029. */
  70030. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70031. /**
  70032. * Dispose and release the resources attached to this renderer.
  70033. */
  70034. dispose(): void;
  70035. }
  70036. }
  70037. declare module BABYLON {
  70038. interface Scene {
  70039. /** @hidden (Backing field) */
  70040. _depthRenderer: {
  70041. [id: string]: DepthRenderer;
  70042. };
  70043. /**
  70044. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70045. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70046. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70047. * @returns the created depth renderer
  70048. */
  70049. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70050. /**
  70051. * Disables a depth renderer for a given camera
  70052. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70053. */
  70054. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70055. }
  70056. /**
  70057. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70058. * in several rendering techniques.
  70059. */
  70060. export class DepthRendererSceneComponent implements ISceneComponent {
  70061. /**
  70062. * The component name helpfull to identify the component in the list of scene components.
  70063. */
  70064. readonly name: string;
  70065. /**
  70066. * The scene the component belongs to.
  70067. */
  70068. scene: Scene;
  70069. /**
  70070. * Creates a new instance of the component for the given scene
  70071. * @param scene Defines the scene to register the component in
  70072. */
  70073. constructor(scene: Scene);
  70074. /**
  70075. * Registers the component in a given scene
  70076. */
  70077. register(): void;
  70078. /**
  70079. * Rebuilds the elements related to this component in case of
  70080. * context lost for instance.
  70081. */
  70082. rebuild(): void;
  70083. /**
  70084. * Disposes the component and the associated ressources
  70085. */
  70086. dispose(): void;
  70087. private _gatherRenderTargets;
  70088. private _gatherActiveCameraRenderTargets;
  70089. }
  70090. }
  70091. declare module BABYLON {
  70092. /** @hidden */
  70093. export var outlinePixelShader: {
  70094. name: string;
  70095. shader: string;
  70096. };
  70097. }
  70098. declare module BABYLON {
  70099. /** @hidden */
  70100. export var outlineVertexShader: {
  70101. name: string;
  70102. shader: string;
  70103. };
  70104. }
  70105. declare module BABYLON {
  70106. interface Scene {
  70107. /** @hidden */
  70108. _outlineRenderer: OutlineRenderer;
  70109. /**
  70110. * Gets the outline renderer associated with the scene
  70111. * @returns a OutlineRenderer
  70112. */
  70113. getOutlineRenderer(): OutlineRenderer;
  70114. }
  70115. interface AbstractMesh {
  70116. /** @hidden (Backing field) */
  70117. _renderOutline: boolean;
  70118. /**
  70119. * Gets or sets a boolean indicating if the outline must be rendered as well
  70120. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70121. */
  70122. renderOutline: boolean;
  70123. /** @hidden (Backing field) */
  70124. _renderOverlay: boolean;
  70125. /**
  70126. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70127. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70128. */
  70129. renderOverlay: boolean;
  70130. }
  70131. /**
  70132. * This class is responsible to draw bothe outline/overlay of meshes.
  70133. * It should not be used directly but through the available method on mesh.
  70134. */
  70135. export class OutlineRenderer implements ISceneComponent {
  70136. /**
  70137. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70138. */
  70139. private static _StencilReference;
  70140. /**
  70141. * The name of the component. Each component must have a unique name.
  70142. */
  70143. name: string;
  70144. /**
  70145. * The scene the component belongs to.
  70146. */
  70147. scene: Scene;
  70148. /**
  70149. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70150. */
  70151. zOffset: number;
  70152. private _engine;
  70153. private _effect;
  70154. private _cachedDefines;
  70155. private _savedDepthWrite;
  70156. /**
  70157. * Instantiates a new outline renderer. (There could be only one per scene).
  70158. * @param scene Defines the scene it belongs to
  70159. */
  70160. constructor(scene: Scene);
  70161. /**
  70162. * Register the component to one instance of a scene.
  70163. */
  70164. register(): void;
  70165. /**
  70166. * Rebuilds the elements related to this component in case of
  70167. * context lost for instance.
  70168. */
  70169. rebuild(): void;
  70170. /**
  70171. * Disposes the component and the associated ressources.
  70172. */
  70173. dispose(): void;
  70174. /**
  70175. * Renders the outline in the canvas.
  70176. * @param subMesh Defines the sumesh to render
  70177. * @param batch Defines the batch of meshes in case of instances
  70178. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70179. */
  70180. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70181. /**
  70182. * Returns whether or not the outline renderer is ready for a given submesh.
  70183. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70184. * @param subMesh Defines the submesh to check readyness for
  70185. * @param useInstances Defines wheter wee are trying to render instances or not
  70186. * @returns true if ready otherwise false
  70187. */
  70188. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70189. private _beforeRenderingMesh;
  70190. private _afterRenderingMesh;
  70191. }
  70192. }
  70193. declare module BABYLON {
  70194. /**
  70195. * Defines the basic options interface of a Sprite Frame Source Size.
  70196. */
  70197. export interface ISpriteJSONSpriteSourceSize {
  70198. /**
  70199. * number of the original width of the Frame
  70200. */
  70201. w: number;
  70202. /**
  70203. * number of the original height of the Frame
  70204. */
  70205. h: number;
  70206. }
  70207. /**
  70208. * Defines the basic options interface of a Sprite Frame Data.
  70209. */
  70210. export interface ISpriteJSONSpriteFrameData {
  70211. /**
  70212. * number of the x offset of the Frame
  70213. */
  70214. x: number;
  70215. /**
  70216. * number of the y offset of the Frame
  70217. */
  70218. y: number;
  70219. /**
  70220. * number of the width of the Frame
  70221. */
  70222. w: number;
  70223. /**
  70224. * number of the height of the Frame
  70225. */
  70226. h: number;
  70227. }
  70228. /**
  70229. * Defines the basic options interface of a JSON Sprite.
  70230. */
  70231. export interface ISpriteJSONSprite {
  70232. /**
  70233. * string name of the Frame
  70234. */
  70235. filename: string;
  70236. /**
  70237. * ISpriteJSONSpriteFrame basic object of the frame data
  70238. */
  70239. frame: ISpriteJSONSpriteFrameData;
  70240. /**
  70241. * boolean to flag is the frame was rotated.
  70242. */
  70243. rotated: boolean;
  70244. /**
  70245. * boolean to flag is the frame was trimmed.
  70246. */
  70247. trimmed: boolean;
  70248. /**
  70249. * ISpriteJSONSpriteFrame basic object of the source data
  70250. */
  70251. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70252. /**
  70253. * ISpriteJSONSpriteFrame basic object of the source data
  70254. */
  70255. sourceSize: ISpriteJSONSpriteSourceSize;
  70256. }
  70257. /**
  70258. * Defines the basic options interface of a JSON atlas.
  70259. */
  70260. export interface ISpriteJSONAtlas {
  70261. /**
  70262. * Array of objects that contain the frame data.
  70263. */
  70264. frames: Array<ISpriteJSONSprite>;
  70265. /**
  70266. * object basic object containing the sprite meta data.
  70267. */
  70268. meta?: object;
  70269. }
  70270. }
  70271. declare module BABYLON {
  70272. /** @hidden */
  70273. export var spriteMapPixelShader: {
  70274. name: string;
  70275. shader: string;
  70276. };
  70277. }
  70278. declare module BABYLON {
  70279. /** @hidden */
  70280. export var spriteMapVertexShader: {
  70281. name: string;
  70282. shader: string;
  70283. };
  70284. }
  70285. declare module BABYLON {
  70286. /**
  70287. * Defines the basic options interface of a SpriteMap
  70288. */
  70289. export interface ISpriteMapOptions {
  70290. /**
  70291. * Vector2 of the number of cells in the grid.
  70292. */
  70293. stageSize?: Vector2;
  70294. /**
  70295. * Vector2 of the size of the output plane in World Units.
  70296. */
  70297. outputSize?: Vector2;
  70298. /**
  70299. * Vector3 of the position of the output plane in World Units.
  70300. */
  70301. outputPosition?: Vector3;
  70302. /**
  70303. * Vector3 of the rotation of the output plane.
  70304. */
  70305. outputRotation?: Vector3;
  70306. /**
  70307. * number of layers that the system will reserve in resources.
  70308. */
  70309. layerCount?: number;
  70310. /**
  70311. * number of max animation frames a single cell will reserve in resources.
  70312. */
  70313. maxAnimationFrames?: number;
  70314. /**
  70315. * number cell index of the base tile when the system compiles.
  70316. */
  70317. baseTile?: number;
  70318. /**
  70319. * boolean flip the sprite after its been repositioned by the framing data.
  70320. */
  70321. flipU?: boolean;
  70322. /**
  70323. * Vector3 scalar of the global RGB values of the SpriteMap.
  70324. */
  70325. colorMultiply?: Vector3;
  70326. }
  70327. /**
  70328. * Defines the IDisposable interface in order to be cleanable from resources.
  70329. */
  70330. export interface ISpriteMap extends IDisposable {
  70331. /**
  70332. * String name of the SpriteMap.
  70333. */
  70334. name: string;
  70335. /**
  70336. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70337. */
  70338. atlasJSON: ISpriteJSONAtlas;
  70339. /**
  70340. * Texture of the SpriteMap.
  70341. */
  70342. spriteSheet: Texture;
  70343. /**
  70344. * The parameters to initialize the SpriteMap with.
  70345. */
  70346. options: ISpriteMapOptions;
  70347. }
  70348. /**
  70349. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70350. */
  70351. export class SpriteMap implements ISpriteMap {
  70352. /** The Name of the spriteMap */
  70353. name: string;
  70354. /** The JSON file with the frame and meta data */
  70355. atlasJSON: ISpriteJSONAtlas;
  70356. /** The systems Sprite Sheet Texture */
  70357. spriteSheet: Texture;
  70358. /** Arguments passed with the Constructor */
  70359. options: ISpriteMapOptions;
  70360. /** Public Sprite Storage array, parsed from atlasJSON */
  70361. sprites: Array<ISpriteJSONSprite>;
  70362. /** Returns the Number of Sprites in the System */
  70363. get spriteCount(): number;
  70364. /** Returns the Position of Output Plane*/
  70365. get position(): Vector3;
  70366. /** Returns the Position of Output Plane*/
  70367. set position(v: Vector3);
  70368. /** Returns the Rotation of Output Plane*/
  70369. get rotation(): Vector3;
  70370. /** Returns the Rotation of Output Plane*/
  70371. set rotation(v: Vector3);
  70372. /** Sets the AnimationMap*/
  70373. get animationMap(): RawTexture;
  70374. /** Sets the AnimationMap*/
  70375. set animationMap(v: RawTexture);
  70376. /** Scene that the SpriteMap was created in */
  70377. private _scene;
  70378. /** Texture Buffer of Float32 that holds tile frame data*/
  70379. private _frameMap;
  70380. /** Texture Buffers of Float32 that holds tileMap data*/
  70381. private _tileMaps;
  70382. /** Texture Buffer of Float32 that holds Animation Data*/
  70383. private _animationMap;
  70384. /** Custom ShaderMaterial Central to the System*/
  70385. private _material;
  70386. /** Custom ShaderMaterial Central to the System*/
  70387. private _output;
  70388. /** Systems Time Ticker*/
  70389. private _time;
  70390. /**
  70391. * Creates a new SpriteMap
  70392. * @param name defines the SpriteMaps Name
  70393. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70394. * @param spriteSheet is the Texture that the Sprites are on.
  70395. * @param options a basic deployment configuration
  70396. * @param scene The Scene that the map is deployed on
  70397. */
  70398. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70399. /**
  70400. * Returns tileID location
  70401. * @returns Vector2 the cell position ID
  70402. */
  70403. getTileID(): Vector2;
  70404. /**
  70405. * Gets the UV location of the mouse over the SpriteMap.
  70406. * @returns Vector2 the UV position of the mouse interaction
  70407. */
  70408. getMousePosition(): Vector2;
  70409. /**
  70410. * Creates the "frame" texture Buffer
  70411. * -------------------------------------
  70412. * Structure of frames
  70413. * "filename": "Falling-Water-2.png",
  70414. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70415. * "rotated": true,
  70416. * "trimmed": true,
  70417. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70418. * "sourceSize": {"w":32,"h":32}
  70419. * @returns RawTexture of the frameMap
  70420. */
  70421. private _createFrameBuffer;
  70422. /**
  70423. * Creates the tileMap texture Buffer
  70424. * @param buffer normally and array of numbers, or a false to generate from scratch
  70425. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70426. * @returns RawTexture of the tileMap
  70427. */
  70428. private _createTileBuffer;
  70429. /**
  70430. * Modifies the data of the tileMaps
  70431. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70432. * @param pos is the iVector2 Coordinates of the Tile
  70433. * @param tile The SpriteIndex of the new Tile
  70434. */
  70435. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70436. /**
  70437. * Creates the animationMap texture Buffer
  70438. * @param buffer normally and array of numbers, or a false to generate from scratch
  70439. * @returns RawTexture of the animationMap
  70440. */
  70441. private _createTileAnimationBuffer;
  70442. /**
  70443. * Modifies the data of the animationMap
  70444. * @param cellID is the Index of the Sprite
  70445. * @param _frame is the target Animation frame
  70446. * @param toCell is the Target Index of the next frame of the animation
  70447. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70448. * @param speed is a global scalar of the time variable on the map.
  70449. */
  70450. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70451. /**
  70452. * Exports the .tilemaps file
  70453. */
  70454. saveTileMaps(): void;
  70455. /**
  70456. * Imports the .tilemaps file
  70457. * @param url of the .tilemaps file
  70458. */
  70459. loadTileMaps(url: string): void;
  70460. /**
  70461. * Release associated resources
  70462. */
  70463. dispose(): void;
  70464. }
  70465. }
  70466. declare module BABYLON {
  70467. /**
  70468. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70469. * @see http://doc.babylonjs.com/babylon101/sprites
  70470. */
  70471. export class SpritePackedManager extends SpriteManager {
  70472. /** defines the packed manager's name */
  70473. name: string;
  70474. /**
  70475. * Creates a new sprite manager from a packed sprite sheet
  70476. * @param name defines the manager's name
  70477. * @param imgUrl defines the sprite sheet url
  70478. * @param capacity defines the maximum allowed number of sprites
  70479. * @param scene defines the hosting scene
  70480. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70481. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70482. * @param samplingMode defines the smapling mode to use with spritesheet
  70483. * @param fromPacked set to true; do not alter
  70484. */
  70485. constructor(
  70486. /** defines the packed manager's name */
  70487. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70488. }
  70489. }
  70490. declare module BABYLON {
  70491. /**
  70492. * Defines the list of states available for a task inside a AssetsManager
  70493. */
  70494. export enum AssetTaskState {
  70495. /**
  70496. * Initialization
  70497. */
  70498. INIT = 0,
  70499. /**
  70500. * Running
  70501. */
  70502. RUNNING = 1,
  70503. /**
  70504. * Done
  70505. */
  70506. DONE = 2,
  70507. /**
  70508. * Error
  70509. */
  70510. ERROR = 3
  70511. }
  70512. /**
  70513. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70514. */
  70515. export abstract class AbstractAssetTask {
  70516. /**
  70517. * Task name
  70518. */ name: string;
  70519. /**
  70520. * Callback called when the task is successful
  70521. */
  70522. onSuccess: (task: any) => void;
  70523. /**
  70524. * Callback called when the task is not successful
  70525. */
  70526. onError: (task: any, message?: string, exception?: any) => void;
  70527. /**
  70528. * Creates a new AssetsManager
  70529. * @param name defines the name of the task
  70530. */
  70531. constructor(
  70532. /**
  70533. * Task name
  70534. */ name: string);
  70535. private _isCompleted;
  70536. private _taskState;
  70537. private _errorObject;
  70538. /**
  70539. * Get if the task is completed
  70540. */
  70541. get isCompleted(): boolean;
  70542. /**
  70543. * Gets the current state of the task
  70544. */
  70545. get taskState(): AssetTaskState;
  70546. /**
  70547. * Gets the current error object (if task is in error)
  70548. */
  70549. get errorObject(): {
  70550. message?: string;
  70551. exception?: any;
  70552. };
  70553. /**
  70554. * Internal only
  70555. * @hidden
  70556. */
  70557. _setErrorObject(message?: string, exception?: any): void;
  70558. /**
  70559. * Execute the current task
  70560. * @param scene defines the scene where you want your assets to be loaded
  70561. * @param onSuccess is a callback called when the task is successfully executed
  70562. * @param onError is a callback called if an error occurs
  70563. */
  70564. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70565. /**
  70566. * Execute the current task
  70567. * @param scene defines the scene where you want your assets to be loaded
  70568. * @param onSuccess is a callback called when the task is successfully executed
  70569. * @param onError is a callback called if an error occurs
  70570. */
  70571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70572. /**
  70573. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70574. * This can be used with failed tasks that have the reason for failure fixed.
  70575. */
  70576. reset(): void;
  70577. private onErrorCallback;
  70578. private onDoneCallback;
  70579. }
  70580. /**
  70581. * Define the interface used by progress events raised during assets loading
  70582. */
  70583. export interface IAssetsProgressEvent {
  70584. /**
  70585. * Defines the number of remaining tasks to process
  70586. */
  70587. remainingCount: number;
  70588. /**
  70589. * Defines the total number of tasks
  70590. */
  70591. totalCount: number;
  70592. /**
  70593. * Defines the task that was just processed
  70594. */
  70595. task: AbstractAssetTask;
  70596. }
  70597. /**
  70598. * Class used to share progress information about assets loading
  70599. */
  70600. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70601. /**
  70602. * Defines the number of remaining tasks to process
  70603. */
  70604. remainingCount: number;
  70605. /**
  70606. * Defines the total number of tasks
  70607. */
  70608. totalCount: number;
  70609. /**
  70610. * Defines the task that was just processed
  70611. */
  70612. task: AbstractAssetTask;
  70613. /**
  70614. * Creates a AssetsProgressEvent
  70615. * @param remainingCount defines the number of remaining tasks to process
  70616. * @param totalCount defines the total number of tasks
  70617. * @param task defines the task that was just processed
  70618. */
  70619. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70620. }
  70621. /**
  70622. * Define a task used by AssetsManager to load meshes
  70623. */
  70624. export class MeshAssetTask extends AbstractAssetTask {
  70625. /**
  70626. * Defines the name of the task
  70627. */
  70628. name: string;
  70629. /**
  70630. * Defines the list of mesh's names you want to load
  70631. */
  70632. meshesNames: any;
  70633. /**
  70634. * Defines the root url to use as a base to load your meshes and associated resources
  70635. */
  70636. rootUrl: string;
  70637. /**
  70638. * Defines the filename or File of the scene to load from
  70639. */
  70640. sceneFilename: string | File;
  70641. /**
  70642. * Gets the list of loaded meshes
  70643. */
  70644. loadedMeshes: Array<AbstractMesh>;
  70645. /**
  70646. * Gets the list of loaded particle systems
  70647. */
  70648. loadedParticleSystems: Array<IParticleSystem>;
  70649. /**
  70650. * Gets the list of loaded skeletons
  70651. */
  70652. loadedSkeletons: Array<Skeleton>;
  70653. /**
  70654. * Gets the list of loaded animation groups
  70655. */
  70656. loadedAnimationGroups: Array<AnimationGroup>;
  70657. /**
  70658. * Callback called when the task is successful
  70659. */
  70660. onSuccess: (task: MeshAssetTask) => void;
  70661. /**
  70662. * Callback called when the task is successful
  70663. */
  70664. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70665. /**
  70666. * Creates a new MeshAssetTask
  70667. * @param name defines the name of the task
  70668. * @param meshesNames defines the list of mesh's names you want to load
  70669. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70670. * @param sceneFilename defines the filename or File of the scene to load from
  70671. */
  70672. constructor(
  70673. /**
  70674. * Defines the name of the task
  70675. */
  70676. name: string,
  70677. /**
  70678. * Defines the list of mesh's names you want to load
  70679. */
  70680. meshesNames: any,
  70681. /**
  70682. * Defines the root url to use as a base to load your meshes and associated resources
  70683. */
  70684. rootUrl: string,
  70685. /**
  70686. * Defines the filename or File of the scene to load from
  70687. */
  70688. sceneFilename: string | File);
  70689. /**
  70690. * Execute the current task
  70691. * @param scene defines the scene where you want your assets to be loaded
  70692. * @param onSuccess is a callback called when the task is successfully executed
  70693. * @param onError is a callback called if an error occurs
  70694. */
  70695. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70696. }
  70697. /**
  70698. * Define a task used by AssetsManager to load text content
  70699. */
  70700. export class TextFileAssetTask extends AbstractAssetTask {
  70701. /**
  70702. * Defines the name of the task
  70703. */
  70704. name: string;
  70705. /**
  70706. * Defines the location of the file to load
  70707. */
  70708. url: string;
  70709. /**
  70710. * Gets the loaded text string
  70711. */
  70712. text: string;
  70713. /**
  70714. * Callback called when the task is successful
  70715. */
  70716. onSuccess: (task: TextFileAssetTask) => void;
  70717. /**
  70718. * Callback called when the task is successful
  70719. */
  70720. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70721. /**
  70722. * Creates a new TextFileAssetTask object
  70723. * @param name defines the name of the task
  70724. * @param url defines the location of the file to load
  70725. */
  70726. constructor(
  70727. /**
  70728. * Defines the name of the task
  70729. */
  70730. name: string,
  70731. /**
  70732. * Defines the location of the file to load
  70733. */
  70734. url: string);
  70735. /**
  70736. * Execute the current task
  70737. * @param scene defines the scene where you want your assets to be loaded
  70738. * @param onSuccess is a callback called when the task is successfully executed
  70739. * @param onError is a callback called if an error occurs
  70740. */
  70741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70742. }
  70743. /**
  70744. * Define a task used by AssetsManager to load binary data
  70745. */
  70746. export class BinaryFileAssetTask extends AbstractAssetTask {
  70747. /**
  70748. * Defines the name of the task
  70749. */
  70750. name: string;
  70751. /**
  70752. * Defines the location of the file to load
  70753. */
  70754. url: string;
  70755. /**
  70756. * Gets the lodaded data (as an array buffer)
  70757. */
  70758. data: ArrayBuffer;
  70759. /**
  70760. * Callback called when the task is successful
  70761. */
  70762. onSuccess: (task: BinaryFileAssetTask) => void;
  70763. /**
  70764. * Callback called when the task is successful
  70765. */
  70766. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70767. /**
  70768. * Creates a new BinaryFileAssetTask object
  70769. * @param name defines the name of the new task
  70770. * @param url defines the location of the file to load
  70771. */
  70772. constructor(
  70773. /**
  70774. * Defines the name of the task
  70775. */
  70776. name: string,
  70777. /**
  70778. * Defines the location of the file to load
  70779. */
  70780. url: string);
  70781. /**
  70782. * Execute the current task
  70783. * @param scene defines the scene where you want your assets to be loaded
  70784. * @param onSuccess is a callback called when the task is successfully executed
  70785. * @param onError is a callback called if an error occurs
  70786. */
  70787. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70788. }
  70789. /**
  70790. * Define a task used by AssetsManager to load images
  70791. */
  70792. export class ImageAssetTask extends AbstractAssetTask {
  70793. /**
  70794. * Defines the name of the task
  70795. */
  70796. name: string;
  70797. /**
  70798. * Defines the location of the image to load
  70799. */
  70800. url: string;
  70801. /**
  70802. * Gets the loaded images
  70803. */
  70804. image: HTMLImageElement;
  70805. /**
  70806. * Callback called when the task is successful
  70807. */
  70808. onSuccess: (task: ImageAssetTask) => void;
  70809. /**
  70810. * Callback called when the task is successful
  70811. */
  70812. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70813. /**
  70814. * Creates a new ImageAssetTask
  70815. * @param name defines the name of the task
  70816. * @param url defines the location of the image to load
  70817. */
  70818. constructor(
  70819. /**
  70820. * Defines the name of the task
  70821. */
  70822. name: string,
  70823. /**
  70824. * Defines the location of the image to load
  70825. */
  70826. url: string);
  70827. /**
  70828. * Execute the current task
  70829. * @param scene defines the scene where you want your assets to be loaded
  70830. * @param onSuccess is a callback called when the task is successfully executed
  70831. * @param onError is a callback called if an error occurs
  70832. */
  70833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70834. }
  70835. /**
  70836. * Defines the interface used by texture loading tasks
  70837. */
  70838. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70839. /**
  70840. * Gets the loaded texture
  70841. */
  70842. texture: TEX;
  70843. }
  70844. /**
  70845. * Define a task used by AssetsManager to load 2D textures
  70846. */
  70847. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70848. /**
  70849. * Defines the name of the task
  70850. */
  70851. name: string;
  70852. /**
  70853. * Defines the location of the file to load
  70854. */
  70855. url: string;
  70856. /**
  70857. * Defines if mipmap should not be generated (default is false)
  70858. */
  70859. noMipmap?: boolean | undefined;
  70860. /**
  70861. * Defines if texture must be inverted on Y axis (default is true)
  70862. */
  70863. invertY: boolean;
  70864. /**
  70865. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70866. */
  70867. samplingMode: number;
  70868. /**
  70869. * Gets the loaded texture
  70870. */
  70871. texture: Texture;
  70872. /**
  70873. * Callback called when the task is successful
  70874. */
  70875. onSuccess: (task: TextureAssetTask) => void;
  70876. /**
  70877. * Callback called when the task is successful
  70878. */
  70879. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70880. /**
  70881. * Creates a new TextureAssetTask object
  70882. * @param name defines the name of the task
  70883. * @param url defines the location of the file to load
  70884. * @param noMipmap defines if mipmap should not be generated (default is false)
  70885. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70886. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70887. */
  70888. constructor(
  70889. /**
  70890. * Defines the name of the task
  70891. */
  70892. name: string,
  70893. /**
  70894. * Defines the location of the file to load
  70895. */
  70896. url: string,
  70897. /**
  70898. * Defines if mipmap should not be generated (default is false)
  70899. */
  70900. noMipmap?: boolean | undefined,
  70901. /**
  70902. * Defines if texture must be inverted on Y axis (default is true)
  70903. */
  70904. invertY?: boolean,
  70905. /**
  70906. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70907. */
  70908. samplingMode?: number);
  70909. /**
  70910. * Execute the current task
  70911. * @param scene defines the scene where you want your assets to be loaded
  70912. * @param onSuccess is a callback called when the task is successfully executed
  70913. * @param onError is a callback called if an error occurs
  70914. */
  70915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70916. }
  70917. /**
  70918. * Define a task used by AssetsManager to load cube textures
  70919. */
  70920. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70921. /**
  70922. * Defines the name of the task
  70923. */
  70924. name: string;
  70925. /**
  70926. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70927. */
  70928. url: string;
  70929. /**
  70930. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70931. */
  70932. extensions?: string[] | undefined;
  70933. /**
  70934. * Defines if mipmaps should not be generated (default is false)
  70935. */
  70936. noMipmap?: boolean | undefined;
  70937. /**
  70938. * Defines the explicit list of files (undefined by default)
  70939. */
  70940. files?: string[] | undefined;
  70941. /**
  70942. * Gets the loaded texture
  70943. */
  70944. texture: CubeTexture;
  70945. /**
  70946. * Callback called when the task is successful
  70947. */
  70948. onSuccess: (task: CubeTextureAssetTask) => void;
  70949. /**
  70950. * Callback called when the task is successful
  70951. */
  70952. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70953. /**
  70954. * Creates a new CubeTextureAssetTask
  70955. * @param name defines the name of the task
  70956. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70957. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70958. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70959. * @param files defines the explicit list of files (undefined by default)
  70960. */
  70961. constructor(
  70962. /**
  70963. * Defines the name of the task
  70964. */
  70965. name: string,
  70966. /**
  70967. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70968. */
  70969. url: string,
  70970. /**
  70971. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70972. */
  70973. extensions?: string[] | undefined,
  70974. /**
  70975. * Defines if mipmaps should not be generated (default is false)
  70976. */
  70977. noMipmap?: boolean | undefined,
  70978. /**
  70979. * Defines the explicit list of files (undefined by default)
  70980. */
  70981. files?: string[] | undefined);
  70982. /**
  70983. * Execute the current task
  70984. * @param scene defines the scene where you want your assets to be loaded
  70985. * @param onSuccess is a callback called when the task is successfully executed
  70986. * @param onError is a callback called if an error occurs
  70987. */
  70988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70989. }
  70990. /**
  70991. * Define a task used by AssetsManager to load HDR cube textures
  70992. */
  70993. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70994. /**
  70995. * Defines the name of the task
  70996. */
  70997. name: string;
  70998. /**
  70999. * Defines the location of the file to load
  71000. */
  71001. url: string;
  71002. /**
  71003. * Defines the desired size (the more it increases the longer the generation will be)
  71004. */
  71005. size: number;
  71006. /**
  71007. * Defines if mipmaps should not be generated (default is false)
  71008. */
  71009. noMipmap: boolean;
  71010. /**
  71011. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71012. */
  71013. generateHarmonics: boolean;
  71014. /**
  71015. * 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)
  71016. */
  71017. gammaSpace: boolean;
  71018. /**
  71019. * Internal Use Only
  71020. */
  71021. reserved: boolean;
  71022. /**
  71023. * Gets the loaded texture
  71024. */
  71025. texture: HDRCubeTexture;
  71026. /**
  71027. * Callback called when the task is successful
  71028. */
  71029. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71030. /**
  71031. * Callback called when the task is successful
  71032. */
  71033. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71034. /**
  71035. * Creates a new HDRCubeTextureAssetTask object
  71036. * @param name defines the name of the task
  71037. * @param url defines the location of the file to load
  71038. * @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.
  71039. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71040. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71041. * @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)
  71042. * @param reserved Internal use only
  71043. */
  71044. constructor(
  71045. /**
  71046. * Defines the name of the task
  71047. */
  71048. name: string,
  71049. /**
  71050. * Defines the location of the file to load
  71051. */
  71052. url: string,
  71053. /**
  71054. * Defines the desired size (the more it increases the longer the generation will be)
  71055. */
  71056. size: number,
  71057. /**
  71058. * Defines if mipmaps should not be generated (default is false)
  71059. */
  71060. noMipmap?: boolean,
  71061. /**
  71062. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71063. */
  71064. generateHarmonics?: boolean,
  71065. /**
  71066. * 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)
  71067. */
  71068. gammaSpace?: boolean,
  71069. /**
  71070. * Internal Use Only
  71071. */
  71072. reserved?: boolean);
  71073. /**
  71074. * Execute the current task
  71075. * @param scene defines the scene where you want your assets to be loaded
  71076. * @param onSuccess is a callback called when the task is successfully executed
  71077. * @param onError is a callback called if an error occurs
  71078. */
  71079. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71080. }
  71081. /**
  71082. * Define a task used by AssetsManager to load Equirectangular cube textures
  71083. */
  71084. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71085. /**
  71086. * Defines the name of the task
  71087. */
  71088. name: string;
  71089. /**
  71090. * Defines the location of the file to load
  71091. */
  71092. url: string;
  71093. /**
  71094. * Defines the desired size (the more it increases the longer the generation will be)
  71095. */
  71096. size: number;
  71097. /**
  71098. * Defines if mipmaps should not be generated (default is false)
  71099. */
  71100. noMipmap: boolean;
  71101. /**
  71102. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71103. * but the standard material would require them in Gamma space) (default is true)
  71104. */
  71105. gammaSpace: boolean;
  71106. /**
  71107. * Gets the loaded texture
  71108. */
  71109. texture: EquiRectangularCubeTexture;
  71110. /**
  71111. * Callback called when the task is successful
  71112. */
  71113. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71114. /**
  71115. * Callback called when the task is successful
  71116. */
  71117. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71118. /**
  71119. * Creates a new EquiRectangularCubeTextureAssetTask object
  71120. * @param name defines the name of the task
  71121. * @param url defines the location of the file to load
  71122. * @param size defines the desired size (the more it increases the longer the generation will be)
  71123. * If the size is omitted this implies you are using a preprocessed cubemap.
  71124. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71125. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71126. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71127. * (default is true)
  71128. */
  71129. constructor(
  71130. /**
  71131. * Defines the name of the task
  71132. */
  71133. name: string,
  71134. /**
  71135. * Defines the location of the file to load
  71136. */
  71137. url: string,
  71138. /**
  71139. * Defines the desired size (the more it increases the longer the generation will be)
  71140. */
  71141. size: number,
  71142. /**
  71143. * Defines if mipmaps should not be generated (default is false)
  71144. */
  71145. noMipmap?: boolean,
  71146. /**
  71147. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71148. * but the standard material would require them in Gamma space) (default is true)
  71149. */
  71150. gammaSpace?: boolean);
  71151. /**
  71152. * Execute the current task
  71153. * @param scene defines the scene where you want your assets to be loaded
  71154. * @param onSuccess is a callback called when the task is successfully executed
  71155. * @param onError is a callback called if an error occurs
  71156. */
  71157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71158. }
  71159. /**
  71160. * This class can be used to easily import assets into a scene
  71161. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71162. */
  71163. export class AssetsManager {
  71164. private _scene;
  71165. private _isLoading;
  71166. protected _tasks: AbstractAssetTask[];
  71167. protected _waitingTasksCount: number;
  71168. protected _totalTasksCount: number;
  71169. /**
  71170. * Callback called when all tasks are processed
  71171. */
  71172. onFinish: (tasks: AbstractAssetTask[]) => void;
  71173. /**
  71174. * Callback called when a task is successful
  71175. */
  71176. onTaskSuccess: (task: AbstractAssetTask) => void;
  71177. /**
  71178. * Callback called when a task had an error
  71179. */
  71180. onTaskError: (task: AbstractAssetTask) => void;
  71181. /**
  71182. * Callback called when a task is done (whatever the result is)
  71183. */
  71184. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71185. /**
  71186. * Observable called when all tasks are processed
  71187. */
  71188. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71189. /**
  71190. * Observable called when a task had an error
  71191. */
  71192. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71193. /**
  71194. * Observable called when all tasks were executed
  71195. */
  71196. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71197. /**
  71198. * Observable called when a task is done (whatever the result is)
  71199. */
  71200. onProgressObservable: Observable<IAssetsProgressEvent>;
  71201. /**
  71202. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71203. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71204. */
  71205. useDefaultLoadingScreen: boolean;
  71206. /**
  71207. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71208. * when all assets have been downloaded.
  71209. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71210. */
  71211. autoHideLoadingUI: boolean;
  71212. /**
  71213. * Creates a new AssetsManager
  71214. * @param scene defines the scene to work on
  71215. */
  71216. constructor(scene: Scene);
  71217. /**
  71218. * Add a MeshAssetTask to the list of active tasks
  71219. * @param taskName defines the name of the new task
  71220. * @param meshesNames defines the name of meshes to load
  71221. * @param rootUrl defines the root url to use to locate files
  71222. * @param sceneFilename defines the filename of the scene file
  71223. * @returns a new MeshAssetTask object
  71224. */
  71225. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71226. /**
  71227. * Add a TextFileAssetTask to the list of active tasks
  71228. * @param taskName defines the name of the new task
  71229. * @param url defines the url of the file to load
  71230. * @returns a new TextFileAssetTask object
  71231. */
  71232. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71233. /**
  71234. * Add a BinaryFileAssetTask to the list of active tasks
  71235. * @param taskName defines the name of the new task
  71236. * @param url defines the url of the file to load
  71237. * @returns a new BinaryFileAssetTask object
  71238. */
  71239. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71240. /**
  71241. * Add a ImageAssetTask to the list of active tasks
  71242. * @param taskName defines the name of the new task
  71243. * @param url defines the url of the file to load
  71244. * @returns a new ImageAssetTask object
  71245. */
  71246. addImageTask(taskName: string, url: string): ImageAssetTask;
  71247. /**
  71248. * Add a TextureAssetTask to the list of active tasks
  71249. * @param taskName defines the name of the new task
  71250. * @param url defines the url of the file to load
  71251. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71252. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71253. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71254. * @returns a new TextureAssetTask object
  71255. */
  71256. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71257. /**
  71258. * Add a CubeTextureAssetTask to the list of active tasks
  71259. * @param taskName defines the name of the new task
  71260. * @param url defines the url of the file to load
  71261. * @param extensions defines the extension to use to load the cube map (can be null)
  71262. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71263. * @param files defines the list of files to load (can be null)
  71264. * @returns a new CubeTextureAssetTask object
  71265. */
  71266. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71267. /**
  71268. *
  71269. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71270. * @param taskName defines the name of the new task
  71271. * @param url defines the url of the file to load
  71272. * @param size defines the size you want for the cubemap (can be null)
  71273. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71274. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71275. * @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)
  71276. * @param reserved Internal use only
  71277. * @returns a new HDRCubeTextureAssetTask object
  71278. */
  71279. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71280. /**
  71281. *
  71282. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71283. * @param taskName defines the name of the new task
  71284. * @param url defines the url of the file to load
  71285. * @param size defines the size you want for the cubemap (can be null)
  71286. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71287. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71288. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71289. * @returns a new EquiRectangularCubeTextureAssetTask object
  71290. */
  71291. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71292. /**
  71293. * Remove a task from the assets manager.
  71294. * @param task the task to remove
  71295. */
  71296. removeTask(task: AbstractAssetTask): void;
  71297. private _decreaseWaitingTasksCount;
  71298. private _runTask;
  71299. /**
  71300. * Reset the AssetsManager and remove all tasks
  71301. * @return the current instance of the AssetsManager
  71302. */
  71303. reset(): AssetsManager;
  71304. /**
  71305. * Start the loading process
  71306. * @return the current instance of the AssetsManager
  71307. */
  71308. load(): AssetsManager;
  71309. /**
  71310. * Start the loading process as an async operation
  71311. * @return a promise returning the list of failed tasks
  71312. */
  71313. loadAsync(): Promise<void>;
  71314. }
  71315. }
  71316. declare module BABYLON {
  71317. /**
  71318. * Wrapper class for promise with external resolve and reject.
  71319. */
  71320. export class Deferred<T> {
  71321. /**
  71322. * The promise associated with this deferred object.
  71323. */
  71324. readonly promise: Promise<T>;
  71325. private _resolve;
  71326. private _reject;
  71327. /**
  71328. * The resolve method of the promise associated with this deferred object.
  71329. */
  71330. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71331. /**
  71332. * The reject method of the promise associated with this deferred object.
  71333. */
  71334. get reject(): (reason?: any) => void;
  71335. /**
  71336. * Constructor for this deferred object.
  71337. */
  71338. constructor();
  71339. }
  71340. }
  71341. declare module BABYLON {
  71342. /**
  71343. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71344. */
  71345. export class MeshExploder {
  71346. private _centerMesh;
  71347. private _meshes;
  71348. private _meshesOrigins;
  71349. private _toCenterVectors;
  71350. private _scaledDirection;
  71351. private _newPosition;
  71352. private _centerPosition;
  71353. /**
  71354. * Explodes meshes from a center mesh.
  71355. * @param meshes The meshes to explode.
  71356. * @param centerMesh The mesh to be center of explosion.
  71357. */
  71358. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71359. private _setCenterMesh;
  71360. /**
  71361. * Get class name
  71362. * @returns "MeshExploder"
  71363. */
  71364. getClassName(): string;
  71365. /**
  71366. * "Exploded meshes"
  71367. * @returns Array of meshes with the centerMesh at index 0.
  71368. */
  71369. getMeshes(): Array<Mesh>;
  71370. /**
  71371. * Explodes meshes giving a specific direction
  71372. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71373. */
  71374. explode(direction?: number): void;
  71375. }
  71376. }
  71377. declare module BABYLON {
  71378. /**
  71379. * Class used to help managing file picking and drag'n'drop
  71380. */
  71381. export class FilesInput {
  71382. /**
  71383. * List of files ready to be loaded
  71384. */
  71385. static get FilesToLoad(): {
  71386. [key: string]: File;
  71387. };
  71388. /**
  71389. * Callback called when a file is processed
  71390. */
  71391. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71392. private _engine;
  71393. private _currentScene;
  71394. private _sceneLoadedCallback;
  71395. private _progressCallback;
  71396. private _additionalRenderLoopLogicCallback;
  71397. private _textureLoadingCallback;
  71398. private _startingProcessingFilesCallback;
  71399. private _onReloadCallback;
  71400. private _errorCallback;
  71401. private _elementToMonitor;
  71402. private _sceneFileToLoad;
  71403. private _filesToLoad;
  71404. /**
  71405. * Creates a new FilesInput
  71406. * @param engine defines the rendering engine
  71407. * @param scene defines the hosting scene
  71408. * @param sceneLoadedCallback callback called when scene is loaded
  71409. * @param progressCallback callback called to track progress
  71410. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71411. * @param textureLoadingCallback callback called when a texture is loading
  71412. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71413. * @param onReloadCallback callback called when a reload is requested
  71414. * @param errorCallback callback call if an error occurs
  71415. */
  71416. 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);
  71417. private _dragEnterHandler;
  71418. private _dragOverHandler;
  71419. private _dropHandler;
  71420. /**
  71421. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71422. * @param elementToMonitor defines the DOM element to track
  71423. */
  71424. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71425. /**
  71426. * Release all associated resources
  71427. */
  71428. dispose(): void;
  71429. private renderFunction;
  71430. private drag;
  71431. private drop;
  71432. private _traverseFolder;
  71433. private _processFiles;
  71434. /**
  71435. * Load files from a drop event
  71436. * @param event defines the drop event to use as source
  71437. */
  71438. loadFiles(event: any): void;
  71439. private _processReload;
  71440. /**
  71441. * Reload the current scene from the loaded files
  71442. */
  71443. reload(): void;
  71444. }
  71445. }
  71446. declare module BABYLON {
  71447. /**
  71448. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71450. */
  71451. export class SceneOptimization {
  71452. /**
  71453. * Defines the priority of this optimization (0 by default which means first in the list)
  71454. */
  71455. priority: number;
  71456. /**
  71457. * Gets a string describing the action executed by the current optimization
  71458. * @returns description string
  71459. */
  71460. getDescription(): string;
  71461. /**
  71462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71463. * @param scene defines the current scene where to apply this optimization
  71464. * @param optimizer defines the current optimizer
  71465. * @returns true if everything that can be done was applied
  71466. */
  71467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71468. /**
  71469. * Creates the SceneOptimization object
  71470. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71471. * @param desc defines the description associated with the optimization
  71472. */
  71473. constructor(
  71474. /**
  71475. * Defines the priority of this optimization (0 by default which means first in the list)
  71476. */
  71477. priority?: number);
  71478. }
  71479. /**
  71480. * Defines an optimization used to reduce the size of render target textures
  71481. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71482. */
  71483. export class TextureOptimization extends SceneOptimization {
  71484. /**
  71485. * Defines the priority of this optimization (0 by default which means first in the list)
  71486. */
  71487. priority: number;
  71488. /**
  71489. * 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
  71490. */
  71491. maximumSize: number;
  71492. /**
  71493. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71494. */
  71495. step: number;
  71496. /**
  71497. * Gets a string describing the action executed by the current optimization
  71498. * @returns description string
  71499. */
  71500. getDescription(): string;
  71501. /**
  71502. * Creates the TextureOptimization object
  71503. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71504. * @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
  71505. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71506. */
  71507. constructor(
  71508. /**
  71509. * Defines the priority of this optimization (0 by default which means first in the list)
  71510. */
  71511. priority?: number,
  71512. /**
  71513. * 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
  71514. */
  71515. maximumSize?: number,
  71516. /**
  71517. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71518. */
  71519. step?: number);
  71520. /**
  71521. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71522. * @param scene defines the current scene where to apply this optimization
  71523. * @param optimizer defines the current optimizer
  71524. * @returns true if everything that can be done was applied
  71525. */
  71526. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71527. }
  71528. /**
  71529. * Defines an optimization used to increase or decrease the rendering resolution
  71530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71531. */
  71532. export class HardwareScalingOptimization extends SceneOptimization {
  71533. /**
  71534. * Defines the priority of this optimization (0 by default which means first in the list)
  71535. */
  71536. priority: number;
  71537. /**
  71538. * Defines the maximum scale to use (2 by default)
  71539. */
  71540. maximumScale: number;
  71541. /**
  71542. * Defines the step to use between two passes (0.5 by default)
  71543. */
  71544. step: number;
  71545. private _currentScale;
  71546. private _directionOffset;
  71547. /**
  71548. * Gets a string describing the action executed by the current optimization
  71549. * @return description string
  71550. */
  71551. getDescription(): string;
  71552. /**
  71553. * Creates the HardwareScalingOptimization object
  71554. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71555. * @param maximumScale defines the maximum scale to use (2 by default)
  71556. * @param step defines the step to use between two passes (0.5 by default)
  71557. */
  71558. constructor(
  71559. /**
  71560. * Defines the priority of this optimization (0 by default which means first in the list)
  71561. */
  71562. priority?: number,
  71563. /**
  71564. * Defines the maximum scale to use (2 by default)
  71565. */
  71566. maximumScale?: number,
  71567. /**
  71568. * Defines the step to use between two passes (0.5 by default)
  71569. */
  71570. step?: number);
  71571. /**
  71572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71573. * @param scene defines the current scene where to apply this optimization
  71574. * @param optimizer defines the current optimizer
  71575. * @returns true if everything that can be done was applied
  71576. */
  71577. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71578. }
  71579. /**
  71580. * Defines an optimization used to remove shadows
  71581. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71582. */
  71583. export class ShadowsOptimization extends SceneOptimization {
  71584. /**
  71585. * Gets a string describing the action executed by the current optimization
  71586. * @return description string
  71587. */
  71588. getDescription(): string;
  71589. /**
  71590. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71591. * @param scene defines the current scene where to apply this optimization
  71592. * @param optimizer defines the current optimizer
  71593. * @returns true if everything that can be done was applied
  71594. */
  71595. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71596. }
  71597. /**
  71598. * Defines an optimization used to turn post-processes off
  71599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71600. */
  71601. export class PostProcessesOptimization extends SceneOptimization {
  71602. /**
  71603. * Gets a string describing the action executed by the current optimization
  71604. * @return description string
  71605. */
  71606. getDescription(): string;
  71607. /**
  71608. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71609. * @param scene defines the current scene where to apply this optimization
  71610. * @param optimizer defines the current optimizer
  71611. * @returns true if everything that can be done was applied
  71612. */
  71613. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71614. }
  71615. /**
  71616. * Defines an optimization used to turn lens flares off
  71617. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71618. */
  71619. export class LensFlaresOptimization extends SceneOptimization {
  71620. /**
  71621. * Gets a string describing the action executed by the current optimization
  71622. * @return description string
  71623. */
  71624. getDescription(): string;
  71625. /**
  71626. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71627. * @param scene defines the current scene where to apply this optimization
  71628. * @param optimizer defines the current optimizer
  71629. * @returns true if everything that can be done was applied
  71630. */
  71631. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71632. }
  71633. /**
  71634. * Defines an optimization based on user defined callback.
  71635. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71636. */
  71637. export class CustomOptimization extends SceneOptimization {
  71638. /**
  71639. * Callback called to apply the custom optimization.
  71640. */
  71641. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71642. /**
  71643. * Callback called to get custom description
  71644. */
  71645. onGetDescription: () => string;
  71646. /**
  71647. * Gets a string describing the action executed by the current optimization
  71648. * @returns description string
  71649. */
  71650. getDescription(): string;
  71651. /**
  71652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71653. * @param scene defines the current scene where to apply this optimization
  71654. * @param optimizer defines the current optimizer
  71655. * @returns true if everything that can be done was applied
  71656. */
  71657. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71658. }
  71659. /**
  71660. * Defines an optimization used to turn particles off
  71661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71662. */
  71663. export class ParticlesOptimization extends SceneOptimization {
  71664. /**
  71665. * Gets a string describing the action executed by the current optimization
  71666. * @return description string
  71667. */
  71668. getDescription(): string;
  71669. /**
  71670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71671. * @param scene defines the current scene where to apply this optimization
  71672. * @param optimizer defines the current optimizer
  71673. * @returns true if everything that can be done was applied
  71674. */
  71675. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71676. }
  71677. /**
  71678. * Defines an optimization used to turn render targets off
  71679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71680. */
  71681. export class RenderTargetsOptimization extends SceneOptimization {
  71682. /**
  71683. * Gets a string describing the action executed by the current optimization
  71684. * @return description string
  71685. */
  71686. getDescription(): string;
  71687. /**
  71688. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71689. * @param scene defines the current scene where to apply this optimization
  71690. * @param optimizer defines the current optimizer
  71691. * @returns true if everything that can be done was applied
  71692. */
  71693. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71694. }
  71695. /**
  71696. * Defines an optimization used to merge meshes with compatible materials
  71697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71698. */
  71699. export class MergeMeshesOptimization extends SceneOptimization {
  71700. private static _UpdateSelectionTree;
  71701. /**
  71702. * Gets or sets a boolean which defines if optimization octree has to be updated
  71703. */
  71704. static get UpdateSelectionTree(): boolean;
  71705. /**
  71706. * Gets or sets a boolean which defines if optimization octree has to be updated
  71707. */
  71708. static set UpdateSelectionTree(value: boolean);
  71709. /**
  71710. * Gets a string describing the action executed by the current optimization
  71711. * @return description string
  71712. */
  71713. getDescription(): string;
  71714. private _canBeMerged;
  71715. /**
  71716. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71717. * @param scene defines the current scene where to apply this optimization
  71718. * @param optimizer defines the current optimizer
  71719. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71720. * @returns true if everything that can be done was applied
  71721. */
  71722. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71723. }
  71724. /**
  71725. * Defines a list of options used by SceneOptimizer
  71726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71727. */
  71728. export class SceneOptimizerOptions {
  71729. /**
  71730. * Defines the target frame rate to reach (60 by default)
  71731. */
  71732. targetFrameRate: number;
  71733. /**
  71734. * Defines the interval between two checkes (2000ms by default)
  71735. */
  71736. trackerDuration: number;
  71737. /**
  71738. * Gets the list of optimizations to apply
  71739. */
  71740. optimizations: SceneOptimization[];
  71741. /**
  71742. * Creates a new list of options used by SceneOptimizer
  71743. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71744. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71745. */
  71746. constructor(
  71747. /**
  71748. * Defines the target frame rate to reach (60 by default)
  71749. */
  71750. targetFrameRate?: number,
  71751. /**
  71752. * Defines the interval between two checkes (2000ms by default)
  71753. */
  71754. trackerDuration?: number);
  71755. /**
  71756. * Add a new optimization
  71757. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71758. * @returns the current SceneOptimizerOptions
  71759. */
  71760. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71761. /**
  71762. * Add a new custom optimization
  71763. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71764. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71765. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71766. * @returns the current SceneOptimizerOptions
  71767. */
  71768. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71769. /**
  71770. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71771. * @param targetFrameRate defines the target frame rate (60 by default)
  71772. * @returns a SceneOptimizerOptions object
  71773. */
  71774. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71775. /**
  71776. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71777. * @param targetFrameRate defines the target frame rate (60 by default)
  71778. * @returns a SceneOptimizerOptions object
  71779. */
  71780. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71781. /**
  71782. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71783. * @param targetFrameRate defines the target frame rate (60 by default)
  71784. * @returns a SceneOptimizerOptions object
  71785. */
  71786. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71787. }
  71788. /**
  71789. * Class used to run optimizations in order to reach a target frame rate
  71790. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71791. */
  71792. export class SceneOptimizer implements IDisposable {
  71793. private _isRunning;
  71794. private _options;
  71795. private _scene;
  71796. private _currentPriorityLevel;
  71797. private _targetFrameRate;
  71798. private _trackerDuration;
  71799. private _currentFrameRate;
  71800. private _sceneDisposeObserver;
  71801. private _improvementMode;
  71802. /**
  71803. * Defines an observable called when the optimizer reaches the target frame rate
  71804. */
  71805. onSuccessObservable: Observable<SceneOptimizer>;
  71806. /**
  71807. * Defines an observable called when the optimizer enables an optimization
  71808. */
  71809. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71810. /**
  71811. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71812. */
  71813. onFailureObservable: Observable<SceneOptimizer>;
  71814. /**
  71815. * Gets a boolean indicating if the optimizer is in improvement mode
  71816. */
  71817. get isInImprovementMode(): boolean;
  71818. /**
  71819. * Gets the current priority level (0 at start)
  71820. */
  71821. get currentPriorityLevel(): number;
  71822. /**
  71823. * Gets the current frame rate checked by the SceneOptimizer
  71824. */
  71825. get currentFrameRate(): number;
  71826. /**
  71827. * Gets or sets the current target frame rate (60 by default)
  71828. */
  71829. get targetFrameRate(): number;
  71830. /**
  71831. * Gets or sets the current target frame rate (60 by default)
  71832. */
  71833. set targetFrameRate(value: number);
  71834. /**
  71835. * Gets or sets the current interval between two checks (every 2000ms by default)
  71836. */
  71837. get trackerDuration(): number;
  71838. /**
  71839. * Gets or sets the current interval between two checks (every 2000ms by default)
  71840. */
  71841. set trackerDuration(value: number);
  71842. /**
  71843. * Gets the list of active optimizations
  71844. */
  71845. get optimizations(): SceneOptimization[];
  71846. /**
  71847. * Creates a new SceneOptimizer
  71848. * @param scene defines the scene to work on
  71849. * @param options defines the options to use with the SceneOptimizer
  71850. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71851. * @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)
  71852. */
  71853. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71854. /**
  71855. * Stops the current optimizer
  71856. */
  71857. stop(): void;
  71858. /**
  71859. * Reset the optimizer to initial step (current priority level = 0)
  71860. */
  71861. reset(): void;
  71862. /**
  71863. * Start the optimizer. By default it will try to reach a specific framerate
  71864. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71865. */
  71866. start(): void;
  71867. private _checkCurrentState;
  71868. /**
  71869. * Release all resources
  71870. */
  71871. dispose(): void;
  71872. /**
  71873. * Helper function to create a SceneOptimizer with one single line of code
  71874. * @param scene defines the scene to work on
  71875. * @param options defines the options to use with the SceneOptimizer
  71876. * @param onSuccess defines a callback to call on success
  71877. * @param onFailure defines a callback to call on failure
  71878. * @returns the new SceneOptimizer object
  71879. */
  71880. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71881. }
  71882. }
  71883. declare module BABYLON {
  71884. /**
  71885. * Class used to serialize a scene into a string
  71886. */
  71887. export class SceneSerializer {
  71888. /**
  71889. * Clear cache used by a previous serialization
  71890. */
  71891. static ClearCache(): void;
  71892. /**
  71893. * Serialize a scene into a JSON compatible object
  71894. * @param scene defines the scene to serialize
  71895. * @returns a JSON compatible object
  71896. */
  71897. static Serialize(scene: Scene): any;
  71898. /**
  71899. * Serialize a mesh into a JSON compatible object
  71900. * @param toSerialize defines the mesh to serialize
  71901. * @param withParents defines if parents must be serialized as well
  71902. * @param withChildren defines if children must be serialized as well
  71903. * @returns a JSON compatible object
  71904. */
  71905. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71906. }
  71907. }
  71908. declare module BABYLON {
  71909. /**
  71910. * Class used to host texture specific utilities
  71911. */
  71912. export class TextureTools {
  71913. /**
  71914. * Uses the GPU to create a copy texture rescaled at a given size
  71915. * @param texture Texture to copy from
  71916. * @param width defines the desired width
  71917. * @param height defines the desired height
  71918. * @param useBilinearMode defines if bilinear mode has to be used
  71919. * @return the generated texture
  71920. */
  71921. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71922. }
  71923. }
  71924. declare module BABYLON {
  71925. /**
  71926. * This represents the different options available for the video capture.
  71927. */
  71928. export interface VideoRecorderOptions {
  71929. /** Defines the mime type of the video. */
  71930. mimeType: string;
  71931. /** Defines the FPS the video should be recorded at. */
  71932. fps: number;
  71933. /** Defines the chunk size for the recording data. */
  71934. recordChunckSize: number;
  71935. /** The audio tracks to attach to the recording. */
  71936. audioTracks?: MediaStreamTrack[];
  71937. }
  71938. /**
  71939. * This can help with recording videos from BabylonJS.
  71940. * This is based on the available WebRTC functionalities of the browser.
  71941. *
  71942. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71943. */
  71944. export class VideoRecorder {
  71945. private static readonly _defaultOptions;
  71946. /**
  71947. * Returns whether or not the VideoRecorder is available in your browser.
  71948. * @param engine Defines the Babylon Engine.
  71949. * @returns true if supported otherwise false.
  71950. */
  71951. static IsSupported(engine: Engine): boolean;
  71952. private readonly _options;
  71953. private _canvas;
  71954. private _mediaRecorder;
  71955. private _recordedChunks;
  71956. private _fileName;
  71957. private _resolve;
  71958. private _reject;
  71959. /**
  71960. * True when a recording is already in progress.
  71961. */
  71962. get isRecording(): boolean;
  71963. /**
  71964. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71965. * @param engine Defines the BabylonJS Engine you wish to record.
  71966. * @param options Defines options that can be used to customize the capture.
  71967. */
  71968. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71969. /**
  71970. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71971. */
  71972. stopRecording(): void;
  71973. /**
  71974. * Starts recording the canvas for a max duration specified in parameters.
  71975. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71976. * If null no automatic download will start and you can rely on the promise to get the data back.
  71977. * @param maxDuration Defines the maximum recording time in seconds.
  71978. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71979. * @return A promise callback at the end of the recording with the video data in Blob.
  71980. */
  71981. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71982. /**
  71983. * Releases internal resources used during the recording.
  71984. */
  71985. dispose(): void;
  71986. private _handleDataAvailable;
  71987. private _handleError;
  71988. private _handleStop;
  71989. }
  71990. }
  71991. declare module BABYLON {
  71992. /**
  71993. * Class containing a set of static utilities functions for screenshots
  71994. */
  71995. export class ScreenshotTools {
  71996. /**
  71997. * Captures a screenshot of the current rendering
  71998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71999. * @param engine defines the rendering engine
  72000. * @param camera defines the source camera
  72001. * @param size This parameter can be set to a single number or to an object with the
  72002. * following (optional) properties: precision, width, height. If a single number is passed,
  72003. * it will be used for both width and height. If an object is passed, the screenshot size
  72004. * will be derived from the parameters. The precision property is a multiplier allowing
  72005. * rendering at a higher or lower resolution
  72006. * @param successCallback defines the callback receives a single parameter which contains the
  72007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72008. * src parameter of an <img> to display it
  72009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72010. * Check your browser for supported MIME types
  72011. */
  72012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72013. /**
  72014. * Captures a screenshot of the current rendering
  72015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72016. * @param engine defines the rendering engine
  72017. * @param camera defines the source camera
  72018. * @param size This parameter can be set to a single number or to an object with the
  72019. * following (optional) properties: precision, width, height. If a single number is passed,
  72020. * it will be used for both width and height. If an object is passed, the screenshot size
  72021. * will be derived from the parameters. The precision property is a multiplier allowing
  72022. * rendering at a higher or lower resolution
  72023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72024. * Check your browser for supported MIME types
  72025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72026. * to the src parameter of an <img> to display it
  72027. */
  72028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72029. /**
  72030. * Generates an image screenshot from the specified camera.
  72031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72032. * @param engine The engine to use for rendering
  72033. * @param camera The camera to use for rendering
  72034. * @param size This parameter can be set to a single number or to an object with the
  72035. * following (optional) properties: precision, width, height. If a single number is passed,
  72036. * it will be used for both width and height. If an object is passed, the screenshot size
  72037. * will be derived from the parameters. The precision property is a multiplier allowing
  72038. * rendering at a higher or lower resolution
  72039. * @param successCallback The callback receives a single parameter which contains the
  72040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72041. * src parameter of an <img> to display it
  72042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72043. * Check your browser for supported MIME types
  72044. * @param samples Texture samples (default: 1)
  72045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72046. * @param fileName A name for for the downloaded file.
  72047. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72048. */
  72049. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72050. /**
  72051. * Generates an image screenshot from the specified camera.
  72052. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72053. * @param engine The engine to use for rendering
  72054. * @param camera The camera to use for rendering
  72055. * @param size This parameter can be set to a single number or to an object with the
  72056. * following (optional) properties: precision, width, height. If a single number is passed,
  72057. * it will be used for both width and height. If an object is passed, the screenshot size
  72058. * will be derived from the parameters. The precision property is a multiplier allowing
  72059. * rendering at a higher or lower resolution
  72060. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72061. * Check your browser for supported MIME types
  72062. * @param samples Texture samples (default: 1)
  72063. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72064. * @param fileName A name for for the downloaded file.
  72065. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72066. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72067. * to the src parameter of an <img> to display it
  72068. */
  72069. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72070. /**
  72071. * Gets height and width for screenshot size
  72072. * @private
  72073. */
  72074. private static _getScreenshotSize;
  72075. }
  72076. }
  72077. declare module BABYLON {
  72078. /**
  72079. * Interface for a data buffer
  72080. */
  72081. export interface IDataBuffer {
  72082. /**
  72083. * Reads bytes from the data buffer.
  72084. * @param byteOffset The byte offset to read
  72085. * @param byteLength The byte length to read
  72086. * @returns A promise that resolves when the bytes are read
  72087. */
  72088. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72089. /**
  72090. * The byte length of the buffer.
  72091. */
  72092. readonly byteLength: number;
  72093. }
  72094. /**
  72095. * Utility class for reading from a data buffer
  72096. */
  72097. export class DataReader {
  72098. /**
  72099. * The data buffer associated with this data reader.
  72100. */
  72101. readonly buffer: IDataBuffer;
  72102. /**
  72103. * The current byte offset from the beginning of the data buffer.
  72104. */
  72105. byteOffset: number;
  72106. private _dataView;
  72107. private _dataByteOffset;
  72108. /**
  72109. * Constructor
  72110. * @param buffer The buffer to read
  72111. */
  72112. constructor(buffer: IDataBuffer);
  72113. /**
  72114. * Loads the given byte length.
  72115. * @param byteLength The byte length to load
  72116. * @returns A promise that resolves when the load is complete
  72117. */
  72118. loadAsync(byteLength: number): Promise<void>;
  72119. /**
  72120. * Read a unsigned 32-bit integer from the currently loaded data range.
  72121. * @returns The 32-bit integer read
  72122. */
  72123. readUint32(): number;
  72124. /**
  72125. * Read a byte array from the currently loaded data range.
  72126. * @param byteLength The byte length to read
  72127. * @returns The byte array read
  72128. */
  72129. readUint8Array(byteLength: number): Uint8Array;
  72130. /**
  72131. * Read a string from the currently loaded data range.
  72132. * @param byteLength The byte length to read
  72133. * @returns The string read
  72134. */
  72135. readString(byteLength: number): string;
  72136. /**
  72137. * Skips the given byte length the currently loaded data range.
  72138. * @param byteLength The byte length to skip
  72139. */
  72140. skipBytes(byteLength: number): void;
  72141. }
  72142. }
  72143. declare module BABYLON {
  72144. /**
  72145. * Class for storing data to local storage if available or in-memory storage otherwise
  72146. */
  72147. export class DataStorage {
  72148. private static _Storage;
  72149. private static _GetStorage;
  72150. /**
  72151. * Reads a string from the data storage
  72152. * @param key The key to read
  72153. * @param defaultValue The value if the key doesn't exist
  72154. * @returns The string value
  72155. */
  72156. static ReadString(key: string, defaultValue: string): string;
  72157. /**
  72158. * Writes a string to the data storage
  72159. * @param key The key to write
  72160. * @param value The value to write
  72161. */
  72162. static WriteString(key: string, value: string): void;
  72163. /**
  72164. * Reads a boolean from the data storage
  72165. * @param key The key to read
  72166. * @param defaultValue The value if the key doesn't exist
  72167. * @returns The boolean value
  72168. */
  72169. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72170. /**
  72171. * Writes a boolean to the data storage
  72172. * @param key The key to write
  72173. * @param value The value to write
  72174. */
  72175. static WriteBoolean(key: string, value: boolean): void;
  72176. /**
  72177. * Reads a number from the data storage
  72178. * @param key The key to read
  72179. * @param defaultValue The value if the key doesn't exist
  72180. * @returns The number value
  72181. */
  72182. static ReadNumber(key: string, defaultValue: number): number;
  72183. /**
  72184. * Writes a number to the data storage
  72185. * @param key The key to write
  72186. * @param value The value to write
  72187. */
  72188. static WriteNumber(key: string, value: number): void;
  72189. }
  72190. }
  72191. declare module BABYLON {
  72192. /**
  72193. * An interface for all Hit test features
  72194. */
  72195. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72196. /**
  72197. * Triggered when new babylon (transformed) hit test results are available
  72198. */
  72199. onHitTestResultObservable: Observable<T[]>;
  72200. }
  72201. /**
  72202. * Options used for hit testing
  72203. */
  72204. export interface IWebXRLegacyHitTestOptions {
  72205. /**
  72206. * Only test when user interacted with the scene. Default - hit test every frame
  72207. */
  72208. testOnPointerDownOnly?: boolean;
  72209. /**
  72210. * The node to use to transform the local results to world coordinates
  72211. */
  72212. worldParentNode?: TransformNode;
  72213. }
  72214. /**
  72215. * Interface defining the babylon result of raycasting/hit-test
  72216. */
  72217. export interface IWebXRLegacyHitResult {
  72218. /**
  72219. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72220. */
  72221. transformationMatrix: Matrix;
  72222. /**
  72223. * The native hit test result
  72224. */
  72225. xrHitResult: XRHitResult | XRHitTestResult;
  72226. }
  72227. /**
  72228. * The currently-working hit-test module.
  72229. * Hit test (or Ray-casting) is used to interact with the real world.
  72230. * For further information read here - https://github.com/immersive-web/hit-test
  72231. */
  72232. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72233. /**
  72234. * options to use when constructing this feature
  72235. */
  72236. readonly options: IWebXRLegacyHitTestOptions;
  72237. private _direction;
  72238. private _mat;
  72239. private _onSelectEnabled;
  72240. private _origin;
  72241. /**
  72242. * The module's name
  72243. */
  72244. static readonly Name: string;
  72245. /**
  72246. * The (Babylon) version of this module.
  72247. * This is an integer representing the implementation version.
  72248. * This number does not correspond to the WebXR specs version
  72249. */
  72250. static readonly Version: number;
  72251. /**
  72252. * Populated with the last native XR Hit Results
  72253. */
  72254. lastNativeXRHitResults: XRHitResult[];
  72255. /**
  72256. * Triggered when new babylon (transformed) hit test results are available
  72257. */
  72258. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72259. /**
  72260. * Creates a new instance of the (legacy version) hit test feature
  72261. * @param _xrSessionManager an instance of WebXRSessionManager
  72262. * @param options options to use when constructing this feature
  72263. */
  72264. constructor(_xrSessionManager: WebXRSessionManager,
  72265. /**
  72266. * options to use when constructing this feature
  72267. */
  72268. options?: IWebXRLegacyHitTestOptions);
  72269. /**
  72270. * execute a hit test with an XR Ray
  72271. *
  72272. * @param xrSession a native xrSession that will execute this hit test
  72273. * @param xrRay the ray (position and direction) to use for ray-casting
  72274. * @param referenceSpace native XR reference space to use for the hit-test
  72275. * @param filter filter function that will filter the results
  72276. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72277. */
  72278. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72279. /**
  72280. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72281. * @param event the (select) event to use to select with
  72282. * @param referenceSpace the reference space to use for this hit test
  72283. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72284. */
  72285. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72286. /**
  72287. * attach this feature
  72288. * Will usually be called by the features manager
  72289. *
  72290. * @returns true if successful.
  72291. */
  72292. attach(): boolean;
  72293. /**
  72294. * detach this feature.
  72295. * Will usually be called by the features manager
  72296. *
  72297. * @returns true if successful.
  72298. */
  72299. detach(): boolean;
  72300. /**
  72301. * Dispose this feature and all of the resources attached
  72302. */
  72303. dispose(): void;
  72304. protected _onXRFrame(frame: XRFrame): void;
  72305. private _onHitTestResults;
  72306. private _onSelect;
  72307. }
  72308. }
  72309. declare module BABYLON {
  72310. /**
  72311. * Options used for hit testing (version 2)
  72312. */
  72313. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72314. /**
  72315. * Do not create a permanent hit test. Will usually be used when only
  72316. * transient inputs are needed.
  72317. */
  72318. disablePermanentHitTest?: boolean;
  72319. /**
  72320. * Enable transient (for example touch-based) hit test inspections
  72321. */
  72322. enableTransientHitTest?: boolean;
  72323. /**
  72324. * Offset ray for the permanent hit test
  72325. */
  72326. offsetRay?: Vector3;
  72327. /**
  72328. * Offset ray for the transient hit test
  72329. */
  72330. transientOffsetRay?: Vector3;
  72331. /**
  72332. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72333. */
  72334. useReferenceSpace?: boolean;
  72335. }
  72336. /**
  72337. * Interface defining the babylon result of hit-test
  72338. */
  72339. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72340. /**
  72341. * The input source that generated this hit test (if transient)
  72342. */
  72343. inputSource?: XRInputSource;
  72344. /**
  72345. * Is this a transient hit test
  72346. */
  72347. isTransient?: boolean;
  72348. /**
  72349. * Position of the hit test result
  72350. */
  72351. position: Vector3;
  72352. /**
  72353. * Rotation of the hit test result
  72354. */
  72355. rotationQuaternion: Quaternion;
  72356. /**
  72357. * The native hit test result
  72358. */
  72359. xrHitResult: XRHitTestResult;
  72360. }
  72361. /**
  72362. * The currently-working hit-test module.
  72363. * Hit test (or Ray-casting) is used to interact with the real world.
  72364. * For further information read here - https://github.com/immersive-web/hit-test
  72365. *
  72366. * Tested on chrome (mobile) 80.
  72367. */
  72368. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72369. /**
  72370. * options to use when constructing this feature
  72371. */
  72372. readonly options: IWebXRHitTestOptions;
  72373. private _tmpMat;
  72374. private _tmpPos;
  72375. private _tmpQuat;
  72376. private _transientXrHitTestSource;
  72377. private _xrHitTestSource;
  72378. private initHitTestSource;
  72379. /**
  72380. * The module's name
  72381. */
  72382. static readonly Name: string;
  72383. /**
  72384. * The (Babylon) version of this module.
  72385. * This is an integer representing the implementation version.
  72386. * This number does not correspond to the WebXR specs version
  72387. */
  72388. static readonly Version: number;
  72389. /**
  72390. * When set to true, each hit test will have its own position/rotation objects
  72391. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72392. * the developers will clone them or copy them as they see fit.
  72393. */
  72394. autoCloneTransformation: boolean;
  72395. /**
  72396. * Triggered when new babylon (transformed) hit test results are available
  72397. */
  72398. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72399. /**
  72400. * Use this to temporarily pause hit test checks.
  72401. */
  72402. paused: boolean;
  72403. /**
  72404. * Creates a new instance of the hit test feature
  72405. * @param _xrSessionManager an instance of WebXRSessionManager
  72406. * @param options options to use when constructing this feature
  72407. */
  72408. constructor(_xrSessionManager: WebXRSessionManager,
  72409. /**
  72410. * options to use when constructing this feature
  72411. */
  72412. options?: IWebXRHitTestOptions);
  72413. /**
  72414. * attach this feature
  72415. * Will usually be called by the features manager
  72416. *
  72417. * @returns true if successful.
  72418. */
  72419. attach(): boolean;
  72420. /**
  72421. * detach this feature.
  72422. * Will usually be called by the features manager
  72423. *
  72424. * @returns true if successful.
  72425. */
  72426. detach(): boolean;
  72427. /**
  72428. * Dispose this feature and all of the resources attached
  72429. */
  72430. dispose(): void;
  72431. protected _onXRFrame(frame: XRFrame): void;
  72432. private _processWebXRHitTestResult;
  72433. }
  72434. }
  72435. declare module BABYLON {
  72436. /**
  72437. * Configuration options of the anchor system
  72438. */
  72439. export interface IWebXRAnchorSystemOptions {
  72440. /**
  72441. * a node that will be used to convert local to world coordinates
  72442. */
  72443. worldParentNode?: TransformNode;
  72444. /**
  72445. * If set to true a reference of the created anchors will be kept until the next session starts
  72446. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72447. */
  72448. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72449. }
  72450. /**
  72451. * A babylon container for an XR Anchor
  72452. */
  72453. export interface IWebXRAnchor {
  72454. /**
  72455. * A babylon-assigned ID for this anchor
  72456. */
  72457. id: number;
  72458. /**
  72459. * Transformation matrix to apply to an object attached to this anchor
  72460. */
  72461. transformationMatrix: Matrix;
  72462. /**
  72463. * The native anchor object
  72464. */
  72465. xrAnchor: XRAnchor;
  72466. /**
  72467. * if defined, this object will be constantly updated by the anchor's position and rotation
  72468. */
  72469. attachedNode?: TransformNode;
  72470. }
  72471. /**
  72472. * An implementation of the anchor system for WebXR.
  72473. * For further information see https://github.com/immersive-web/anchors/
  72474. */
  72475. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72476. private _options;
  72477. private _lastFrameDetected;
  72478. private _trackedAnchors;
  72479. private _referenceSpaceForFrameAnchors;
  72480. private _futureAnchors;
  72481. /**
  72482. * The module's name
  72483. */
  72484. static readonly Name: string;
  72485. /**
  72486. * The (Babylon) version of this module.
  72487. * This is an integer representing the implementation version.
  72488. * This number does not correspond to the WebXR specs version
  72489. */
  72490. static readonly Version: number;
  72491. /**
  72492. * Observers registered here will be executed when a new anchor was added to the session
  72493. */
  72494. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72495. /**
  72496. * Observers registered here will be executed when an anchor was removed from the session
  72497. */
  72498. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72499. /**
  72500. * Observers registered here will be executed when an existing anchor updates
  72501. * This can execute N times every frame
  72502. */
  72503. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72504. /**
  72505. * Set the reference space to use for anchor creation, when not using a hit test.
  72506. * Will default to the session's reference space if not defined
  72507. */
  72508. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72509. /**
  72510. * constructs a new anchor system
  72511. * @param _xrSessionManager an instance of WebXRSessionManager
  72512. * @param _options configuration object for this feature
  72513. */
  72514. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72515. private _tmpVector;
  72516. private _tmpQuaternion;
  72517. private _populateTmpTransformation;
  72518. /**
  72519. * Create a new anchor point using a hit test result at a specific point in the scene
  72520. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72521. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72522. *
  72523. * @param hitTestResult The hit test result to use for this anchor creation
  72524. * @param position an optional position offset for this anchor
  72525. * @param rotationQuaternion an optional rotation offset for this anchor
  72526. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72527. */
  72528. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72529. /**
  72530. * Add a new anchor at a specific position and rotation
  72531. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72532. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72533. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72534. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72535. *
  72536. * @param position the position in which to add an anchor
  72537. * @param rotationQuaternion an optional rotation for the anchor transformation
  72538. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72539. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72540. */
  72541. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72542. /**
  72543. * detach this feature.
  72544. * Will usually be called by the features manager
  72545. *
  72546. * @returns true if successful.
  72547. */
  72548. detach(): boolean;
  72549. /**
  72550. * Dispose this feature and all of the resources attached
  72551. */
  72552. dispose(): void;
  72553. protected _onXRFrame(frame: XRFrame): void;
  72554. /**
  72555. * avoiding using Array.find for global support.
  72556. * @param xrAnchor the plane to find in the array
  72557. */
  72558. private _findIndexInAnchorArray;
  72559. private _updateAnchorWithXRFrame;
  72560. private _createAnchorAtTransformation;
  72561. }
  72562. }
  72563. declare module BABYLON {
  72564. /**
  72565. * Options used in the plane detector module
  72566. */
  72567. export interface IWebXRPlaneDetectorOptions {
  72568. /**
  72569. * The node to use to transform the local results to world coordinates
  72570. */
  72571. worldParentNode?: TransformNode;
  72572. /**
  72573. * If set to true a reference of the created planes will be kept until the next session starts
  72574. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72575. */
  72576. doNotRemovePlanesOnSessionEnded?: boolean;
  72577. }
  72578. /**
  72579. * A babylon interface for a WebXR plane.
  72580. * A Plane is actually a polygon, built from N points in space
  72581. *
  72582. * Supported in chrome 79, not supported in canary 81 ATM
  72583. */
  72584. export interface IWebXRPlane {
  72585. /**
  72586. * a babylon-assigned ID for this polygon
  72587. */
  72588. id: number;
  72589. /**
  72590. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72591. */
  72592. polygonDefinition: Array<Vector3>;
  72593. /**
  72594. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72595. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72596. */
  72597. transformationMatrix: Matrix;
  72598. /**
  72599. * the native xr-plane object
  72600. */
  72601. xrPlane: XRPlane;
  72602. }
  72603. /**
  72604. * The plane detector is used to detect planes in the real world when in AR
  72605. * For more information see https://github.com/immersive-web/real-world-geometry/
  72606. */
  72607. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72608. private _options;
  72609. private _detectedPlanes;
  72610. private _enabled;
  72611. private _lastFrameDetected;
  72612. /**
  72613. * The module's name
  72614. */
  72615. static readonly Name: string;
  72616. /**
  72617. * The (Babylon) version of this module.
  72618. * This is an integer representing the implementation version.
  72619. * This number does not correspond to the WebXR specs version
  72620. */
  72621. static readonly Version: number;
  72622. /**
  72623. * Observers registered here will be executed when a new plane was added to the session
  72624. */
  72625. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72626. /**
  72627. * Observers registered here will be executed when a plane is no longer detected in the session
  72628. */
  72629. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72630. /**
  72631. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72632. * This can execute N times every frame
  72633. */
  72634. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72635. /**
  72636. * construct a new Plane Detector
  72637. * @param _xrSessionManager an instance of xr Session manager
  72638. * @param _options configuration to use when constructing this feature
  72639. */
  72640. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72641. /**
  72642. * detach this feature.
  72643. * Will usually be called by the features manager
  72644. *
  72645. * @returns true if successful.
  72646. */
  72647. detach(): boolean;
  72648. /**
  72649. * Dispose this feature and all of the resources attached
  72650. */
  72651. dispose(): void;
  72652. protected _onXRFrame(frame: XRFrame): void;
  72653. private _init;
  72654. private _updatePlaneWithXRPlane;
  72655. /**
  72656. * avoiding using Array.find for global support.
  72657. * @param xrPlane the plane to find in the array
  72658. */
  72659. private findIndexInPlaneArray;
  72660. }
  72661. }
  72662. declare module BABYLON {
  72663. /**
  72664. * Options interface for the background remover plugin
  72665. */
  72666. export interface IWebXRBackgroundRemoverOptions {
  72667. /**
  72668. * Further background meshes to disable when entering AR
  72669. */
  72670. backgroundMeshes?: AbstractMesh[];
  72671. /**
  72672. * flags to configure the removal of the environment helper.
  72673. * If not set, the entire background will be removed. If set, flags should be set as well.
  72674. */
  72675. environmentHelperRemovalFlags?: {
  72676. /**
  72677. * Should the skybox be removed (default false)
  72678. */
  72679. skyBox?: boolean;
  72680. /**
  72681. * Should the ground be removed (default false)
  72682. */
  72683. ground?: boolean;
  72684. };
  72685. /**
  72686. * don't disable the environment helper
  72687. */
  72688. ignoreEnvironmentHelper?: boolean;
  72689. }
  72690. /**
  72691. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72692. */
  72693. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72694. /**
  72695. * read-only options to be used in this module
  72696. */
  72697. readonly options: IWebXRBackgroundRemoverOptions;
  72698. /**
  72699. * The module's name
  72700. */
  72701. static readonly Name: string;
  72702. /**
  72703. * The (Babylon) version of this module.
  72704. * This is an integer representing the implementation version.
  72705. * This number does not correspond to the WebXR specs version
  72706. */
  72707. static readonly Version: number;
  72708. /**
  72709. * registered observers will be triggered when the background state changes
  72710. */
  72711. onBackgroundStateChangedObservable: Observable<boolean>;
  72712. /**
  72713. * constructs a new background remover module
  72714. * @param _xrSessionManager the session manager for this module
  72715. * @param options read-only options to be used in this module
  72716. */
  72717. constructor(_xrSessionManager: WebXRSessionManager,
  72718. /**
  72719. * read-only options to be used in this module
  72720. */
  72721. options?: IWebXRBackgroundRemoverOptions);
  72722. /**
  72723. * attach this feature
  72724. * Will usually be called by the features manager
  72725. *
  72726. * @returns true if successful.
  72727. */
  72728. attach(): boolean;
  72729. /**
  72730. * detach this feature.
  72731. * Will usually be called by the features manager
  72732. *
  72733. * @returns true if successful.
  72734. */
  72735. detach(): boolean;
  72736. /**
  72737. * Dispose this feature and all of the resources attached
  72738. */
  72739. dispose(): void;
  72740. protected _onXRFrame(_xrFrame: XRFrame): void;
  72741. private _setBackgroundState;
  72742. }
  72743. }
  72744. declare module BABYLON {
  72745. /**
  72746. * Options for the controller physics feature
  72747. */
  72748. export class IWebXRControllerPhysicsOptions {
  72749. /**
  72750. * Should the headset get its own impostor
  72751. */
  72752. enableHeadsetImpostor?: boolean;
  72753. /**
  72754. * Optional parameters for the headset impostor
  72755. */
  72756. headsetImpostorParams?: {
  72757. /**
  72758. * The type of impostor to create. Default is sphere
  72759. */
  72760. impostorType: number;
  72761. /**
  72762. * the size of the impostor. Defaults to 10cm
  72763. */
  72764. impostorSize?: number | {
  72765. width: number;
  72766. height: number;
  72767. depth: number;
  72768. };
  72769. /**
  72770. * Friction definitions
  72771. */
  72772. friction?: number;
  72773. /**
  72774. * Restitution
  72775. */
  72776. restitution?: number;
  72777. };
  72778. /**
  72779. * The physics properties of the future impostors
  72780. */
  72781. physicsProperties?: {
  72782. /**
  72783. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72784. * Note that this requires a physics engine that supports mesh impostors!
  72785. */
  72786. useControllerMesh?: boolean;
  72787. /**
  72788. * The type of impostor to create. Default is sphere
  72789. */
  72790. impostorType?: number;
  72791. /**
  72792. * the size of the impostor. Defaults to 10cm
  72793. */
  72794. impostorSize?: number | {
  72795. width: number;
  72796. height: number;
  72797. depth: number;
  72798. };
  72799. /**
  72800. * Friction definitions
  72801. */
  72802. friction?: number;
  72803. /**
  72804. * Restitution
  72805. */
  72806. restitution?: number;
  72807. };
  72808. /**
  72809. * the xr input to use with this pointer selection
  72810. */
  72811. xrInput: WebXRInput;
  72812. }
  72813. /**
  72814. * Add physics impostor to your webxr controllers,
  72815. * including naive calculation of their linear and angular velocity
  72816. */
  72817. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72818. private readonly _options;
  72819. private _attachController;
  72820. private _controllers;
  72821. private _debugMode;
  72822. private _delta;
  72823. private _headsetImpostor?;
  72824. private _headsetMesh?;
  72825. private _lastTimestamp;
  72826. private _tmpQuaternion;
  72827. private _tmpVector;
  72828. /**
  72829. * The module's name
  72830. */
  72831. static readonly Name: string;
  72832. /**
  72833. * The (Babylon) version of this module.
  72834. * This is an integer representing the implementation version.
  72835. * This number does not correspond to the webxr specs version
  72836. */
  72837. static readonly Version: number;
  72838. /**
  72839. * Construct a new Controller Physics Feature
  72840. * @param _xrSessionManager the corresponding xr session manager
  72841. * @param _options options to create this feature with
  72842. */
  72843. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72844. /**
  72845. * @hidden
  72846. * enable debugging - will show console outputs and the impostor mesh
  72847. */
  72848. _enablePhysicsDebug(): void;
  72849. /**
  72850. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72851. * @param xrController the controller to add
  72852. */
  72853. addController(xrController: WebXRInputSource): void;
  72854. /**
  72855. * attach this feature
  72856. * Will usually be called by the features manager
  72857. *
  72858. * @returns true if successful.
  72859. */
  72860. attach(): boolean;
  72861. /**
  72862. * detach this feature.
  72863. * Will usually be called by the features manager
  72864. *
  72865. * @returns true if successful.
  72866. */
  72867. detach(): boolean;
  72868. /**
  72869. * Get the headset impostor, if enabled
  72870. * @returns the impostor
  72871. */
  72872. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72873. /**
  72874. * Get the physics impostor of a specific controller.
  72875. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72876. * @param controller the controller or the controller id of which to get the impostor
  72877. * @returns the impostor or null
  72878. */
  72879. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72880. /**
  72881. * Update the physics properties provided in the constructor
  72882. * @param newProperties the new properties object
  72883. */
  72884. setPhysicsProperties(newProperties: {
  72885. impostorType?: number;
  72886. impostorSize?: number | {
  72887. width: number;
  72888. height: number;
  72889. depth: number;
  72890. };
  72891. friction?: number;
  72892. restitution?: number;
  72893. }): void;
  72894. protected _onXRFrame(_xrFrame: any): void;
  72895. private _detachController;
  72896. }
  72897. }
  72898. declare module BABYLON {
  72899. /**
  72900. * The motion controller class for all microsoft mixed reality controllers
  72901. */
  72902. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72903. protected readonly _mapping: {
  72904. defaultButton: {
  72905. valueNodeName: string;
  72906. unpressedNodeName: string;
  72907. pressedNodeName: string;
  72908. };
  72909. defaultAxis: {
  72910. valueNodeName: string;
  72911. minNodeName: string;
  72912. maxNodeName: string;
  72913. };
  72914. buttons: {
  72915. "xr-standard-trigger": {
  72916. rootNodeName: string;
  72917. componentProperty: string;
  72918. states: string[];
  72919. };
  72920. "xr-standard-squeeze": {
  72921. rootNodeName: string;
  72922. componentProperty: string;
  72923. states: string[];
  72924. };
  72925. "xr-standard-touchpad": {
  72926. rootNodeName: string;
  72927. labelAnchorNodeName: string;
  72928. touchPointNodeName: string;
  72929. };
  72930. "xr-standard-thumbstick": {
  72931. rootNodeName: string;
  72932. componentProperty: string;
  72933. states: string[];
  72934. };
  72935. };
  72936. axes: {
  72937. "xr-standard-touchpad": {
  72938. "x-axis": {
  72939. rootNodeName: string;
  72940. };
  72941. "y-axis": {
  72942. rootNodeName: string;
  72943. };
  72944. };
  72945. "xr-standard-thumbstick": {
  72946. "x-axis": {
  72947. rootNodeName: string;
  72948. };
  72949. "y-axis": {
  72950. rootNodeName: string;
  72951. };
  72952. };
  72953. };
  72954. };
  72955. /**
  72956. * The base url used to load the left and right controller models
  72957. */
  72958. static MODEL_BASE_URL: string;
  72959. /**
  72960. * The name of the left controller model file
  72961. */
  72962. static MODEL_LEFT_FILENAME: string;
  72963. /**
  72964. * The name of the right controller model file
  72965. */
  72966. static MODEL_RIGHT_FILENAME: string;
  72967. profileId: string;
  72968. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72969. protected _getFilenameAndPath(): {
  72970. filename: string;
  72971. path: string;
  72972. };
  72973. protected _getModelLoadingConstraints(): boolean;
  72974. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72975. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72976. protected _updateModel(): void;
  72977. }
  72978. }
  72979. declare module BABYLON {
  72980. /**
  72981. * The motion controller class for oculus touch (quest, rift).
  72982. * This class supports legacy mapping as well the standard xr mapping
  72983. */
  72984. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72985. private _forceLegacyControllers;
  72986. private _modelRootNode;
  72987. /**
  72988. * The base url used to load the left and right controller models
  72989. */
  72990. static MODEL_BASE_URL: string;
  72991. /**
  72992. * The name of the left controller model file
  72993. */
  72994. static MODEL_LEFT_FILENAME: string;
  72995. /**
  72996. * The name of the right controller model file
  72997. */
  72998. static MODEL_RIGHT_FILENAME: string;
  72999. /**
  73000. * Base Url for the Quest controller model.
  73001. */
  73002. static QUEST_MODEL_BASE_URL: string;
  73003. profileId: string;
  73004. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73005. protected _getFilenameAndPath(): {
  73006. filename: string;
  73007. path: string;
  73008. };
  73009. protected _getModelLoadingConstraints(): boolean;
  73010. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73011. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73012. protected _updateModel(): void;
  73013. /**
  73014. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73015. * between the touch and touch 2.
  73016. */
  73017. private _isQuest;
  73018. }
  73019. }
  73020. declare module BABYLON {
  73021. /**
  73022. * The motion controller class for the standard HTC-Vive controllers
  73023. */
  73024. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73025. private _modelRootNode;
  73026. /**
  73027. * The base url used to load the left and right controller models
  73028. */
  73029. static MODEL_BASE_URL: string;
  73030. /**
  73031. * File name for the controller model.
  73032. */
  73033. static MODEL_FILENAME: string;
  73034. profileId: string;
  73035. /**
  73036. * Create a new Vive motion controller object
  73037. * @param scene the scene to use to create this controller
  73038. * @param gamepadObject the corresponding gamepad object
  73039. * @param handedness the handedness of the controller
  73040. */
  73041. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73042. protected _getFilenameAndPath(): {
  73043. filename: string;
  73044. path: string;
  73045. };
  73046. protected _getModelLoadingConstraints(): boolean;
  73047. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73048. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73049. protected _updateModel(): void;
  73050. }
  73051. }
  73052. declare module BABYLON {
  73053. /**
  73054. * A cursor which tracks a point on a path
  73055. */
  73056. export class PathCursor {
  73057. private path;
  73058. /**
  73059. * Stores path cursor callbacks for when an onchange event is triggered
  73060. */
  73061. private _onchange;
  73062. /**
  73063. * The value of the path cursor
  73064. */
  73065. value: number;
  73066. /**
  73067. * The animation array of the path cursor
  73068. */
  73069. animations: Animation[];
  73070. /**
  73071. * Initializes the path cursor
  73072. * @param path The path to track
  73073. */
  73074. constructor(path: Path2);
  73075. /**
  73076. * Gets the cursor point on the path
  73077. * @returns A point on the path cursor at the cursor location
  73078. */
  73079. getPoint(): Vector3;
  73080. /**
  73081. * Moves the cursor ahead by the step amount
  73082. * @param step The amount to move the cursor forward
  73083. * @returns This path cursor
  73084. */
  73085. moveAhead(step?: number): PathCursor;
  73086. /**
  73087. * Moves the cursor behind by the step amount
  73088. * @param step The amount to move the cursor back
  73089. * @returns This path cursor
  73090. */
  73091. moveBack(step?: number): PathCursor;
  73092. /**
  73093. * Moves the cursor by the step amount
  73094. * If the step amount is greater than one, an exception is thrown
  73095. * @param step The amount to move the cursor
  73096. * @returns This path cursor
  73097. */
  73098. move(step: number): PathCursor;
  73099. /**
  73100. * Ensures that the value is limited between zero and one
  73101. * @returns This path cursor
  73102. */
  73103. private ensureLimits;
  73104. /**
  73105. * Runs onchange callbacks on change (used by the animation engine)
  73106. * @returns This path cursor
  73107. */
  73108. private raiseOnChange;
  73109. /**
  73110. * Executes a function on change
  73111. * @param f A path cursor onchange callback
  73112. * @returns This path cursor
  73113. */
  73114. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73115. }
  73116. }
  73117. declare module BABYLON {
  73118. /** @hidden */
  73119. export var blurPixelShader: {
  73120. name: string;
  73121. shader: string;
  73122. };
  73123. }
  73124. declare module BABYLON {
  73125. /** @hidden */
  73126. export var pointCloudVertexDeclaration: {
  73127. name: string;
  73128. shader: string;
  73129. };
  73130. }
  73131. // Mixins
  73132. interface Window {
  73133. mozIndexedDB: IDBFactory;
  73134. webkitIndexedDB: IDBFactory;
  73135. msIndexedDB: IDBFactory;
  73136. webkitURL: typeof URL;
  73137. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73138. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73139. WebGLRenderingContext: WebGLRenderingContext;
  73140. MSGesture: MSGesture;
  73141. CANNON: any;
  73142. AudioContext: AudioContext;
  73143. webkitAudioContext: AudioContext;
  73144. PointerEvent: any;
  73145. Math: Math;
  73146. Uint8Array: Uint8ArrayConstructor;
  73147. Float32Array: Float32ArrayConstructor;
  73148. mozURL: typeof URL;
  73149. msURL: typeof URL;
  73150. VRFrameData: any; // WebVR, from specs 1.1
  73151. DracoDecoderModule: any;
  73152. setImmediate(handler: (...args: any[]) => void): number;
  73153. }
  73154. interface HTMLCanvasElement {
  73155. requestPointerLock(): void;
  73156. msRequestPointerLock?(): void;
  73157. mozRequestPointerLock?(): void;
  73158. webkitRequestPointerLock?(): void;
  73159. /** Track wether a record is in progress */
  73160. isRecording: boolean;
  73161. /** Capture Stream method defined by some browsers */
  73162. captureStream(fps?: number): MediaStream;
  73163. }
  73164. interface CanvasRenderingContext2D {
  73165. msImageSmoothingEnabled: boolean;
  73166. }
  73167. interface MouseEvent {
  73168. mozMovementX: number;
  73169. mozMovementY: number;
  73170. webkitMovementX: number;
  73171. webkitMovementY: number;
  73172. msMovementX: number;
  73173. msMovementY: number;
  73174. }
  73175. interface Navigator {
  73176. mozGetVRDevices: (any: any) => any;
  73177. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73178. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73179. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73180. webkitGetGamepads(): Gamepad[];
  73181. msGetGamepads(): Gamepad[];
  73182. webkitGamepads(): Gamepad[];
  73183. }
  73184. interface HTMLVideoElement {
  73185. mozSrcObject: any;
  73186. }
  73187. interface Math {
  73188. fround(x: number): number;
  73189. imul(a: number, b: number): number;
  73190. }
  73191. interface WebGLRenderingContext {
  73192. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73193. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73194. vertexAttribDivisor(index: number, divisor: number): void;
  73195. createVertexArray(): any;
  73196. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73197. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73198. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73199. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73200. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73201. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73202. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73203. // Queries
  73204. createQuery(): WebGLQuery;
  73205. deleteQuery(query: WebGLQuery): void;
  73206. beginQuery(target: number, query: WebGLQuery): void;
  73207. endQuery(target: number): void;
  73208. getQueryParameter(query: WebGLQuery, pname: number): any;
  73209. getQuery(target: number, pname: number): any;
  73210. MAX_SAMPLES: number;
  73211. RGBA8: number;
  73212. READ_FRAMEBUFFER: number;
  73213. DRAW_FRAMEBUFFER: number;
  73214. UNIFORM_BUFFER: number;
  73215. HALF_FLOAT_OES: number;
  73216. RGBA16F: number;
  73217. RGBA32F: number;
  73218. R32F: number;
  73219. RG32F: number;
  73220. RGB32F: number;
  73221. R16F: number;
  73222. RG16F: number;
  73223. RGB16F: number;
  73224. RED: number;
  73225. RG: number;
  73226. R8: number;
  73227. RG8: number;
  73228. UNSIGNED_INT_24_8: number;
  73229. DEPTH24_STENCIL8: number;
  73230. MIN: number;
  73231. MAX: number;
  73232. /* Multiple Render Targets */
  73233. drawBuffers(buffers: number[]): void;
  73234. readBuffer(src: number): void;
  73235. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73236. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73237. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73238. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73239. // Occlusion Query
  73240. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73241. ANY_SAMPLES_PASSED: number;
  73242. QUERY_RESULT_AVAILABLE: number;
  73243. QUERY_RESULT: number;
  73244. }
  73245. interface WebGLProgram {
  73246. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73247. }
  73248. interface EXT_disjoint_timer_query {
  73249. QUERY_COUNTER_BITS_EXT: number;
  73250. TIME_ELAPSED_EXT: number;
  73251. TIMESTAMP_EXT: number;
  73252. GPU_DISJOINT_EXT: number;
  73253. QUERY_RESULT_EXT: number;
  73254. QUERY_RESULT_AVAILABLE_EXT: number;
  73255. queryCounterEXT(query: WebGLQuery, target: number): void;
  73256. createQueryEXT(): WebGLQuery;
  73257. beginQueryEXT(target: number, query: WebGLQuery): void;
  73258. endQueryEXT(target: number): void;
  73259. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73260. deleteQueryEXT(query: WebGLQuery): void;
  73261. }
  73262. interface WebGLUniformLocation {
  73263. _currentState: any;
  73264. }
  73265. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73266. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73267. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73268. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73269. interface WebGLRenderingContext {
  73270. readonly RASTERIZER_DISCARD: number;
  73271. readonly DEPTH_COMPONENT24: number;
  73272. readonly TEXTURE_3D: number;
  73273. readonly TEXTURE_2D_ARRAY: number;
  73274. readonly TEXTURE_COMPARE_FUNC: number;
  73275. readonly TEXTURE_COMPARE_MODE: number;
  73276. readonly COMPARE_REF_TO_TEXTURE: number;
  73277. readonly TEXTURE_WRAP_R: number;
  73278. readonly HALF_FLOAT: number;
  73279. readonly RGB8: number;
  73280. readonly RED_INTEGER: number;
  73281. readonly RG_INTEGER: number;
  73282. readonly RGB_INTEGER: number;
  73283. readonly RGBA_INTEGER: number;
  73284. readonly R8_SNORM: number;
  73285. readonly RG8_SNORM: number;
  73286. readonly RGB8_SNORM: number;
  73287. readonly RGBA8_SNORM: number;
  73288. readonly R8I: number;
  73289. readonly RG8I: number;
  73290. readonly RGB8I: number;
  73291. readonly RGBA8I: number;
  73292. readonly R8UI: number;
  73293. readonly RG8UI: number;
  73294. readonly RGB8UI: number;
  73295. readonly RGBA8UI: number;
  73296. readonly R16I: number;
  73297. readonly RG16I: number;
  73298. readonly RGB16I: number;
  73299. readonly RGBA16I: number;
  73300. readonly R16UI: number;
  73301. readonly RG16UI: number;
  73302. readonly RGB16UI: number;
  73303. readonly RGBA16UI: number;
  73304. readonly R32I: number;
  73305. readonly RG32I: number;
  73306. readonly RGB32I: number;
  73307. readonly RGBA32I: number;
  73308. readonly R32UI: number;
  73309. readonly RG32UI: number;
  73310. readonly RGB32UI: number;
  73311. readonly RGBA32UI: number;
  73312. readonly RGB10_A2UI: number;
  73313. readonly R11F_G11F_B10F: number;
  73314. readonly RGB9_E5: number;
  73315. readonly RGB10_A2: number;
  73316. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73317. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73318. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73319. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73320. readonly DEPTH_COMPONENT32F: number;
  73321. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73322. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73323. 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;
  73324. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73325. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73326. readonly TRANSFORM_FEEDBACK: number;
  73327. readonly INTERLEAVED_ATTRIBS: number;
  73328. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73329. createTransformFeedback(): WebGLTransformFeedback;
  73330. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73331. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73332. beginTransformFeedback(primitiveMode: number): void;
  73333. endTransformFeedback(): void;
  73334. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73335. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73336. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73337. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73338. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73339. }
  73340. interface ImageBitmap {
  73341. readonly width: number;
  73342. readonly height: number;
  73343. close(): void;
  73344. }
  73345. interface WebGLQuery extends WebGLObject {
  73346. }
  73347. declare var WebGLQuery: {
  73348. prototype: WebGLQuery;
  73349. new(): WebGLQuery;
  73350. };
  73351. interface WebGLSampler extends WebGLObject {
  73352. }
  73353. declare var WebGLSampler: {
  73354. prototype: WebGLSampler;
  73355. new(): WebGLSampler;
  73356. };
  73357. interface WebGLSync extends WebGLObject {
  73358. }
  73359. declare var WebGLSync: {
  73360. prototype: WebGLSync;
  73361. new(): WebGLSync;
  73362. };
  73363. interface WebGLTransformFeedback extends WebGLObject {
  73364. }
  73365. declare var WebGLTransformFeedback: {
  73366. prototype: WebGLTransformFeedback;
  73367. new(): WebGLTransformFeedback;
  73368. };
  73369. interface WebGLVertexArrayObject extends WebGLObject {
  73370. }
  73371. declare var WebGLVertexArrayObject: {
  73372. prototype: WebGLVertexArrayObject;
  73373. new(): WebGLVertexArrayObject;
  73374. };
  73375. // Type definitions for WebVR API
  73376. // Project: https://w3c.github.io/webvr/
  73377. // Definitions by: six a <https://github.com/lostfictions>
  73378. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73379. interface VRDisplay extends EventTarget {
  73380. /**
  73381. * Dictionary of capabilities describing the VRDisplay.
  73382. */
  73383. readonly capabilities: VRDisplayCapabilities;
  73384. /**
  73385. * z-depth defining the far plane of the eye view frustum
  73386. * enables mapping of values in the render target depth
  73387. * attachment to scene coordinates. Initially set to 10000.0.
  73388. */
  73389. depthFar: number;
  73390. /**
  73391. * z-depth defining the near plane of the eye view frustum
  73392. * enables mapping of values in the render target depth
  73393. * attachment to scene coordinates. Initially set to 0.01.
  73394. */
  73395. depthNear: number;
  73396. /**
  73397. * An identifier for this distinct VRDisplay. Used as an
  73398. * association point in the Gamepad API.
  73399. */
  73400. readonly displayId: number;
  73401. /**
  73402. * A display name, a user-readable name identifying it.
  73403. */
  73404. readonly displayName: string;
  73405. readonly isConnected: boolean;
  73406. readonly isPresenting: boolean;
  73407. /**
  73408. * If this VRDisplay supports room-scale experiences, the optional
  73409. * stage attribute contains details on the room-scale parameters.
  73410. */
  73411. readonly stageParameters: VRStageParameters | null;
  73412. /**
  73413. * Passing the value returned by `requestAnimationFrame` to
  73414. * `cancelAnimationFrame` will unregister the callback.
  73415. * @param handle Define the hanle of the request to cancel
  73416. */
  73417. cancelAnimationFrame(handle: number): void;
  73418. /**
  73419. * Stops presenting to the VRDisplay.
  73420. * @returns a promise to know when it stopped
  73421. */
  73422. exitPresent(): Promise<void>;
  73423. /**
  73424. * Return the current VREyeParameters for the given eye.
  73425. * @param whichEye Define the eye we want the parameter for
  73426. * @returns the eye parameters
  73427. */
  73428. getEyeParameters(whichEye: string): VREyeParameters;
  73429. /**
  73430. * Populates the passed VRFrameData with the information required to render
  73431. * the current frame.
  73432. * @param frameData Define the data structure to populate
  73433. * @returns true if ok otherwise false
  73434. */
  73435. getFrameData(frameData: VRFrameData): boolean;
  73436. /**
  73437. * Get the layers currently being presented.
  73438. * @returns the list of VR layers
  73439. */
  73440. getLayers(): VRLayer[];
  73441. /**
  73442. * Return a VRPose containing the future predicted pose of the VRDisplay
  73443. * when the current frame will be presented. The value returned will not
  73444. * change until JavaScript has returned control to the browser.
  73445. *
  73446. * The VRPose will contain the position, orientation, velocity,
  73447. * and acceleration of each of these properties.
  73448. * @returns the pose object
  73449. */
  73450. getPose(): VRPose;
  73451. /**
  73452. * Return the current instantaneous pose of the VRDisplay, with no
  73453. * prediction applied.
  73454. * @returns the current instantaneous pose
  73455. */
  73456. getImmediatePose(): VRPose;
  73457. /**
  73458. * The callback passed to `requestAnimationFrame` will be called
  73459. * any time a new frame should be rendered. When the VRDisplay is
  73460. * presenting the callback will be called at the native refresh
  73461. * rate of the HMD. When not presenting this function acts
  73462. * identically to how window.requestAnimationFrame acts. Content should
  73463. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73464. * asynchronously from other displays and at differing refresh rates.
  73465. * @param callback Define the eaction to run next frame
  73466. * @returns the request handle it
  73467. */
  73468. requestAnimationFrame(callback: FrameRequestCallback): number;
  73469. /**
  73470. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73471. * Repeat calls while already presenting will update the VRLayers being displayed.
  73472. * @param layers Define the list of layer to present
  73473. * @returns a promise to know when the request has been fulfilled
  73474. */
  73475. requestPresent(layers: VRLayer[]): Promise<void>;
  73476. /**
  73477. * Reset the pose for this display, treating its current position and
  73478. * orientation as the "origin/zero" values. VRPose.position,
  73479. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73480. * updated when calling resetPose(). This should be called in only
  73481. * sitting-space experiences.
  73482. */
  73483. resetPose(): void;
  73484. /**
  73485. * The VRLayer provided to the VRDisplay will be captured and presented
  73486. * in the HMD. Calling this function has the same effect on the source
  73487. * canvas as any other operation that uses its source image, and canvases
  73488. * created without preserveDrawingBuffer set to true will be cleared.
  73489. * @param pose Define the pose to submit
  73490. */
  73491. submitFrame(pose?: VRPose): void;
  73492. }
  73493. declare var VRDisplay: {
  73494. prototype: VRDisplay;
  73495. new(): VRDisplay;
  73496. };
  73497. interface VRLayer {
  73498. leftBounds?: number[] | Float32Array | null;
  73499. rightBounds?: number[] | Float32Array | null;
  73500. source?: HTMLCanvasElement | null;
  73501. }
  73502. interface VRDisplayCapabilities {
  73503. readonly canPresent: boolean;
  73504. readonly hasExternalDisplay: boolean;
  73505. readonly hasOrientation: boolean;
  73506. readonly hasPosition: boolean;
  73507. readonly maxLayers: number;
  73508. }
  73509. interface VREyeParameters {
  73510. /** @deprecated */
  73511. readonly fieldOfView: VRFieldOfView;
  73512. readonly offset: Float32Array;
  73513. readonly renderHeight: number;
  73514. readonly renderWidth: number;
  73515. }
  73516. interface VRFieldOfView {
  73517. readonly downDegrees: number;
  73518. readonly leftDegrees: number;
  73519. readonly rightDegrees: number;
  73520. readonly upDegrees: number;
  73521. }
  73522. interface VRFrameData {
  73523. readonly leftProjectionMatrix: Float32Array;
  73524. readonly leftViewMatrix: Float32Array;
  73525. readonly pose: VRPose;
  73526. readonly rightProjectionMatrix: Float32Array;
  73527. readonly rightViewMatrix: Float32Array;
  73528. readonly timestamp: number;
  73529. }
  73530. interface VRPose {
  73531. readonly angularAcceleration: Float32Array | null;
  73532. readonly angularVelocity: Float32Array | null;
  73533. readonly linearAcceleration: Float32Array | null;
  73534. readonly linearVelocity: Float32Array | null;
  73535. readonly orientation: Float32Array | null;
  73536. readonly position: Float32Array | null;
  73537. readonly timestamp: number;
  73538. }
  73539. interface VRStageParameters {
  73540. sittingToStandingTransform?: Float32Array;
  73541. sizeX?: number;
  73542. sizeY?: number;
  73543. }
  73544. interface Navigator {
  73545. getVRDisplays(): Promise<VRDisplay[]>;
  73546. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73547. }
  73548. interface Window {
  73549. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73550. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73551. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73552. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73553. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73554. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73555. }
  73556. interface Gamepad {
  73557. readonly displayId: number;
  73558. }
  73559. type XRSessionMode =
  73560. | "inline"
  73561. | "immersive-vr"
  73562. | "immersive-ar";
  73563. type XRReferenceSpaceType =
  73564. | "viewer"
  73565. | "local"
  73566. | "local-floor"
  73567. | "bounded-floor"
  73568. | "unbounded";
  73569. type XREnvironmentBlendMode =
  73570. | "opaque"
  73571. | "additive"
  73572. | "alpha-blend";
  73573. type XRVisibilityState =
  73574. | "visible"
  73575. | "visible-blurred"
  73576. | "hidden";
  73577. type XRHandedness =
  73578. | "none"
  73579. | "left"
  73580. | "right";
  73581. type XRTargetRayMode =
  73582. | "gaze"
  73583. | "tracked-pointer"
  73584. | "screen";
  73585. type XREye =
  73586. | "none"
  73587. | "left"
  73588. | "right";
  73589. type XREventType =
  73590. | "devicechange"
  73591. | "visibilitychange"
  73592. | "end"
  73593. | "inputsourceschange"
  73594. | "select"
  73595. | "selectstart"
  73596. | "selectend"
  73597. | "squeeze"
  73598. | "squeezestart"
  73599. | "squeezeend"
  73600. | "reset";
  73601. interface XRSpace extends EventTarget {
  73602. }
  73603. interface XRRenderState {
  73604. depthNear?: number;
  73605. depthFar?: number;
  73606. inlineVerticalFieldOfView?: number;
  73607. baseLayer?: XRWebGLLayer;
  73608. }
  73609. interface XRInputSource {
  73610. handedness: XRHandedness;
  73611. targetRayMode: XRTargetRayMode;
  73612. targetRaySpace: XRSpace;
  73613. gripSpace: XRSpace | undefined;
  73614. gamepad: Gamepad | undefined;
  73615. profiles: Array<string>;
  73616. }
  73617. interface XRSessionInit {
  73618. optionalFeatures?: string[];
  73619. requiredFeatures?: string[];
  73620. }
  73621. interface XRSession {
  73622. addEventListener: Function;
  73623. removeEventListener: Function;
  73624. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73625. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73626. requestAnimationFrame: Function;
  73627. end(): Promise<void>;
  73628. renderState: XRRenderState;
  73629. inputSources: Array<XRInputSource>;
  73630. // hit test
  73631. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73632. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73633. // legacy AR hit test
  73634. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73635. // legacy plane detection
  73636. updateWorldTrackingState(options: {
  73637. planeDetectionState?: { enabled: boolean; }
  73638. }): void;
  73639. }
  73640. interface XRReferenceSpace extends XRSpace {
  73641. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73642. onreset: any;
  73643. }
  73644. type XRPlaneSet = Set<XRPlane>;
  73645. type XRAnchorSet = Set<XRAnchor>;
  73646. interface XRFrame {
  73647. session: XRSession;
  73648. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73649. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73650. // AR
  73651. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73652. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73653. // Anchors
  73654. trackedAnchors?: XRAnchorSet;
  73655. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  73656. // Planes
  73657. worldInformation: {
  73658. detectedPlanes?: XRPlaneSet;
  73659. };
  73660. }
  73661. interface XRViewerPose extends XRPose {
  73662. views: Array<XRView>;
  73663. }
  73664. interface XRPose {
  73665. transform: XRRigidTransform;
  73666. emulatedPosition: boolean;
  73667. }
  73668. interface XRWebGLLayerOptions {
  73669. antialias?: boolean;
  73670. depth?: boolean;
  73671. stencil?: boolean;
  73672. alpha?: boolean;
  73673. multiview?: boolean;
  73674. framebufferScaleFactor?: number;
  73675. }
  73676. declare var XRWebGLLayer: {
  73677. prototype: XRWebGLLayer;
  73678. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73679. };
  73680. interface XRWebGLLayer {
  73681. framebuffer: WebGLFramebuffer;
  73682. framebufferWidth: number;
  73683. framebufferHeight: number;
  73684. getViewport: Function;
  73685. }
  73686. declare class XRRigidTransform {
  73687. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73688. position: DOMPointReadOnly;
  73689. orientation: DOMPointReadOnly;
  73690. matrix: Float32Array;
  73691. inverse: XRRigidTransform;
  73692. }
  73693. interface XRView {
  73694. eye: XREye;
  73695. projectionMatrix: Float32Array;
  73696. transform: XRRigidTransform;
  73697. }
  73698. interface XRInputSourceChangeEvent {
  73699. session: XRSession;
  73700. removed: Array<XRInputSource>;
  73701. added: Array<XRInputSource>;
  73702. }
  73703. interface XRInputSourceEvent extends Event {
  73704. readonly frame: XRFrame;
  73705. readonly inputSource: XRInputSource;
  73706. }
  73707. // Experimental(er) features
  73708. declare class XRRay {
  73709. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73710. origin: DOMPointReadOnly;
  73711. direction: DOMPointReadOnly;
  73712. matrix: Float32Array;
  73713. }
  73714. declare enum XRHitTestTrackableType {
  73715. "point",
  73716. "plane"
  73717. }
  73718. interface XRHitResult {
  73719. hitMatrix: Float32Array;
  73720. }
  73721. interface XRTransientInputHitTestResult {
  73722. readonly inputSource: XRInputSource;
  73723. readonly results: Array<XRHitTestResult>;
  73724. }
  73725. interface XRHitTestResult {
  73726. getPose(baseSpace: XRSpace): XRPose | undefined;
  73727. // When anchor system is enabled
  73728. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  73729. }
  73730. interface XRHitTestSource {
  73731. cancel(): void;
  73732. }
  73733. interface XRTransientInputHitTestSource {
  73734. cancel(): void;
  73735. }
  73736. interface XRHitTestOptionsInit {
  73737. space: XRSpace;
  73738. entityTypes?: Array<XRHitTestTrackableType>;
  73739. offsetRay?: XRRay;
  73740. }
  73741. interface XRTransientInputHitTestOptionsInit {
  73742. profile: string;
  73743. entityTypes?: Array<XRHitTestTrackableType>;
  73744. offsetRay?: XRRay;
  73745. }
  73746. interface XRAnchor {
  73747. anchorSpace: XRSpace;
  73748. delete(): void;
  73749. }
  73750. interface XRPlane {
  73751. orientation: "Horizontal" | "Vertical";
  73752. planeSpace: XRSpace;
  73753. polygon: Array<DOMPointReadOnly>;
  73754. lastChangedTime: number;
  73755. }
  73756. /**
  73757. * @ignore
  73758. */
  73759. declare module BABYLON.GLTF2.Exporter {
  73760. }
  73761. /**
  73762. * @ignore
  73763. */
  73764. declare module BABYLON.GLTF1 {
  73765. }
  73766. declare module BABYLON.GUI {
  73767. /**
  73768. * Class used to specific a value and its associated unit
  73769. */
  73770. export class ValueAndUnit {
  73771. /** defines the unit to store */
  73772. unit: number;
  73773. /** defines a boolean indicating if the value can be negative */
  73774. negativeValueAllowed: boolean;
  73775. private _value;
  73776. private _originalUnit;
  73777. /**
  73778. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73779. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73780. */
  73781. ignoreAdaptiveScaling: boolean;
  73782. /**
  73783. * Creates a new ValueAndUnit
  73784. * @param value defines the value to store
  73785. * @param unit defines the unit to store
  73786. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73787. */
  73788. constructor(value: number,
  73789. /** defines the unit to store */
  73790. unit?: number,
  73791. /** defines a boolean indicating if the value can be negative */
  73792. negativeValueAllowed?: boolean);
  73793. /** Gets a boolean indicating if the value is a percentage */
  73794. get isPercentage(): boolean;
  73795. /** Gets a boolean indicating if the value is store as pixel */
  73796. get isPixel(): boolean;
  73797. /** Gets direct internal value */
  73798. get internalValue(): number;
  73799. /**
  73800. * Gets value as pixel
  73801. * @param host defines the root host
  73802. * @param refValue defines the reference value for percentages
  73803. * @returns the value as pixel
  73804. */
  73805. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73806. /**
  73807. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73808. * @param value defines the value to store
  73809. * @param unit defines the unit to store
  73810. * @returns the current ValueAndUnit
  73811. */
  73812. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73813. /**
  73814. * Gets the value accordingly to its unit
  73815. * @param host defines the root host
  73816. * @returns the value
  73817. */
  73818. getValue(host: AdvancedDynamicTexture): number;
  73819. /**
  73820. * Gets a string representation of the value
  73821. * @param host defines the root host
  73822. * @param decimals defines an optional number of decimals to display
  73823. * @returns a string
  73824. */
  73825. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73826. /**
  73827. * Store a value parsed from a string
  73828. * @param source defines the source string
  73829. * @returns true if the value was successfully parsed
  73830. */
  73831. fromString(source: string | number): boolean;
  73832. private static _Regex;
  73833. private static _UNITMODE_PERCENTAGE;
  73834. private static _UNITMODE_PIXEL;
  73835. /** UNITMODE_PERCENTAGE */
  73836. static get UNITMODE_PERCENTAGE(): number;
  73837. /** UNITMODE_PIXEL */
  73838. static get UNITMODE_PIXEL(): number;
  73839. }
  73840. }
  73841. declare module BABYLON.GUI {
  73842. /**
  73843. * Define a style used by control to automatically setup properties based on a template.
  73844. * Only support font related properties so far
  73845. */
  73846. export class Style implements BABYLON.IDisposable {
  73847. private _fontFamily;
  73848. private _fontStyle;
  73849. private _fontWeight;
  73850. /** @hidden */
  73851. _host: AdvancedDynamicTexture;
  73852. /** @hidden */
  73853. _fontSize: ValueAndUnit;
  73854. /**
  73855. * BABYLON.Observable raised when the style values are changed
  73856. */
  73857. onChangedObservable: BABYLON.Observable<Style>;
  73858. /**
  73859. * Creates a new style object
  73860. * @param host defines the AdvancedDynamicTexture which hosts this style
  73861. */
  73862. constructor(host: AdvancedDynamicTexture);
  73863. /**
  73864. * Gets or sets the font size
  73865. */
  73866. get fontSize(): string | number;
  73867. set fontSize(value: string | number);
  73868. /**
  73869. * Gets or sets the font family
  73870. */
  73871. get fontFamily(): string;
  73872. set fontFamily(value: string);
  73873. /**
  73874. * Gets or sets the font style
  73875. */
  73876. get fontStyle(): string;
  73877. set fontStyle(value: string);
  73878. /** Gets or sets font weight */
  73879. get fontWeight(): string;
  73880. set fontWeight(value: string);
  73881. /** Dispose all associated resources */
  73882. dispose(): void;
  73883. }
  73884. }
  73885. declare module BABYLON.GUI {
  73886. /**
  73887. * Class used to transport BABYLON.Vector2 information for pointer events
  73888. */
  73889. export class Vector2WithInfo extends BABYLON.Vector2 {
  73890. /** defines the current mouse button index */
  73891. buttonIndex: number;
  73892. /**
  73893. * Creates a new Vector2WithInfo
  73894. * @param source defines the vector2 data to transport
  73895. * @param buttonIndex defines the current mouse button index
  73896. */
  73897. constructor(source: BABYLON.Vector2,
  73898. /** defines the current mouse button index */
  73899. buttonIndex?: number);
  73900. }
  73901. /** Class used to provide 2D matrix features */
  73902. export class Matrix2D {
  73903. /** Gets the internal array of 6 floats used to store matrix data */
  73904. m: Float32Array;
  73905. /**
  73906. * Creates a new matrix
  73907. * @param m00 defines value for (0, 0)
  73908. * @param m01 defines value for (0, 1)
  73909. * @param m10 defines value for (1, 0)
  73910. * @param m11 defines value for (1, 1)
  73911. * @param m20 defines value for (2, 0)
  73912. * @param m21 defines value for (2, 1)
  73913. */
  73914. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73915. /**
  73916. * Fills the matrix from direct values
  73917. * @param m00 defines value for (0, 0)
  73918. * @param m01 defines value for (0, 1)
  73919. * @param m10 defines value for (1, 0)
  73920. * @param m11 defines value for (1, 1)
  73921. * @param m20 defines value for (2, 0)
  73922. * @param m21 defines value for (2, 1)
  73923. * @returns the current modified matrix
  73924. */
  73925. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73926. /**
  73927. * Gets matrix determinant
  73928. * @returns the determinant
  73929. */
  73930. determinant(): number;
  73931. /**
  73932. * Inverses the matrix and stores it in a target matrix
  73933. * @param result defines the target matrix
  73934. * @returns the current matrix
  73935. */
  73936. invertToRef(result: Matrix2D): Matrix2D;
  73937. /**
  73938. * Multiplies the current matrix with another one
  73939. * @param other defines the second operand
  73940. * @param result defines the target matrix
  73941. * @returns the current matrix
  73942. */
  73943. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73944. /**
  73945. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73946. * @param x defines the x coordinate to transform
  73947. * @param y defines the x coordinate to transform
  73948. * @param result defines the target vector2
  73949. * @returns the current matrix
  73950. */
  73951. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73952. /**
  73953. * Creates an identity matrix
  73954. * @returns a new matrix
  73955. */
  73956. static Identity(): Matrix2D;
  73957. /**
  73958. * Creates a translation matrix and stores it in a target matrix
  73959. * @param x defines the x coordinate of the translation
  73960. * @param y defines the y coordinate of the translation
  73961. * @param result defines the target matrix
  73962. */
  73963. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73964. /**
  73965. * Creates a scaling matrix and stores it in a target matrix
  73966. * @param x defines the x coordinate of the scaling
  73967. * @param y defines the y coordinate of the scaling
  73968. * @param result defines the target matrix
  73969. */
  73970. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73971. /**
  73972. * Creates a rotation matrix and stores it in a target matrix
  73973. * @param angle defines the rotation angle
  73974. * @param result defines the target matrix
  73975. */
  73976. static RotationToRef(angle: number, result: Matrix2D): void;
  73977. private static _TempPreTranslationMatrix;
  73978. private static _TempPostTranslationMatrix;
  73979. private static _TempRotationMatrix;
  73980. private static _TempScalingMatrix;
  73981. private static _TempCompose0;
  73982. private static _TempCompose1;
  73983. private static _TempCompose2;
  73984. /**
  73985. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73986. * @param tx defines the x coordinate of the translation
  73987. * @param ty defines the y coordinate of the translation
  73988. * @param angle defines the rotation angle
  73989. * @param scaleX defines the x coordinate of the scaling
  73990. * @param scaleY defines the y coordinate of the scaling
  73991. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73992. * @param result defines the target matrix
  73993. */
  73994. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73995. }
  73996. }
  73997. declare module BABYLON.GUI {
  73998. /**
  73999. * Class used to store 2D control sizes
  74000. */
  74001. export class Measure {
  74002. /** defines left coordinate */
  74003. left: number;
  74004. /** defines top coordinate */
  74005. top: number;
  74006. /** defines width dimension */
  74007. width: number;
  74008. /** defines height dimension */
  74009. height: number;
  74010. /**
  74011. * Creates a new measure
  74012. * @param left defines left coordinate
  74013. * @param top defines top coordinate
  74014. * @param width defines width dimension
  74015. * @param height defines height dimension
  74016. */
  74017. constructor(
  74018. /** defines left coordinate */
  74019. left: number,
  74020. /** defines top coordinate */
  74021. top: number,
  74022. /** defines width dimension */
  74023. width: number,
  74024. /** defines height dimension */
  74025. height: number);
  74026. /**
  74027. * Copy from another measure
  74028. * @param other defines the other measure to copy from
  74029. */
  74030. copyFrom(other: Measure): void;
  74031. /**
  74032. * Copy from a group of 4 floats
  74033. * @param left defines left coordinate
  74034. * @param top defines top coordinate
  74035. * @param width defines width dimension
  74036. * @param height defines height dimension
  74037. */
  74038. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74039. /**
  74040. * Computes the axis aligned bounding box measure for two given measures
  74041. * @param a Input measure
  74042. * @param b Input measure
  74043. * @param result the resulting bounding measure
  74044. */
  74045. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74046. /**
  74047. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74048. * @param transform the matrix to transform the measure before computing the AABB
  74049. * @param result the resulting AABB
  74050. */
  74051. transformToRef(transform: Matrix2D, result: Measure): void;
  74052. /**
  74053. * Check equality between this measure and another one
  74054. * @param other defines the other measures
  74055. * @returns true if both measures are equals
  74056. */
  74057. isEqualsTo(other: Measure): boolean;
  74058. /**
  74059. * Creates an empty measure
  74060. * @returns a new measure
  74061. */
  74062. static Empty(): Measure;
  74063. }
  74064. }
  74065. declare module BABYLON.GUI {
  74066. /**
  74067. * Interface used to define a control that can receive focus
  74068. */
  74069. export interface IFocusableControl {
  74070. /**
  74071. * Function called when the control receives the focus
  74072. */
  74073. onFocus(): void;
  74074. /**
  74075. * Function called when the control loses the focus
  74076. */
  74077. onBlur(): void;
  74078. /**
  74079. * Function called to let the control handle keyboard events
  74080. * @param evt defines the current keyboard event
  74081. */
  74082. processKeyboard(evt: KeyboardEvent): void;
  74083. /**
  74084. * Function called to get the list of controls that should not steal the focus from this control
  74085. * @returns an array of controls
  74086. */
  74087. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74088. }
  74089. /**
  74090. * Class used to create texture to support 2D GUI elements
  74091. * @see http://doc.babylonjs.com/how_to/gui
  74092. */
  74093. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74094. private _isDirty;
  74095. private _renderObserver;
  74096. private _resizeObserver;
  74097. private _preKeyboardObserver;
  74098. private _pointerMoveObserver;
  74099. private _pointerObserver;
  74100. private _canvasPointerOutObserver;
  74101. private _background;
  74102. /** @hidden */
  74103. _rootContainer: Container;
  74104. /** @hidden */
  74105. _lastPickedControl: Control;
  74106. /** @hidden */
  74107. _lastControlOver: {
  74108. [pointerId: number]: Control;
  74109. };
  74110. /** @hidden */
  74111. _lastControlDown: {
  74112. [pointerId: number]: Control;
  74113. };
  74114. /** @hidden */
  74115. _capturingControl: {
  74116. [pointerId: number]: Control;
  74117. };
  74118. /** @hidden */
  74119. _shouldBlockPointer: boolean;
  74120. /** @hidden */
  74121. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74122. /** @hidden */
  74123. _linkedControls: Control[];
  74124. private _isFullscreen;
  74125. private _fullscreenViewport;
  74126. private _idealWidth;
  74127. private _idealHeight;
  74128. private _useSmallestIdeal;
  74129. private _renderAtIdealSize;
  74130. private _focusedControl;
  74131. private _blockNextFocusCheck;
  74132. private _renderScale;
  74133. private _rootElement;
  74134. private _cursorChanged;
  74135. private _defaultMousePointerId;
  74136. /** @hidden */
  74137. _numLayoutCalls: number;
  74138. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74139. get numLayoutCalls(): number;
  74140. /** @hidden */
  74141. _numRenderCalls: number;
  74142. /** Gets the number of render calls made the last time the ADT has been rendered */
  74143. get numRenderCalls(): number;
  74144. /**
  74145. * Define type to string to ensure compatibility across browsers
  74146. * Safari doesn't support DataTransfer constructor
  74147. */
  74148. private _clipboardData;
  74149. /**
  74150. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74151. */
  74152. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74153. /**
  74154. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74155. */
  74156. onControlPickedObservable: BABYLON.Observable<Control>;
  74157. /**
  74158. * BABYLON.Observable event triggered before layout is evaluated
  74159. */
  74160. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74161. /**
  74162. * BABYLON.Observable event triggered after the layout was evaluated
  74163. */
  74164. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74165. /**
  74166. * BABYLON.Observable event triggered before the texture is rendered
  74167. */
  74168. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74169. /**
  74170. * BABYLON.Observable event triggered after the texture was rendered
  74171. */
  74172. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74173. /**
  74174. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74175. */
  74176. premulAlpha: boolean;
  74177. /**
  74178. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74179. * Useful when you want more antialiasing
  74180. */
  74181. get renderScale(): number;
  74182. set renderScale(value: number);
  74183. /** Gets or sets the background color */
  74184. get background(): string;
  74185. set background(value: string);
  74186. /**
  74187. * Gets or sets the ideal width used to design controls.
  74188. * The GUI will then rescale everything accordingly
  74189. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74190. */
  74191. get idealWidth(): number;
  74192. set idealWidth(value: number);
  74193. /**
  74194. * Gets or sets the ideal height used to design controls.
  74195. * The GUI will then rescale everything accordingly
  74196. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74197. */
  74198. get idealHeight(): number;
  74199. set idealHeight(value: number);
  74200. /**
  74201. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74202. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74203. */
  74204. get useSmallestIdeal(): boolean;
  74205. set useSmallestIdeal(value: boolean);
  74206. /**
  74207. * Gets or sets a boolean indicating if adaptive scaling must be used
  74208. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74209. */
  74210. get renderAtIdealSize(): boolean;
  74211. set renderAtIdealSize(value: boolean);
  74212. /**
  74213. * Gets the ratio used when in "ideal mode"
  74214. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74215. * */
  74216. get idealRatio(): number;
  74217. /**
  74218. * Gets the underlying layer used to render the texture when in fullscreen mode
  74219. */
  74220. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74221. /**
  74222. * Gets the root container control
  74223. */
  74224. get rootContainer(): Container;
  74225. /**
  74226. * Returns an array containing the root container.
  74227. * This is mostly used to let the Inspector introspects the ADT
  74228. * @returns an array containing the rootContainer
  74229. */
  74230. getChildren(): Array<Container>;
  74231. /**
  74232. * Will return all controls that are inside this texture
  74233. * @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
  74234. * @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
  74235. * @return all child controls
  74236. */
  74237. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74238. /**
  74239. * Gets or sets the current focused control
  74240. */
  74241. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74242. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74243. /**
  74244. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74245. */
  74246. get isForeground(): boolean;
  74247. set isForeground(value: boolean);
  74248. /**
  74249. * Gets or set information about clipboardData
  74250. */
  74251. get clipboardData(): string;
  74252. set clipboardData(value: string);
  74253. /**
  74254. * Creates a new AdvancedDynamicTexture
  74255. * @param name defines the name of the texture
  74256. * @param width defines the width of the texture
  74257. * @param height defines the height of the texture
  74258. * @param scene defines the hosting scene
  74259. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74260. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74261. */
  74262. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74263. /**
  74264. * Get the current class name of the texture useful for serialization or dynamic coding.
  74265. * @returns "AdvancedDynamicTexture"
  74266. */
  74267. getClassName(): string;
  74268. /**
  74269. * Function used to execute a function on all controls
  74270. * @param func defines the function to execute
  74271. * @param container defines the container where controls belong. If null the root container will be used
  74272. */
  74273. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74274. private _useInvalidateRectOptimization;
  74275. /**
  74276. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74277. */
  74278. get useInvalidateRectOptimization(): boolean;
  74279. set useInvalidateRectOptimization(value: boolean);
  74280. private _invalidatedRectangle;
  74281. /**
  74282. * Invalidates a rectangle area on the gui texture
  74283. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74284. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74285. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74286. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74287. */
  74288. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74289. /**
  74290. * Marks the texture as dirty forcing a complete update
  74291. */
  74292. markAsDirty(): void;
  74293. /**
  74294. * Helper function used to create a new style
  74295. * @returns a new style
  74296. * @see http://doc.babylonjs.com/how_to/gui#styles
  74297. */
  74298. createStyle(): Style;
  74299. /**
  74300. * Adds a new control to the root container
  74301. * @param control defines the control to add
  74302. * @returns the current texture
  74303. */
  74304. addControl(control: Control): AdvancedDynamicTexture;
  74305. /**
  74306. * Removes a control from the root container
  74307. * @param control defines the control to remove
  74308. * @returns the current texture
  74309. */
  74310. removeControl(control: Control): AdvancedDynamicTexture;
  74311. /**
  74312. * Release all resources
  74313. */
  74314. dispose(): void;
  74315. private _onResize;
  74316. /** @hidden */
  74317. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74318. /**
  74319. * Get screen coordinates for a vector3
  74320. * @param position defines the position to project
  74321. * @param worldMatrix defines the world matrix to use
  74322. * @returns the projected position
  74323. */
  74324. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74325. private _checkUpdate;
  74326. private _clearMeasure;
  74327. private _render;
  74328. /** @hidden */
  74329. _changeCursor(cursor: string): void;
  74330. /** @hidden */
  74331. _registerLastControlDown(control: Control, pointerId: number): void;
  74332. private _doPicking;
  74333. /** @hidden */
  74334. _cleanControlAfterRemovalFromList(list: {
  74335. [pointerId: number]: Control;
  74336. }, control: Control): void;
  74337. /** @hidden */
  74338. _cleanControlAfterRemoval(control: Control): void;
  74339. /** Attach to all scene events required to support pointer events */
  74340. attach(): void;
  74341. /** @hidden */
  74342. private onClipboardCopy;
  74343. /** @hidden */
  74344. private onClipboardCut;
  74345. /** @hidden */
  74346. private onClipboardPaste;
  74347. /**
  74348. * Register the clipboard Events onto the canvas
  74349. */
  74350. registerClipboardEvents(): void;
  74351. /**
  74352. * Unregister the clipboard Events from the canvas
  74353. */
  74354. unRegisterClipboardEvents(): void;
  74355. /**
  74356. * Connect the texture to a hosting mesh to enable interactions
  74357. * @param mesh defines the mesh to attach to
  74358. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74359. */
  74360. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74361. /**
  74362. * Move the focus to a specific control
  74363. * @param control defines the control which will receive the focus
  74364. */
  74365. moveFocusToControl(control: IFocusableControl): void;
  74366. private _manageFocus;
  74367. private _attachToOnPointerOut;
  74368. /**
  74369. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74370. * @param mesh defines the mesh which will receive the texture
  74371. * @param width defines the texture width (1024 by default)
  74372. * @param height defines the texture height (1024 by default)
  74373. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74374. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74375. * @returns a new AdvancedDynamicTexture
  74376. */
  74377. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74378. /**
  74379. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74380. * In this mode the texture will rely on a layer for its rendering.
  74381. * This allows it to be treated like any other layer.
  74382. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74383. * LayerMask is set through advancedTexture.layer.layerMask
  74384. * @param name defines name for the texture
  74385. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74386. * @param scene defines the hsoting scene
  74387. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74388. * @returns a new AdvancedDynamicTexture
  74389. */
  74390. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74391. }
  74392. }
  74393. declare module BABYLON.GUI {
  74394. /**
  74395. * Root class used for all 2D controls
  74396. * @see http://doc.babylonjs.com/how_to/gui#controls
  74397. */
  74398. export class Control {
  74399. /** defines the name of the control */
  74400. name?: string | undefined;
  74401. /**
  74402. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74403. */
  74404. static AllowAlphaInheritance: boolean;
  74405. private _alpha;
  74406. private _alphaSet;
  74407. private _zIndex;
  74408. /** @hidden */
  74409. _host: AdvancedDynamicTexture;
  74410. /** Gets or sets the control parent */
  74411. parent: BABYLON.Nullable<Container>;
  74412. /** @hidden */
  74413. _currentMeasure: Measure;
  74414. private _fontFamily;
  74415. private _fontStyle;
  74416. private _fontWeight;
  74417. private _fontSize;
  74418. private _font;
  74419. /** @hidden */
  74420. _width: ValueAndUnit;
  74421. /** @hidden */
  74422. _height: ValueAndUnit;
  74423. /** @hidden */
  74424. protected _fontOffset: {
  74425. ascent: number;
  74426. height: number;
  74427. descent: number;
  74428. };
  74429. private _color;
  74430. private _style;
  74431. private _styleObserver;
  74432. /** @hidden */
  74433. protected _horizontalAlignment: number;
  74434. /** @hidden */
  74435. protected _verticalAlignment: number;
  74436. /** @hidden */
  74437. protected _isDirty: boolean;
  74438. /** @hidden */
  74439. protected _wasDirty: boolean;
  74440. /** @hidden */
  74441. _tempParentMeasure: Measure;
  74442. /** @hidden */
  74443. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74444. /** @hidden */
  74445. protected _cachedParentMeasure: Measure;
  74446. private _paddingLeft;
  74447. private _paddingRight;
  74448. private _paddingTop;
  74449. private _paddingBottom;
  74450. /** @hidden */
  74451. _left: ValueAndUnit;
  74452. /** @hidden */
  74453. _top: ValueAndUnit;
  74454. private _scaleX;
  74455. private _scaleY;
  74456. private _rotation;
  74457. private _transformCenterX;
  74458. private _transformCenterY;
  74459. /** @hidden */
  74460. _transformMatrix: Matrix2D;
  74461. /** @hidden */
  74462. protected _invertTransformMatrix: Matrix2D;
  74463. /** @hidden */
  74464. protected _transformedPosition: BABYLON.Vector2;
  74465. private _isMatrixDirty;
  74466. private _cachedOffsetX;
  74467. private _cachedOffsetY;
  74468. private _isVisible;
  74469. private _isHighlighted;
  74470. /** @hidden */
  74471. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74472. private _fontSet;
  74473. private _dummyVector2;
  74474. private _downCount;
  74475. private _enterCount;
  74476. private _doNotRender;
  74477. private _downPointerIds;
  74478. protected _isEnabled: boolean;
  74479. protected _disabledColor: string;
  74480. protected _disabledColorItem: string;
  74481. /** @hidden */
  74482. protected _rebuildLayout: boolean;
  74483. /** @hidden */
  74484. _customData: any;
  74485. /** @hidden */
  74486. _isClipped: boolean;
  74487. /** @hidden */
  74488. _automaticSize: boolean;
  74489. /** @hidden */
  74490. _tag: any;
  74491. /**
  74492. * 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
  74493. */
  74494. uniqueId: number;
  74495. /**
  74496. * Gets or sets an object used to store user defined information for the node
  74497. */
  74498. metadata: any;
  74499. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74500. isHitTestVisible: boolean;
  74501. /** Gets or sets a boolean indicating if the control can block pointer events */
  74502. isPointerBlocker: boolean;
  74503. /** Gets or sets a boolean indicating if the control can be focusable */
  74504. isFocusInvisible: boolean;
  74505. /**
  74506. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74507. * 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
  74508. */
  74509. clipChildren: boolean;
  74510. /**
  74511. * Gets or sets a boolean indicating that control content must be clipped
  74512. * 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
  74513. */
  74514. clipContent: boolean;
  74515. /**
  74516. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74517. */
  74518. useBitmapCache: boolean;
  74519. private _cacheData;
  74520. private _shadowOffsetX;
  74521. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74522. get shadowOffsetX(): number;
  74523. set shadowOffsetX(value: number);
  74524. private _shadowOffsetY;
  74525. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74526. get shadowOffsetY(): number;
  74527. set shadowOffsetY(value: number);
  74528. private _shadowBlur;
  74529. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74530. get shadowBlur(): number;
  74531. set shadowBlur(value: number);
  74532. private _shadowColor;
  74533. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74534. get shadowColor(): string;
  74535. set shadowColor(value: string);
  74536. /** Gets or sets the cursor to use when the control is hovered */
  74537. hoverCursor: string;
  74538. /** @hidden */
  74539. protected _linkOffsetX: ValueAndUnit;
  74540. /** @hidden */
  74541. protected _linkOffsetY: ValueAndUnit;
  74542. /** Gets the control type name */
  74543. get typeName(): string;
  74544. /**
  74545. * Get the current class name of the control.
  74546. * @returns current class name
  74547. */
  74548. getClassName(): string;
  74549. /**
  74550. * An event triggered when pointer wheel is scrolled
  74551. */
  74552. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74553. /**
  74554. * An event triggered when the pointer move over the control.
  74555. */
  74556. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74557. /**
  74558. * An event triggered when the pointer move out of the control.
  74559. */
  74560. onPointerOutObservable: BABYLON.Observable<Control>;
  74561. /**
  74562. * An event triggered when the pointer taps the control
  74563. */
  74564. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74565. /**
  74566. * An event triggered when pointer up
  74567. */
  74568. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74569. /**
  74570. * An event triggered when a control is clicked on
  74571. */
  74572. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74573. /**
  74574. * An event triggered when pointer enters the control
  74575. */
  74576. onPointerEnterObservable: BABYLON.Observable<Control>;
  74577. /**
  74578. * An event triggered when the control is marked as dirty
  74579. */
  74580. onDirtyObservable: BABYLON.Observable<Control>;
  74581. /**
  74582. * An event triggered before drawing the control
  74583. */
  74584. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74585. /**
  74586. * An event triggered after the control was drawn
  74587. */
  74588. onAfterDrawObservable: BABYLON.Observable<Control>;
  74589. /**
  74590. * An event triggered when the control has been disposed
  74591. */
  74592. onDisposeObservable: BABYLON.Observable<Control>;
  74593. /**
  74594. * Get the hosting AdvancedDynamicTexture
  74595. */
  74596. get host(): AdvancedDynamicTexture;
  74597. /** Gets or set information about font offsets (used to render and align text) */
  74598. get fontOffset(): {
  74599. ascent: number;
  74600. height: number;
  74601. descent: number;
  74602. };
  74603. set fontOffset(offset: {
  74604. ascent: number;
  74605. height: number;
  74606. descent: number;
  74607. });
  74608. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74609. get alpha(): number;
  74610. set alpha(value: number);
  74611. /**
  74612. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74613. */
  74614. get isHighlighted(): boolean;
  74615. set isHighlighted(value: boolean);
  74616. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74617. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74618. */
  74619. get scaleX(): number;
  74620. set scaleX(value: number);
  74621. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74622. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74623. */
  74624. get scaleY(): number;
  74625. set scaleY(value: number);
  74626. /** Gets or sets the rotation angle (0 by default)
  74627. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74628. */
  74629. get rotation(): number;
  74630. set rotation(value: number);
  74631. /** Gets or sets the transformation center on Y axis (0 by default)
  74632. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74633. */
  74634. get transformCenterY(): number;
  74635. set transformCenterY(value: number);
  74636. /** Gets or sets the transformation center on X axis (0 by default)
  74637. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74638. */
  74639. get transformCenterX(): number;
  74640. set transformCenterX(value: number);
  74641. /**
  74642. * Gets or sets the horizontal alignment
  74643. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74644. */
  74645. get horizontalAlignment(): number;
  74646. set horizontalAlignment(value: number);
  74647. /**
  74648. * Gets or sets the vertical alignment
  74649. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74650. */
  74651. get verticalAlignment(): number;
  74652. set verticalAlignment(value: number);
  74653. /**
  74654. * Gets or sets control width
  74655. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74656. */
  74657. get width(): string | number;
  74658. set width(value: string | number);
  74659. /**
  74660. * Gets or sets the control width in pixel
  74661. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74662. */
  74663. get widthInPixels(): number;
  74664. set widthInPixels(value: number);
  74665. /**
  74666. * Gets or sets control height
  74667. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74668. */
  74669. get height(): string | number;
  74670. set height(value: string | number);
  74671. /**
  74672. * Gets or sets control height in pixel
  74673. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74674. */
  74675. get heightInPixels(): number;
  74676. set heightInPixels(value: number);
  74677. /** Gets or set font family */
  74678. get fontFamily(): string;
  74679. set fontFamily(value: string);
  74680. /** Gets or sets font style */
  74681. get fontStyle(): string;
  74682. set fontStyle(value: string);
  74683. /** Gets or sets font weight */
  74684. get fontWeight(): string;
  74685. set fontWeight(value: string);
  74686. /**
  74687. * Gets or sets style
  74688. * @see http://doc.babylonjs.com/how_to/gui#styles
  74689. */
  74690. get style(): BABYLON.Nullable<Style>;
  74691. set style(value: BABYLON.Nullable<Style>);
  74692. /** @hidden */
  74693. get _isFontSizeInPercentage(): boolean;
  74694. /** Gets or sets font size in pixels */
  74695. get fontSizeInPixels(): number;
  74696. set fontSizeInPixels(value: number);
  74697. /** Gets or sets font size */
  74698. get fontSize(): string | number;
  74699. set fontSize(value: string | number);
  74700. /** Gets or sets foreground color */
  74701. get color(): string;
  74702. set color(value: string);
  74703. /** Gets or sets z index which is used to reorder controls on the z axis */
  74704. get zIndex(): number;
  74705. set zIndex(value: number);
  74706. /** Gets or sets a boolean indicating if the control can be rendered */
  74707. get notRenderable(): boolean;
  74708. set notRenderable(value: boolean);
  74709. /** Gets or sets a boolean indicating if the control is visible */
  74710. get isVisible(): boolean;
  74711. set isVisible(value: boolean);
  74712. /** Gets a boolean indicating that the control needs to update its rendering */
  74713. get isDirty(): boolean;
  74714. /**
  74715. * Gets the current linked mesh (or null if none)
  74716. */
  74717. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74718. /**
  74719. * Gets or sets a value indicating the padding to use on the left of the control
  74720. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74721. */
  74722. get paddingLeft(): string | number;
  74723. set paddingLeft(value: string | number);
  74724. /**
  74725. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74726. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74727. */
  74728. get paddingLeftInPixels(): number;
  74729. set paddingLeftInPixels(value: number);
  74730. /**
  74731. * Gets or sets a value indicating the padding to use on the right of the control
  74732. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74733. */
  74734. get paddingRight(): string | number;
  74735. set paddingRight(value: string | number);
  74736. /**
  74737. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74738. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74739. */
  74740. get paddingRightInPixels(): number;
  74741. set paddingRightInPixels(value: number);
  74742. /**
  74743. * Gets or sets a value indicating the padding to use on the top of the control
  74744. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74745. */
  74746. get paddingTop(): string | number;
  74747. set paddingTop(value: string | number);
  74748. /**
  74749. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74750. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74751. */
  74752. get paddingTopInPixels(): number;
  74753. set paddingTopInPixels(value: number);
  74754. /**
  74755. * Gets or sets a value indicating the padding to use on the bottom of the control
  74756. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74757. */
  74758. get paddingBottom(): string | number;
  74759. set paddingBottom(value: string | number);
  74760. /**
  74761. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74762. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74763. */
  74764. get paddingBottomInPixels(): number;
  74765. set paddingBottomInPixels(value: number);
  74766. /**
  74767. * Gets or sets a value indicating the left coordinate of the control
  74768. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74769. */
  74770. get left(): string | number;
  74771. set left(value: string | number);
  74772. /**
  74773. * Gets or sets a value indicating the left coordinate in pixels of the control
  74774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74775. */
  74776. get leftInPixels(): number;
  74777. set leftInPixels(value: number);
  74778. /**
  74779. * Gets or sets a value indicating the top coordinate of the control
  74780. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74781. */
  74782. get top(): string | number;
  74783. set top(value: string | number);
  74784. /**
  74785. * Gets or sets a value indicating the top coordinate in pixels of the control
  74786. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74787. */
  74788. get topInPixels(): number;
  74789. set topInPixels(value: number);
  74790. /**
  74791. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74792. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74793. */
  74794. get linkOffsetX(): string | number;
  74795. set linkOffsetX(value: string | number);
  74796. /**
  74797. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74798. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74799. */
  74800. get linkOffsetXInPixels(): number;
  74801. set linkOffsetXInPixels(value: number);
  74802. /**
  74803. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74804. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74805. */
  74806. get linkOffsetY(): string | number;
  74807. set linkOffsetY(value: string | number);
  74808. /**
  74809. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74810. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74811. */
  74812. get linkOffsetYInPixels(): number;
  74813. set linkOffsetYInPixels(value: number);
  74814. /** Gets the center coordinate on X axis */
  74815. get centerX(): number;
  74816. /** Gets the center coordinate on Y axis */
  74817. get centerY(): number;
  74818. /** Gets or sets if control is Enabled*/
  74819. get isEnabled(): boolean;
  74820. set isEnabled(value: boolean);
  74821. /** Gets or sets background color of control if it's disabled*/
  74822. get disabledColor(): string;
  74823. set disabledColor(value: string);
  74824. /** Gets or sets front color of control if it's disabled*/
  74825. get disabledColorItem(): string;
  74826. set disabledColorItem(value: string);
  74827. /**
  74828. * Creates a new control
  74829. * @param name defines the name of the control
  74830. */
  74831. constructor(
  74832. /** defines the name of the control */
  74833. name?: string | undefined);
  74834. /** @hidden */
  74835. protected _getTypeName(): string;
  74836. /**
  74837. * Gets the first ascendant in the hierarchy of the given type
  74838. * @param className defines the required type
  74839. * @returns the ascendant or null if not found
  74840. */
  74841. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74842. /** @hidden */
  74843. _resetFontCache(): void;
  74844. /**
  74845. * Determines if a container is an ascendant of the current control
  74846. * @param container defines the container to look for
  74847. * @returns true if the container is one of the ascendant of the control
  74848. */
  74849. isAscendant(container: Control): boolean;
  74850. /**
  74851. * Gets coordinates in local control space
  74852. * @param globalCoordinates defines the coordinates to transform
  74853. * @returns the new coordinates in local space
  74854. */
  74855. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74856. /**
  74857. * Gets coordinates in local control space
  74858. * @param globalCoordinates defines the coordinates to transform
  74859. * @param result defines the target vector2 where to store the result
  74860. * @returns the current control
  74861. */
  74862. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74863. /**
  74864. * Gets coordinates in parent local control space
  74865. * @param globalCoordinates defines the coordinates to transform
  74866. * @returns the new coordinates in parent local space
  74867. */
  74868. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74869. /**
  74870. * Move the current control to a vector3 position projected onto the screen.
  74871. * @param position defines the target position
  74872. * @param scene defines the hosting scene
  74873. */
  74874. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74875. /**
  74876. * Will store all controls that have this control as ascendant in a given array
  74877. * @param results defines the array where to store the descendants
  74878. * @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
  74879. * @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
  74880. */
  74881. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74882. /**
  74883. * Will return all controls that have this control as ascendant
  74884. * @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
  74885. * @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
  74886. * @return all child controls
  74887. */
  74888. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74889. /**
  74890. * Link current control with a target mesh
  74891. * @param mesh defines the mesh to link with
  74892. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74893. */
  74894. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74895. /** @hidden */
  74896. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74897. /** @hidden */
  74898. _offsetLeft(offset: number): void;
  74899. /** @hidden */
  74900. _offsetTop(offset: number): void;
  74901. /** @hidden */
  74902. _markMatrixAsDirty(): void;
  74903. /** @hidden */
  74904. _flagDescendantsAsMatrixDirty(): void;
  74905. /** @hidden */
  74906. _intersectsRect(rect: Measure): boolean;
  74907. /** @hidden */
  74908. protected invalidateRect(): void;
  74909. /** @hidden */
  74910. _markAsDirty(force?: boolean): void;
  74911. /** @hidden */
  74912. _markAllAsDirty(): void;
  74913. /** @hidden */
  74914. _link(host: AdvancedDynamicTexture): void;
  74915. /** @hidden */
  74916. protected _transform(context?: CanvasRenderingContext2D): void;
  74917. /** @hidden */
  74918. _renderHighlight(context: CanvasRenderingContext2D): void;
  74919. /** @hidden */
  74920. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74921. /** @hidden */
  74922. protected _applyStates(context: CanvasRenderingContext2D): void;
  74923. /** @hidden */
  74924. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74925. /** @hidden */
  74926. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74927. protected _evaluateClippingState(parentMeasure: Measure): void;
  74928. /** @hidden */
  74929. _measure(): void;
  74930. /** @hidden */
  74931. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74932. /** @hidden */
  74933. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74934. /** @hidden */
  74935. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74936. /** @hidden */
  74937. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74938. private static _ClipMeasure;
  74939. private _tmpMeasureA;
  74940. private _clip;
  74941. /** @hidden */
  74942. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74943. /** @hidden */
  74944. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74945. /**
  74946. * Tests if a given coordinates belong to the current control
  74947. * @param x defines x coordinate to test
  74948. * @param y defines y coordinate to test
  74949. * @returns true if the coordinates are inside the control
  74950. */
  74951. contains(x: number, y: number): boolean;
  74952. /** @hidden */
  74953. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74954. /** @hidden */
  74955. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74956. /** @hidden */
  74957. _onPointerEnter(target: Control): boolean;
  74958. /** @hidden */
  74959. _onPointerOut(target: Control, force?: boolean): void;
  74960. /** @hidden */
  74961. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74962. /** @hidden */
  74963. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74964. /** @hidden */
  74965. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74966. /** @hidden */
  74967. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74968. /** @hidden */
  74969. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74970. private _prepareFont;
  74971. /** Releases associated resources */
  74972. dispose(): void;
  74973. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74974. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74975. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74976. private static _VERTICAL_ALIGNMENT_TOP;
  74977. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74978. private static _VERTICAL_ALIGNMENT_CENTER;
  74979. /** HORIZONTAL_ALIGNMENT_LEFT */
  74980. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74981. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74982. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74983. /** HORIZONTAL_ALIGNMENT_CENTER */
  74984. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74985. /** VERTICAL_ALIGNMENT_TOP */
  74986. static get VERTICAL_ALIGNMENT_TOP(): number;
  74987. /** VERTICAL_ALIGNMENT_BOTTOM */
  74988. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74989. /** VERTICAL_ALIGNMENT_CENTER */
  74990. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74991. private static _FontHeightSizes;
  74992. /** @hidden */
  74993. static _GetFontOffset(font: string): {
  74994. ascent: number;
  74995. height: number;
  74996. descent: number;
  74997. };
  74998. /**
  74999. * Creates a stack panel that can be used to render headers
  75000. * @param control defines the control to associate with the header
  75001. * @param text defines the text of the header
  75002. * @param size defines the size of the header
  75003. * @param options defines options used to configure the header
  75004. * @returns a new StackPanel
  75005. * @ignore
  75006. * @hidden
  75007. */
  75008. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75009. isHorizontal: boolean;
  75010. controlFirst: boolean;
  75011. }) => any;
  75012. /** @hidden */
  75013. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75014. }
  75015. }
  75016. declare module BABYLON.GUI {
  75017. /**
  75018. * Root class for 2D containers
  75019. * @see http://doc.babylonjs.com/how_to/gui#containers
  75020. */
  75021. export class Container extends Control {
  75022. name?: string | undefined;
  75023. /** @hidden */
  75024. _children: Control[];
  75025. /** @hidden */
  75026. protected _measureForChildren: Measure;
  75027. /** @hidden */
  75028. protected _background: string;
  75029. /** @hidden */
  75030. protected _adaptWidthToChildren: boolean;
  75031. /** @hidden */
  75032. protected _adaptHeightToChildren: boolean;
  75033. /**
  75034. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75035. */
  75036. logLayoutCycleErrors: boolean;
  75037. /**
  75038. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75039. */
  75040. maxLayoutCycle: number;
  75041. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75042. get adaptHeightToChildren(): boolean;
  75043. set adaptHeightToChildren(value: boolean);
  75044. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75045. get adaptWidthToChildren(): boolean;
  75046. set adaptWidthToChildren(value: boolean);
  75047. /** Gets or sets background color */
  75048. get background(): string;
  75049. set background(value: string);
  75050. /** Gets the list of children */
  75051. get children(): Control[];
  75052. /**
  75053. * Creates a new Container
  75054. * @param name defines the name of the container
  75055. */
  75056. constructor(name?: string | undefined);
  75057. protected _getTypeName(): string;
  75058. _flagDescendantsAsMatrixDirty(): void;
  75059. /**
  75060. * Gets a child using its name
  75061. * @param name defines the child name to look for
  75062. * @returns the child control if found
  75063. */
  75064. getChildByName(name: string): BABYLON.Nullable<Control>;
  75065. /**
  75066. * Gets a child using its type and its name
  75067. * @param name defines the child name to look for
  75068. * @param type defines the child type to look for
  75069. * @returns the child control if found
  75070. */
  75071. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75072. /**
  75073. * Search for a specific control in children
  75074. * @param control defines the control to look for
  75075. * @returns true if the control is in child list
  75076. */
  75077. containsControl(control: Control): boolean;
  75078. /**
  75079. * Adds a new control to the current container
  75080. * @param control defines the control to add
  75081. * @returns the current container
  75082. */
  75083. addControl(control: BABYLON.Nullable<Control>): Container;
  75084. /**
  75085. * Removes all controls from the current container
  75086. * @returns the current container
  75087. */
  75088. clearControls(): Container;
  75089. /**
  75090. * Removes a control from the current container
  75091. * @param control defines the control to remove
  75092. * @returns the current container
  75093. */
  75094. removeControl(control: Control): Container;
  75095. /** @hidden */
  75096. _reOrderControl(control: Control): void;
  75097. /** @hidden */
  75098. _offsetLeft(offset: number): void;
  75099. /** @hidden */
  75100. _offsetTop(offset: number): void;
  75101. /** @hidden */
  75102. _markAllAsDirty(): void;
  75103. /** @hidden */
  75104. protected _localDraw(context: CanvasRenderingContext2D): void;
  75105. /** @hidden */
  75106. _link(host: AdvancedDynamicTexture): void;
  75107. /** @hidden */
  75108. protected _beforeLayout(): void;
  75109. /** @hidden */
  75110. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75111. /** @hidden */
  75112. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75113. protected _postMeasure(): void;
  75114. /** @hidden */
  75115. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75116. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75117. /** @hidden */
  75118. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75119. /** @hidden */
  75120. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75121. /** Releases associated resources */
  75122. dispose(): void;
  75123. }
  75124. }
  75125. declare module BABYLON.GUI {
  75126. /** Class used to create rectangle container */
  75127. export class Rectangle extends Container {
  75128. name?: string | undefined;
  75129. private _thickness;
  75130. private _cornerRadius;
  75131. /** Gets or sets border thickness */
  75132. get thickness(): number;
  75133. set thickness(value: number);
  75134. /** Gets or sets the corner radius angle */
  75135. get cornerRadius(): number;
  75136. set cornerRadius(value: number);
  75137. /**
  75138. * Creates a new Rectangle
  75139. * @param name defines the control name
  75140. */
  75141. constructor(name?: string | undefined);
  75142. protected _getTypeName(): string;
  75143. protected _localDraw(context: CanvasRenderingContext2D): void;
  75144. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75145. private _drawRoundedRect;
  75146. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75147. }
  75148. }
  75149. declare module BABYLON.GUI {
  75150. /**
  75151. * Enum that determines the text-wrapping mode to use.
  75152. */
  75153. export enum TextWrapping {
  75154. /**
  75155. * Clip the text when it's larger than Control.width; this is the default mode.
  75156. */
  75157. Clip = 0,
  75158. /**
  75159. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75160. */
  75161. WordWrap = 1,
  75162. /**
  75163. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75164. */
  75165. Ellipsis = 2
  75166. }
  75167. /**
  75168. * Class used to create text block control
  75169. */
  75170. export class TextBlock extends Control {
  75171. /**
  75172. * Defines the name of the control
  75173. */
  75174. name?: string | undefined;
  75175. private _text;
  75176. private _textWrapping;
  75177. private _textHorizontalAlignment;
  75178. private _textVerticalAlignment;
  75179. private _lines;
  75180. private _resizeToFit;
  75181. private _lineSpacing;
  75182. private _outlineWidth;
  75183. private _outlineColor;
  75184. /**
  75185. * An event triggered after the text is changed
  75186. */
  75187. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75188. /**
  75189. * An event triggered after the text was broken up into lines
  75190. */
  75191. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75192. /**
  75193. * Function used to split a string into words. By default, a string is split at each space character found
  75194. */
  75195. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75196. /**
  75197. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75198. */
  75199. get lines(): any[];
  75200. /**
  75201. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75202. */
  75203. get resizeToFit(): boolean;
  75204. /**
  75205. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75206. */
  75207. set resizeToFit(value: boolean);
  75208. /**
  75209. * Gets or sets a boolean indicating if text must be wrapped
  75210. */
  75211. get textWrapping(): TextWrapping | boolean;
  75212. /**
  75213. * Gets or sets a boolean indicating if text must be wrapped
  75214. */
  75215. set textWrapping(value: TextWrapping | boolean);
  75216. /**
  75217. * Gets or sets text to display
  75218. */
  75219. get text(): string;
  75220. /**
  75221. * Gets or sets text to display
  75222. */
  75223. set text(value: string);
  75224. /**
  75225. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75226. */
  75227. get textHorizontalAlignment(): number;
  75228. /**
  75229. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75230. */
  75231. set textHorizontalAlignment(value: number);
  75232. /**
  75233. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75234. */
  75235. get textVerticalAlignment(): number;
  75236. /**
  75237. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75238. */
  75239. set textVerticalAlignment(value: number);
  75240. /**
  75241. * Gets or sets line spacing value
  75242. */
  75243. set lineSpacing(value: string | number);
  75244. /**
  75245. * Gets or sets line spacing value
  75246. */
  75247. get lineSpacing(): string | number;
  75248. /**
  75249. * Gets or sets outlineWidth of the text to display
  75250. */
  75251. get outlineWidth(): number;
  75252. /**
  75253. * Gets or sets outlineWidth of the text to display
  75254. */
  75255. set outlineWidth(value: number);
  75256. /**
  75257. * Gets or sets outlineColor of the text to display
  75258. */
  75259. get outlineColor(): string;
  75260. /**
  75261. * Gets or sets outlineColor of the text to display
  75262. */
  75263. set outlineColor(value: string);
  75264. /**
  75265. * Creates a new TextBlock object
  75266. * @param name defines the name of the control
  75267. * @param text defines the text to display (emptry string by default)
  75268. */
  75269. constructor(
  75270. /**
  75271. * Defines the name of the control
  75272. */
  75273. name?: string | undefined, text?: string);
  75274. protected _getTypeName(): string;
  75275. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75276. private _drawText;
  75277. /** @hidden */
  75278. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75279. protected _applyStates(context: CanvasRenderingContext2D): void;
  75280. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75281. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75282. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75283. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75284. protected _renderLines(context: CanvasRenderingContext2D): void;
  75285. /**
  75286. * Given a width constraint applied on the text block, find the expected height
  75287. * @returns expected height
  75288. */
  75289. computeExpectedHeight(): number;
  75290. dispose(): void;
  75291. }
  75292. }
  75293. declare module BABYLON.GUI {
  75294. /**
  75295. * Class used to create 2D images
  75296. */
  75297. export class Image extends Control {
  75298. name?: string | undefined;
  75299. private _workingCanvas;
  75300. private _domImage;
  75301. private _imageWidth;
  75302. private _imageHeight;
  75303. private _loaded;
  75304. private _stretch;
  75305. private _source;
  75306. private _autoScale;
  75307. private _sourceLeft;
  75308. private _sourceTop;
  75309. private _sourceWidth;
  75310. private _sourceHeight;
  75311. private _svgAttributesComputationCompleted;
  75312. private _isSVG;
  75313. private _cellWidth;
  75314. private _cellHeight;
  75315. private _cellId;
  75316. private _populateNinePatchSlicesFromImage;
  75317. private _sliceLeft;
  75318. private _sliceRight;
  75319. private _sliceTop;
  75320. private _sliceBottom;
  75321. private _detectPointerOnOpaqueOnly;
  75322. /**
  75323. * BABYLON.Observable notified when the content is loaded
  75324. */
  75325. onImageLoadedObservable: BABYLON.Observable<Image>;
  75326. /**
  75327. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75328. */
  75329. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75330. /**
  75331. * Gets a boolean indicating that the content is loaded
  75332. */
  75333. get isLoaded(): boolean;
  75334. /**
  75335. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75336. */
  75337. get populateNinePatchSlicesFromImage(): boolean;
  75338. set populateNinePatchSlicesFromImage(value: boolean);
  75339. /**
  75340. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75341. * Beware using this as this will comsume more memory as the image has to be stored twice
  75342. */
  75343. get detectPointerOnOpaqueOnly(): boolean;
  75344. set detectPointerOnOpaqueOnly(value: boolean);
  75345. /**
  75346. * Gets or sets the left value for slicing (9-patch)
  75347. */
  75348. get sliceLeft(): number;
  75349. set sliceLeft(value: number);
  75350. /**
  75351. * Gets or sets the right value for slicing (9-patch)
  75352. */
  75353. get sliceRight(): number;
  75354. set sliceRight(value: number);
  75355. /**
  75356. * Gets or sets the top value for slicing (9-patch)
  75357. */
  75358. get sliceTop(): number;
  75359. set sliceTop(value: number);
  75360. /**
  75361. * Gets or sets the bottom value for slicing (9-patch)
  75362. */
  75363. get sliceBottom(): number;
  75364. set sliceBottom(value: number);
  75365. /**
  75366. * Gets or sets the left coordinate in the source image
  75367. */
  75368. get sourceLeft(): number;
  75369. set sourceLeft(value: number);
  75370. /**
  75371. * Gets or sets the top coordinate in the source image
  75372. */
  75373. get sourceTop(): number;
  75374. set sourceTop(value: number);
  75375. /**
  75376. * Gets or sets the width to capture in the source image
  75377. */
  75378. get sourceWidth(): number;
  75379. set sourceWidth(value: number);
  75380. /**
  75381. * Gets or sets the height to capture in the source image
  75382. */
  75383. get sourceHeight(): number;
  75384. set sourceHeight(value: number);
  75385. /** Indicates if the format of the image is SVG */
  75386. get isSVG(): boolean;
  75387. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75388. get svgAttributesComputationCompleted(): boolean;
  75389. /**
  75390. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75391. * @see http://doc.babylonjs.com/how_to/gui#image
  75392. */
  75393. get autoScale(): boolean;
  75394. set autoScale(value: boolean);
  75395. /** Gets or sets the streching mode used by the image */
  75396. get stretch(): number;
  75397. set stretch(value: number);
  75398. /** @hidden */
  75399. _rotate90(n: number, preserveProperties?: boolean): Image;
  75400. private _handleRotationForSVGImage;
  75401. private _rotate90SourceProperties;
  75402. /**
  75403. * Gets or sets the internal DOM image used to render the control
  75404. */
  75405. set domImage(value: HTMLImageElement);
  75406. get domImage(): HTMLImageElement;
  75407. private _onImageLoaded;
  75408. private _extractNinePatchSliceDataFromImage;
  75409. /**
  75410. * Gets or sets image source url
  75411. */
  75412. set source(value: BABYLON.Nullable<string>);
  75413. /**
  75414. * Checks for svg document with icon id present
  75415. */
  75416. private _svgCheck;
  75417. /**
  75418. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75419. * given external svg file and icon id
  75420. */
  75421. private _getSVGAttribs;
  75422. /**
  75423. * Gets or sets the cell width to use when animation sheet is enabled
  75424. * @see http://doc.babylonjs.com/how_to/gui#image
  75425. */
  75426. get cellWidth(): number;
  75427. set cellWidth(value: number);
  75428. /**
  75429. * Gets or sets the cell height to use when animation sheet is enabled
  75430. * @see http://doc.babylonjs.com/how_to/gui#image
  75431. */
  75432. get cellHeight(): number;
  75433. set cellHeight(value: number);
  75434. /**
  75435. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75436. * @see http://doc.babylonjs.com/how_to/gui#image
  75437. */
  75438. get cellId(): number;
  75439. set cellId(value: number);
  75440. /**
  75441. * Creates a new Image
  75442. * @param name defines the control name
  75443. * @param url defines the image url
  75444. */
  75445. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75446. /**
  75447. * Tests if a given coordinates belong to the current control
  75448. * @param x defines x coordinate to test
  75449. * @param y defines y coordinate to test
  75450. * @returns true if the coordinates are inside the control
  75451. */
  75452. contains(x: number, y: number): boolean;
  75453. protected _getTypeName(): string;
  75454. /** Force the control to synchronize with its content */
  75455. synchronizeSizeWithContent(): void;
  75456. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75457. private _prepareWorkingCanvasForOpaqueDetection;
  75458. private _drawImage;
  75459. _draw(context: CanvasRenderingContext2D): void;
  75460. private _renderCornerPatch;
  75461. private _renderNinePatch;
  75462. dispose(): void;
  75463. /** STRETCH_NONE */
  75464. static readonly STRETCH_NONE: number;
  75465. /** STRETCH_FILL */
  75466. static readonly STRETCH_FILL: number;
  75467. /** STRETCH_UNIFORM */
  75468. static readonly STRETCH_UNIFORM: number;
  75469. /** STRETCH_EXTEND */
  75470. static readonly STRETCH_EXTEND: number;
  75471. /** NINE_PATCH */
  75472. static readonly STRETCH_NINE_PATCH: number;
  75473. }
  75474. }
  75475. declare module BABYLON.GUI {
  75476. /**
  75477. * Class used to create 2D buttons
  75478. */
  75479. export class Button extends Rectangle {
  75480. name?: string | undefined;
  75481. /**
  75482. * Function called to generate a pointer enter animation
  75483. */
  75484. pointerEnterAnimation: () => void;
  75485. /**
  75486. * Function called to generate a pointer out animation
  75487. */
  75488. pointerOutAnimation: () => void;
  75489. /**
  75490. * Function called to generate a pointer down animation
  75491. */
  75492. pointerDownAnimation: () => void;
  75493. /**
  75494. * Function called to generate a pointer up animation
  75495. */
  75496. pointerUpAnimation: () => void;
  75497. /**
  75498. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75499. */
  75500. delegatePickingToChildren: boolean;
  75501. private _image;
  75502. /**
  75503. * Returns the image part of the button (if any)
  75504. */
  75505. get image(): BABYLON.Nullable<Image>;
  75506. private _textBlock;
  75507. /**
  75508. * Returns the image part of the button (if any)
  75509. */
  75510. get textBlock(): BABYLON.Nullable<TextBlock>;
  75511. /**
  75512. * Creates a new Button
  75513. * @param name defines the name of the button
  75514. */
  75515. constructor(name?: string | undefined);
  75516. protected _getTypeName(): string;
  75517. /** @hidden */
  75518. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75519. /** @hidden */
  75520. _onPointerEnter(target: Control): boolean;
  75521. /** @hidden */
  75522. _onPointerOut(target: Control, force?: boolean): void;
  75523. /** @hidden */
  75524. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75525. /** @hidden */
  75526. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75527. /**
  75528. * Creates a new button made with an image and a text
  75529. * @param name defines the name of the button
  75530. * @param text defines the text of the button
  75531. * @param imageUrl defines the url of the image
  75532. * @returns a new Button
  75533. */
  75534. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75535. /**
  75536. * Creates a new button made with an image
  75537. * @param name defines the name of the button
  75538. * @param imageUrl defines the url of the image
  75539. * @returns a new Button
  75540. */
  75541. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75542. /**
  75543. * Creates a new button made with a text
  75544. * @param name defines the name of the button
  75545. * @param text defines the text of the button
  75546. * @returns a new Button
  75547. */
  75548. static CreateSimpleButton(name: string, text: string): Button;
  75549. /**
  75550. * Creates a new button made with an image and a centered text
  75551. * @param name defines the name of the button
  75552. * @param text defines the text of the button
  75553. * @param imageUrl defines the url of the image
  75554. * @returns a new Button
  75555. */
  75556. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75557. }
  75558. }
  75559. declare module BABYLON.GUI {
  75560. /**
  75561. * Class used to create a 2D stack panel container
  75562. */
  75563. export class StackPanel extends Container {
  75564. name?: string | undefined;
  75565. private _isVertical;
  75566. private _manualWidth;
  75567. private _manualHeight;
  75568. private _doNotTrackManualChanges;
  75569. /**
  75570. * Gets or sets a boolean indicating that layou warnings should be ignored
  75571. */
  75572. ignoreLayoutWarnings: boolean;
  75573. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75574. get isVertical(): boolean;
  75575. set isVertical(value: boolean);
  75576. /**
  75577. * Gets or sets panel width.
  75578. * This value should not be set when in horizontal mode as it will be computed automatically
  75579. */
  75580. set width(value: string | number);
  75581. get width(): string | number;
  75582. /**
  75583. * Gets or sets panel height.
  75584. * This value should not be set when in vertical mode as it will be computed automatically
  75585. */
  75586. set height(value: string | number);
  75587. get height(): string | number;
  75588. /**
  75589. * Creates a new StackPanel
  75590. * @param name defines control name
  75591. */
  75592. constructor(name?: string | undefined);
  75593. protected _getTypeName(): string;
  75594. /** @hidden */
  75595. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75596. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75597. protected _postMeasure(): void;
  75598. }
  75599. }
  75600. declare module BABYLON.GUI {
  75601. /**
  75602. * Class used to represent a 2D checkbox
  75603. */
  75604. export class Checkbox extends Control {
  75605. name?: string | undefined;
  75606. private _isChecked;
  75607. private _background;
  75608. private _checkSizeRatio;
  75609. private _thickness;
  75610. /** Gets or sets border thickness */
  75611. get thickness(): number;
  75612. set thickness(value: number);
  75613. /**
  75614. * BABYLON.Observable raised when isChecked property changes
  75615. */
  75616. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75617. /** Gets or sets a value indicating the ratio between overall size and check size */
  75618. get checkSizeRatio(): number;
  75619. set checkSizeRatio(value: number);
  75620. /** Gets or sets background color */
  75621. get background(): string;
  75622. set background(value: string);
  75623. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75624. get isChecked(): boolean;
  75625. set isChecked(value: boolean);
  75626. /**
  75627. * Creates a new CheckBox
  75628. * @param name defines the control name
  75629. */
  75630. constructor(name?: string | undefined);
  75631. protected _getTypeName(): string;
  75632. /** @hidden */
  75633. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75634. /** @hidden */
  75635. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75636. /**
  75637. * Utility function to easily create a checkbox with a header
  75638. * @param title defines the label to use for the header
  75639. * @param onValueChanged defines the callback to call when value changes
  75640. * @returns a StackPanel containing the checkbox and a textBlock
  75641. */
  75642. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75643. }
  75644. }
  75645. declare module BABYLON.GUI {
  75646. /**
  75647. * Class used to store key control properties
  75648. */
  75649. export class KeyPropertySet {
  75650. /** Width */
  75651. width?: string;
  75652. /** Height */
  75653. height?: string;
  75654. /** Left padding */
  75655. paddingLeft?: string;
  75656. /** Right padding */
  75657. paddingRight?: string;
  75658. /** Top padding */
  75659. paddingTop?: string;
  75660. /** Bottom padding */
  75661. paddingBottom?: string;
  75662. /** Foreground color */
  75663. color?: string;
  75664. /** Background color */
  75665. background?: string;
  75666. }
  75667. /**
  75668. * Class used to create virtual keyboard
  75669. */
  75670. export class VirtualKeyboard extends StackPanel {
  75671. /** BABYLON.Observable raised when a key is pressed */
  75672. onKeyPressObservable: BABYLON.Observable<string>;
  75673. /** Gets or sets default key button width */
  75674. defaultButtonWidth: string;
  75675. /** Gets or sets default key button height */
  75676. defaultButtonHeight: string;
  75677. /** Gets or sets default key button left padding */
  75678. defaultButtonPaddingLeft: string;
  75679. /** Gets or sets default key button right padding */
  75680. defaultButtonPaddingRight: string;
  75681. /** Gets or sets default key button top padding */
  75682. defaultButtonPaddingTop: string;
  75683. /** Gets or sets default key button bottom padding */
  75684. defaultButtonPaddingBottom: string;
  75685. /** Gets or sets default key button foreground color */
  75686. defaultButtonColor: string;
  75687. /** Gets or sets default key button background color */
  75688. defaultButtonBackground: string;
  75689. /** Gets or sets shift button foreground color */
  75690. shiftButtonColor: string;
  75691. /** Gets or sets shift button thickness*/
  75692. selectedShiftThickness: number;
  75693. /** Gets shift key state */
  75694. shiftState: number;
  75695. protected _getTypeName(): string;
  75696. private _createKey;
  75697. /**
  75698. * Adds a new row of keys
  75699. * @param keys defines the list of keys to add
  75700. * @param propertySets defines the associated property sets
  75701. */
  75702. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75703. /**
  75704. * Set the shift key to a specific state
  75705. * @param shiftState defines the new shift state
  75706. */
  75707. applyShiftState(shiftState: number): void;
  75708. private _currentlyConnectedInputText;
  75709. private _connectedInputTexts;
  75710. private _onKeyPressObserver;
  75711. /** Gets the input text control currently attached to the keyboard */
  75712. get connectedInputText(): BABYLON.Nullable<InputText>;
  75713. /**
  75714. * Connects the keyboard with an input text control
  75715. *
  75716. * @param input defines the target control
  75717. */
  75718. connect(input: InputText): void;
  75719. /**
  75720. * Disconnects the keyboard from connected InputText controls
  75721. *
  75722. * @param input optionally defines a target control, otherwise all are disconnected
  75723. */
  75724. disconnect(input?: InputText): void;
  75725. private _removeConnectedInputObservables;
  75726. /**
  75727. * Release all resources
  75728. */
  75729. dispose(): void;
  75730. /**
  75731. * Creates a new keyboard using a default layout
  75732. *
  75733. * @param name defines control name
  75734. * @returns a new VirtualKeyboard
  75735. */
  75736. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75737. }
  75738. }
  75739. declare module BABYLON.GUI {
  75740. /**
  75741. * Class used to create input text control
  75742. */
  75743. export class InputText extends Control implements IFocusableControl {
  75744. name?: string | undefined;
  75745. private _text;
  75746. private _placeholderText;
  75747. private _background;
  75748. private _focusedBackground;
  75749. private _focusedColor;
  75750. private _placeholderColor;
  75751. private _thickness;
  75752. private _margin;
  75753. private _autoStretchWidth;
  75754. private _maxWidth;
  75755. private _isFocused;
  75756. private _blinkTimeout;
  75757. private _blinkIsEven;
  75758. private _cursorOffset;
  75759. private _scrollLeft;
  75760. private _textWidth;
  75761. private _clickedCoordinate;
  75762. private _deadKey;
  75763. private _addKey;
  75764. private _currentKey;
  75765. private _isTextHighlightOn;
  75766. private _textHighlightColor;
  75767. private _highligherOpacity;
  75768. private _highlightedText;
  75769. private _startHighlightIndex;
  75770. private _endHighlightIndex;
  75771. private _cursorIndex;
  75772. private _onFocusSelectAll;
  75773. private _isPointerDown;
  75774. private _onClipboardObserver;
  75775. private _onPointerDblTapObserver;
  75776. /** @hidden */
  75777. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75778. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75779. promptMessage: string;
  75780. /** Force disable prompt on mobile device */
  75781. disableMobilePrompt: boolean;
  75782. /** BABYLON.Observable raised when the text changes */
  75783. onTextChangedObservable: BABYLON.Observable<InputText>;
  75784. /** BABYLON.Observable raised just before an entered character is to be added */
  75785. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75786. /** BABYLON.Observable raised when the control gets the focus */
  75787. onFocusObservable: BABYLON.Observable<InputText>;
  75788. /** BABYLON.Observable raised when the control loses the focus */
  75789. onBlurObservable: BABYLON.Observable<InputText>;
  75790. /**Observable raised when the text is highlighted */
  75791. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75792. /**Observable raised when copy event is triggered */
  75793. onTextCopyObservable: BABYLON.Observable<InputText>;
  75794. /** BABYLON.Observable raised when cut event is triggered */
  75795. onTextCutObservable: BABYLON.Observable<InputText>;
  75796. /** BABYLON.Observable raised when paste event is triggered */
  75797. onTextPasteObservable: BABYLON.Observable<InputText>;
  75798. /** BABYLON.Observable raised when a key event was processed */
  75799. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75800. /** Gets or sets the maximum width allowed by the control */
  75801. get maxWidth(): string | number;
  75802. /** Gets the maximum width allowed by the control in pixels */
  75803. get maxWidthInPixels(): number;
  75804. set maxWidth(value: string | number);
  75805. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75806. get highligherOpacity(): number;
  75807. set highligherOpacity(value: number);
  75808. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75809. get onFocusSelectAll(): boolean;
  75810. set onFocusSelectAll(value: boolean);
  75811. /** Gets or sets the text hightlight color */
  75812. get textHighlightColor(): string;
  75813. set textHighlightColor(value: string);
  75814. /** Gets or sets control margin */
  75815. get margin(): string;
  75816. /** Gets control margin in pixels */
  75817. get marginInPixels(): number;
  75818. set margin(value: string);
  75819. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75820. get autoStretchWidth(): boolean;
  75821. set autoStretchWidth(value: boolean);
  75822. /** Gets or sets border thickness */
  75823. get thickness(): number;
  75824. set thickness(value: number);
  75825. /** Gets or sets the background color when focused */
  75826. get focusedBackground(): string;
  75827. set focusedBackground(value: string);
  75828. /** Gets or sets the background color when focused */
  75829. get focusedColor(): string;
  75830. set focusedColor(value: string);
  75831. /** Gets or sets the background color */
  75832. get background(): string;
  75833. set background(value: string);
  75834. /** Gets or sets the placeholder color */
  75835. get placeholderColor(): string;
  75836. set placeholderColor(value: string);
  75837. /** Gets or sets the text displayed when the control is empty */
  75838. get placeholderText(): string;
  75839. set placeholderText(value: string);
  75840. /** Gets or sets the dead key flag */
  75841. get deadKey(): boolean;
  75842. set deadKey(flag: boolean);
  75843. /** Gets or sets the highlight text */
  75844. get highlightedText(): string;
  75845. set highlightedText(text: string);
  75846. /** Gets or sets if the current key should be added */
  75847. get addKey(): boolean;
  75848. set addKey(flag: boolean);
  75849. /** Gets or sets the value of the current key being entered */
  75850. get currentKey(): string;
  75851. set currentKey(key: string);
  75852. /** Gets or sets the text displayed in the control */
  75853. get text(): string;
  75854. set text(value: string);
  75855. /** Gets or sets control width */
  75856. get width(): string | number;
  75857. set width(value: string | number);
  75858. /**
  75859. * Creates a new InputText
  75860. * @param name defines the control name
  75861. * @param text defines the text of the control
  75862. */
  75863. constructor(name?: string | undefined, text?: string);
  75864. /** @hidden */
  75865. onBlur(): void;
  75866. /** @hidden */
  75867. onFocus(): void;
  75868. protected _getTypeName(): string;
  75869. /**
  75870. * Function called to get the list of controls that should not steal the focus from this control
  75871. * @returns an array of controls
  75872. */
  75873. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75874. /** @hidden */
  75875. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75876. /** @hidden */
  75877. private _updateValueFromCursorIndex;
  75878. /** @hidden */
  75879. private _processDblClick;
  75880. /** @hidden */
  75881. private _selectAllText;
  75882. /**
  75883. * Handles the keyboard event
  75884. * @param evt Defines the KeyboardEvent
  75885. */
  75886. processKeyboard(evt: KeyboardEvent): void;
  75887. /** @hidden */
  75888. private _onCopyText;
  75889. /** @hidden */
  75890. private _onCutText;
  75891. /** @hidden */
  75892. private _onPasteText;
  75893. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75894. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75895. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75896. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75897. protected _beforeRenderText(text: string): string;
  75898. dispose(): void;
  75899. }
  75900. }
  75901. declare module BABYLON.GUI {
  75902. /**
  75903. * Class used to create a 2D grid container
  75904. */
  75905. export class Grid extends Container {
  75906. name?: string | undefined;
  75907. private _rowDefinitions;
  75908. private _columnDefinitions;
  75909. private _cells;
  75910. private _childControls;
  75911. /**
  75912. * Gets the number of columns
  75913. */
  75914. get columnCount(): number;
  75915. /**
  75916. * Gets the number of rows
  75917. */
  75918. get rowCount(): number;
  75919. /** Gets the list of children */
  75920. get children(): Control[];
  75921. /** Gets the list of cells (e.g. the containers) */
  75922. get cells(): {
  75923. [key: string]: Container;
  75924. };
  75925. /**
  75926. * Gets the definition of a specific row
  75927. * @param index defines the index of the row
  75928. * @returns the row definition
  75929. */
  75930. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75931. /**
  75932. * Gets the definition of a specific column
  75933. * @param index defines the index of the column
  75934. * @returns the column definition
  75935. */
  75936. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75937. /**
  75938. * Adds a new row to the grid
  75939. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75940. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75941. * @returns the current grid
  75942. */
  75943. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75944. /**
  75945. * Adds a new column to the grid
  75946. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75947. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75948. * @returns the current grid
  75949. */
  75950. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75951. /**
  75952. * Update a row definition
  75953. * @param index defines the index of the row to update
  75954. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75955. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75956. * @returns the current grid
  75957. */
  75958. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75959. /**
  75960. * Update a column definition
  75961. * @param index defines the index of the column to update
  75962. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75963. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75964. * @returns the current grid
  75965. */
  75966. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75967. /**
  75968. * Gets the list of children stored in a specific cell
  75969. * @param row defines the row to check
  75970. * @param column defines the column to check
  75971. * @returns the list of controls
  75972. */
  75973. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75974. /**
  75975. * Gets a string representing the child cell info (row x column)
  75976. * @param child defines the control to get info from
  75977. * @returns a string containing the child cell info (row x column)
  75978. */
  75979. getChildCellInfo(child: Control): string;
  75980. private _removeCell;
  75981. private _offsetCell;
  75982. /**
  75983. * Remove a column definition at specified index
  75984. * @param index defines the index of the column to remove
  75985. * @returns the current grid
  75986. */
  75987. removeColumnDefinition(index: number): Grid;
  75988. /**
  75989. * Remove a row definition at specified index
  75990. * @param index defines the index of the row to remove
  75991. * @returns the current grid
  75992. */
  75993. removeRowDefinition(index: number): Grid;
  75994. /**
  75995. * Adds a new control to the current grid
  75996. * @param control defines the control to add
  75997. * @param row defines the row where to add the control (0 by default)
  75998. * @param column defines the column where to add the control (0 by default)
  75999. * @returns the current grid
  76000. */
  76001. addControl(control: Control, row?: number, column?: number): Grid;
  76002. /**
  76003. * Removes a control from the current container
  76004. * @param control defines the control to remove
  76005. * @returns the current container
  76006. */
  76007. removeControl(control: Control): Container;
  76008. /**
  76009. * Creates a new Grid
  76010. * @param name defines control name
  76011. */
  76012. constructor(name?: string | undefined);
  76013. protected _getTypeName(): string;
  76014. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76015. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76016. _flagDescendantsAsMatrixDirty(): void;
  76017. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76018. /** Releases associated resources */
  76019. dispose(): void;
  76020. }
  76021. }
  76022. declare module BABYLON.GUI {
  76023. /** Class used to create color pickers */
  76024. export class ColorPicker extends Control {
  76025. name?: string | undefined;
  76026. private static _Epsilon;
  76027. private _colorWheelCanvas;
  76028. private _value;
  76029. private _tmpColor;
  76030. private _pointerStartedOnSquare;
  76031. private _pointerStartedOnWheel;
  76032. private _squareLeft;
  76033. private _squareTop;
  76034. private _squareSize;
  76035. private _h;
  76036. private _s;
  76037. private _v;
  76038. private _lastPointerDownID;
  76039. /**
  76040. * BABYLON.Observable raised when the value changes
  76041. */
  76042. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76043. /** Gets or sets the color of the color picker */
  76044. get value(): BABYLON.Color3;
  76045. set value(value: BABYLON.Color3);
  76046. /**
  76047. * Gets or sets control width
  76048. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76049. */
  76050. get width(): string | number;
  76051. set width(value: string | number);
  76052. /**
  76053. * Gets or sets control height
  76054. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76055. */
  76056. get height(): string | number;
  76057. /** Gets or sets control height */
  76058. set height(value: string | number);
  76059. /** Gets or sets control size */
  76060. get size(): string | number;
  76061. set size(value: string | number);
  76062. /**
  76063. * Creates a new ColorPicker
  76064. * @param name defines the control name
  76065. */
  76066. constructor(name?: string | undefined);
  76067. protected _getTypeName(): string;
  76068. /** @hidden */
  76069. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76070. private _updateSquareProps;
  76071. private _drawGradientSquare;
  76072. private _drawCircle;
  76073. private _createColorWheelCanvas;
  76074. /** @hidden */
  76075. _draw(context: CanvasRenderingContext2D): void;
  76076. private _pointerIsDown;
  76077. private _updateValueFromPointer;
  76078. private _isPointOnSquare;
  76079. private _isPointOnWheel;
  76080. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76081. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76082. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76083. /**
  76084. * This function expands the color picker by creating a color picker dialog with manual
  76085. * color value input and the ability to save colors into an array to be used later in
  76086. * subsequent launches of the dialogue.
  76087. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76088. * @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.
  76089. * @returns picked color as a hex string and the saved colors array as hex strings.
  76090. */
  76091. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76092. pickerWidth?: string;
  76093. pickerHeight?: string;
  76094. headerHeight?: string;
  76095. lastColor?: string;
  76096. swatchLimit?: number;
  76097. numSwatchesPerLine?: number;
  76098. savedColors?: Array<string>;
  76099. }): Promise<{
  76100. savedColors?: string[];
  76101. pickedColor: string;
  76102. }>;
  76103. }
  76104. }
  76105. declare module BABYLON.GUI {
  76106. /** Class used to create 2D ellipse containers */
  76107. export class Ellipse extends Container {
  76108. name?: string | undefined;
  76109. private _thickness;
  76110. /** Gets or sets border thickness */
  76111. get thickness(): number;
  76112. set thickness(value: number);
  76113. /**
  76114. * Creates a new Ellipse
  76115. * @param name defines the control name
  76116. */
  76117. constructor(name?: string | undefined);
  76118. protected _getTypeName(): string;
  76119. protected _localDraw(context: CanvasRenderingContext2D): void;
  76120. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76121. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76122. }
  76123. }
  76124. declare module BABYLON.GUI {
  76125. /**
  76126. * Class used to create a password control
  76127. */
  76128. export class InputPassword extends InputText {
  76129. protected _beforeRenderText(text: string): string;
  76130. }
  76131. }
  76132. declare module BABYLON.GUI {
  76133. /** Class used to render 2D lines */
  76134. export class Line extends Control {
  76135. name?: string | undefined;
  76136. private _lineWidth;
  76137. private _x1;
  76138. private _y1;
  76139. private _x2;
  76140. private _y2;
  76141. private _dash;
  76142. private _connectedControl;
  76143. private _connectedControlDirtyObserver;
  76144. /** Gets or sets the dash pattern */
  76145. get dash(): Array<number>;
  76146. set dash(value: Array<number>);
  76147. /** Gets or sets the control connected with the line end */
  76148. get connectedControl(): Control;
  76149. set connectedControl(value: Control);
  76150. /** Gets or sets start coordinates on X axis */
  76151. get x1(): string | number;
  76152. set x1(value: string | number);
  76153. /** Gets or sets start coordinates on Y axis */
  76154. get y1(): string | number;
  76155. set y1(value: string | number);
  76156. /** Gets or sets end coordinates on X axis */
  76157. get x2(): string | number;
  76158. set x2(value: string | number);
  76159. /** Gets or sets end coordinates on Y axis */
  76160. get y2(): string | number;
  76161. set y2(value: string | number);
  76162. /** Gets or sets line width */
  76163. get lineWidth(): number;
  76164. set lineWidth(value: number);
  76165. /** Gets or sets horizontal alignment */
  76166. set horizontalAlignment(value: number);
  76167. /** Gets or sets vertical alignment */
  76168. set verticalAlignment(value: number);
  76169. private get _effectiveX2();
  76170. private get _effectiveY2();
  76171. /**
  76172. * Creates a new Line
  76173. * @param name defines the control name
  76174. */
  76175. constructor(name?: string | undefined);
  76176. protected _getTypeName(): string;
  76177. _draw(context: CanvasRenderingContext2D): void;
  76178. _measure(): void;
  76179. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76180. /**
  76181. * Move one end of the line given 3D cartesian coordinates.
  76182. * @param position Targeted world position
  76183. * @param scene BABYLON.Scene
  76184. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76185. */
  76186. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76187. /**
  76188. * Move one end of the line to a position in screen absolute space.
  76189. * @param projectedPosition Position in screen absolute space (X, Y)
  76190. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76191. */
  76192. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76193. }
  76194. }
  76195. declare module BABYLON.GUI {
  76196. /**
  76197. * Class used to store a point for a MultiLine object.
  76198. * The point can be pure 2D coordinates, a mesh or a control
  76199. */
  76200. export class MultiLinePoint {
  76201. private _multiLine;
  76202. private _x;
  76203. private _y;
  76204. private _control;
  76205. private _mesh;
  76206. private _controlObserver;
  76207. private _meshObserver;
  76208. /** @hidden */
  76209. _point: BABYLON.Vector2;
  76210. /**
  76211. * Creates a new MultiLinePoint
  76212. * @param multiLine defines the source MultiLine object
  76213. */
  76214. constructor(multiLine: MultiLine);
  76215. /** Gets or sets x coordinate */
  76216. get x(): string | number;
  76217. set x(value: string | number);
  76218. /** Gets or sets y coordinate */
  76219. get y(): string | number;
  76220. set y(value: string | number);
  76221. /** Gets or sets the control associated with this point */
  76222. get control(): BABYLON.Nullable<Control>;
  76223. set control(value: BABYLON.Nullable<Control>);
  76224. /** Gets or sets the mesh associated with this point */
  76225. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76226. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76227. /** Resets links */
  76228. resetLinks(): void;
  76229. /**
  76230. * Gets a translation vector
  76231. * @returns the translation vector
  76232. */
  76233. translate(): BABYLON.Vector2;
  76234. private _translatePoint;
  76235. /** Release associated resources */
  76236. dispose(): void;
  76237. }
  76238. }
  76239. declare module BABYLON.GUI {
  76240. /**
  76241. * Class used to create multi line control
  76242. */
  76243. export class MultiLine extends Control {
  76244. name?: string | undefined;
  76245. private _lineWidth;
  76246. private _dash;
  76247. private _points;
  76248. private _minX;
  76249. private _minY;
  76250. private _maxX;
  76251. private _maxY;
  76252. /**
  76253. * Creates a new MultiLine
  76254. * @param name defines the control name
  76255. */
  76256. constructor(name?: string | undefined);
  76257. /** Gets or sets dash pattern */
  76258. get dash(): Array<number>;
  76259. set dash(value: Array<number>);
  76260. /**
  76261. * Gets point stored at specified index
  76262. * @param index defines the index to look for
  76263. * @returns the requested point if found
  76264. */
  76265. getAt(index: number): MultiLinePoint;
  76266. /** Function called when a point is updated */
  76267. onPointUpdate: () => void;
  76268. /**
  76269. * Adds new points to the point collection
  76270. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76271. * @returns the list of created MultiLinePoint
  76272. */
  76273. add(...items: (AbstractMesh | Control | {
  76274. x: string | number;
  76275. y: string | number;
  76276. })[]): MultiLinePoint[];
  76277. /**
  76278. * Adds a new point to the point collection
  76279. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76280. * @returns the created MultiLinePoint
  76281. */
  76282. push(item?: (AbstractMesh | Control | {
  76283. x: string | number;
  76284. y: string | number;
  76285. })): MultiLinePoint;
  76286. /**
  76287. * Remove a specific value or point from the active point collection
  76288. * @param value defines the value or point to remove
  76289. */
  76290. remove(value: number | MultiLinePoint): void;
  76291. /**
  76292. * Resets this object to initial state (no point)
  76293. */
  76294. reset(): void;
  76295. /**
  76296. * Resets all links
  76297. */
  76298. resetLinks(): void;
  76299. /** Gets or sets line width */
  76300. get lineWidth(): number;
  76301. set lineWidth(value: number);
  76302. set horizontalAlignment(value: number);
  76303. set verticalAlignment(value: number);
  76304. protected _getTypeName(): string;
  76305. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76306. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76307. _measure(): void;
  76308. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76309. dispose(): void;
  76310. }
  76311. }
  76312. declare module BABYLON.GUI {
  76313. /**
  76314. * Class used to create radio button controls
  76315. */
  76316. export class RadioButton extends Control {
  76317. name?: string | undefined;
  76318. private _isChecked;
  76319. private _background;
  76320. private _checkSizeRatio;
  76321. private _thickness;
  76322. /** Gets or sets border thickness */
  76323. get thickness(): number;
  76324. set thickness(value: number);
  76325. /** Gets or sets group name */
  76326. group: string;
  76327. /** BABYLON.Observable raised when isChecked is changed */
  76328. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76329. /** Gets or sets a value indicating the ratio between overall size and check size */
  76330. get checkSizeRatio(): number;
  76331. set checkSizeRatio(value: number);
  76332. /** Gets or sets background color */
  76333. get background(): string;
  76334. set background(value: string);
  76335. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76336. get isChecked(): boolean;
  76337. set isChecked(value: boolean);
  76338. /**
  76339. * Creates a new RadioButton
  76340. * @param name defines the control name
  76341. */
  76342. constructor(name?: string | undefined);
  76343. protected _getTypeName(): string;
  76344. _draw(context: CanvasRenderingContext2D): void;
  76345. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76346. /**
  76347. * Utility function to easily create a radio button with a header
  76348. * @param title defines the label to use for the header
  76349. * @param group defines the group to use for the radio button
  76350. * @param isChecked defines the initial state of the radio button
  76351. * @param onValueChanged defines the callback to call when value changes
  76352. * @returns a StackPanel containing the radio button and a textBlock
  76353. */
  76354. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76355. }
  76356. }
  76357. declare module BABYLON.GUI {
  76358. /**
  76359. * Class used to create slider controls
  76360. */
  76361. export class BaseSlider extends Control {
  76362. name?: string | undefined;
  76363. protected _thumbWidth: ValueAndUnit;
  76364. private _minimum;
  76365. private _maximum;
  76366. private _value;
  76367. private _isVertical;
  76368. protected _barOffset: ValueAndUnit;
  76369. private _isThumbClamped;
  76370. protected _displayThumb: boolean;
  76371. private _step;
  76372. private _lastPointerDownID;
  76373. protected _effectiveBarOffset: number;
  76374. protected _renderLeft: number;
  76375. protected _renderTop: number;
  76376. protected _renderWidth: number;
  76377. protected _renderHeight: number;
  76378. protected _backgroundBoxLength: number;
  76379. protected _backgroundBoxThickness: number;
  76380. protected _effectiveThumbThickness: number;
  76381. /** BABYLON.Observable raised when the sldier value changes */
  76382. onValueChangedObservable: BABYLON.Observable<number>;
  76383. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76384. get displayThumb(): boolean;
  76385. set displayThumb(value: boolean);
  76386. /** Gets or sets a step to apply to values (0 by default) */
  76387. get step(): number;
  76388. set step(value: number);
  76389. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76390. get barOffset(): string | number;
  76391. /** Gets main bar offset in pixels*/
  76392. get barOffsetInPixels(): number;
  76393. set barOffset(value: string | number);
  76394. /** Gets or sets thumb width */
  76395. get thumbWidth(): string | number;
  76396. /** Gets thumb width in pixels */
  76397. get thumbWidthInPixels(): number;
  76398. set thumbWidth(value: string | number);
  76399. /** Gets or sets minimum value */
  76400. get minimum(): number;
  76401. set minimum(value: number);
  76402. /** Gets or sets maximum value */
  76403. get maximum(): number;
  76404. set maximum(value: number);
  76405. /** Gets or sets current value */
  76406. get value(): number;
  76407. set value(value: number);
  76408. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76409. get isVertical(): boolean;
  76410. set isVertical(value: boolean);
  76411. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76412. get isThumbClamped(): boolean;
  76413. set isThumbClamped(value: boolean);
  76414. /**
  76415. * Creates a new BaseSlider
  76416. * @param name defines the control name
  76417. */
  76418. constructor(name?: string | undefined);
  76419. protected _getTypeName(): string;
  76420. protected _getThumbPosition(): number;
  76421. protected _getThumbThickness(type: string): number;
  76422. protected _prepareRenderingData(type: string): void;
  76423. private _pointerIsDown;
  76424. /** @hidden */
  76425. protected _updateValueFromPointer(x: number, y: number): void;
  76426. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76427. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76428. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76429. }
  76430. }
  76431. declare module BABYLON.GUI {
  76432. /**
  76433. * Class used to create slider controls
  76434. */
  76435. export class Slider extends BaseSlider {
  76436. name?: string | undefined;
  76437. private _background;
  76438. private _borderColor;
  76439. private _isThumbCircle;
  76440. protected _displayValueBar: boolean;
  76441. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76442. get displayValueBar(): boolean;
  76443. set displayValueBar(value: boolean);
  76444. /** Gets or sets border color */
  76445. get borderColor(): string;
  76446. set borderColor(value: string);
  76447. /** Gets or sets background color */
  76448. get background(): string;
  76449. set background(value: string);
  76450. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76451. get isThumbCircle(): boolean;
  76452. set isThumbCircle(value: boolean);
  76453. /**
  76454. * Creates a new Slider
  76455. * @param name defines the control name
  76456. */
  76457. constructor(name?: string | undefined);
  76458. protected _getTypeName(): string;
  76459. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76460. }
  76461. }
  76462. declare module BABYLON.GUI {
  76463. /** Class used to create a RadioGroup
  76464. * which contains groups of radio buttons
  76465. */
  76466. export class SelectorGroup {
  76467. /** name of SelectorGroup */
  76468. name: string;
  76469. private _groupPanel;
  76470. private _selectors;
  76471. private _groupHeader;
  76472. /**
  76473. * Creates a new SelectorGroup
  76474. * @param name of group, used as a group heading
  76475. */
  76476. constructor(
  76477. /** name of SelectorGroup */
  76478. name: string);
  76479. /** Gets the groupPanel of the SelectorGroup */
  76480. get groupPanel(): StackPanel;
  76481. /** Gets the selectors array */
  76482. get selectors(): StackPanel[];
  76483. /** Gets and sets the group header */
  76484. get header(): string;
  76485. set header(label: string);
  76486. /** @hidden */
  76487. private _addGroupHeader;
  76488. /** @hidden*/
  76489. _getSelector(selectorNb: number): StackPanel | undefined;
  76490. /** Removes the selector at the given position
  76491. * @param selectorNb the position of the selector within the group
  76492. */
  76493. removeSelector(selectorNb: number): void;
  76494. }
  76495. /** Class used to create a CheckboxGroup
  76496. * which contains groups of checkbox buttons
  76497. */
  76498. export class CheckboxGroup extends SelectorGroup {
  76499. /** Adds a checkbox as a control
  76500. * @param text is the label for the selector
  76501. * @param func is the function called when the Selector is checked
  76502. * @param checked is true when Selector is checked
  76503. */
  76504. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76505. /** @hidden */
  76506. _setSelectorLabel(selectorNb: number, label: string): void;
  76507. /** @hidden */
  76508. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76509. /** @hidden */
  76510. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76511. /** @hidden */
  76512. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76513. }
  76514. /** Class used to create a RadioGroup
  76515. * which contains groups of radio buttons
  76516. */
  76517. export class RadioGroup extends SelectorGroup {
  76518. private _selectNb;
  76519. /** Adds a radio button as a control
  76520. * @param label is the label for the selector
  76521. * @param func is the function called when the Selector is checked
  76522. * @param checked is true when Selector is checked
  76523. */
  76524. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76525. /** @hidden */
  76526. _setSelectorLabel(selectorNb: number, label: string): void;
  76527. /** @hidden */
  76528. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76529. /** @hidden */
  76530. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76531. /** @hidden */
  76532. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76533. }
  76534. /** Class used to create a SliderGroup
  76535. * which contains groups of slider buttons
  76536. */
  76537. export class SliderGroup extends SelectorGroup {
  76538. /**
  76539. * Adds a slider to the SelectorGroup
  76540. * @param label is the label for the SliderBar
  76541. * @param func is the function called when the Slider moves
  76542. * @param unit is a string describing the units used, eg degrees or metres
  76543. * @param min is the minimum value for the Slider
  76544. * @param max is the maximum value for the Slider
  76545. * @param value is the start value for the Slider between min and max
  76546. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76547. */
  76548. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76549. /** @hidden */
  76550. _setSelectorLabel(selectorNb: number, label: string): void;
  76551. /** @hidden */
  76552. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76553. /** @hidden */
  76554. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76555. /** @hidden */
  76556. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76557. }
  76558. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76559. * @see http://doc.babylonjs.com/how_to/selector
  76560. */
  76561. export class SelectionPanel extends Rectangle {
  76562. /** name of SelectionPanel */
  76563. name: string;
  76564. /** an array of SelectionGroups */
  76565. groups: SelectorGroup[];
  76566. private _panel;
  76567. private _buttonColor;
  76568. private _buttonBackground;
  76569. private _headerColor;
  76570. private _barColor;
  76571. private _barHeight;
  76572. private _spacerHeight;
  76573. private _labelColor;
  76574. private _groups;
  76575. private _bars;
  76576. /**
  76577. * Creates a new SelectionPanel
  76578. * @param name of SelectionPanel
  76579. * @param groups is an array of SelectionGroups
  76580. */
  76581. constructor(
  76582. /** name of SelectionPanel */
  76583. name: string,
  76584. /** an array of SelectionGroups */
  76585. groups?: SelectorGroup[]);
  76586. protected _getTypeName(): string;
  76587. /** Gets or sets the headerColor */
  76588. get headerColor(): string;
  76589. set headerColor(color: string);
  76590. private _setHeaderColor;
  76591. /** Gets or sets the button color */
  76592. get buttonColor(): string;
  76593. set buttonColor(color: string);
  76594. private _setbuttonColor;
  76595. /** Gets or sets the label color */
  76596. get labelColor(): string;
  76597. set labelColor(color: string);
  76598. private _setLabelColor;
  76599. /** Gets or sets the button background */
  76600. get buttonBackground(): string;
  76601. set buttonBackground(color: string);
  76602. private _setButtonBackground;
  76603. /** Gets or sets the color of separator bar */
  76604. get barColor(): string;
  76605. set barColor(color: string);
  76606. private _setBarColor;
  76607. /** Gets or sets the height of separator bar */
  76608. get barHeight(): string;
  76609. set barHeight(value: string);
  76610. private _setBarHeight;
  76611. /** Gets or sets the height of spacers*/
  76612. get spacerHeight(): string;
  76613. set spacerHeight(value: string);
  76614. private _setSpacerHeight;
  76615. /** Adds a bar between groups */
  76616. private _addSpacer;
  76617. /** Add a group to the selection panel
  76618. * @param group is the selector group to add
  76619. */
  76620. addGroup(group: SelectorGroup): void;
  76621. /** Remove the group from the given position
  76622. * @param groupNb is the position of the group in the list
  76623. */
  76624. removeGroup(groupNb: number): void;
  76625. /** Change a group header label
  76626. * @param label is the new group header label
  76627. * @param groupNb is the number of the group to relabel
  76628. * */
  76629. setHeaderName(label: string, groupNb: number): void;
  76630. /** Change selector label to the one given
  76631. * @param label is the new selector label
  76632. * @param groupNb is the number of the groupcontaining the selector
  76633. * @param selectorNb is the number of the selector within a group to relabel
  76634. * */
  76635. relabel(label: string, groupNb: number, selectorNb: number): void;
  76636. /** For a given group position remove the selector at the given position
  76637. * @param groupNb is the number of the group to remove the selector from
  76638. * @param selectorNb is the number of the selector within the group
  76639. */
  76640. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76641. /** For a given group position of correct type add a checkbox button
  76642. * @param groupNb is the number of the group to remove the selector from
  76643. * @param label is the label for the selector
  76644. * @param func is the function called when the Selector is checked
  76645. * @param checked is true when Selector is checked
  76646. */
  76647. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76648. /** For a given group position of correct type add a radio button
  76649. * @param groupNb is the number of the group to remove the selector from
  76650. * @param label is the label for the selector
  76651. * @param func is the function called when the Selector is checked
  76652. * @param checked is true when Selector is checked
  76653. */
  76654. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76655. /**
  76656. * For a given slider group add a slider
  76657. * @param groupNb is the number of the group to add the slider to
  76658. * @param label is the label for the Slider
  76659. * @param func is the function called when the Slider moves
  76660. * @param unit is a string describing the units used, eg degrees or metres
  76661. * @param min is the minimum value for the Slider
  76662. * @param max is the maximum value for the Slider
  76663. * @param value is the start value for the Slider between min and max
  76664. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76665. */
  76666. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76667. }
  76668. }
  76669. declare module BABYLON.GUI {
  76670. /**
  76671. * Class used to hold a the container for ScrollViewer
  76672. * @hidden
  76673. */
  76674. export class _ScrollViewerWindow extends Container {
  76675. parentClientWidth: number;
  76676. parentClientHeight: number;
  76677. private _freezeControls;
  76678. private _parentMeasure;
  76679. private _oldLeft;
  76680. private _oldTop;
  76681. get freezeControls(): boolean;
  76682. set freezeControls(value: boolean);
  76683. private _bucketWidth;
  76684. private _bucketHeight;
  76685. private _buckets;
  76686. private _bucketLen;
  76687. get bucketWidth(): number;
  76688. get bucketHeight(): number;
  76689. setBucketSizes(width: number, height: number): void;
  76690. private _useBuckets;
  76691. private _makeBuckets;
  76692. private _dispatchInBuckets;
  76693. private _updateMeasures;
  76694. private _updateChildrenMeasures;
  76695. private _restoreMeasures;
  76696. /**
  76697. * Creates a new ScrollViewerWindow
  76698. * @param name of ScrollViewerWindow
  76699. */
  76700. constructor(name?: string);
  76701. protected _getTypeName(): string;
  76702. /** @hidden */
  76703. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76704. /** @hidden */
  76705. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76706. private _scrollChildren;
  76707. private _scrollChildrenWithBuckets;
  76708. /** @hidden */
  76709. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76710. protected _postMeasure(): void;
  76711. }
  76712. }
  76713. declare module BABYLON.GUI {
  76714. /**
  76715. * Class used to create slider controls
  76716. */
  76717. export class ScrollBar extends BaseSlider {
  76718. name?: string | undefined;
  76719. private _background;
  76720. private _borderColor;
  76721. private _tempMeasure;
  76722. /** Gets or sets border color */
  76723. get borderColor(): string;
  76724. set borderColor(value: string);
  76725. /** Gets or sets background color */
  76726. get background(): string;
  76727. set background(value: string);
  76728. /**
  76729. * Creates a new Slider
  76730. * @param name defines the control name
  76731. */
  76732. constructor(name?: string | undefined);
  76733. protected _getTypeName(): string;
  76734. protected _getThumbThickness(): number;
  76735. _draw(context: CanvasRenderingContext2D): void;
  76736. private _first;
  76737. private _originX;
  76738. private _originY;
  76739. /** @hidden */
  76740. protected _updateValueFromPointer(x: number, y: number): void;
  76741. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76742. }
  76743. }
  76744. declare module BABYLON.GUI {
  76745. /**
  76746. * Class used to create slider controls
  76747. */
  76748. export class ImageScrollBar extends BaseSlider {
  76749. name?: string | undefined;
  76750. private _backgroundBaseImage;
  76751. private _backgroundImage;
  76752. private _thumbImage;
  76753. private _thumbBaseImage;
  76754. private _thumbLength;
  76755. private _thumbHeight;
  76756. private _barImageHeight;
  76757. private _tempMeasure;
  76758. /** Number of 90° rotation to apply on the images when in vertical mode */
  76759. num90RotationInVerticalMode: number;
  76760. /**
  76761. * Gets or sets the image used to render the background for horizontal bar
  76762. */
  76763. get backgroundImage(): Image;
  76764. set backgroundImage(value: Image);
  76765. /**
  76766. * Gets or sets the image used to render the thumb
  76767. */
  76768. get thumbImage(): Image;
  76769. set thumbImage(value: Image);
  76770. /**
  76771. * Gets or sets the length of the thumb
  76772. */
  76773. get thumbLength(): number;
  76774. set thumbLength(value: number);
  76775. /**
  76776. * Gets or sets the height of the thumb
  76777. */
  76778. get thumbHeight(): number;
  76779. set thumbHeight(value: number);
  76780. /**
  76781. * Gets or sets the height of the bar image
  76782. */
  76783. get barImageHeight(): number;
  76784. set barImageHeight(value: number);
  76785. /**
  76786. * Creates a new ImageScrollBar
  76787. * @param name defines the control name
  76788. */
  76789. constructor(name?: string | undefined);
  76790. protected _getTypeName(): string;
  76791. protected _getThumbThickness(): number;
  76792. _draw(context: CanvasRenderingContext2D): void;
  76793. private _first;
  76794. private _originX;
  76795. private _originY;
  76796. /** @hidden */
  76797. protected _updateValueFromPointer(x: number, y: number): void;
  76798. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76799. }
  76800. }
  76801. declare module BABYLON.GUI {
  76802. /**
  76803. * Class used to hold a viewer window and sliders in a grid
  76804. */
  76805. export class ScrollViewer extends Rectangle {
  76806. private _grid;
  76807. private _horizontalBarSpace;
  76808. private _verticalBarSpace;
  76809. private _dragSpace;
  76810. private _horizontalBar;
  76811. private _verticalBar;
  76812. private _barColor;
  76813. private _barBackground;
  76814. private _barImage;
  76815. private _horizontalBarImage;
  76816. private _verticalBarImage;
  76817. private _barBackgroundImage;
  76818. private _horizontalBarBackgroundImage;
  76819. private _verticalBarBackgroundImage;
  76820. private _barSize;
  76821. private _window;
  76822. private _pointerIsOver;
  76823. private _wheelPrecision;
  76824. private _onWheelObserver;
  76825. private _clientWidth;
  76826. private _clientHeight;
  76827. private _useImageBar;
  76828. private _thumbLength;
  76829. private _thumbHeight;
  76830. private _barImageHeight;
  76831. private _horizontalBarImageHeight;
  76832. private _verticalBarImageHeight;
  76833. private _oldWindowContentsWidth;
  76834. private _oldWindowContentsHeight;
  76835. /**
  76836. * Gets the horizontal scrollbar
  76837. */
  76838. get horizontalBar(): ScrollBar | ImageScrollBar;
  76839. /**
  76840. * Gets the vertical scrollbar
  76841. */
  76842. get verticalBar(): ScrollBar | ImageScrollBar;
  76843. /**
  76844. * Adds a new control to the current container
  76845. * @param control defines the control to add
  76846. * @returns the current container
  76847. */
  76848. addControl(control: BABYLON.Nullable<Control>): Container;
  76849. /**
  76850. * Removes a control from the current container
  76851. * @param control defines the control to remove
  76852. * @returns the current container
  76853. */
  76854. removeControl(control: Control): Container;
  76855. /** Gets the list of children */
  76856. get children(): Control[];
  76857. _flagDescendantsAsMatrixDirty(): void;
  76858. /**
  76859. * Freezes or unfreezes the controls in the window.
  76860. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76861. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76862. */
  76863. get freezeControls(): boolean;
  76864. set freezeControls(value: boolean);
  76865. /** Gets the bucket width */
  76866. get bucketWidth(): number;
  76867. /** Gets the bucket height */
  76868. get bucketHeight(): number;
  76869. /**
  76870. * Sets the bucket sizes.
  76871. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76872. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76873. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76874. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76875. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76876. * used), that's why it is not enabled by default.
  76877. * @param width width of the bucket
  76878. * @param height height of the bucket
  76879. */
  76880. setBucketSizes(width: number, height: number): void;
  76881. private _forceHorizontalBar;
  76882. private _forceVerticalBar;
  76883. /**
  76884. * Forces the horizontal scroll bar to be displayed
  76885. */
  76886. get forceHorizontalBar(): boolean;
  76887. set forceHorizontalBar(value: boolean);
  76888. /**
  76889. * Forces the vertical scroll bar to be displayed
  76890. */
  76891. get forceVerticalBar(): boolean;
  76892. set forceVerticalBar(value: boolean);
  76893. /**
  76894. * Creates a new ScrollViewer
  76895. * @param name of ScrollViewer
  76896. */
  76897. constructor(name?: string, isImageBased?: boolean);
  76898. /** Reset the scroll viewer window to initial size */
  76899. resetWindow(): void;
  76900. protected _getTypeName(): string;
  76901. private _buildClientSizes;
  76902. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76903. protected _postMeasure(): void;
  76904. /**
  76905. * Gets or sets the mouse wheel precision
  76906. * from 0 to 1 with a default value of 0.05
  76907. * */
  76908. get wheelPrecision(): number;
  76909. set wheelPrecision(value: number);
  76910. /** Gets or sets the scroll bar container background color */
  76911. get scrollBackground(): string;
  76912. set scrollBackground(color: string);
  76913. /** Gets or sets the bar color */
  76914. get barColor(): string;
  76915. set barColor(color: string);
  76916. /** Gets or sets the bar image */
  76917. get thumbImage(): Image;
  76918. set thumbImage(value: Image);
  76919. /** Gets or sets the horizontal bar image */
  76920. get horizontalThumbImage(): Image;
  76921. set horizontalThumbImage(value: Image);
  76922. /** Gets or sets the vertical bar image */
  76923. get verticalThumbImage(): Image;
  76924. set verticalThumbImage(value: Image);
  76925. /** Gets or sets the size of the bar */
  76926. get barSize(): number;
  76927. set barSize(value: number);
  76928. /** Gets or sets the length of the thumb */
  76929. get thumbLength(): number;
  76930. set thumbLength(value: number);
  76931. /** Gets or sets the height of the thumb */
  76932. get thumbHeight(): number;
  76933. set thumbHeight(value: number);
  76934. /** Gets or sets the height of the bar image */
  76935. get barImageHeight(): number;
  76936. set barImageHeight(value: number);
  76937. /** Gets or sets the height of the horizontal bar image */
  76938. get horizontalBarImageHeight(): number;
  76939. set horizontalBarImageHeight(value: number);
  76940. /** Gets or sets the height of the vertical bar image */
  76941. get verticalBarImageHeight(): number;
  76942. set verticalBarImageHeight(value: number);
  76943. /** Gets or sets the bar background */
  76944. get barBackground(): string;
  76945. set barBackground(color: string);
  76946. /** Gets or sets the bar background image */
  76947. get barImage(): Image;
  76948. set barImage(value: Image);
  76949. /** Gets or sets the horizontal bar background image */
  76950. get horizontalBarImage(): Image;
  76951. set horizontalBarImage(value: Image);
  76952. /** Gets or sets the vertical bar background image */
  76953. get verticalBarImage(): Image;
  76954. set verticalBarImage(value: Image);
  76955. private _setWindowPosition;
  76956. /** @hidden */
  76957. private _updateScroller;
  76958. _link(host: AdvancedDynamicTexture): void;
  76959. /** @hidden */
  76960. private _addBar;
  76961. /** @hidden */
  76962. private _attachWheel;
  76963. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76964. /** Releases associated resources */
  76965. dispose(): void;
  76966. }
  76967. }
  76968. declare module BABYLON.GUI {
  76969. /** Class used to render a grid */
  76970. export class DisplayGrid extends Control {
  76971. name?: string | undefined;
  76972. private _cellWidth;
  76973. private _cellHeight;
  76974. private _minorLineTickness;
  76975. private _minorLineColor;
  76976. private _majorLineTickness;
  76977. private _majorLineColor;
  76978. private _majorLineFrequency;
  76979. private _background;
  76980. private _displayMajorLines;
  76981. private _displayMinorLines;
  76982. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76983. get displayMinorLines(): boolean;
  76984. set displayMinorLines(value: boolean);
  76985. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76986. get displayMajorLines(): boolean;
  76987. set displayMajorLines(value: boolean);
  76988. /** Gets or sets background color (Black by default) */
  76989. get background(): string;
  76990. set background(value: string);
  76991. /** Gets or sets the width of each cell (20 by default) */
  76992. get cellWidth(): number;
  76993. set cellWidth(value: number);
  76994. /** Gets or sets the height of each cell (20 by default) */
  76995. get cellHeight(): number;
  76996. set cellHeight(value: number);
  76997. /** Gets or sets the tickness of minor lines (1 by default) */
  76998. get minorLineTickness(): number;
  76999. set minorLineTickness(value: number);
  77000. /** Gets or sets the color of minor lines (DarkGray by default) */
  77001. get minorLineColor(): string;
  77002. set minorLineColor(value: string);
  77003. /** Gets or sets the tickness of major lines (2 by default) */
  77004. get majorLineTickness(): number;
  77005. set majorLineTickness(value: number);
  77006. /** Gets or sets the color of major lines (White by default) */
  77007. get majorLineColor(): string;
  77008. set majorLineColor(value: string);
  77009. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77010. get majorLineFrequency(): number;
  77011. set majorLineFrequency(value: number);
  77012. /**
  77013. * Creates a new GridDisplayRectangle
  77014. * @param name defines the control name
  77015. */
  77016. constructor(name?: string | undefined);
  77017. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77018. protected _getTypeName(): string;
  77019. }
  77020. }
  77021. declare module BABYLON.GUI {
  77022. /**
  77023. * Class used to create slider controls based on images
  77024. */
  77025. export class ImageBasedSlider extends BaseSlider {
  77026. name?: string | undefined;
  77027. private _backgroundImage;
  77028. private _thumbImage;
  77029. private _valueBarImage;
  77030. private _tempMeasure;
  77031. get displayThumb(): boolean;
  77032. set displayThumb(value: boolean);
  77033. /**
  77034. * Gets or sets the image used to render the background
  77035. */
  77036. get backgroundImage(): Image;
  77037. set backgroundImage(value: Image);
  77038. /**
  77039. * Gets or sets the image used to render the value bar
  77040. */
  77041. get valueBarImage(): Image;
  77042. set valueBarImage(value: Image);
  77043. /**
  77044. * Gets or sets the image used to render the thumb
  77045. */
  77046. get thumbImage(): Image;
  77047. set thumbImage(value: Image);
  77048. /**
  77049. * Creates a new ImageBasedSlider
  77050. * @param name defines the control name
  77051. */
  77052. constructor(name?: string | undefined);
  77053. protected _getTypeName(): string;
  77054. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77055. }
  77056. }
  77057. declare module BABYLON.GUI {
  77058. /**
  77059. * Forcing an export so that this code will execute
  77060. * @hidden
  77061. */
  77062. const name = "Statics";
  77063. }
  77064. declare module BABYLON.GUI {
  77065. /**
  77066. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77067. */
  77068. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77069. /**
  77070. * Define the instrumented AdvancedDynamicTexture.
  77071. */
  77072. texture: AdvancedDynamicTexture;
  77073. private _captureRenderTime;
  77074. private _renderTime;
  77075. private _captureLayoutTime;
  77076. private _layoutTime;
  77077. private _onBeginRenderObserver;
  77078. private _onEndRenderObserver;
  77079. private _onBeginLayoutObserver;
  77080. private _onEndLayoutObserver;
  77081. /**
  77082. * Gets the perf counter used to capture render time
  77083. */
  77084. get renderTimeCounter(): BABYLON.PerfCounter;
  77085. /**
  77086. * Gets the perf counter used to capture layout time
  77087. */
  77088. get layoutTimeCounter(): BABYLON.PerfCounter;
  77089. /**
  77090. * Enable or disable the render time capture
  77091. */
  77092. get captureRenderTime(): boolean;
  77093. set captureRenderTime(value: boolean);
  77094. /**
  77095. * Enable or disable the layout time capture
  77096. */
  77097. get captureLayoutTime(): boolean;
  77098. set captureLayoutTime(value: boolean);
  77099. /**
  77100. * Instantiates a new advanced dynamic texture instrumentation.
  77101. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77102. * @param texture Defines the AdvancedDynamicTexture to instrument
  77103. */
  77104. constructor(
  77105. /**
  77106. * Define the instrumented AdvancedDynamicTexture.
  77107. */
  77108. texture: AdvancedDynamicTexture);
  77109. /**
  77110. * Dispose and release associated resources.
  77111. */
  77112. dispose(): void;
  77113. }
  77114. }
  77115. declare module BABYLON.GUI {
  77116. /**
  77117. * Class used to load GUI via XML.
  77118. */
  77119. export class XmlLoader {
  77120. private _nodes;
  77121. private _nodeTypes;
  77122. private _isLoaded;
  77123. private _objectAttributes;
  77124. private _parentClass;
  77125. /**
  77126. * Create a new xml loader
  77127. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77128. */
  77129. constructor(parentClass?: null);
  77130. private _getChainElement;
  77131. private _getClassAttribute;
  77132. private _createGuiElement;
  77133. private _parseGrid;
  77134. private _parseElement;
  77135. private _prepareSourceElement;
  77136. private _parseElementsFromSource;
  77137. private _parseXml;
  77138. /**
  77139. * Gets if the loading has finished.
  77140. * @returns whether the loading has finished or not
  77141. */
  77142. isLoaded(): boolean;
  77143. /**
  77144. * Gets a loaded node / control by id.
  77145. * @param id the Controls id set in the xml
  77146. * @returns element of type Control
  77147. */
  77148. getNodeById(id: string): any;
  77149. /**
  77150. * Gets all loaded nodes / controls
  77151. * @returns Array of controls
  77152. */
  77153. getNodes(): any;
  77154. /**
  77155. * Initiates the xml layout loading
  77156. * @param xmlFile defines the xml layout to load
  77157. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77158. * @param callback defines the callback called on layout load.
  77159. */
  77160. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77161. }
  77162. }
  77163. declare module BABYLON.GUI {
  77164. /**
  77165. * Class used to create containers for controls
  77166. */
  77167. export class Container3D extends Control3D {
  77168. private _blockLayout;
  77169. /**
  77170. * Gets the list of child controls
  77171. */
  77172. protected _children: Control3D[];
  77173. /**
  77174. * Gets the list of child controls
  77175. */
  77176. get children(): Array<Control3D>;
  77177. /**
  77178. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77179. * This is helpful to optimize layout operation when adding multiple children in a row
  77180. */
  77181. get blockLayout(): boolean;
  77182. set blockLayout(value: boolean);
  77183. /**
  77184. * Creates a new container
  77185. * @param name defines the container name
  77186. */
  77187. constructor(name?: string);
  77188. /**
  77189. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77190. * @returns the current container
  77191. */
  77192. updateLayout(): Container3D;
  77193. /**
  77194. * Gets a boolean indicating if the given control is in the children of this control
  77195. * @param control defines the control to check
  77196. * @returns true if the control is in the child list
  77197. */
  77198. containsControl(control: Control3D): boolean;
  77199. /**
  77200. * Adds a control to the children of this control
  77201. * @param control defines the control to add
  77202. * @returns the current container
  77203. */
  77204. addControl(control: Control3D): Container3D;
  77205. /**
  77206. * This function will be called everytime a new control is added
  77207. */
  77208. protected _arrangeChildren(): void;
  77209. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77210. /**
  77211. * Removes a control from the children of this control
  77212. * @param control defines the control to remove
  77213. * @returns the current container
  77214. */
  77215. removeControl(control: Control3D): Container3D;
  77216. protected _getTypeName(): string;
  77217. /**
  77218. * Releases all associated resources
  77219. */
  77220. dispose(): void;
  77221. /** Control rotation will remain unchanged */
  77222. static readonly UNSET_ORIENTATION: number;
  77223. /** Control will rotate to make it look at sphere central axis */
  77224. static readonly FACEORIGIN_ORIENTATION: number;
  77225. /** Control will rotate to make it look back at sphere central axis */
  77226. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77227. /** Control will rotate to look at z axis (0, 0, 1) */
  77228. static readonly FACEFORWARD_ORIENTATION: number;
  77229. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77230. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77231. }
  77232. }
  77233. declare module BABYLON.GUI {
  77234. /**
  77235. * Class used to manage 3D user interface
  77236. * @see http://doc.babylonjs.com/how_to/gui3d
  77237. */
  77238. export class GUI3DManager implements BABYLON.IDisposable {
  77239. private _scene;
  77240. private _sceneDisposeObserver;
  77241. private _utilityLayer;
  77242. private _rootContainer;
  77243. private _pointerObserver;
  77244. private _pointerOutObserver;
  77245. /** @hidden */
  77246. _lastPickedControl: Control3D;
  77247. /** @hidden */
  77248. _lastControlOver: {
  77249. [pointerId: number]: Control3D;
  77250. };
  77251. /** @hidden */
  77252. _lastControlDown: {
  77253. [pointerId: number]: Control3D;
  77254. };
  77255. /**
  77256. * BABYLON.Observable raised when the point picked by the pointer events changed
  77257. */
  77258. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77259. /** @hidden */
  77260. _sharedMaterials: {
  77261. [key: string]: BABYLON.Material;
  77262. };
  77263. /** Gets the hosting scene */
  77264. get scene(): BABYLON.Scene;
  77265. /** Gets associated utility layer */
  77266. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77267. /**
  77268. * Creates a new GUI3DManager
  77269. * @param scene
  77270. */
  77271. constructor(scene?: BABYLON.Scene);
  77272. private _handlePointerOut;
  77273. private _doPicking;
  77274. /**
  77275. * Gets the root container
  77276. */
  77277. get rootContainer(): Container3D;
  77278. /**
  77279. * Gets a boolean indicating if the given control is in the root child list
  77280. * @param control defines the control to check
  77281. * @returns true if the control is in the root child list
  77282. */
  77283. containsControl(control: Control3D): boolean;
  77284. /**
  77285. * Adds a control to the root child list
  77286. * @param control defines the control to add
  77287. * @returns the current manager
  77288. */
  77289. addControl(control: Control3D): GUI3DManager;
  77290. /**
  77291. * Removes a control from the root child list
  77292. * @param control defines the control to remove
  77293. * @returns the current container
  77294. */
  77295. removeControl(control: Control3D): GUI3DManager;
  77296. /**
  77297. * Releases all associated resources
  77298. */
  77299. dispose(): void;
  77300. }
  77301. }
  77302. declare module BABYLON.GUI {
  77303. /**
  77304. * Class used to transport BABYLON.Vector3 information for pointer events
  77305. */
  77306. export class Vector3WithInfo extends BABYLON.Vector3 {
  77307. /** defines the current mouse button index */
  77308. buttonIndex: number;
  77309. /**
  77310. * Creates a new Vector3WithInfo
  77311. * @param source defines the vector3 data to transport
  77312. * @param buttonIndex defines the current mouse button index
  77313. */
  77314. constructor(source: BABYLON.Vector3,
  77315. /** defines the current mouse button index */
  77316. buttonIndex?: number);
  77317. }
  77318. }
  77319. declare module BABYLON.GUI {
  77320. /**
  77321. * Class used as base class for controls
  77322. */
  77323. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77324. /** Defines the control name */
  77325. name?: string | undefined;
  77326. /** @hidden */
  77327. _host: GUI3DManager;
  77328. private _node;
  77329. private _downCount;
  77330. private _enterCount;
  77331. private _downPointerIds;
  77332. private _isVisible;
  77333. /** Gets or sets the control position in world space */
  77334. get position(): BABYLON.Vector3;
  77335. set position(value: BABYLON.Vector3);
  77336. /** Gets or sets the control scaling in world space */
  77337. get scaling(): BABYLON.Vector3;
  77338. set scaling(value: BABYLON.Vector3);
  77339. /** Callback used to start pointer enter animation */
  77340. pointerEnterAnimation: () => void;
  77341. /** Callback used to start pointer out animation */
  77342. pointerOutAnimation: () => void;
  77343. /** Callback used to start pointer down animation */
  77344. pointerDownAnimation: () => void;
  77345. /** Callback used to start pointer up animation */
  77346. pointerUpAnimation: () => void;
  77347. /**
  77348. * An event triggered when the pointer move over the control
  77349. */
  77350. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77351. /**
  77352. * An event triggered when the pointer move out of the control
  77353. */
  77354. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77355. /**
  77356. * An event triggered when the pointer taps the control
  77357. */
  77358. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77359. /**
  77360. * An event triggered when pointer is up
  77361. */
  77362. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77363. /**
  77364. * An event triggered when a control is clicked on (with a mouse)
  77365. */
  77366. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77367. /**
  77368. * An event triggered when pointer enters the control
  77369. */
  77370. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77371. /**
  77372. * Gets or sets the parent container
  77373. */
  77374. parent: BABYLON.Nullable<Container3D>;
  77375. private _behaviors;
  77376. /**
  77377. * Gets the list of attached behaviors
  77378. * @see http://doc.babylonjs.com/features/behaviour
  77379. */
  77380. get behaviors(): BABYLON.Behavior<Control3D>[];
  77381. /**
  77382. * Attach a behavior to the control
  77383. * @see http://doc.babylonjs.com/features/behaviour
  77384. * @param behavior defines the behavior to attach
  77385. * @returns the current control
  77386. */
  77387. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77388. /**
  77389. * Remove an attached behavior
  77390. * @see http://doc.babylonjs.com/features/behaviour
  77391. * @param behavior defines the behavior to attach
  77392. * @returns the current control
  77393. */
  77394. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77395. /**
  77396. * Gets an attached behavior by name
  77397. * @param name defines the name of the behavior to look for
  77398. * @see http://doc.babylonjs.com/features/behaviour
  77399. * @returns null if behavior was not found else the requested behavior
  77400. */
  77401. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77402. /** Gets or sets a boolean indicating if the control is visible */
  77403. get isVisible(): boolean;
  77404. set isVisible(value: boolean);
  77405. /**
  77406. * Creates a new control
  77407. * @param name defines the control name
  77408. */
  77409. constructor(
  77410. /** Defines the control name */
  77411. name?: string | undefined);
  77412. /**
  77413. * Gets a string representing the class name
  77414. */
  77415. get typeName(): string;
  77416. /**
  77417. * Get the current class name of the control.
  77418. * @returns current class name
  77419. */
  77420. getClassName(): string;
  77421. protected _getTypeName(): string;
  77422. /**
  77423. * Gets the transform node used by this control
  77424. */
  77425. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77426. /**
  77427. * Gets the mesh used to render this control
  77428. */
  77429. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77430. /**
  77431. * Link the control as child of the given node
  77432. * @param node defines the node to link to. Use null to unlink the control
  77433. * @returns the current control
  77434. */
  77435. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77436. /** @hidden **/
  77437. _prepareNode(scene: BABYLON.Scene): void;
  77438. /**
  77439. * Node creation.
  77440. * Can be overriden by children
  77441. * @param scene defines the scene where the node must be attached
  77442. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77443. */
  77444. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77445. /**
  77446. * Affect a material to the given mesh
  77447. * @param mesh defines the mesh which will represent the control
  77448. */
  77449. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77450. /** @hidden */
  77451. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77452. /** @hidden */
  77453. _onPointerEnter(target: Control3D): boolean;
  77454. /** @hidden */
  77455. _onPointerOut(target: Control3D): void;
  77456. /** @hidden */
  77457. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77458. /** @hidden */
  77459. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77460. /** @hidden */
  77461. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77462. /** @hidden */
  77463. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77464. /** @hidden */
  77465. _disposeNode(): void;
  77466. /**
  77467. * Releases all associated resources
  77468. */
  77469. dispose(): void;
  77470. }
  77471. }
  77472. declare module BABYLON.GUI {
  77473. /**
  77474. * Class used as a root to all buttons
  77475. */
  77476. export class AbstractButton3D extends Control3D {
  77477. /**
  77478. * Creates a new button
  77479. * @param name defines the control name
  77480. */
  77481. constructor(name?: string);
  77482. protected _getTypeName(): string;
  77483. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77484. }
  77485. }
  77486. declare module BABYLON.GUI {
  77487. /**
  77488. * Class used to create a button in 3D
  77489. */
  77490. export class Button3D extends AbstractButton3D {
  77491. /** @hidden */
  77492. protected _currentMaterial: BABYLON.Material;
  77493. private _facadeTexture;
  77494. private _content;
  77495. private _contentResolution;
  77496. private _contentScaleRatio;
  77497. /**
  77498. * Gets or sets the texture resolution used to render content (512 by default)
  77499. */
  77500. get contentResolution(): BABYLON.int;
  77501. set contentResolution(value: BABYLON.int);
  77502. /**
  77503. * Gets or sets the texture scale ratio used to render content (2 by default)
  77504. */
  77505. get contentScaleRatio(): number;
  77506. set contentScaleRatio(value: number);
  77507. protected _disposeFacadeTexture(): void;
  77508. protected _resetContent(): void;
  77509. /**
  77510. * Creates a new button
  77511. * @param name defines the control name
  77512. */
  77513. constructor(name?: string);
  77514. /**
  77515. * Gets or sets the GUI 2D content used to display the button's facade
  77516. */
  77517. get content(): Control;
  77518. set content(value: Control);
  77519. /**
  77520. * Apply the facade texture (created from the content property).
  77521. * This function can be overloaded by child classes
  77522. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77523. */
  77524. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77525. protected _getTypeName(): string;
  77526. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77527. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77528. /**
  77529. * Releases all associated resources
  77530. */
  77531. dispose(): void;
  77532. }
  77533. }
  77534. declare module BABYLON.GUI {
  77535. /**
  77536. * Abstract class used to create a container panel deployed on the surface of a volume
  77537. */
  77538. export abstract class VolumeBasedPanel extends Container3D {
  77539. private _columns;
  77540. private _rows;
  77541. private _rowThenColum;
  77542. private _orientation;
  77543. protected _cellWidth: number;
  77544. protected _cellHeight: number;
  77545. /**
  77546. * Gets or sets the distance between elements
  77547. */
  77548. margin: number;
  77549. /**
  77550. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77551. * | Value | Type | Description |
  77552. * | ----- | ----------------------------------- | ----------- |
  77553. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77554. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77555. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77556. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77557. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77558. */
  77559. get orientation(): number;
  77560. set orientation(value: number);
  77561. /**
  77562. * Gets or sets the number of columns requested (10 by default).
  77563. * The panel will automatically compute the number of rows based on number of child controls.
  77564. */
  77565. get columns(): BABYLON.int;
  77566. set columns(value: BABYLON.int);
  77567. /**
  77568. * Gets or sets a the number of rows requested.
  77569. * The panel will automatically compute the number of columns based on number of child controls.
  77570. */
  77571. get rows(): BABYLON.int;
  77572. set rows(value: BABYLON.int);
  77573. /**
  77574. * Creates new VolumeBasedPanel
  77575. */
  77576. constructor();
  77577. protected _arrangeChildren(): void;
  77578. /** Child classes must implement this function to provide correct control positioning */
  77579. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77580. /** Child classes can implement this function to provide additional processing */
  77581. protected _finalProcessing(): void;
  77582. }
  77583. }
  77584. declare module BABYLON.GUI {
  77585. /**
  77586. * Class used to create a container panel deployed on the surface of a cylinder
  77587. */
  77588. export class CylinderPanel extends VolumeBasedPanel {
  77589. private _radius;
  77590. /**
  77591. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77592. */
  77593. get radius(): BABYLON.float;
  77594. set radius(value: BABYLON.float);
  77595. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77596. private _cylindricalMapping;
  77597. }
  77598. }
  77599. declare module BABYLON.GUI {
  77600. /** @hidden */
  77601. export var fluentVertexShader: {
  77602. name: string;
  77603. shader: string;
  77604. };
  77605. }
  77606. declare module BABYLON.GUI {
  77607. /** @hidden */
  77608. export var fluentPixelShader: {
  77609. name: string;
  77610. shader: string;
  77611. };
  77612. }
  77613. declare module BABYLON.GUI {
  77614. /** @hidden */
  77615. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77616. INNERGLOW: boolean;
  77617. BORDER: boolean;
  77618. HOVERLIGHT: boolean;
  77619. TEXTURE: boolean;
  77620. constructor();
  77621. }
  77622. /**
  77623. * Class used to render controls with fluent desgin
  77624. */
  77625. export class FluentMaterial extends BABYLON.PushMaterial {
  77626. /**
  77627. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77628. */
  77629. innerGlowColorIntensity: number;
  77630. /**
  77631. * Gets or sets the inner glow color (white by default)
  77632. */
  77633. innerGlowColor: BABYLON.Color3;
  77634. /**
  77635. * Gets or sets alpha value (default is 1.0)
  77636. */
  77637. alpha: number;
  77638. /**
  77639. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77640. */
  77641. albedoColor: BABYLON.Color3;
  77642. /**
  77643. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77644. */
  77645. renderBorders: boolean;
  77646. /**
  77647. * Gets or sets border width (default is 0.5)
  77648. */
  77649. borderWidth: number;
  77650. /**
  77651. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77652. */
  77653. edgeSmoothingValue: number;
  77654. /**
  77655. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77656. */
  77657. borderMinValue: number;
  77658. /**
  77659. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77660. */
  77661. renderHoverLight: boolean;
  77662. /**
  77663. * Gets or sets the radius used to render the hover light (default is 1.0)
  77664. */
  77665. hoverRadius: number;
  77666. /**
  77667. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77668. */
  77669. hoverColor: BABYLON.Color4;
  77670. /**
  77671. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77672. */
  77673. hoverPosition: BABYLON.Vector3;
  77674. private _albedoTexture;
  77675. /** Gets or sets the texture to use for albedo color */
  77676. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77677. /**
  77678. * Creates a new Fluent material
  77679. * @param name defines the name of the material
  77680. * @param scene defines the hosting scene
  77681. */
  77682. constructor(name: string, scene: BABYLON.Scene);
  77683. needAlphaBlending(): boolean;
  77684. needAlphaTesting(): boolean;
  77685. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77686. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77687. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77688. getActiveTextures(): BABYLON.BaseTexture[];
  77689. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77690. dispose(forceDisposeEffect?: boolean): void;
  77691. clone(name: string): FluentMaterial;
  77692. serialize(): any;
  77693. getClassName(): string;
  77694. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77695. }
  77696. }
  77697. declare module BABYLON.GUI {
  77698. /**
  77699. * Class used to create a holographic button in 3D
  77700. */
  77701. export class HolographicButton extends Button3D {
  77702. private _backPlate;
  77703. private _textPlate;
  77704. private _frontPlate;
  77705. private _text;
  77706. private _imageUrl;
  77707. private _shareMaterials;
  77708. private _frontMaterial;
  77709. private _backMaterial;
  77710. private _plateMaterial;
  77711. private _pickedPointObserver;
  77712. private _tooltipFade;
  77713. private _tooltipTextBlock;
  77714. private _tooltipTexture;
  77715. private _tooltipMesh;
  77716. private _tooltipHoverObserver;
  77717. private _tooltipOutObserver;
  77718. private _disposeTooltip;
  77719. /**
  77720. * Rendering ground id of all the mesh in the button
  77721. */
  77722. set renderingGroupId(id: number);
  77723. get renderingGroupId(): number;
  77724. /**
  77725. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77726. */
  77727. set tooltipText(text: BABYLON.Nullable<string>);
  77728. get tooltipText(): BABYLON.Nullable<string>;
  77729. /**
  77730. * Gets or sets text for the button
  77731. */
  77732. get text(): string;
  77733. set text(value: string);
  77734. /**
  77735. * Gets or sets the image url for the button
  77736. */
  77737. get imageUrl(): string;
  77738. set imageUrl(value: string);
  77739. /**
  77740. * Gets the back material used by this button
  77741. */
  77742. get backMaterial(): FluentMaterial;
  77743. /**
  77744. * Gets the front material used by this button
  77745. */
  77746. get frontMaterial(): FluentMaterial;
  77747. /**
  77748. * Gets the plate material used by this button
  77749. */
  77750. get plateMaterial(): BABYLON.StandardMaterial;
  77751. /**
  77752. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77753. */
  77754. get shareMaterials(): boolean;
  77755. /**
  77756. * Creates a new button
  77757. * @param name defines the control name
  77758. */
  77759. constructor(name?: string, shareMaterials?: boolean);
  77760. protected _getTypeName(): string;
  77761. private _rebuildContent;
  77762. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77763. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77764. private _createBackMaterial;
  77765. private _createFrontMaterial;
  77766. private _createPlateMaterial;
  77767. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77768. /**
  77769. * Releases all associated resources
  77770. */
  77771. dispose(): void;
  77772. }
  77773. }
  77774. declare module BABYLON.GUI {
  77775. /**
  77776. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77777. */
  77778. export class MeshButton3D extends Button3D {
  77779. /** @hidden */
  77780. protected _currentMesh: BABYLON.Mesh;
  77781. /**
  77782. * Creates a new 3D button based on a mesh
  77783. * @param mesh mesh to become a 3D button
  77784. * @param name defines the control name
  77785. */
  77786. constructor(mesh: BABYLON.Mesh, name?: string);
  77787. protected _getTypeName(): string;
  77788. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77789. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77790. }
  77791. }
  77792. declare module BABYLON.GUI {
  77793. /**
  77794. * Class used to create a container panel deployed on the surface of a plane
  77795. */
  77796. export class PlanePanel extends VolumeBasedPanel {
  77797. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77798. }
  77799. }
  77800. declare module BABYLON.GUI {
  77801. /**
  77802. * Class used to create a container panel where items get randomized planar mapping
  77803. */
  77804. export class ScatterPanel extends VolumeBasedPanel {
  77805. private _iteration;
  77806. /**
  77807. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77808. */
  77809. get iteration(): BABYLON.float;
  77810. set iteration(value: BABYLON.float);
  77811. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77812. private _scatterMapping;
  77813. protected _finalProcessing(): void;
  77814. }
  77815. }
  77816. declare module BABYLON.GUI {
  77817. /**
  77818. * Class used to create a container panel deployed on the surface of a sphere
  77819. */
  77820. export class SpherePanel extends VolumeBasedPanel {
  77821. private _radius;
  77822. /**
  77823. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77824. */
  77825. get radius(): BABYLON.float;
  77826. set radius(value: BABYLON.float);
  77827. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77828. private _sphericalMapping;
  77829. }
  77830. }
  77831. declare module BABYLON.GUI {
  77832. /**
  77833. * Class used to create a stack panel in 3D on XY plane
  77834. */
  77835. export class StackPanel3D extends Container3D {
  77836. private _isVertical;
  77837. /**
  77838. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77839. */
  77840. get isVertical(): boolean;
  77841. set isVertical(value: boolean);
  77842. /**
  77843. * Gets or sets the distance between elements
  77844. */
  77845. margin: number;
  77846. /**
  77847. * Creates new StackPanel
  77848. * @param isVertical
  77849. */
  77850. constructor(isVertical?: boolean);
  77851. protected _arrangeChildren(): void;
  77852. }
  77853. }
  77854. declare module BABYLON {
  77855. /**
  77856. * Configuration for glTF validation
  77857. */
  77858. export interface IGLTFValidationConfiguration {
  77859. /**
  77860. * The url of the glTF validator.
  77861. */
  77862. url: string;
  77863. }
  77864. /**
  77865. * glTF validation
  77866. */
  77867. export class GLTFValidation {
  77868. /**
  77869. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77870. */
  77871. static Configuration: IGLTFValidationConfiguration;
  77872. private static _LoadScriptPromise;
  77873. /**
  77874. * Validate a glTF asset using the glTF-Validator.
  77875. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77876. * @param rootUrl The root url for the glTF
  77877. * @param fileName The file name for the glTF
  77878. * @param getExternalResource The callback to get external resources for the glTF validator
  77879. * @returns A promise that resolves with the glTF validation results once complete
  77880. */
  77881. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77882. }
  77883. }
  77884. declare module BABYLON {
  77885. /**
  77886. * Mode that determines the coordinate system to use.
  77887. */
  77888. export enum GLTFLoaderCoordinateSystemMode {
  77889. /**
  77890. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77891. */
  77892. AUTO = 0,
  77893. /**
  77894. * Sets the useRightHandedSystem flag on the scene.
  77895. */
  77896. FORCE_RIGHT_HANDED = 1
  77897. }
  77898. /**
  77899. * Mode that determines what animations will start.
  77900. */
  77901. export enum GLTFLoaderAnimationStartMode {
  77902. /**
  77903. * No animation will start.
  77904. */
  77905. NONE = 0,
  77906. /**
  77907. * The first animation will start.
  77908. */
  77909. FIRST = 1,
  77910. /**
  77911. * All animations will start.
  77912. */
  77913. ALL = 2
  77914. }
  77915. /**
  77916. * Interface that contains the data for the glTF asset.
  77917. */
  77918. export interface IGLTFLoaderData {
  77919. /**
  77920. * The object that represents the glTF JSON.
  77921. */
  77922. json: Object;
  77923. /**
  77924. * The BIN chunk of a binary glTF.
  77925. */
  77926. bin: Nullable<IDataBuffer>;
  77927. }
  77928. /**
  77929. * Interface for extending the loader.
  77930. */
  77931. export interface IGLTFLoaderExtension {
  77932. /**
  77933. * The name of this extension.
  77934. */
  77935. readonly name: string;
  77936. /**
  77937. * Defines whether this extension is enabled.
  77938. */
  77939. enabled: boolean;
  77940. /**
  77941. * Defines the order of this extension.
  77942. * The loader sorts the extensions using these values when loading.
  77943. */
  77944. order?: number;
  77945. }
  77946. /**
  77947. * Loader state.
  77948. */
  77949. export enum GLTFLoaderState {
  77950. /**
  77951. * The asset is loading.
  77952. */
  77953. LOADING = 0,
  77954. /**
  77955. * The asset is ready for rendering.
  77956. */
  77957. READY = 1,
  77958. /**
  77959. * The asset is completely loaded.
  77960. */
  77961. COMPLETE = 2
  77962. }
  77963. /** @hidden */
  77964. export interface IImportMeshAsyncOutput {
  77965. meshes: AbstractMesh[];
  77966. particleSystems: IParticleSystem[];
  77967. skeletons: Skeleton[];
  77968. animationGroups: AnimationGroup[];
  77969. lights: Light[];
  77970. transformNodes: TransformNode[];
  77971. }
  77972. /** @hidden */
  77973. export interface IGLTFLoader extends IDisposable {
  77974. readonly state: Nullable<GLTFLoaderState>;
  77975. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77976. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77977. }
  77978. /**
  77979. * File loader for loading glTF files into a scene.
  77980. */
  77981. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77982. /** @hidden */
  77983. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77984. /** @hidden */
  77985. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77986. /**
  77987. * Raised when the asset has been parsed
  77988. */
  77989. onParsedObservable: Observable<IGLTFLoaderData>;
  77990. private _onParsedObserver;
  77991. /**
  77992. * Raised when the asset has been parsed
  77993. */
  77994. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77995. /**
  77996. * 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.
  77997. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77998. * Defaults to true.
  77999. * @hidden
  78000. */
  78001. static IncrementalLoading: boolean;
  78002. /**
  78003. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78004. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78005. * @hidden
  78006. */
  78007. static HomogeneousCoordinates: boolean;
  78008. /**
  78009. * The coordinate system mode. Defaults to AUTO.
  78010. */
  78011. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78012. /**
  78013. * The animation start mode. Defaults to FIRST.
  78014. */
  78015. animationStartMode: GLTFLoaderAnimationStartMode;
  78016. /**
  78017. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78018. */
  78019. compileMaterials: boolean;
  78020. /**
  78021. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78022. */
  78023. useClipPlane: boolean;
  78024. /**
  78025. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78026. */
  78027. compileShadowGenerators: boolean;
  78028. /**
  78029. * Defines if the Alpha blended materials are only applied as coverage.
  78030. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78031. * If true, no extra effects are applied to transparent pixels.
  78032. */
  78033. transparencyAsCoverage: boolean;
  78034. /**
  78035. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78036. * Enabling will disable offline support and glTF validator.
  78037. * Defaults to false.
  78038. */
  78039. useRangeRequests: boolean;
  78040. /**
  78041. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78042. */
  78043. createInstances: boolean;
  78044. /**
  78045. * Function called before loading a url referenced by the asset.
  78046. */
  78047. preprocessUrlAsync: (url: string) => Promise<string>;
  78048. /**
  78049. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78050. */
  78051. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78052. private _onMeshLoadedObserver;
  78053. /**
  78054. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78055. */
  78056. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78057. /**
  78058. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78059. */
  78060. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78061. private _onTextureLoadedObserver;
  78062. /**
  78063. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78064. */
  78065. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78066. /**
  78067. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78068. */
  78069. readonly onMaterialLoadedObservable: Observable<Material>;
  78070. private _onMaterialLoadedObserver;
  78071. /**
  78072. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78073. */
  78074. set onMaterialLoaded(callback: (material: Material) => void);
  78075. /**
  78076. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78077. */
  78078. readonly onCameraLoadedObservable: Observable<Camera>;
  78079. private _onCameraLoadedObserver;
  78080. /**
  78081. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78082. */
  78083. set onCameraLoaded(callback: (camera: Camera) => void);
  78084. /**
  78085. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78086. * For assets with LODs, raised when all of the LODs are complete.
  78087. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78088. */
  78089. readonly onCompleteObservable: Observable<void>;
  78090. private _onCompleteObserver;
  78091. /**
  78092. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78093. * For assets with LODs, raised when all of the LODs are complete.
  78094. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78095. */
  78096. set onComplete(callback: () => void);
  78097. /**
  78098. * Observable raised when an error occurs.
  78099. */
  78100. readonly onErrorObservable: Observable<any>;
  78101. private _onErrorObserver;
  78102. /**
  78103. * Callback raised when an error occurs.
  78104. */
  78105. set onError(callback: (reason: any) => void);
  78106. /**
  78107. * Observable raised after the loader is disposed.
  78108. */
  78109. readonly onDisposeObservable: Observable<void>;
  78110. private _onDisposeObserver;
  78111. /**
  78112. * Callback raised after the loader is disposed.
  78113. */
  78114. set onDispose(callback: () => void);
  78115. /**
  78116. * Observable raised after a loader extension is created.
  78117. * Set additional options for a loader extension in this event.
  78118. */
  78119. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78120. private _onExtensionLoadedObserver;
  78121. /**
  78122. * Callback raised after a loader extension is created.
  78123. */
  78124. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78125. /**
  78126. * Defines if the loader logging is enabled.
  78127. */
  78128. get loggingEnabled(): boolean;
  78129. set loggingEnabled(value: boolean);
  78130. /**
  78131. * Defines if the loader should capture performance counters.
  78132. */
  78133. get capturePerformanceCounters(): boolean;
  78134. set capturePerformanceCounters(value: boolean);
  78135. /**
  78136. * Defines if the loader should validate the asset.
  78137. */
  78138. validate: boolean;
  78139. /**
  78140. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78141. */
  78142. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78143. private _onValidatedObserver;
  78144. /**
  78145. * Callback raised after a loader extension is created.
  78146. */
  78147. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78148. private _loader;
  78149. /**
  78150. * Name of the loader ("gltf")
  78151. */
  78152. name: string;
  78153. /** @hidden */
  78154. extensions: ISceneLoaderPluginExtensions;
  78155. /**
  78156. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78157. */
  78158. dispose(): void;
  78159. /** @hidden */
  78160. _clear(): void;
  78161. /** @hidden */
  78162. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78163. /** @hidden */
  78164. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78165. /** @hidden */
  78166. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78167. meshes: AbstractMesh[];
  78168. particleSystems: IParticleSystem[];
  78169. skeletons: Skeleton[];
  78170. animationGroups: AnimationGroup[];
  78171. }>;
  78172. /** @hidden */
  78173. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78174. /** @hidden */
  78175. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78176. /** @hidden */
  78177. canDirectLoad(data: string): boolean;
  78178. /** @hidden */
  78179. directLoad(scene: Scene, data: string): any;
  78180. /**
  78181. * The callback that allows custom handling of the root url based on the response url.
  78182. * @param rootUrl the original root url
  78183. * @param responseURL the response url if available
  78184. * @returns the new root url
  78185. */
  78186. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78187. /** @hidden */
  78188. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78189. /**
  78190. * The loader state or null if the loader is not active.
  78191. */
  78192. get loaderState(): Nullable<GLTFLoaderState>;
  78193. /**
  78194. * Returns a promise that resolves when the asset is completely loaded.
  78195. * @returns a promise that resolves when the asset is completely loaded.
  78196. */
  78197. whenCompleteAsync(): Promise<void>;
  78198. private _validate;
  78199. private _getLoader;
  78200. private _parseJson;
  78201. private _unpackBinaryAsync;
  78202. private _unpackBinaryV1Async;
  78203. private _unpackBinaryV2Async;
  78204. private static _parseVersion;
  78205. private static _compareVersion;
  78206. private static readonly _logSpaces;
  78207. private _logIndentLevel;
  78208. private _loggingEnabled;
  78209. /** @hidden */
  78210. _log: (message: string) => void;
  78211. /** @hidden */
  78212. _logOpen(message: string): void;
  78213. /** @hidden */
  78214. _logClose(): void;
  78215. private _logEnabled;
  78216. private _logDisabled;
  78217. private _capturePerformanceCounters;
  78218. /** @hidden */
  78219. _startPerformanceCounter: (counterName: string) => void;
  78220. /** @hidden */
  78221. _endPerformanceCounter: (counterName: string) => void;
  78222. private _startPerformanceCounterEnabled;
  78223. private _startPerformanceCounterDisabled;
  78224. private _endPerformanceCounterEnabled;
  78225. private _endPerformanceCounterDisabled;
  78226. }
  78227. }
  78228. declare module BABYLON.GLTF1 {
  78229. /**
  78230. * Enums
  78231. * @hidden
  78232. */
  78233. export enum EComponentType {
  78234. BYTE = 5120,
  78235. UNSIGNED_BYTE = 5121,
  78236. SHORT = 5122,
  78237. UNSIGNED_SHORT = 5123,
  78238. FLOAT = 5126
  78239. }
  78240. /** @hidden */
  78241. export enum EShaderType {
  78242. FRAGMENT = 35632,
  78243. VERTEX = 35633
  78244. }
  78245. /** @hidden */
  78246. export enum EParameterType {
  78247. BYTE = 5120,
  78248. UNSIGNED_BYTE = 5121,
  78249. SHORT = 5122,
  78250. UNSIGNED_SHORT = 5123,
  78251. INT = 5124,
  78252. UNSIGNED_INT = 5125,
  78253. FLOAT = 5126,
  78254. FLOAT_VEC2 = 35664,
  78255. FLOAT_VEC3 = 35665,
  78256. FLOAT_VEC4 = 35666,
  78257. INT_VEC2 = 35667,
  78258. INT_VEC3 = 35668,
  78259. INT_VEC4 = 35669,
  78260. BOOL = 35670,
  78261. BOOL_VEC2 = 35671,
  78262. BOOL_VEC3 = 35672,
  78263. BOOL_VEC4 = 35673,
  78264. FLOAT_MAT2 = 35674,
  78265. FLOAT_MAT3 = 35675,
  78266. FLOAT_MAT4 = 35676,
  78267. SAMPLER_2D = 35678
  78268. }
  78269. /** @hidden */
  78270. export enum ETextureWrapMode {
  78271. CLAMP_TO_EDGE = 33071,
  78272. MIRRORED_REPEAT = 33648,
  78273. REPEAT = 10497
  78274. }
  78275. /** @hidden */
  78276. export enum ETextureFilterType {
  78277. NEAREST = 9728,
  78278. LINEAR = 9728,
  78279. NEAREST_MIPMAP_NEAREST = 9984,
  78280. LINEAR_MIPMAP_NEAREST = 9985,
  78281. NEAREST_MIPMAP_LINEAR = 9986,
  78282. LINEAR_MIPMAP_LINEAR = 9987
  78283. }
  78284. /** @hidden */
  78285. export enum ETextureFormat {
  78286. ALPHA = 6406,
  78287. RGB = 6407,
  78288. RGBA = 6408,
  78289. LUMINANCE = 6409,
  78290. LUMINANCE_ALPHA = 6410
  78291. }
  78292. /** @hidden */
  78293. export enum ECullingType {
  78294. FRONT = 1028,
  78295. BACK = 1029,
  78296. FRONT_AND_BACK = 1032
  78297. }
  78298. /** @hidden */
  78299. export enum EBlendingFunction {
  78300. ZERO = 0,
  78301. ONE = 1,
  78302. SRC_COLOR = 768,
  78303. ONE_MINUS_SRC_COLOR = 769,
  78304. DST_COLOR = 774,
  78305. ONE_MINUS_DST_COLOR = 775,
  78306. SRC_ALPHA = 770,
  78307. ONE_MINUS_SRC_ALPHA = 771,
  78308. DST_ALPHA = 772,
  78309. ONE_MINUS_DST_ALPHA = 773,
  78310. CONSTANT_COLOR = 32769,
  78311. ONE_MINUS_CONSTANT_COLOR = 32770,
  78312. CONSTANT_ALPHA = 32771,
  78313. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78314. SRC_ALPHA_SATURATE = 776
  78315. }
  78316. /** @hidden */
  78317. export interface IGLTFProperty {
  78318. extensions?: {
  78319. [key: string]: any;
  78320. };
  78321. extras?: Object;
  78322. }
  78323. /** @hidden */
  78324. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78325. name?: string;
  78326. }
  78327. /** @hidden */
  78328. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78329. bufferView: string;
  78330. byteOffset: number;
  78331. byteStride: number;
  78332. count: number;
  78333. type: string;
  78334. componentType: EComponentType;
  78335. max?: number[];
  78336. min?: number[];
  78337. name?: string;
  78338. }
  78339. /** @hidden */
  78340. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78341. buffer: string;
  78342. byteOffset: number;
  78343. byteLength: number;
  78344. byteStride: number;
  78345. target?: number;
  78346. }
  78347. /** @hidden */
  78348. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78349. uri: string;
  78350. byteLength?: number;
  78351. type?: string;
  78352. }
  78353. /** @hidden */
  78354. export interface IGLTFShader extends IGLTFChildRootProperty {
  78355. uri: string;
  78356. type: EShaderType;
  78357. }
  78358. /** @hidden */
  78359. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78360. attributes: string[];
  78361. fragmentShader: string;
  78362. vertexShader: string;
  78363. }
  78364. /** @hidden */
  78365. export interface IGLTFTechniqueParameter {
  78366. type: number;
  78367. count?: number;
  78368. semantic?: string;
  78369. node?: string;
  78370. value?: number | boolean | string | Array<any>;
  78371. source?: string;
  78372. babylonValue?: any;
  78373. }
  78374. /** @hidden */
  78375. export interface IGLTFTechniqueCommonProfile {
  78376. lightingModel: string;
  78377. texcoordBindings: Object;
  78378. parameters?: Array<any>;
  78379. }
  78380. /** @hidden */
  78381. export interface IGLTFTechniqueStatesFunctions {
  78382. blendColor?: number[];
  78383. blendEquationSeparate?: number[];
  78384. blendFuncSeparate?: number[];
  78385. colorMask: boolean[];
  78386. cullFace: number[];
  78387. }
  78388. /** @hidden */
  78389. export interface IGLTFTechniqueStates {
  78390. enable: number[];
  78391. functions: IGLTFTechniqueStatesFunctions;
  78392. }
  78393. /** @hidden */
  78394. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78395. parameters: {
  78396. [key: string]: IGLTFTechniqueParameter;
  78397. };
  78398. program: string;
  78399. attributes: {
  78400. [key: string]: string;
  78401. };
  78402. uniforms: {
  78403. [key: string]: string;
  78404. };
  78405. states: IGLTFTechniqueStates;
  78406. }
  78407. /** @hidden */
  78408. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78409. technique?: string;
  78410. values: string[];
  78411. }
  78412. /** @hidden */
  78413. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78414. attributes: {
  78415. [key: string]: string;
  78416. };
  78417. indices: string;
  78418. material: string;
  78419. mode?: number;
  78420. }
  78421. /** @hidden */
  78422. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78423. primitives: IGLTFMeshPrimitive[];
  78424. }
  78425. /** @hidden */
  78426. export interface IGLTFImage extends IGLTFChildRootProperty {
  78427. uri: string;
  78428. }
  78429. /** @hidden */
  78430. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78431. magFilter?: number;
  78432. minFilter?: number;
  78433. wrapS?: number;
  78434. wrapT?: number;
  78435. }
  78436. /** @hidden */
  78437. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78438. sampler: string;
  78439. source: string;
  78440. format?: ETextureFormat;
  78441. internalFormat?: ETextureFormat;
  78442. target?: number;
  78443. type?: number;
  78444. babylonTexture?: Texture;
  78445. }
  78446. /** @hidden */
  78447. export interface IGLTFAmbienLight {
  78448. color?: number[];
  78449. }
  78450. /** @hidden */
  78451. export interface IGLTFDirectionalLight {
  78452. color?: number[];
  78453. }
  78454. /** @hidden */
  78455. export interface IGLTFPointLight {
  78456. color?: number[];
  78457. constantAttenuation?: number;
  78458. linearAttenuation?: number;
  78459. quadraticAttenuation?: number;
  78460. }
  78461. /** @hidden */
  78462. export interface IGLTFSpotLight {
  78463. color?: number[];
  78464. constantAttenuation?: number;
  78465. fallOfAngle?: number;
  78466. fallOffExponent?: number;
  78467. linearAttenuation?: number;
  78468. quadraticAttenuation?: number;
  78469. }
  78470. /** @hidden */
  78471. export interface IGLTFLight extends IGLTFChildRootProperty {
  78472. type: string;
  78473. }
  78474. /** @hidden */
  78475. export interface IGLTFCameraOrthographic {
  78476. xmag: number;
  78477. ymag: number;
  78478. zfar: number;
  78479. znear: number;
  78480. }
  78481. /** @hidden */
  78482. export interface IGLTFCameraPerspective {
  78483. aspectRatio: number;
  78484. yfov: number;
  78485. zfar: number;
  78486. znear: number;
  78487. }
  78488. /** @hidden */
  78489. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78490. type: string;
  78491. }
  78492. /** @hidden */
  78493. export interface IGLTFAnimationChannelTarget {
  78494. id: string;
  78495. path: string;
  78496. }
  78497. /** @hidden */
  78498. export interface IGLTFAnimationChannel {
  78499. sampler: string;
  78500. target: IGLTFAnimationChannelTarget;
  78501. }
  78502. /** @hidden */
  78503. export interface IGLTFAnimationSampler {
  78504. input: string;
  78505. output: string;
  78506. interpolation?: string;
  78507. }
  78508. /** @hidden */
  78509. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78510. channels?: IGLTFAnimationChannel[];
  78511. parameters?: {
  78512. [key: string]: string;
  78513. };
  78514. samplers?: {
  78515. [key: string]: IGLTFAnimationSampler;
  78516. };
  78517. }
  78518. /** @hidden */
  78519. export interface IGLTFNodeInstanceSkin {
  78520. skeletons: string[];
  78521. skin: string;
  78522. meshes: string[];
  78523. }
  78524. /** @hidden */
  78525. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78526. bindShapeMatrix: number[];
  78527. inverseBindMatrices: string;
  78528. jointNames: string[];
  78529. babylonSkeleton?: Skeleton;
  78530. }
  78531. /** @hidden */
  78532. export interface IGLTFNode extends IGLTFChildRootProperty {
  78533. camera?: string;
  78534. children: string[];
  78535. skin?: string;
  78536. jointName?: string;
  78537. light?: string;
  78538. matrix: number[];
  78539. mesh?: string;
  78540. meshes?: string[];
  78541. rotation?: number[];
  78542. scale?: number[];
  78543. translation?: number[];
  78544. babylonNode?: Node;
  78545. }
  78546. /** @hidden */
  78547. export interface IGLTFScene extends IGLTFChildRootProperty {
  78548. nodes: string[];
  78549. }
  78550. /** @hidden */
  78551. export interface IGLTFRuntime {
  78552. extensions: {
  78553. [key: string]: any;
  78554. };
  78555. accessors: {
  78556. [key: string]: IGLTFAccessor;
  78557. };
  78558. buffers: {
  78559. [key: string]: IGLTFBuffer;
  78560. };
  78561. bufferViews: {
  78562. [key: string]: IGLTFBufferView;
  78563. };
  78564. meshes: {
  78565. [key: string]: IGLTFMesh;
  78566. };
  78567. lights: {
  78568. [key: string]: IGLTFLight;
  78569. };
  78570. cameras: {
  78571. [key: string]: IGLTFCamera;
  78572. };
  78573. nodes: {
  78574. [key: string]: IGLTFNode;
  78575. };
  78576. images: {
  78577. [key: string]: IGLTFImage;
  78578. };
  78579. textures: {
  78580. [key: string]: IGLTFTexture;
  78581. };
  78582. shaders: {
  78583. [key: string]: IGLTFShader;
  78584. };
  78585. programs: {
  78586. [key: string]: IGLTFProgram;
  78587. };
  78588. samplers: {
  78589. [key: string]: IGLTFSampler;
  78590. };
  78591. techniques: {
  78592. [key: string]: IGLTFTechnique;
  78593. };
  78594. materials: {
  78595. [key: string]: IGLTFMaterial;
  78596. };
  78597. animations: {
  78598. [key: string]: IGLTFAnimation;
  78599. };
  78600. skins: {
  78601. [key: string]: IGLTFSkins;
  78602. };
  78603. currentScene?: Object;
  78604. scenes: {
  78605. [key: string]: IGLTFScene;
  78606. };
  78607. extensionsUsed: string[];
  78608. extensionsRequired?: string[];
  78609. buffersCount: number;
  78610. shaderscount: number;
  78611. scene: Scene;
  78612. rootUrl: string;
  78613. loadedBufferCount: number;
  78614. loadedBufferViews: {
  78615. [name: string]: ArrayBufferView;
  78616. };
  78617. loadedShaderCount: number;
  78618. importOnlyMeshes: boolean;
  78619. importMeshesNames?: string[];
  78620. dummyNodes: Node[];
  78621. forAssetContainer: boolean;
  78622. }
  78623. /** @hidden */
  78624. export interface INodeToRoot {
  78625. bone: Bone;
  78626. node: IGLTFNode;
  78627. id: string;
  78628. }
  78629. /** @hidden */
  78630. export interface IJointNode {
  78631. node: IGLTFNode;
  78632. id: string;
  78633. }
  78634. }
  78635. declare module BABYLON.GLTF1 {
  78636. /**
  78637. * Utils functions for GLTF
  78638. * @hidden
  78639. */
  78640. export class GLTFUtils {
  78641. /**
  78642. * Sets the given "parameter" matrix
  78643. * @param scene: the Scene object
  78644. * @param source: the source node where to pick the matrix
  78645. * @param parameter: the GLTF technique parameter
  78646. * @param uniformName: the name of the shader's uniform
  78647. * @param shaderMaterial: the shader material
  78648. */
  78649. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78650. /**
  78651. * Sets the given "parameter" matrix
  78652. * @param shaderMaterial: the shader material
  78653. * @param uniform: the name of the shader's uniform
  78654. * @param value: the value of the uniform
  78655. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78656. */
  78657. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78658. /**
  78659. * Returns the wrap mode of the texture
  78660. * @param mode: the mode value
  78661. */
  78662. static GetWrapMode(mode: number): number;
  78663. /**
  78664. * Returns the byte stride giving an accessor
  78665. * @param accessor: the GLTF accessor objet
  78666. */
  78667. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78668. /**
  78669. * Returns the texture filter mode giving a mode value
  78670. * @param mode: the filter mode value
  78671. */
  78672. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78673. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78674. /**
  78675. * Returns a buffer from its accessor
  78676. * @param gltfRuntime: the GLTF runtime
  78677. * @param accessor: the GLTF accessor
  78678. */
  78679. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78680. /**
  78681. * Decodes a buffer view into a string
  78682. * @param view: the buffer view
  78683. */
  78684. static DecodeBufferToText(view: ArrayBufferView): string;
  78685. /**
  78686. * Returns the default material of gltf. Related to
  78687. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78688. * @param scene: the Babylon.js scene
  78689. */
  78690. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78691. private static _DefaultMaterial;
  78692. }
  78693. }
  78694. declare module BABYLON.GLTF1 {
  78695. /**
  78696. * Implementation of the base glTF spec
  78697. * @hidden
  78698. */
  78699. export class GLTFLoaderBase {
  78700. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78701. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78702. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78703. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78704. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78705. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78706. }
  78707. /**
  78708. * glTF V1 Loader
  78709. * @hidden
  78710. */
  78711. export class GLTFLoader implements IGLTFLoader {
  78712. static Extensions: {
  78713. [name: string]: GLTFLoaderExtension;
  78714. };
  78715. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78716. state: Nullable<GLTFLoaderState>;
  78717. dispose(): void;
  78718. private _importMeshAsync;
  78719. /**
  78720. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78721. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78722. * @param scene the scene the meshes should be added to
  78723. * @param forAssetContainer defines if the entities must be stored in the scene
  78724. * @param data gltf data containing information of the meshes in a loaded file
  78725. * @param rootUrl root url to load from
  78726. * @param onProgress event that fires when loading progress has occured
  78727. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78728. */
  78729. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78730. private _loadAsync;
  78731. /**
  78732. * Imports all objects from a loaded gltf file and adds them to the scene
  78733. * @param scene the scene the objects should be added to
  78734. * @param data gltf data containing information of the meshes in a loaded file
  78735. * @param rootUrl root url to load from
  78736. * @param onProgress event that fires when loading progress has occured
  78737. * @returns a promise which completes when objects have been loaded to the scene
  78738. */
  78739. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78740. private _loadShadersAsync;
  78741. private _loadBuffersAsync;
  78742. private _createNodes;
  78743. }
  78744. /** @hidden */
  78745. export abstract class GLTFLoaderExtension {
  78746. private _name;
  78747. constructor(name: string);
  78748. get name(): string;
  78749. /**
  78750. * Defines an override for loading the runtime
  78751. * Return true to stop further extensions from loading the runtime
  78752. */
  78753. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78754. /**
  78755. * Defines an onverride for creating gltf runtime
  78756. * Return true to stop further extensions from creating the runtime
  78757. */
  78758. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78759. /**
  78760. * Defines an override for loading buffers
  78761. * Return true to stop further extensions from loading this buffer
  78762. */
  78763. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78764. /**
  78765. * Defines an override for loading texture buffers
  78766. * Return true to stop further extensions from loading this texture data
  78767. */
  78768. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78769. /**
  78770. * Defines an override for creating textures
  78771. * Return true to stop further extensions from loading this texture
  78772. */
  78773. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78774. /**
  78775. * Defines an override for loading shader strings
  78776. * Return true to stop further extensions from loading this shader data
  78777. */
  78778. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78779. /**
  78780. * Defines an override for loading materials
  78781. * Return true to stop further extensions from loading this material
  78782. */
  78783. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78784. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78785. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78786. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78787. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78788. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78789. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78790. private static LoadTextureBufferAsync;
  78791. private static CreateTextureAsync;
  78792. private static ApplyExtensions;
  78793. }
  78794. }
  78795. declare module BABYLON.GLTF1 {
  78796. /** @hidden */
  78797. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78798. private _bin;
  78799. constructor();
  78800. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78801. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78802. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78803. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78804. }
  78805. }
  78806. declare module BABYLON.GLTF1 {
  78807. /** @hidden */
  78808. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78809. constructor();
  78810. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78811. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78812. private _loadTexture;
  78813. }
  78814. }
  78815. declare module BABYLON.GLTF2.Loader {
  78816. /**
  78817. * Loader interface with an index field.
  78818. */
  78819. export interface IArrayItem {
  78820. /**
  78821. * The index of this item in the array.
  78822. */
  78823. index: number;
  78824. }
  78825. /**
  78826. * Loader interface with additional members.
  78827. */
  78828. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78829. /** @hidden */
  78830. _data?: Promise<ArrayBufferView>;
  78831. /** @hidden */
  78832. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78833. }
  78834. /**
  78835. * Loader interface with additional members.
  78836. */
  78837. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78838. }
  78839. /** @hidden */
  78840. export interface _IAnimationSamplerData {
  78841. input: Float32Array;
  78842. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78843. output: Float32Array;
  78844. }
  78845. /**
  78846. * Loader interface with additional members.
  78847. */
  78848. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78849. /** @hidden */
  78850. _data?: Promise<_IAnimationSamplerData>;
  78851. }
  78852. /**
  78853. * Loader interface with additional members.
  78854. */
  78855. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78856. channels: IAnimationChannel[];
  78857. samplers: IAnimationSampler[];
  78858. /** @hidden */
  78859. _babylonAnimationGroup?: AnimationGroup;
  78860. }
  78861. /**
  78862. * Loader interface with additional members.
  78863. */
  78864. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78865. /** @hidden */
  78866. _data?: Promise<ArrayBufferView>;
  78867. }
  78868. /**
  78869. * Loader interface with additional members.
  78870. */
  78871. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78872. /** @hidden */
  78873. _data?: Promise<ArrayBufferView>;
  78874. /** @hidden */
  78875. _babylonBuffer?: Promise<Buffer>;
  78876. }
  78877. /**
  78878. * Loader interface with additional members.
  78879. */
  78880. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78881. }
  78882. /**
  78883. * Loader interface with additional members.
  78884. */
  78885. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78886. /** @hidden */
  78887. _data?: Promise<ArrayBufferView>;
  78888. }
  78889. /**
  78890. * Loader interface with additional members.
  78891. */
  78892. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78893. }
  78894. /**
  78895. * Loader interface with additional members.
  78896. */
  78897. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78898. }
  78899. /**
  78900. * Loader interface with additional members.
  78901. */
  78902. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78903. baseColorTexture?: ITextureInfo;
  78904. metallicRoughnessTexture?: ITextureInfo;
  78905. }
  78906. /**
  78907. * Loader interface with additional members.
  78908. */
  78909. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78910. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78911. normalTexture?: IMaterialNormalTextureInfo;
  78912. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78913. emissiveTexture?: ITextureInfo;
  78914. /** @hidden */
  78915. _data?: {
  78916. [babylonDrawMode: number]: {
  78917. babylonMaterial: Material;
  78918. babylonMeshes: AbstractMesh[];
  78919. promise: Promise<void>;
  78920. };
  78921. };
  78922. }
  78923. /**
  78924. * Loader interface with additional members.
  78925. */
  78926. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78927. primitives: IMeshPrimitive[];
  78928. }
  78929. /**
  78930. * Loader interface with additional members.
  78931. */
  78932. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78933. /** @hidden */
  78934. _instanceData?: {
  78935. babylonSourceMesh: Mesh;
  78936. promise: Promise<any>;
  78937. };
  78938. }
  78939. /**
  78940. * Loader interface with additional members.
  78941. */
  78942. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78943. /**
  78944. * The parent glTF node.
  78945. */
  78946. parent?: INode;
  78947. /** @hidden */
  78948. _babylonTransformNode?: TransformNode;
  78949. /** @hidden */
  78950. _primitiveBabylonMeshes?: AbstractMesh[];
  78951. /** @hidden */
  78952. _babylonBones?: Bone[];
  78953. /** @hidden */
  78954. _numMorphTargets?: number;
  78955. }
  78956. /** @hidden */
  78957. export interface _ISamplerData {
  78958. noMipMaps: boolean;
  78959. samplingMode: number;
  78960. wrapU: number;
  78961. wrapV: number;
  78962. }
  78963. /**
  78964. * Loader interface with additional members.
  78965. */
  78966. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78967. /** @hidden */
  78968. _data?: _ISamplerData;
  78969. }
  78970. /**
  78971. * Loader interface with additional members.
  78972. */
  78973. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78974. }
  78975. /**
  78976. * Loader interface with additional members.
  78977. */
  78978. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78979. /** @hidden */
  78980. _data?: {
  78981. babylonSkeleton: Skeleton;
  78982. promise: Promise<void>;
  78983. };
  78984. }
  78985. /**
  78986. * Loader interface with additional members.
  78987. */
  78988. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78989. }
  78990. /**
  78991. * Loader interface with additional members.
  78992. */
  78993. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78994. }
  78995. /**
  78996. * Loader interface with additional members.
  78997. */
  78998. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78999. accessors?: IAccessor[];
  79000. animations?: IAnimation[];
  79001. buffers?: IBuffer[];
  79002. bufferViews?: IBufferView[];
  79003. cameras?: ICamera[];
  79004. images?: IImage[];
  79005. materials?: IMaterial[];
  79006. meshes?: IMesh[];
  79007. nodes?: INode[];
  79008. samplers?: ISampler[];
  79009. scenes?: IScene[];
  79010. skins?: ISkin[];
  79011. textures?: ITexture[];
  79012. }
  79013. }
  79014. declare module BABYLON.GLTF2 {
  79015. /**
  79016. * Interface for a glTF loader extension.
  79017. */
  79018. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79019. /**
  79020. * Called after the loader state changes to LOADING.
  79021. */
  79022. onLoading?(): void;
  79023. /**
  79024. * Called after the loader state changes to READY.
  79025. */
  79026. onReady?(): void;
  79027. /**
  79028. * Define this method to modify the default behavior when loading scenes.
  79029. * @param context The context when loading the asset
  79030. * @param scene The glTF scene property
  79031. * @returns A promise that resolves when the load is complete or null if not handled
  79032. */
  79033. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79034. /**
  79035. * Define this method to modify the default behavior when loading nodes.
  79036. * @param context The context when loading the asset
  79037. * @param node The glTF node property
  79038. * @param assign A function called synchronously after parsing the glTF properties
  79039. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79040. */
  79041. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79042. /**
  79043. * Define this method to modify the default behavior when loading cameras.
  79044. * @param context The context when loading the asset
  79045. * @param camera The glTF camera property
  79046. * @param assign A function called synchronously after parsing the glTF properties
  79047. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79048. */
  79049. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79050. /**
  79051. * @hidden
  79052. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79053. * @param context The context when loading the asset
  79054. * @param primitive The glTF mesh primitive property
  79055. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79056. */
  79057. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79058. /**
  79059. * @hidden
  79060. * Define this method to modify the default behavior when loading data for mesh primitives.
  79061. * @param context The context when loading the asset
  79062. * @param name The mesh name when loading the asset
  79063. * @param node The glTF node when loading the asset
  79064. * @param mesh The glTF mesh when loading the asset
  79065. * @param primitive The glTF mesh primitive property
  79066. * @param assign A function called synchronously after parsing the glTF properties
  79067. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79068. */
  79069. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79070. /**
  79071. * @hidden
  79072. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79073. * @param context The context when loading the asset
  79074. * @param material The glTF material property
  79075. * @param assign A function called synchronously after parsing the glTF properties
  79076. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79077. */
  79078. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79079. /**
  79080. * Define this method to modify the default behavior when creating materials.
  79081. * @param context The context when loading the asset
  79082. * @param material The glTF material property
  79083. * @param babylonDrawMode The draw mode for the Babylon material
  79084. * @returns The Babylon material or null if not handled
  79085. */
  79086. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79087. /**
  79088. * Define this method to modify the default behavior when loading material properties.
  79089. * @param context The context when loading the asset
  79090. * @param material The glTF material property
  79091. * @param babylonMaterial The Babylon material
  79092. * @returns A promise that resolves when the load is complete or null if not handled
  79093. */
  79094. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79095. /**
  79096. * Define this method to modify the default behavior when loading texture infos.
  79097. * @param context The context when loading the asset
  79098. * @param textureInfo The glTF texture info property
  79099. * @param assign A function called synchronously after parsing the glTF properties
  79100. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79101. */
  79102. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79103. /**
  79104. * @hidden
  79105. * Define this method to modify the default behavior when loading textures.
  79106. * @param context The context when loading the asset
  79107. * @param texture The glTF texture property
  79108. * @param assign A function called synchronously after parsing the glTF properties
  79109. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79110. */
  79111. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79112. /**
  79113. * Define this method to modify the default behavior when loading animations.
  79114. * @param context The context when loading the asset
  79115. * @param animation The glTF animation property
  79116. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79117. */
  79118. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79119. /**
  79120. * @hidden
  79121. * Define this method to modify the default behavior when loading skins.
  79122. * @param context The context when loading the asset
  79123. * @param node The glTF node property
  79124. * @param skin The glTF skin property
  79125. * @returns A promise that resolves when the load is complete or null if not handled
  79126. */
  79127. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79128. /**
  79129. * @hidden
  79130. * Define this method to modify the default behavior when loading uris.
  79131. * @param context The context when loading the asset
  79132. * @param property The glTF property associated with the uri
  79133. * @param uri The uri to load
  79134. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79135. */
  79136. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79137. /**
  79138. * Define this method to modify the default behavior when loading buffer views.
  79139. * @param context The context when loading the asset
  79140. * @param bufferView The glTF buffer view property
  79141. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79142. */
  79143. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79144. /**
  79145. * Define this method to modify the default behavior when loading buffers.
  79146. * @param context The context when loading the asset
  79147. * @param buffer The glTF buffer property
  79148. * @param byteOffset The byte offset to load
  79149. * @param byteLength The byte length to load
  79150. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79151. */
  79152. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79153. }
  79154. }
  79155. declare module BABYLON.GLTF2 {
  79156. /**
  79157. * Helper class for working with arrays when loading the glTF asset
  79158. */
  79159. export class ArrayItem {
  79160. /**
  79161. * Gets an item from the given array.
  79162. * @param context The context when loading the asset
  79163. * @param array The array to get the item from
  79164. * @param index The index to the array
  79165. * @returns The array item
  79166. */
  79167. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79168. /**
  79169. * Assign an `index` field to each item of the given array.
  79170. * @param array The array of items
  79171. */
  79172. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79173. }
  79174. /**
  79175. * The glTF 2.0 loader
  79176. */
  79177. export class GLTFLoader implements IGLTFLoader {
  79178. /** @hidden */
  79179. _completePromises: Promise<any>[];
  79180. /** @hidden */
  79181. _forAssetContainer: boolean;
  79182. /** Storage */
  79183. _babylonLights: Light[];
  79184. /** @hidden */
  79185. _disableInstancedMesh: number;
  79186. private _disposed;
  79187. private _parent;
  79188. private _state;
  79189. private _extensions;
  79190. private _rootUrl;
  79191. private _fileName;
  79192. private _uniqueRootUrl;
  79193. private _gltf;
  79194. private _bin;
  79195. private _babylonScene;
  79196. private _rootBabylonMesh;
  79197. private _defaultBabylonMaterialData;
  79198. private _progressCallback?;
  79199. private _requests;
  79200. private static _RegisteredExtensions;
  79201. /**
  79202. * The default glTF sampler.
  79203. */
  79204. static readonly DefaultSampler: ISampler;
  79205. /**
  79206. * Registers a loader extension.
  79207. * @param name The name of the loader extension.
  79208. * @param factory The factory function that creates the loader extension.
  79209. */
  79210. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79211. /**
  79212. * Unregisters a loader extension.
  79213. * @param name The name of the loader extension.
  79214. * @returns A boolean indicating whether the extension has been unregistered
  79215. */
  79216. static UnregisterExtension(name: string): boolean;
  79217. /**
  79218. * The loader state.
  79219. */
  79220. get state(): Nullable<GLTFLoaderState>;
  79221. /**
  79222. * The object that represents the glTF JSON.
  79223. */
  79224. get gltf(): IGLTF;
  79225. /**
  79226. * The BIN chunk of a binary glTF.
  79227. */
  79228. get bin(): Nullable<IDataBuffer>;
  79229. /**
  79230. * The parent file loader.
  79231. */
  79232. get parent(): GLTFFileLoader;
  79233. /**
  79234. * The Babylon scene when loading the asset.
  79235. */
  79236. get babylonScene(): Scene;
  79237. /**
  79238. * The root Babylon mesh when loading the asset.
  79239. */
  79240. get rootBabylonMesh(): Mesh;
  79241. /** @hidden */
  79242. constructor(parent: GLTFFileLoader);
  79243. /** @hidden */
  79244. dispose(): void;
  79245. /** @hidden */
  79246. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79247. /** @hidden */
  79248. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79249. private _loadAsync;
  79250. private _loadData;
  79251. private _setupData;
  79252. private _loadExtensions;
  79253. private _checkExtensions;
  79254. private _setState;
  79255. private _createRootNode;
  79256. /**
  79257. * Loads a glTF scene.
  79258. * @param context The context when loading the asset
  79259. * @param scene The glTF scene property
  79260. * @returns A promise that resolves when the load is complete
  79261. */
  79262. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79263. private _forEachPrimitive;
  79264. private _getMeshes;
  79265. private _getTransformNodes;
  79266. private _getSkeletons;
  79267. private _getAnimationGroups;
  79268. private _startAnimations;
  79269. /**
  79270. * Loads a glTF node.
  79271. * @param context The context when loading the asset
  79272. * @param node The glTF node property
  79273. * @param assign A function called synchronously after parsing the glTF properties
  79274. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79275. */
  79276. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79277. private _loadMeshAsync;
  79278. /**
  79279. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79280. * @param context The context when loading the asset
  79281. * @param name The mesh name when loading the asset
  79282. * @param node The glTF node when loading the asset
  79283. * @param mesh The glTF mesh when loading the asset
  79284. * @param primitive The glTF mesh primitive property
  79285. * @param assign A function called synchronously after parsing the glTF properties
  79286. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79287. */
  79288. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79289. private _loadVertexDataAsync;
  79290. private _createMorphTargets;
  79291. private _loadMorphTargetsAsync;
  79292. private _loadMorphTargetVertexDataAsync;
  79293. private static _LoadTransform;
  79294. private _loadSkinAsync;
  79295. private _loadBones;
  79296. private _loadBone;
  79297. private _loadSkinInverseBindMatricesDataAsync;
  79298. private _updateBoneMatrices;
  79299. private _getNodeMatrix;
  79300. /**
  79301. * Loads a glTF camera.
  79302. * @param context The context when loading the asset
  79303. * @param camera The glTF camera property
  79304. * @param assign A function called synchronously after parsing the glTF properties
  79305. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79306. */
  79307. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79308. private _loadAnimationsAsync;
  79309. /**
  79310. * Loads a glTF animation.
  79311. * @param context The context when loading the asset
  79312. * @param animation The glTF animation property
  79313. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79314. */
  79315. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79316. /**
  79317. * @hidden Loads a glTF animation channel.
  79318. * @param context The context when loading the asset
  79319. * @param animationContext The context of the animation when loading the asset
  79320. * @param animation The glTF animation property
  79321. * @param channel The glTF animation channel property
  79322. * @param babylonAnimationGroup The babylon animation group property
  79323. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79324. * @returns A void promise when the channel load is complete
  79325. */
  79326. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79327. private _loadAnimationSamplerAsync;
  79328. private _loadBufferAsync;
  79329. /**
  79330. * Loads a glTF buffer view.
  79331. * @param context The context when loading the asset
  79332. * @param bufferView The glTF buffer view property
  79333. * @returns A promise that resolves with the loaded data when the load is complete
  79334. */
  79335. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79336. private _loadAccessorAsync;
  79337. /** @hidden */
  79338. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79339. private _loadIndicesAccessorAsync;
  79340. private _loadVertexBufferViewAsync;
  79341. private _loadVertexAccessorAsync;
  79342. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79343. /** @hidden */
  79344. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79345. private _createDefaultMaterial;
  79346. /**
  79347. * Creates a Babylon material from a glTF material.
  79348. * @param context The context when loading the asset
  79349. * @param material The glTF material property
  79350. * @param babylonDrawMode The draw mode for the Babylon material
  79351. * @returns The Babylon material
  79352. */
  79353. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79354. /**
  79355. * Loads properties from a glTF material into a Babylon material.
  79356. * @param context The context when loading the asset
  79357. * @param material The glTF material property
  79358. * @param babylonMaterial The Babylon material
  79359. * @returns A promise that resolves when the load is complete
  79360. */
  79361. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79362. /**
  79363. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79364. * @param context The context when loading the asset
  79365. * @param material The glTF material property
  79366. * @param babylonMaterial The Babylon material
  79367. * @returns A promise that resolves when the load is complete
  79368. */
  79369. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79370. /**
  79371. * Loads the alpha properties from a glTF material into a Babylon material.
  79372. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79373. * @param context The context when loading the asset
  79374. * @param material The glTF material property
  79375. * @param babylonMaterial The Babylon material
  79376. */
  79377. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79378. /**
  79379. * Loads a glTF texture info.
  79380. * @param context The context when loading the asset
  79381. * @param textureInfo The glTF texture info property
  79382. * @param assign A function called synchronously after parsing the glTF properties
  79383. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79384. */
  79385. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79386. /** @hidden */
  79387. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79388. /** @hidden */
  79389. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79390. private _loadSampler;
  79391. /**
  79392. * Loads a glTF image.
  79393. * @param context The context when loading the asset
  79394. * @param image The glTF image property
  79395. * @returns A promise that resolves with the loaded data when the load is complete
  79396. */
  79397. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79398. /**
  79399. * Loads a glTF uri.
  79400. * @param context The context when loading the asset
  79401. * @param property The glTF property associated with the uri
  79402. * @param uri The base64 or relative uri
  79403. * @returns A promise that resolves with the loaded data when the load is complete
  79404. */
  79405. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79406. private _onProgress;
  79407. /**
  79408. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79409. * @param babylonObject the Babylon object with metadata
  79410. * @param pointer the JSON pointer
  79411. */
  79412. static AddPointerMetadata(babylonObject: {
  79413. metadata: any;
  79414. }, pointer: string): void;
  79415. private static _GetTextureWrapMode;
  79416. private static _GetTextureSamplingMode;
  79417. private static _GetTypedArrayConstructor;
  79418. private static _GetTypedArray;
  79419. private static _GetNumComponents;
  79420. private static _ValidateUri;
  79421. private static _GetDrawMode;
  79422. private _compileMaterialsAsync;
  79423. private _compileShadowGeneratorsAsync;
  79424. private _forEachExtensions;
  79425. private _applyExtensions;
  79426. private _extensionsOnLoading;
  79427. private _extensionsOnReady;
  79428. private _extensionsLoadSceneAsync;
  79429. private _extensionsLoadNodeAsync;
  79430. private _extensionsLoadCameraAsync;
  79431. private _extensionsLoadVertexDataAsync;
  79432. private _extensionsLoadMeshPrimitiveAsync;
  79433. private _extensionsLoadMaterialAsync;
  79434. private _extensionsCreateMaterial;
  79435. private _extensionsLoadMaterialPropertiesAsync;
  79436. private _extensionsLoadTextureInfoAsync;
  79437. private _extensionsLoadTextureAsync;
  79438. private _extensionsLoadAnimationAsync;
  79439. private _extensionsLoadSkinAsync;
  79440. private _extensionsLoadUriAsync;
  79441. private _extensionsLoadBufferViewAsync;
  79442. private _extensionsLoadBufferAsync;
  79443. /**
  79444. * Helper method called by a loader extension to load an glTF extension.
  79445. * @param context The context when loading the asset
  79446. * @param property The glTF property to load the extension from
  79447. * @param extensionName The name of the extension to load
  79448. * @param actionAsync The action to run
  79449. * @returns The promise returned by actionAsync or null if the extension does not exist
  79450. */
  79451. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79452. /**
  79453. * Helper method called by a loader extension to load a glTF extra.
  79454. * @param context The context when loading the asset
  79455. * @param property The glTF property to load the extra from
  79456. * @param extensionName The name of the extension to load
  79457. * @param actionAsync The action to run
  79458. * @returns The promise returned by actionAsync or null if the extra does not exist
  79459. */
  79460. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79461. /**
  79462. * Checks for presence of an extension.
  79463. * @param name The name of the extension to check
  79464. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79465. */
  79466. isExtensionUsed(name: string): boolean;
  79467. /**
  79468. * Increments the indentation level and logs a message.
  79469. * @param message The message to log
  79470. */
  79471. logOpen(message: string): void;
  79472. /**
  79473. * Decrements the indentation level.
  79474. */
  79475. logClose(): void;
  79476. /**
  79477. * Logs a message
  79478. * @param message The message to log
  79479. */
  79480. log(message: string): void;
  79481. /**
  79482. * Starts a performance counter.
  79483. * @param counterName The name of the performance counter
  79484. */
  79485. startPerformanceCounter(counterName: string): void;
  79486. /**
  79487. * Ends a performance counter.
  79488. * @param counterName The name of the performance counter
  79489. */
  79490. endPerformanceCounter(counterName: string): void;
  79491. }
  79492. }
  79493. declare module BABYLON.GLTF2.Loader.Extensions {
  79494. /**
  79495. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79496. */
  79497. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79498. /**
  79499. * The name of this extension.
  79500. */
  79501. readonly name: string;
  79502. /**
  79503. * Defines whether this extension is enabled.
  79504. */
  79505. enabled: boolean;
  79506. private _loader;
  79507. private _lights?;
  79508. /** @hidden */
  79509. constructor(loader: GLTFLoader);
  79510. /** @hidden */
  79511. dispose(): void;
  79512. /** @hidden */
  79513. onLoading(): void;
  79514. /** @hidden */
  79515. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79516. private _loadLightAsync;
  79517. }
  79518. }
  79519. declare module BABYLON.GLTF2.Loader.Extensions {
  79520. /**
  79521. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79522. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79523. * !!! Experimental Extension Subject to Changes !!!
  79524. */
  79525. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79526. /**
  79527. * The name of this extension.
  79528. */
  79529. readonly name: string;
  79530. /**
  79531. * Defines whether this extension is enabled.
  79532. */
  79533. enabled: boolean;
  79534. private _loader;
  79535. /** @hidden */
  79536. constructor(loader: GLTFLoader);
  79537. /** @hidden */
  79538. dispose(): void;
  79539. /** @hidden */
  79540. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79541. }
  79542. }
  79543. declare module BABYLON.GLTF2.Loader.Extensions {
  79544. /**
  79545. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79546. */
  79547. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79548. /**
  79549. * The name of this extension.
  79550. */
  79551. readonly name: string;
  79552. /**
  79553. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79554. */
  79555. dracoCompression?: DracoCompression;
  79556. /**
  79557. * Defines whether this extension is enabled.
  79558. */
  79559. enabled: boolean;
  79560. private _loader;
  79561. /** @hidden */
  79562. constructor(loader: GLTFLoader);
  79563. /** @hidden */
  79564. dispose(): void;
  79565. /** @hidden */
  79566. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79567. }
  79568. }
  79569. declare module BABYLON.GLTF2.Loader.Extensions {
  79570. /**
  79571. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79572. */
  79573. export class KHR_lights implements IGLTFLoaderExtension {
  79574. /**
  79575. * The name of this extension.
  79576. */
  79577. readonly name: string;
  79578. /**
  79579. * Defines whether this extension is enabled.
  79580. */
  79581. enabled: boolean;
  79582. private _loader;
  79583. private _lights?;
  79584. /** @hidden */
  79585. constructor(loader: GLTFLoader);
  79586. /** @hidden */
  79587. dispose(): void;
  79588. /** @hidden */
  79589. onLoading(): void;
  79590. /** @hidden */
  79591. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79592. }
  79593. }
  79594. declare module BABYLON.GLTF2.Loader.Extensions {
  79595. /**
  79596. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79597. */
  79598. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79599. /**
  79600. * The name of this extension.
  79601. */
  79602. readonly name: string;
  79603. /**
  79604. * Defines whether this extension is enabled.
  79605. */
  79606. enabled: boolean;
  79607. /**
  79608. * Defines a number that determines the order the extensions are applied.
  79609. */
  79610. order: number;
  79611. private _loader;
  79612. /** @hidden */
  79613. constructor(loader: GLTFLoader);
  79614. /** @hidden */
  79615. dispose(): void;
  79616. /** @hidden */
  79617. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79618. private _loadSpecularGlossinessPropertiesAsync;
  79619. }
  79620. }
  79621. declare module BABYLON.GLTF2.Loader.Extensions {
  79622. /**
  79623. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79624. */
  79625. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79626. /**
  79627. * The name of this extension.
  79628. */
  79629. readonly name: string;
  79630. /**
  79631. * Defines whether this extension is enabled.
  79632. */
  79633. enabled: boolean;
  79634. /**
  79635. * Defines a number that determines the order the extensions are applied.
  79636. */
  79637. order: number;
  79638. private _loader;
  79639. /** @hidden */
  79640. constructor(loader: GLTFLoader);
  79641. /** @hidden */
  79642. dispose(): void;
  79643. /** @hidden */
  79644. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79645. private _loadUnlitPropertiesAsync;
  79646. }
  79647. }
  79648. declare module BABYLON.GLTF2.Loader.Extensions {
  79649. /**
  79650. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79651. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79652. * !!! Experimental Extension Subject to Changes !!!
  79653. */
  79654. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79655. /**
  79656. * The name of this extension.
  79657. */
  79658. readonly name: string;
  79659. /**
  79660. * Defines whether this extension is enabled.
  79661. */
  79662. enabled: boolean;
  79663. /**
  79664. * Defines a number that determines the order the extensions are applied.
  79665. */
  79666. order: number;
  79667. private _loader;
  79668. /** @hidden */
  79669. constructor(loader: GLTFLoader);
  79670. /** @hidden */
  79671. dispose(): void;
  79672. /** @hidden */
  79673. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79674. private _loadClearCoatPropertiesAsync;
  79675. }
  79676. }
  79677. declare module BABYLON.GLTF2.Loader.Extensions {
  79678. /**
  79679. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79680. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79681. * !!! Experimental Extension Subject to Changes !!!
  79682. */
  79683. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79684. /**
  79685. * The name of this extension.
  79686. */
  79687. readonly name: string;
  79688. /**
  79689. * Defines whether this extension is enabled.
  79690. */
  79691. enabled: boolean;
  79692. /**
  79693. * Defines a number that determines the order the extensions are applied.
  79694. */
  79695. order: number;
  79696. private _loader;
  79697. /** @hidden */
  79698. constructor(loader: GLTFLoader);
  79699. /** @hidden */
  79700. dispose(): void;
  79701. /** @hidden */
  79702. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79703. private _loadSheenPropertiesAsync;
  79704. }
  79705. }
  79706. declare module BABYLON.GLTF2.Loader.Extensions {
  79707. /**
  79708. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79709. * !!! Experimental Extension Subject to Changes !!!
  79710. */
  79711. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79712. /**
  79713. * The name of this extension.
  79714. */
  79715. readonly name: string;
  79716. /**
  79717. * Defines whether this extension is enabled.
  79718. */
  79719. enabled: boolean;
  79720. /**
  79721. * Defines a number that determines the order the extensions are applied.
  79722. */
  79723. order: number;
  79724. private _loader;
  79725. /** @hidden */
  79726. constructor(loader: GLTFLoader);
  79727. /** @hidden */
  79728. dispose(): void;
  79729. /** @hidden */
  79730. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79731. private _loadSpecularPropertiesAsync;
  79732. }
  79733. }
  79734. declare module BABYLON.GLTF2.Loader.Extensions {
  79735. /**
  79736. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79737. * !!! Experimental Extension Subject to Changes !!!
  79738. */
  79739. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79740. /**
  79741. * Default ior Value from the spec.
  79742. */
  79743. private static readonly _DEFAULT_IOR;
  79744. /**
  79745. * The name of this extension.
  79746. */
  79747. readonly name: string;
  79748. /**
  79749. * Defines whether this extension is enabled.
  79750. */
  79751. enabled: boolean;
  79752. /**
  79753. * Defines a number that determines the order the extensions are applied.
  79754. */
  79755. order: number;
  79756. private _loader;
  79757. /** @hidden */
  79758. constructor(loader: GLTFLoader);
  79759. /** @hidden */
  79760. dispose(): void;
  79761. /** @hidden */
  79762. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79763. private _loadIorPropertiesAsync;
  79764. }
  79765. }
  79766. declare module BABYLON.GLTF2.Loader.Extensions {
  79767. /**
  79768. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79769. */
  79770. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79771. /**
  79772. * The name of this extension.
  79773. */
  79774. readonly name: string;
  79775. /**
  79776. * Defines whether this extension is enabled.
  79777. */
  79778. enabled: boolean;
  79779. /** @hidden */
  79780. constructor(loader: GLTFLoader);
  79781. /** @hidden */
  79782. dispose(): void;
  79783. }
  79784. }
  79785. declare module BABYLON.GLTF2.Loader.Extensions {
  79786. /**
  79787. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79788. * !!! Experimental Extension Subject to Changes !!!
  79789. */
  79790. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79791. /** The name of this extension. */
  79792. readonly name: string;
  79793. /** Defines whether this extension is enabled. */
  79794. enabled: boolean;
  79795. private _loader;
  79796. /** @hidden */
  79797. constructor(loader: GLTFLoader);
  79798. /** @hidden */
  79799. dispose(): void;
  79800. /** @hidden */
  79801. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79802. }
  79803. }
  79804. declare module BABYLON.GLTF2.Loader.Extensions {
  79805. /**
  79806. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79807. */
  79808. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79809. /**
  79810. * The name of this extension.
  79811. */
  79812. readonly name: string;
  79813. /**
  79814. * Defines whether this extension is enabled.
  79815. */
  79816. enabled: boolean;
  79817. private _loader;
  79818. /** @hidden */
  79819. constructor(loader: GLTFLoader);
  79820. /** @hidden */
  79821. dispose(): void;
  79822. /** @hidden */
  79823. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79824. }
  79825. }
  79826. declare module BABYLON.GLTF2.Loader.Extensions {
  79827. /**
  79828. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  79829. * !!! Experimental Extension Subject to Changes !!!
  79830. */
  79831. export class KHR_xmp implements IGLTFLoaderExtension {
  79832. /**
  79833. * The name of this extension.
  79834. */
  79835. readonly name: string;
  79836. /**
  79837. * Defines whether this extension is enabled.
  79838. */
  79839. enabled: boolean;
  79840. /**
  79841. * Defines a number that determines the order the extensions are applied.
  79842. */
  79843. order: number;
  79844. private _loader;
  79845. /** @hidden */
  79846. constructor(loader: GLTFLoader);
  79847. /** @hidden */
  79848. dispose(): void;
  79849. /**
  79850. * Called after the loader state changes to LOADING.
  79851. */
  79852. onLoading(): void;
  79853. }
  79854. }
  79855. declare module BABYLON.GLTF2.Loader.Extensions {
  79856. /**
  79857. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79858. */
  79859. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79860. /**
  79861. * The name of this extension.
  79862. */
  79863. readonly name: string;
  79864. /**
  79865. * Defines whether this extension is enabled.
  79866. */
  79867. enabled: boolean;
  79868. private _loader;
  79869. private _clips;
  79870. private _emitters;
  79871. /** @hidden */
  79872. constructor(loader: GLTFLoader);
  79873. /** @hidden */
  79874. dispose(): void;
  79875. /** @hidden */
  79876. onLoading(): void;
  79877. /** @hidden */
  79878. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79879. /** @hidden */
  79880. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79881. /** @hidden */
  79882. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79883. private _loadClipAsync;
  79884. private _loadEmitterAsync;
  79885. private _getEventAction;
  79886. private _loadAnimationEventAsync;
  79887. }
  79888. }
  79889. declare module BABYLON.GLTF2.Loader.Extensions {
  79890. /**
  79891. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79892. */
  79893. export class MSFT_lod implements IGLTFLoaderExtension {
  79894. /**
  79895. * The name of this extension.
  79896. */
  79897. readonly name: string;
  79898. /**
  79899. * Defines whether this extension is enabled.
  79900. */
  79901. enabled: boolean;
  79902. /**
  79903. * Defines a number that determines the order the extensions are applied.
  79904. */
  79905. order: number;
  79906. /**
  79907. * Maximum number of LODs to load, starting from the lowest LOD.
  79908. */
  79909. maxLODsToLoad: number;
  79910. /**
  79911. * Observable raised when all node LODs of one level are loaded.
  79912. * The event data is the index of the loaded LOD starting from zero.
  79913. * Dispose the loader to cancel the loading of the next level of LODs.
  79914. */
  79915. onNodeLODsLoadedObservable: Observable<number>;
  79916. /**
  79917. * Observable raised when all material LODs of one level are loaded.
  79918. * The event data is the index of the loaded LOD starting from zero.
  79919. * Dispose the loader to cancel the loading of the next level of LODs.
  79920. */
  79921. onMaterialLODsLoadedObservable: Observable<number>;
  79922. private _loader;
  79923. private _nodeIndexLOD;
  79924. private _nodeSignalLODs;
  79925. private _nodePromiseLODs;
  79926. private _materialIndexLOD;
  79927. private _materialSignalLODs;
  79928. private _materialPromiseLODs;
  79929. private _indexLOD;
  79930. private _bufferLODs;
  79931. /** @hidden */
  79932. constructor(loader: GLTFLoader);
  79933. /** @hidden */
  79934. dispose(): void;
  79935. /** @hidden */
  79936. onReady(): void;
  79937. /** @hidden */
  79938. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79939. /** @hidden */
  79940. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79941. /** @hidden */
  79942. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79943. /** @hidden */
  79944. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79945. /** @hidden */
  79946. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79947. private _loadBufferLOD;
  79948. /**
  79949. * Gets an array of LOD properties from lowest to highest.
  79950. */
  79951. private _getLODs;
  79952. private _disposeTransformNode;
  79953. private _disposeMaterials;
  79954. }
  79955. }
  79956. declare module BABYLON.GLTF2.Loader.Extensions {
  79957. /** @hidden */
  79958. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79959. readonly name: string;
  79960. enabled: boolean;
  79961. private _loader;
  79962. constructor(loader: GLTFLoader);
  79963. dispose(): void;
  79964. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79965. }
  79966. }
  79967. declare module BABYLON.GLTF2.Loader.Extensions {
  79968. /** @hidden */
  79969. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79970. readonly name: string;
  79971. enabled: boolean;
  79972. private _loader;
  79973. constructor(loader: GLTFLoader);
  79974. dispose(): void;
  79975. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79976. }
  79977. }
  79978. declare module BABYLON.GLTF2.Loader.Extensions {
  79979. /**
  79980. * Store glTF extras (if present) in BJS objects' metadata
  79981. */
  79982. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79983. /**
  79984. * The name of this extension.
  79985. */
  79986. readonly name: string;
  79987. /**
  79988. * Defines whether this extension is enabled.
  79989. */
  79990. enabled: boolean;
  79991. private _loader;
  79992. private _assignExtras;
  79993. /** @hidden */
  79994. constructor(loader: GLTFLoader);
  79995. /** @hidden */
  79996. dispose(): void;
  79997. /** @hidden */
  79998. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79999. /** @hidden */
  80000. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80001. /** @hidden */
  80002. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80003. }
  80004. }
  80005. declare module BABYLON {
  80006. /**
  80007. * Class reading and parsing the MTL file bundled with the obj file.
  80008. */
  80009. export class MTLFileLoader {
  80010. /**
  80011. * Invert Y-Axis of referenced textures on load
  80012. */
  80013. static INVERT_TEXTURE_Y: boolean;
  80014. /**
  80015. * All material loaded from the mtl will be set here
  80016. */
  80017. materials: StandardMaterial[];
  80018. /**
  80019. * This function will read the mtl file and create each material described inside
  80020. * This function could be improve by adding :
  80021. * -some component missing (Ni, Tf...)
  80022. * -including the specific options available
  80023. *
  80024. * @param scene defines the scene the material will be created in
  80025. * @param data defines the mtl data to parse
  80026. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80027. * @param forAssetContainer defines if the material should be registered in the scene
  80028. */
  80029. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80030. /**
  80031. * Gets the texture for the material.
  80032. *
  80033. * If the material is imported from input file,
  80034. * We sanitize the url to ensure it takes the textre from aside the material.
  80035. *
  80036. * @param rootUrl The root url to load from
  80037. * @param value The value stored in the mtl
  80038. * @return The Texture
  80039. */
  80040. private static _getTexture;
  80041. }
  80042. }
  80043. declare module BABYLON {
  80044. /**
  80045. * Options for loading OBJ/MTL files
  80046. */
  80047. type MeshLoadOptions = {
  80048. /**
  80049. * Defines if UVs are optimized by default during load.
  80050. */
  80051. OptimizeWithUV: boolean;
  80052. /**
  80053. * Defines custom scaling of UV coordinates of loaded meshes.
  80054. */
  80055. UVScaling: Vector2;
  80056. /**
  80057. * Invert model on y-axis (does a model scaling inversion)
  80058. */
  80059. InvertY: boolean;
  80060. /**
  80061. * Invert Y-Axis of referenced textures on load
  80062. */
  80063. InvertTextureY: boolean;
  80064. /**
  80065. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80066. */
  80067. ImportVertexColors: boolean;
  80068. /**
  80069. * Compute the normals for the model, even if normals are present in the file.
  80070. */
  80071. ComputeNormals: boolean;
  80072. /**
  80073. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80074. */
  80075. SkipMaterials: boolean;
  80076. /**
  80077. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80078. */
  80079. MaterialLoadingFailsSilently: boolean;
  80080. };
  80081. /**
  80082. * OBJ file type loader.
  80083. * This is a babylon scene loader plugin.
  80084. */
  80085. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80086. /**
  80087. * Defines if UVs are optimized by default during load.
  80088. */
  80089. static OPTIMIZE_WITH_UV: boolean;
  80090. /**
  80091. * Invert model on y-axis (does a model scaling inversion)
  80092. */
  80093. static INVERT_Y: boolean;
  80094. /**
  80095. * Invert Y-Axis of referenced textures on load
  80096. */
  80097. static get INVERT_TEXTURE_Y(): boolean;
  80098. static set INVERT_TEXTURE_Y(value: boolean);
  80099. /**
  80100. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80101. */
  80102. static IMPORT_VERTEX_COLORS: boolean;
  80103. /**
  80104. * Compute the normals for the model, even if normals are present in the file.
  80105. */
  80106. static COMPUTE_NORMALS: boolean;
  80107. /**
  80108. * Defines custom scaling of UV coordinates of loaded meshes.
  80109. */
  80110. static UV_SCALING: Vector2;
  80111. /**
  80112. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80113. */
  80114. static SKIP_MATERIALS: boolean;
  80115. /**
  80116. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80117. *
  80118. * Defaults to true for backwards compatibility.
  80119. */
  80120. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80121. /**
  80122. * Defines the name of the plugin.
  80123. */
  80124. name: string;
  80125. /**
  80126. * Defines the extension the plugin is able to load.
  80127. */
  80128. extensions: string;
  80129. /** @hidden */
  80130. obj: RegExp;
  80131. /** @hidden */
  80132. group: RegExp;
  80133. /** @hidden */
  80134. mtllib: RegExp;
  80135. /** @hidden */
  80136. usemtl: RegExp;
  80137. /** @hidden */
  80138. smooth: RegExp;
  80139. /** @hidden */
  80140. vertexPattern: RegExp;
  80141. /** @hidden */
  80142. normalPattern: RegExp;
  80143. /** @hidden */
  80144. uvPattern: RegExp;
  80145. /** @hidden */
  80146. facePattern1: RegExp;
  80147. /** @hidden */
  80148. facePattern2: RegExp;
  80149. /** @hidden */
  80150. facePattern3: RegExp;
  80151. /** @hidden */
  80152. facePattern4: RegExp;
  80153. /** @hidden */
  80154. facePattern5: RegExp;
  80155. private _forAssetContainer;
  80156. private _meshLoadOptions;
  80157. /**
  80158. * Creates loader for .OBJ files
  80159. *
  80160. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80161. */
  80162. constructor(meshLoadOptions?: MeshLoadOptions);
  80163. private static get currentMeshLoadOptions();
  80164. /**
  80165. * Calls synchronously the MTL file attached to this obj.
  80166. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80167. * Without this function materials are not displayed in the first frame (but displayed after).
  80168. * In consequence it is impossible to get material information in your HTML file
  80169. *
  80170. * @param url The URL of the MTL file
  80171. * @param rootUrl
  80172. * @param onSuccess Callback function to be called when the MTL file is loaded
  80173. * @private
  80174. */
  80175. private _loadMTL;
  80176. /**
  80177. * Instantiates a OBJ file loader plugin.
  80178. * @returns the created plugin
  80179. */
  80180. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80181. /**
  80182. * If the data string can be loaded directly.
  80183. *
  80184. * @param data string containing the file data
  80185. * @returns if the data can be loaded directly
  80186. */
  80187. canDirectLoad(data: string): boolean;
  80188. /**
  80189. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80190. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80191. * @param scene the scene the meshes should be added to
  80192. * @param data the OBJ data to load
  80193. * @param rootUrl root url to load from
  80194. * @param onProgress event that fires when loading progress has occured
  80195. * @param fileName Defines the name of the file to load
  80196. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80197. */
  80198. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80199. meshes: AbstractMesh[];
  80200. particleSystems: IParticleSystem[];
  80201. skeletons: Skeleton[];
  80202. animationGroups: AnimationGroup[];
  80203. }>;
  80204. /**
  80205. * Imports all objects from the loaded OBJ data and adds them to the scene
  80206. * @param scene the scene the objects should be added to
  80207. * @param data the OBJ data to load
  80208. * @param rootUrl root url to load from
  80209. * @param onProgress event that fires when loading progress has occured
  80210. * @param fileName Defines the name of the file to load
  80211. * @returns a promise which completes when objects have been loaded to the scene
  80212. */
  80213. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80214. /**
  80215. * Load into an asset container.
  80216. * @param scene The scene to load into
  80217. * @param data The data to import
  80218. * @param rootUrl The root url for scene and resources
  80219. * @param onProgress The callback when the load progresses
  80220. * @param fileName Defines the name of the file to load
  80221. * @returns The loaded asset container
  80222. */
  80223. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80224. /**
  80225. * Read the OBJ file and create an Array of meshes.
  80226. * Each mesh contains all information given by the OBJ and the MTL file.
  80227. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80228. *
  80229. * @param meshesNames
  80230. * @param scene Scene The scene where are displayed the data
  80231. * @param data String The content of the obj file
  80232. * @param rootUrl String The path to the folder
  80233. * @returns Array<AbstractMesh>
  80234. * @private
  80235. */
  80236. private _parseSolid;
  80237. }
  80238. }
  80239. declare module BABYLON {
  80240. /**
  80241. * STL file type loader.
  80242. * This is a babylon scene loader plugin.
  80243. */
  80244. export class STLFileLoader implements ISceneLoaderPlugin {
  80245. /** @hidden */
  80246. solidPattern: RegExp;
  80247. /** @hidden */
  80248. facetsPattern: RegExp;
  80249. /** @hidden */
  80250. normalPattern: RegExp;
  80251. /** @hidden */
  80252. vertexPattern: RegExp;
  80253. /**
  80254. * Defines the name of the plugin.
  80255. */
  80256. name: string;
  80257. /**
  80258. * Defines the extensions the stl loader is able to load.
  80259. * force data to come in as an ArrayBuffer
  80260. * we'll convert to string if it looks like it's an ASCII .stl
  80261. */
  80262. extensions: ISceneLoaderPluginExtensions;
  80263. /**
  80264. * Import meshes into a scene.
  80265. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80266. * @param scene The scene to import into
  80267. * @param data The data to import
  80268. * @param rootUrl The root url for scene and resources
  80269. * @param meshes The meshes array to import into
  80270. * @param particleSystems The particle systems array to import into
  80271. * @param skeletons The skeletons array to import into
  80272. * @param onError The callback when import fails
  80273. * @returns True if successful or false otherwise
  80274. */
  80275. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80276. /**
  80277. * Load into a scene.
  80278. * @param scene The scene to load into
  80279. * @param data The data to import
  80280. * @param rootUrl The root url for scene and resources
  80281. * @param onError The callback when import fails
  80282. * @returns true if successful or false otherwise
  80283. */
  80284. load(scene: Scene, data: any, rootUrl: string): boolean;
  80285. /**
  80286. * Load into an asset container.
  80287. * @param scene The scene to load into
  80288. * @param data The data to import
  80289. * @param rootUrl The root url for scene and resources
  80290. * @param onError The callback when import fails
  80291. * @returns The loaded asset container
  80292. */
  80293. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80294. private _isBinary;
  80295. private _parseBinary;
  80296. private _parseASCII;
  80297. }
  80298. }
  80299. declare module BABYLON {
  80300. /**
  80301. * Class for generating OBJ data from a Babylon scene.
  80302. */
  80303. export class OBJExport {
  80304. /**
  80305. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80306. * @param mesh defines the list of meshes to serialize
  80307. * @param materials defines if materials should be exported
  80308. * @param matlibname defines the name of the associated mtl file
  80309. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80310. * @returns the OBJ content
  80311. */
  80312. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80313. /**
  80314. * Exports the material(s) of a mesh in .MTL file format (text)
  80315. * @param mesh defines the mesh to extract the material from
  80316. * @returns the mtl content
  80317. */
  80318. static MTL(mesh: Mesh): string;
  80319. }
  80320. }
  80321. declare module BABYLON {
  80322. /** @hidden */
  80323. export var __IGLTFExporterExtension: number;
  80324. /**
  80325. * Interface for extending the exporter
  80326. * @hidden
  80327. */
  80328. export interface IGLTFExporterExtension {
  80329. /**
  80330. * The name of this extension
  80331. */
  80332. readonly name: string;
  80333. /**
  80334. * Defines whether this extension is enabled
  80335. */
  80336. enabled: boolean;
  80337. /**
  80338. * Defines whether this extension is required
  80339. */
  80340. required: boolean;
  80341. }
  80342. }
  80343. declare module BABYLON.GLTF2.Exporter {
  80344. /** @hidden */
  80345. export var __IGLTFExporterExtensionV2: number;
  80346. /**
  80347. * Interface for a glTF exporter extension
  80348. * @hidden
  80349. */
  80350. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80351. /**
  80352. * Define this method to modify the default behavior before exporting a texture
  80353. * @param context The context when loading the asset
  80354. * @param babylonTexture The Babylon.js texture
  80355. * @param mimeType The mime-type of the generated image
  80356. * @returns A promise that resolves with the exported texture
  80357. */
  80358. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80359. /**
  80360. * Define this method to get notified when a texture info is created
  80361. * @param context The context when loading the asset
  80362. * @param textureInfo The glTF texture info
  80363. * @param babylonTexture The Babylon.js texture
  80364. */
  80365. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80366. /**
  80367. * Define this method to modify the default behavior when exporting texture info
  80368. * @param context The context when loading the asset
  80369. * @param meshPrimitive glTF mesh primitive
  80370. * @param babylonSubMesh Babylon submesh
  80371. * @param binaryWriter glTF serializer binary writer instance
  80372. * @returns nullable IMeshPrimitive promise
  80373. */
  80374. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80375. /**
  80376. * Define this method to modify the default behavior when exporting a node
  80377. * @param context The context when exporting the node
  80378. * @param node glTF node
  80379. * @param babylonNode BabylonJS node
  80380. * @returns nullable INode promise
  80381. */
  80382. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80383. [key: number]: number;
  80384. }): Promise<Nullable<INode>>;
  80385. /**
  80386. * Define this method to modify the default behavior when exporting a material
  80387. * @param material glTF material
  80388. * @param babylonMaterial BabylonJS material
  80389. * @returns nullable IMaterial promise
  80390. */
  80391. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80392. /**
  80393. * Define this method to return additional textures to export from a material
  80394. * @param material glTF material
  80395. * @param babylonMaterial BabylonJS material
  80396. * @returns List of textures
  80397. */
  80398. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80399. /** Gets a boolean indicating that this extension was used */
  80400. wasUsed: boolean;
  80401. /** Gets a boolean indicating that this extension is required for the file to work */
  80402. required: boolean;
  80403. /**
  80404. * Called after the exporter state changes to EXPORTING
  80405. */
  80406. onExporting?(): void;
  80407. }
  80408. }
  80409. declare module BABYLON.GLTF2.Exporter {
  80410. /**
  80411. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80412. * @hidden
  80413. */
  80414. export class _GLTFMaterialExporter {
  80415. /**
  80416. * Represents the dielectric specular values for R, G and B
  80417. */
  80418. private static readonly _DielectricSpecular;
  80419. /**
  80420. * Allows the maximum specular power to be defined for material calculations
  80421. */
  80422. private static readonly _MaxSpecularPower;
  80423. /**
  80424. * Mapping to store textures
  80425. */
  80426. private _textureMap;
  80427. /**
  80428. * Numeric tolerance value
  80429. */
  80430. private static readonly _Epsilon;
  80431. /**
  80432. * Reference to the glTF Exporter
  80433. */
  80434. private _exporter;
  80435. constructor(exporter: _Exporter);
  80436. /**
  80437. * Specifies if two colors are approximately equal in value
  80438. * @param color1 first color to compare to
  80439. * @param color2 second color to compare to
  80440. * @param epsilon threshold value
  80441. */
  80442. private static FuzzyEquals;
  80443. /**
  80444. * Gets the materials from a Babylon scene and converts them to glTF materials
  80445. * @param scene babylonjs scene
  80446. * @param mimeType texture mime type
  80447. * @param images array of images
  80448. * @param textures array of textures
  80449. * @param materials array of materials
  80450. * @param imageData mapping of texture names to base64 textures
  80451. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80452. */
  80453. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80454. /**
  80455. * Makes a copy of the glTF material without the texture parameters
  80456. * @param originalMaterial original glTF material
  80457. * @returns glTF material without texture parameters
  80458. */
  80459. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80460. /**
  80461. * Specifies if the material has any texture parameters present
  80462. * @param material glTF Material
  80463. * @returns boolean specifying if texture parameters are present
  80464. */
  80465. _hasTexturesPresent(material: IMaterial): boolean;
  80466. /**
  80467. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80468. * @param babylonStandardMaterial
  80469. * @returns glTF Metallic Roughness Material representation
  80470. */
  80471. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80472. /**
  80473. * Computes the metallic factor
  80474. * @param diffuse diffused value
  80475. * @param specular specular value
  80476. * @param oneMinusSpecularStrength one minus the specular strength
  80477. * @returns metallic value
  80478. */
  80479. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80480. /**
  80481. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80482. * @param glTFMaterial glTF material
  80483. * @param babylonMaterial Babylon material
  80484. */
  80485. private static _SetAlphaMode;
  80486. /**
  80487. * Converts a Babylon Standard Material to a glTF Material
  80488. * @param babylonStandardMaterial BJS Standard Material
  80489. * @param mimeType mime type to use for the textures
  80490. * @param images array of glTF image interfaces
  80491. * @param textures array of glTF texture interfaces
  80492. * @param materials array of glTF material interfaces
  80493. * @param imageData map of image file name to data
  80494. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80495. */
  80496. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80497. private _finishMaterial;
  80498. /**
  80499. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80500. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80501. * @param mimeType mime type to use for the textures
  80502. * @param images array of glTF image interfaces
  80503. * @param textures array of glTF texture interfaces
  80504. * @param materials array of glTF material interfaces
  80505. * @param imageData map of image file name to data
  80506. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80507. */
  80508. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80509. /**
  80510. * Converts an image typed array buffer to a base64 image
  80511. * @param buffer typed array buffer
  80512. * @param width width of the image
  80513. * @param height height of the image
  80514. * @param mimeType mimetype of the image
  80515. * @returns base64 image string
  80516. */
  80517. private _createBase64FromCanvasAsync;
  80518. /**
  80519. * Generates a white texture based on the specified width and height
  80520. * @param width width of the texture in pixels
  80521. * @param height height of the texture in pixels
  80522. * @param scene babylonjs scene
  80523. * @returns white texture
  80524. */
  80525. private _createWhiteTexture;
  80526. /**
  80527. * 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
  80528. * @param texture1 first texture to resize
  80529. * @param texture2 second texture to resize
  80530. * @param scene babylonjs scene
  80531. * @returns resized textures or null
  80532. */
  80533. private _resizeTexturesToSameDimensions;
  80534. /**
  80535. * Converts an array of pixels to a Float32Array
  80536. * Throws an error if the pixel format is not supported
  80537. * @param pixels - array buffer containing pixel values
  80538. * @returns Float32 of pixels
  80539. */
  80540. private _convertPixelArrayToFloat32;
  80541. /**
  80542. * Convert Specular Glossiness Textures to Metallic Roughness
  80543. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80544. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80545. * @param diffuseTexture texture used to store diffuse information
  80546. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80547. * @param factors specular glossiness material factors
  80548. * @param mimeType the mime type to use for the texture
  80549. * @returns pbr metallic roughness interface or null
  80550. */
  80551. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80552. /**
  80553. * Converts specular glossiness material properties to metallic roughness
  80554. * @param specularGlossiness interface with specular glossiness material properties
  80555. * @returns interface with metallic roughness material properties
  80556. */
  80557. private _convertSpecularGlossinessToMetallicRoughness;
  80558. /**
  80559. * Calculates the surface reflectance, independent of lighting conditions
  80560. * @param color Color source to calculate brightness from
  80561. * @returns number representing the perceived brightness, or zero if color is undefined
  80562. */
  80563. private _getPerceivedBrightness;
  80564. /**
  80565. * Returns the maximum color component value
  80566. * @param color
  80567. * @returns maximum color component value, or zero if color is null or undefined
  80568. */
  80569. private _getMaxComponent;
  80570. /**
  80571. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80572. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80573. * @param mimeType mime type to use for the textures
  80574. * @param images array of glTF image interfaces
  80575. * @param textures array of glTF texture interfaces
  80576. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80577. * @param imageData map of image file name to data
  80578. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80579. * @returns glTF PBR Metallic Roughness factors
  80580. */
  80581. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80582. private _getGLTFTextureSampler;
  80583. private _getGLTFTextureWrapMode;
  80584. private _getGLTFTextureWrapModesSampler;
  80585. /**
  80586. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80587. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80588. * @param mimeType mime type to use for the textures
  80589. * @param images array of glTF image interfaces
  80590. * @param textures array of glTF texture interfaces
  80591. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80592. * @param imageData map of image file name to data
  80593. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80594. * @returns glTF PBR Metallic Roughness factors
  80595. */
  80596. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80597. /**
  80598. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80599. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80600. * @param mimeType mime type to use for the textures
  80601. * @param images array of glTF image interfaces
  80602. * @param textures array of glTF texture interfaces
  80603. * @param materials array of glTF material interfaces
  80604. * @param imageData map of image file name to data
  80605. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80606. */
  80607. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80608. private setMetallicRoughnessPbrMaterial;
  80609. private getPixelsFromTexture;
  80610. /**
  80611. * Extracts a texture from a Babylon texture into file data and glTF data
  80612. * @param babylonTexture Babylon texture to extract
  80613. * @param mimeType Mime Type of the babylonTexture
  80614. * @return glTF texture info, or null if the texture format is not supported
  80615. */
  80616. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80617. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80618. /**
  80619. * Builds a texture from base64 string
  80620. * @param base64Texture base64 texture string
  80621. * @param baseTextureName Name to use for the texture
  80622. * @param mimeType image mime type for the texture
  80623. * @param images array of images
  80624. * @param textures array of textures
  80625. * @param imageData map of image data
  80626. * @returns glTF texture info, or null if the texture format is not supported
  80627. */
  80628. private _getTextureInfoFromBase64;
  80629. }
  80630. }
  80631. declare module BABYLON {
  80632. /**
  80633. * Class for holding and downloading glTF file data
  80634. */
  80635. export class GLTFData {
  80636. /**
  80637. * Object which contains the file name as the key and its data as the value
  80638. */
  80639. glTFFiles: {
  80640. [fileName: string]: string | Blob;
  80641. };
  80642. /**
  80643. * Initializes the glTF file object
  80644. */
  80645. constructor();
  80646. /**
  80647. * Downloads the glTF data as files based on their names and data
  80648. */
  80649. downloadFiles(): void;
  80650. }
  80651. }
  80652. declare module BABYLON {
  80653. /**
  80654. * Holds a collection of exporter options and parameters
  80655. */
  80656. export interface IExportOptions {
  80657. /**
  80658. * Function which indicates whether a babylon node should be exported or not
  80659. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80660. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80661. */
  80662. shouldExportNode?(node: Node): boolean;
  80663. /**
  80664. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80665. * @param metadata source metadata to read from
  80666. * @returns the data to store to glTF node extras
  80667. */
  80668. metadataSelector?(metadata: any): any;
  80669. /**
  80670. * The sample rate to bake animation curves
  80671. */
  80672. animationSampleRate?: number;
  80673. /**
  80674. * Begin serialization without waiting for the scene to be ready
  80675. */
  80676. exportWithoutWaitingForScene?: boolean;
  80677. /**
  80678. * Indicates if coordinate system swapping root nodes should be included in export
  80679. */
  80680. includeCoordinateSystemConversionNodes?: boolean;
  80681. }
  80682. /**
  80683. * Class for generating glTF data from a Babylon scene.
  80684. */
  80685. export class GLTF2Export {
  80686. /**
  80687. * Exports the geometry of the scene to .gltf file format asynchronously
  80688. * @param scene Babylon scene with scene hierarchy information
  80689. * @param filePrefix File prefix to use when generating the glTF file
  80690. * @param options Exporter options
  80691. * @returns Returns an object with a .gltf file and associates texture names
  80692. * as keys and their data and paths as values
  80693. */
  80694. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80695. private static _PreExportAsync;
  80696. private static _PostExportAsync;
  80697. /**
  80698. * Exports the geometry of the scene to .glb file format asychronously
  80699. * @param scene Babylon scene with scene hierarchy information
  80700. * @param filePrefix File prefix to use when generating glb file
  80701. * @param options Exporter options
  80702. * @returns Returns an object with a .glb filename as key and data as value
  80703. */
  80704. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80705. }
  80706. }
  80707. declare module BABYLON.GLTF2.Exporter {
  80708. /**
  80709. * @hidden
  80710. */
  80711. export class _GLTFUtilities {
  80712. /**
  80713. * Creates a buffer view based on the supplied arguments
  80714. * @param bufferIndex index value of the specified buffer
  80715. * @param byteOffset byte offset value
  80716. * @param byteLength byte length of the bufferView
  80717. * @param byteStride byte distance between conequential elements
  80718. * @param name name of the buffer view
  80719. * @returns bufferView for glTF
  80720. */
  80721. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80722. /**
  80723. * Creates an accessor based on the supplied arguments
  80724. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80725. * @param name The name of the accessor
  80726. * @param type The type of the accessor
  80727. * @param componentType The datatype of components in the attribute
  80728. * @param count The number of attributes referenced by this accessor
  80729. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80730. * @param min Minimum value of each component in this attribute
  80731. * @param max Maximum value of each component in this attribute
  80732. * @returns accessor for glTF
  80733. */
  80734. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80735. /**
  80736. * Calculates the minimum and maximum values of an array of position floats
  80737. * @param positions Positions array of a mesh
  80738. * @param vertexStart Starting vertex offset to calculate min and max values
  80739. * @param vertexCount Number of vertices to check for min and max values
  80740. * @returns min number array and max number array
  80741. */
  80742. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80743. min: number[];
  80744. max: number[];
  80745. };
  80746. /**
  80747. * Converts a new right-handed Vector3
  80748. * @param vector vector3 array
  80749. * @returns right-handed Vector3
  80750. */
  80751. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80752. /**
  80753. * Converts a Vector3 to right-handed
  80754. * @param vector Vector3 to convert to right-handed
  80755. */
  80756. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80757. /**
  80758. * Converts a three element number array to right-handed
  80759. * @param vector number array to convert to right-handed
  80760. */
  80761. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80762. /**
  80763. * Converts a new right-handed Vector3
  80764. * @param vector vector3 array
  80765. * @returns right-handed Vector3
  80766. */
  80767. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80768. /**
  80769. * Converts a Vector3 to right-handed
  80770. * @param vector Vector3 to convert to right-handed
  80771. */
  80772. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80773. /**
  80774. * Converts a three element number array to right-handed
  80775. * @param vector number array to convert to right-handed
  80776. */
  80777. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80778. /**
  80779. * Converts a Vector4 to right-handed
  80780. * @param vector Vector4 to convert to right-handed
  80781. */
  80782. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80783. /**
  80784. * Converts a Vector4 to right-handed
  80785. * @param vector Vector4 to convert to right-handed
  80786. */
  80787. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80788. /**
  80789. * Converts a Quaternion to right-handed
  80790. * @param quaternion Source quaternion to convert to right-handed
  80791. */
  80792. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80793. /**
  80794. * Converts a Quaternion to right-handed
  80795. * @param quaternion Source quaternion to convert to right-handed
  80796. */
  80797. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80798. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80799. }
  80800. }
  80801. declare module BABYLON.GLTF2.Exporter {
  80802. /**
  80803. * Converts Babylon Scene into glTF 2.0.
  80804. * @hidden
  80805. */
  80806. export class _Exporter {
  80807. /**
  80808. * Stores the glTF to export
  80809. */
  80810. _glTF: IGLTF;
  80811. /**
  80812. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80813. */
  80814. _bufferViews: IBufferView[];
  80815. /**
  80816. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80817. */
  80818. _accessors: IAccessor[];
  80819. /**
  80820. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80821. */
  80822. _nodes: INode[];
  80823. /**
  80824. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80825. */
  80826. private _scenes;
  80827. /**
  80828. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80829. */
  80830. private _meshes;
  80831. /**
  80832. * Stores all the generated material information, which represents the appearance of each primitive
  80833. */
  80834. _materials: IMaterial[];
  80835. _materialMap: {
  80836. [materialID: number]: number;
  80837. };
  80838. /**
  80839. * Stores all the generated texture information, which is referenced by glTF materials
  80840. */
  80841. _textures: ITexture[];
  80842. /**
  80843. * Stores all the generated image information, which is referenced by glTF textures
  80844. */
  80845. _images: IImage[];
  80846. /**
  80847. * Stores all the texture samplers
  80848. */
  80849. _samplers: ISampler[];
  80850. /**
  80851. * Stores all the generated animation samplers, which is referenced by glTF animations
  80852. */
  80853. /**
  80854. * Stores the animations for glTF models
  80855. */
  80856. private _animations;
  80857. /**
  80858. * Stores the total amount of bytes stored in the glTF buffer
  80859. */
  80860. private _totalByteLength;
  80861. /**
  80862. * Stores a reference to the Babylon scene containing the source geometry and material information
  80863. */
  80864. _babylonScene: Scene;
  80865. /**
  80866. * Stores a map of the image data, where the key is the file name and the value
  80867. * is the image data
  80868. */
  80869. _imageData: {
  80870. [fileName: string]: {
  80871. data: Uint8Array;
  80872. mimeType: ImageMimeType;
  80873. };
  80874. };
  80875. /**
  80876. * Stores a map of the unique id of a node to its index in the node array
  80877. */
  80878. _nodeMap: {
  80879. [key: number]: number;
  80880. };
  80881. /**
  80882. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80883. */
  80884. _convertToRightHandedSystem: boolean;
  80885. /**
  80886. * Specifies if a Babylon node should be converted to right-handed on export
  80887. */
  80888. _convertToRightHandedSystemMap: {
  80889. [nodeId: number]: boolean;
  80890. };
  80891. _includeCoordinateSystemConversionNodes: boolean;
  80892. /**
  80893. * Baked animation sample rate
  80894. */
  80895. private _animationSampleRate;
  80896. private _options;
  80897. private _localEngine;
  80898. _glTFMaterialExporter: _GLTFMaterialExporter;
  80899. private _extensions;
  80900. private static _ExtensionNames;
  80901. private static _ExtensionFactories;
  80902. private _applyExtension;
  80903. private _applyExtensions;
  80904. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80905. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80906. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80907. [key: number]: number;
  80908. }): Promise<Nullable<INode>>;
  80909. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80910. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80911. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80912. private _forEachExtensions;
  80913. private _extensionsOnExporting;
  80914. /**
  80915. * Load glTF serializer extensions
  80916. */
  80917. private _loadExtensions;
  80918. /**
  80919. * Creates a glTF Exporter instance, which can accept optional exporter options
  80920. * @param babylonScene Babylon scene object
  80921. * @param options Options to modify the behavior of the exporter
  80922. */
  80923. constructor(babylonScene: Scene, options?: IExportOptions);
  80924. dispose(): void;
  80925. /**
  80926. * Registers a glTF exporter extension
  80927. * @param name Name of the extension to export
  80928. * @param factory The factory function that creates the exporter extension
  80929. */
  80930. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80931. /**
  80932. * Un-registers an exporter extension
  80933. * @param name The name fo the exporter extension
  80934. * @returns A boolean indicating whether the extension has been un-registered
  80935. */
  80936. static UnregisterExtension(name: string): boolean;
  80937. /**
  80938. * Lazy load a local engine
  80939. */
  80940. _getLocalEngine(): Engine;
  80941. private reorderIndicesBasedOnPrimitiveMode;
  80942. /**
  80943. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80944. * clock-wise during export to glTF
  80945. * @param submesh BabylonJS submesh
  80946. * @param primitiveMode Primitive mode of the mesh
  80947. * @param sideOrientation the winding order of the submesh
  80948. * @param vertexBufferKind The type of vertex attribute
  80949. * @param meshAttributeArray The vertex attribute data
  80950. * @param byteOffset The offset to the binary data
  80951. * @param binaryWriter The binary data for the glTF file
  80952. * @param convertToRightHandedSystem Converts the values to right-handed
  80953. */
  80954. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80955. /**
  80956. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80957. * clock-wise during export to glTF
  80958. * @param submesh BabylonJS submesh
  80959. * @param primitiveMode Primitive mode of the mesh
  80960. * @param sideOrientation the winding order of the submesh
  80961. * @param vertexBufferKind The type of vertex attribute
  80962. * @param meshAttributeArray The vertex attribute data
  80963. * @param byteOffset The offset to the binary data
  80964. * @param binaryWriter The binary data for the glTF file
  80965. * @param convertToRightHandedSystem Converts the values to right-handed
  80966. */
  80967. private reorderTriangleFillMode;
  80968. /**
  80969. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80970. * clock-wise during export to glTF
  80971. * @param submesh BabylonJS submesh
  80972. * @param primitiveMode Primitive mode of the mesh
  80973. * @param sideOrientation the winding order of the submesh
  80974. * @param vertexBufferKind The type of vertex attribute
  80975. * @param meshAttributeArray The vertex attribute data
  80976. * @param byteOffset The offset to the binary data
  80977. * @param binaryWriter The binary data for the glTF file
  80978. * @param convertToRightHandedSystem Converts the values to right-handed
  80979. */
  80980. private reorderTriangleStripDrawMode;
  80981. /**
  80982. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80983. * clock-wise during export to glTF
  80984. * @param submesh BabylonJS submesh
  80985. * @param primitiveMode Primitive mode of the mesh
  80986. * @param sideOrientation the winding order of the submesh
  80987. * @param vertexBufferKind The type of vertex attribute
  80988. * @param meshAttributeArray The vertex attribute data
  80989. * @param byteOffset The offset to the binary data
  80990. * @param binaryWriter The binary data for the glTF file
  80991. * @param convertToRightHandedSystem Converts the values to right-handed
  80992. */
  80993. private reorderTriangleFanMode;
  80994. /**
  80995. * Writes the vertex attribute data to binary
  80996. * @param vertices The vertices to write to the binary writer
  80997. * @param byteOffset The offset into the binary writer to overwrite binary data
  80998. * @param vertexAttributeKind The vertex attribute type
  80999. * @param meshAttributeArray The vertex attribute data
  81000. * @param binaryWriter The writer containing the binary data
  81001. * @param convertToRightHandedSystem Converts the values to right-handed
  81002. */
  81003. private writeVertexAttributeData;
  81004. /**
  81005. * Writes mesh attribute data to a data buffer
  81006. * Returns the bytelength of the data
  81007. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81008. * @param meshAttributeArray Array containing the attribute data
  81009. * @param binaryWriter The buffer to write the binary data to
  81010. * @param indices Used to specify the order of the vertex data
  81011. * @param convertToRightHandedSystem Converts the values to right-handed
  81012. */
  81013. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81014. /**
  81015. * Generates glTF json data
  81016. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81017. * @param glTFPrefix Text to use when prefixing a glTF file
  81018. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81019. * @returns json data as string
  81020. */
  81021. private generateJSON;
  81022. /**
  81023. * Generates data for .gltf and .bin files based on the glTF prefix string
  81024. * @param glTFPrefix Text to use when prefixing a glTF file
  81025. * @param dispose Dispose the exporter
  81026. * @returns GLTFData with glTF file data
  81027. */
  81028. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81029. /**
  81030. * Creates a binary buffer for glTF
  81031. * @returns array buffer for binary data
  81032. */
  81033. private _generateBinaryAsync;
  81034. /**
  81035. * Pads the number to a multiple of 4
  81036. * @param num number to pad
  81037. * @returns padded number
  81038. */
  81039. private _getPadding;
  81040. /**
  81041. * @hidden
  81042. */
  81043. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81044. /**
  81045. * Sets the TRS for each node
  81046. * @param node glTF Node for storing the transformation data
  81047. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81048. * @param convertToRightHandedSystem Converts the values to right-handed
  81049. */
  81050. private setNodeTransformation;
  81051. private getVertexBufferFromMesh;
  81052. /**
  81053. * Creates a bufferview based on the vertices type for the Babylon mesh
  81054. * @param kind Indicates the type of vertices data
  81055. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81056. * @param binaryWriter The buffer to write the bufferview data to
  81057. * @param convertToRightHandedSystem Converts the values to right-handed
  81058. */
  81059. private createBufferViewKind;
  81060. /**
  81061. * The primitive mode of the Babylon mesh
  81062. * @param babylonMesh The BabylonJS mesh
  81063. */
  81064. private getMeshPrimitiveMode;
  81065. /**
  81066. * Sets the primitive mode of the glTF mesh primitive
  81067. * @param meshPrimitive glTF mesh primitive
  81068. * @param primitiveMode The primitive mode
  81069. */
  81070. private setPrimitiveMode;
  81071. /**
  81072. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81073. * @param meshPrimitive glTF mesh primitive
  81074. * @param attributeKind vertex attribute
  81075. * @returns boolean specifying if uv coordinates are present
  81076. */
  81077. private setAttributeKind;
  81078. /**
  81079. * Sets data for the primitive attributes of each submesh
  81080. * @param mesh glTF Mesh object to store the primitive attribute information
  81081. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81082. * @param binaryWriter Buffer to write the attribute data to
  81083. * @param convertToRightHandedSystem Converts the values to right-handed
  81084. */
  81085. private setPrimitiveAttributesAsync;
  81086. /**
  81087. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81088. * @param node The node to check
  81089. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81090. */
  81091. private isBabylonCoordinateSystemConvertingNode;
  81092. /**
  81093. * Creates a glTF scene based on the array of meshes
  81094. * Returns the the total byte offset
  81095. * @param babylonScene Babylon scene to get the mesh data from
  81096. * @param binaryWriter Buffer to write binary data to
  81097. */
  81098. private createSceneAsync;
  81099. /**
  81100. * Creates a mapping of Node unique id to node index and handles animations
  81101. * @param babylonScene Babylon Scene
  81102. * @param nodes Babylon transform nodes
  81103. * @param binaryWriter Buffer to write binary data to
  81104. * @returns Node mapping of unique id to index
  81105. */
  81106. private createNodeMapAndAnimationsAsync;
  81107. /**
  81108. * Creates a glTF node from a Babylon mesh
  81109. * @param babylonMesh Source Babylon mesh
  81110. * @param binaryWriter Buffer for storing geometry data
  81111. * @param convertToRightHandedSystem Converts the values to right-handed
  81112. * @param nodeMap Node mapping of unique id to glTF node index
  81113. * @returns glTF node
  81114. */
  81115. private createNodeAsync;
  81116. }
  81117. /**
  81118. * @hidden
  81119. *
  81120. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81121. */
  81122. export class _BinaryWriter {
  81123. /**
  81124. * Array buffer which stores all binary data
  81125. */
  81126. private _arrayBuffer;
  81127. /**
  81128. * View of the array buffer
  81129. */
  81130. private _dataView;
  81131. /**
  81132. * byte offset of data in array buffer
  81133. */
  81134. private _byteOffset;
  81135. /**
  81136. * Initialize binary writer with an initial byte length
  81137. * @param byteLength Initial byte length of the array buffer
  81138. */
  81139. constructor(byteLength: number);
  81140. /**
  81141. * Resize the array buffer to the specified byte length
  81142. * @param byteLength
  81143. */
  81144. private resizeBuffer;
  81145. /**
  81146. * Get an array buffer with the length of the byte offset
  81147. * @returns ArrayBuffer resized to the byte offset
  81148. */
  81149. getArrayBuffer(): ArrayBuffer;
  81150. /**
  81151. * Get the byte offset of the array buffer
  81152. * @returns byte offset
  81153. */
  81154. getByteOffset(): number;
  81155. /**
  81156. * Stores an UInt8 in the array buffer
  81157. * @param entry
  81158. * @param byteOffset If defined, specifies where to set the value as an offset.
  81159. */
  81160. setUInt8(entry: number, byteOffset?: number): void;
  81161. /**
  81162. * Gets an UInt32 in the array buffer
  81163. * @param entry
  81164. * @param byteOffset If defined, specifies where to set the value as an offset.
  81165. */
  81166. getUInt32(byteOffset: number): number;
  81167. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81168. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81169. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81170. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81171. /**
  81172. * Stores a Float32 in the array buffer
  81173. * @param entry
  81174. */
  81175. setFloat32(entry: number, byteOffset?: number): void;
  81176. /**
  81177. * Stores an UInt32 in the array buffer
  81178. * @param entry
  81179. * @param byteOffset If defined, specifies where to set the value as an offset.
  81180. */
  81181. setUInt32(entry: number, byteOffset?: number): void;
  81182. }
  81183. }
  81184. declare module BABYLON.GLTF2.Exporter {
  81185. /**
  81186. * @hidden
  81187. * Interface to store animation data.
  81188. */
  81189. export interface _IAnimationData {
  81190. /**
  81191. * Keyframe data.
  81192. */
  81193. inputs: number[];
  81194. /**
  81195. * Value data.
  81196. */
  81197. outputs: number[][];
  81198. /**
  81199. * Animation interpolation data.
  81200. */
  81201. samplerInterpolation: AnimationSamplerInterpolation;
  81202. /**
  81203. * Minimum keyframe value.
  81204. */
  81205. inputsMin: number;
  81206. /**
  81207. * Maximum keyframe value.
  81208. */
  81209. inputsMax: number;
  81210. }
  81211. /**
  81212. * @hidden
  81213. */
  81214. export interface _IAnimationInfo {
  81215. /**
  81216. * The target channel for the animation
  81217. */
  81218. animationChannelTargetPath: AnimationChannelTargetPath;
  81219. /**
  81220. * The glTF accessor type for the data.
  81221. */
  81222. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81223. /**
  81224. * Specifies if quaternions should be used.
  81225. */
  81226. useQuaternion: boolean;
  81227. }
  81228. /**
  81229. * @hidden
  81230. * Utility class for generating glTF animation data from BabylonJS.
  81231. */
  81232. export class _GLTFAnimation {
  81233. /**
  81234. * @ignore
  81235. *
  81236. * Creates glTF channel animation from BabylonJS animation.
  81237. * @param babylonTransformNode - BabylonJS mesh.
  81238. * @param animation - animation.
  81239. * @param animationChannelTargetPath - The target animation channel.
  81240. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81241. * @param useQuaternion - Specifies if quaternions are used.
  81242. * @returns nullable IAnimationData
  81243. */
  81244. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81245. private static _DeduceAnimationInfo;
  81246. /**
  81247. * @ignore
  81248. * Create node animations from the transform node animations
  81249. * @param babylonNode
  81250. * @param runtimeGLTFAnimation
  81251. * @param idleGLTFAnimations
  81252. * @param nodeMap
  81253. * @param nodes
  81254. * @param binaryWriter
  81255. * @param bufferViews
  81256. * @param accessors
  81257. * @param convertToRightHandedSystem
  81258. * @param animationSampleRate
  81259. */
  81260. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81261. [key: number]: number;
  81262. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81263. /**
  81264. * @ignore
  81265. * Create node animations from the animation groups
  81266. * @param babylonScene
  81267. * @param glTFAnimations
  81268. * @param nodeMap
  81269. * @param nodes
  81270. * @param binaryWriter
  81271. * @param bufferViews
  81272. * @param accessors
  81273. * @param convertToRightHandedSystemMap
  81274. * @param animationSampleRate
  81275. */
  81276. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81277. [key: number]: number;
  81278. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81279. [nodeId: number]: boolean;
  81280. }, animationSampleRate: number): void;
  81281. private static AddAnimation;
  81282. /**
  81283. * Create a baked animation
  81284. * @param babylonTransformNode BabylonJS mesh
  81285. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81286. * @param animationChannelTargetPath animation target channel
  81287. * @param minFrame minimum animation frame
  81288. * @param maxFrame maximum animation frame
  81289. * @param fps frames per second of the animation
  81290. * @param inputs input key frames of the animation
  81291. * @param outputs output key frame data of the animation
  81292. * @param convertToRightHandedSystem converts the values to right-handed
  81293. * @param useQuaternion specifies if quaternions should be used
  81294. */
  81295. private static _CreateBakedAnimation;
  81296. private static _ConvertFactorToVector3OrQuaternion;
  81297. private static _SetInterpolatedValue;
  81298. /**
  81299. * Creates linear animation from the animation key frames
  81300. * @param babylonTransformNode BabylonJS mesh
  81301. * @param animation BabylonJS animation
  81302. * @param animationChannelTargetPath The target animation channel
  81303. * @param frameDelta The difference between the last and first frame of the animation
  81304. * @param inputs Array to store the key frame times
  81305. * @param outputs Array to store the key frame data
  81306. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81307. * @param useQuaternion Specifies if quaternions are used in the animation
  81308. */
  81309. private static _CreateLinearOrStepAnimation;
  81310. /**
  81311. * Creates cubic spline animation from the animation key frames
  81312. * @param babylonTransformNode BabylonJS mesh
  81313. * @param animation BabylonJS animation
  81314. * @param animationChannelTargetPath The target animation channel
  81315. * @param frameDelta The difference between the last and first frame of the animation
  81316. * @param inputs Array to store the key frame times
  81317. * @param outputs Array to store the key frame data
  81318. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81319. * @param useQuaternion Specifies if quaternions are used in the animation
  81320. */
  81321. private static _CreateCubicSplineAnimation;
  81322. private static _GetBasePositionRotationOrScale;
  81323. /**
  81324. * Adds a key frame value
  81325. * @param keyFrame
  81326. * @param animation
  81327. * @param outputs
  81328. * @param animationChannelTargetPath
  81329. * @param basePositionRotationOrScale
  81330. * @param convertToRightHandedSystem
  81331. * @param useQuaternion
  81332. */
  81333. private static _AddKeyframeValue;
  81334. /**
  81335. * Determine the interpolation based on the key frames
  81336. * @param keyFrames
  81337. * @param animationChannelTargetPath
  81338. * @param useQuaternion
  81339. */
  81340. private static _DeduceInterpolation;
  81341. /**
  81342. * Adds an input tangent or output tangent to the output data
  81343. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81344. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81345. * @param outputs The animation data by keyframe
  81346. * @param animationChannelTargetPath The target animation channel
  81347. * @param interpolation The interpolation type
  81348. * @param keyFrame The key frame with the animation data
  81349. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81350. * @param useQuaternion Specifies if quaternions are used
  81351. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81352. */
  81353. private static AddSplineTangent;
  81354. /**
  81355. * Get the minimum and maximum key frames' frame values
  81356. * @param keyFrames animation key frames
  81357. * @returns the minimum and maximum key frame value
  81358. */
  81359. private static calculateMinMaxKeyFrames;
  81360. }
  81361. }
  81362. declare module BABYLON.GLTF2.Exporter {
  81363. /** @hidden */
  81364. export var textureTransformPixelShader: {
  81365. name: string;
  81366. shader: string;
  81367. };
  81368. }
  81369. declare module BABYLON.GLTF2.Exporter.Extensions {
  81370. /**
  81371. * @hidden
  81372. */
  81373. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81374. private _recordedTextures;
  81375. /** Name of this extension */
  81376. readonly name: string;
  81377. /** Defines whether this extension is enabled */
  81378. enabled: boolean;
  81379. /** Defines whether this extension is required */
  81380. required: boolean;
  81381. /** Reference to the glTF exporter */
  81382. private _wasUsed;
  81383. constructor(exporter: _Exporter);
  81384. dispose(): void;
  81385. /** @hidden */
  81386. get wasUsed(): boolean;
  81387. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81388. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81389. /**
  81390. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81391. * @param babylonTexture
  81392. * @param offset
  81393. * @param rotation
  81394. * @param scale
  81395. * @param scene
  81396. */
  81397. private _textureTransformTextureAsync;
  81398. }
  81399. }
  81400. declare module BABYLON.GLTF2.Exporter.Extensions {
  81401. /**
  81402. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81403. */
  81404. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81405. /** The name of this extension. */
  81406. readonly name: string;
  81407. /** Defines whether this extension is enabled. */
  81408. enabled: boolean;
  81409. /** Defines whether this extension is required */
  81410. required: boolean;
  81411. /** Reference to the glTF exporter */
  81412. private _exporter;
  81413. private _lights;
  81414. /** @hidden */
  81415. constructor(exporter: _Exporter);
  81416. /** @hidden */
  81417. dispose(): void;
  81418. /** @hidden */
  81419. get wasUsed(): boolean;
  81420. /** @hidden */
  81421. onExporting(): void;
  81422. /**
  81423. * Define this method to modify the default behavior when exporting a node
  81424. * @param context The context when exporting the node
  81425. * @param node glTF node
  81426. * @param babylonNode BabylonJS node
  81427. * @param nodeMap Node mapping of unique id to glTF node index
  81428. * @returns nullable INode promise
  81429. */
  81430. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81431. [key: number]: number;
  81432. }): Promise<Nullable<INode>>;
  81433. }
  81434. }
  81435. declare module BABYLON.GLTF2.Exporter.Extensions {
  81436. /**
  81437. * @hidden
  81438. */
  81439. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81440. /** Name of this extension */
  81441. readonly name: string;
  81442. /** Defines whether this extension is enabled */
  81443. enabled: boolean;
  81444. /** Defines whether this extension is required */
  81445. required: boolean;
  81446. /** Reference to the glTF exporter */
  81447. private _textureInfos;
  81448. private _exportedTextures;
  81449. private _wasUsed;
  81450. constructor(exporter: _Exporter);
  81451. dispose(): void;
  81452. /** @hidden */
  81453. get wasUsed(): boolean;
  81454. private _getTextureIndex;
  81455. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81456. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81457. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81458. }
  81459. }
  81460. declare module BABYLON {
  81461. /**
  81462. * Class for generating STL data from a Babylon scene.
  81463. */
  81464. export class STLExport {
  81465. /**
  81466. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81467. * @param meshes list defines the mesh to serialize
  81468. * @param download triggers the automatic download of the file.
  81469. * @param fileName changes the downloads fileName.
  81470. * @param binary changes the STL to a binary type.
  81471. * @param isLittleEndian toggle for binary type exporter.
  81472. * @returns the STL as UTF8 string
  81473. */
  81474. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81475. }
  81476. }
  81477. declare module "babylonjs-gltf2interface" {
  81478. export = BABYLON.GLTF2;
  81479. }
  81480. /**
  81481. * Module for glTF 2.0 Interface
  81482. */
  81483. declare module BABYLON.GLTF2 {
  81484. /**
  81485. * The datatype of the components in the attribute
  81486. */
  81487. const enum AccessorComponentType {
  81488. /**
  81489. * Byte
  81490. */
  81491. BYTE = 5120,
  81492. /**
  81493. * Unsigned Byte
  81494. */
  81495. UNSIGNED_BYTE = 5121,
  81496. /**
  81497. * Short
  81498. */
  81499. SHORT = 5122,
  81500. /**
  81501. * Unsigned Short
  81502. */
  81503. UNSIGNED_SHORT = 5123,
  81504. /**
  81505. * Unsigned Int
  81506. */
  81507. UNSIGNED_INT = 5125,
  81508. /**
  81509. * Float
  81510. */
  81511. FLOAT = 5126,
  81512. }
  81513. /**
  81514. * Specifies if the attirbute is a scalar, vector, or matrix
  81515. */
  81516. const enum AccessorType {
  81517. /**
  81518. * Scalar
  81519. */
  81520. SCALAR = "SCALAR",
  81521. /**
  81522. * Vector2
  81523. */
  81524. VEC2 = "VEC2",
  81525. /**
  81526. * Vector3
  81527. */
  81528. VEC3 = "VEC3",
  81529. /**
  81530. * Vector4
  81531. */
  81532. VEC4 = "VEC4",
  81533. /**
  81534. * Matrix2x2
  81535. */
  81536. MAT2 = "MAT2",
  81537. /**
  81538. * Matrix3x3
  81539. */
  81540. MAT3 = "MAT3",
  81541. /**
  81542. * Matrix4x4
  81543. */
  81544. MAT4 = "MAT4",
  81545. }
  81546. /**
  81547. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81548. */
  81549. const enum AnimationChannelTargetPath {
  81550. /**
  81551. * Translation
  81552. */
  81553. TRANSLATION = "translation",
  81554. /**
  81555. * Rotation
  81556. */
  81557. ROTATION = "rotation",
  81558. /**
  81559. * Scale
  81560. */
  81561. SCALE = "scale",
  81562. /**
  81563. * Weights
  81564. */
  81565. WEIGHTS = "weights",
  81566. }
  81567. /**
  81568. * Interpolation algorithm
  81569. */
  81570. const enum AnimationSamplerInterpolation {
  81571. /**
  81572. * The animated values are linearly interpolated between keyframes
  81573. */
  81574. LINEAR = "LINEAR",
  81575. /**
  81576. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81577. */
  81578. STEP = "STEP",
  81579. /**
  81580. * The animation's interpolation is computed using a cubic spline with specified tangents
  81581. */
  81582. CUBICSPLINE = "CUBICSPLINE",
  81583. }
  81584. /**
  81585. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81586. */
  81587. const enum CameraType {
  81588. /**
  81589. * A perspective camera containing properties to create a perspective projection matrix
  81590. */
  81591. PERSPECTIVE = "perspective",
  81592. /**
  81593. * An orthographic camera containing properties to create an orthographic projection matrix
  81594. */
  81595. ORTHOGRAPHIC = "orthographic",
  81596. }
  81597. /**
  81598. * The mime-type of the image
  81599. */
  81600. const enum ImageMimeType {
  81601. /**
  81602. * JPEG Mime-type
  81603. */
  81604. JPEG = "image/jpeg",
  81605. /**
  81606. * PNG Mime-type
  81607. */
  81608. PNG = "image/png",
  81609. }
  81610. /**
  81611. * The alpha rendering mode of the material
  81612. */
  81613. const enum MaterialAlphaMode {
  81614. /**
  81615. * The alpha value is ignored and the rendered output is fully opaque
  81616. */
  81617. OPAQUE = "OPAQUE",
  81618. /**
  81619. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81620. */
  81621. MASK = "MASK",
  81622. /**
  81623. * 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)
  81624. */
  81625. BLEND = "BLEND",
  81626. }
  81627. /**
  81628. * The type of the primitives to render
  81629. */
  81630. const enum MeshPrimitiveMode {
  81631. /**
  81632. * Points
  81633. */
  81634. POINTS = 0,
  81635. /**
  81636. * Lines
  81637. */
  81638. LINES = 1,
  81639. /**
  81640. * Line Loop
  81641. */
  81642. LINE_LOOP = 2,
  81643. /**
  81644. * Line Strip
  81645. */
  81646. LINE_STRIP = 3,
  81647. /**
  81648. * Triangles
  81649. */
  81650. TRIANGLES = 4,
  81651. /**
  81652. * Triangle Strip
  81653. */
  81654. TRIANGLE_STRIP = 5,
  81655. /**
  81656. * Triangle Fan
  81657. */
  81658. TRIANGLE_FAN = 6,
  81659. }
  81660. /**
  81661. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81662. */
  81663. const enum TextureMagFilter {
  81664. /**
  81665. * Nearest
  81666. */
  81667. NEAREST = 9728,
  81668. /**
  81669. * Linear
  81670. */
  81671. LINEAR = 9729,
  81672. }
  81673. /**
  81674. * Minification filter. All valid values correspond to WebGL enums
  81675. */
  81676. const enum TextureMinFilter {
  81677. /**
  81678. * Nearest
  81679. */
  81680. NEAREST = 9728,
  81681. /**
  81682. * Linear
  81683. */
  81684. LINEAR = 9729,
  81685. /**
  81686. * Nearest Mip-Map Nearest
  81687. */
  81688. NEAREST_MIPMAP_NEAREST = 9984,
  81689. /**
  81690. * Linear Mipmap Nearest
  81691. */
  81692. LINEAR_MIPMAP_NEAREST = 9985,
  81693. /**
  81694. * Nearest Mipmap Linear
  81695. */
  81696. NEAREST_MIPMAP_LINEAR = 9986,
  81697. /**
  81698. * Linear Mipmap Linear
  81699. */
  81700. LINEAR_MIPMAP_LINEAR = 9987,
  81701. }
  81702. /**
  81703. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81704. */
  81705. const enum TextureWrapMode {
  81706. /**
  81707. * Clamp to Edge
  81708. */
  81709. CLAMP_TO_EDGE = 33071,
  81710. /**
  81711. * Mirrored Repeat
  81712. */
  81713. MIRRORED_REPEAT = 33648,
  81714. /**
  81715. * Repeat
  81716. */
  81717. REPEAT = 10497,
  81718. }
  81719. /**
  81720. * glTF Property
  81721. */
  81722. interface IProperty {
  81723. /**
  81724. * Dictionary object with extension-specific objects
  81725. */
  81726. extensions?: {
  81727. [key: string]: any;
  81728. };
  81729. /**
  81730. * Application-Specific data
  81731. */
  81732. extras?: any;
  81733. }
  81734. /**
  81735. * glTF Child of Root Property
  81736. */
  81737. interface IChildRootProperty extends IProperty {
  81738. /**
  81739. * The user-defined name of this object
  81740. */
  81741. name?: string;
  81742. }
  81743. /**
  81744. * Indices of those attributes that deviate from their initialization value
  81745. */
  81746. interface IAccessorSparseIndices extends IProperty {
  81747. /**
  81748. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81749. */
  81750. bufferView: number;
  81751. /**
  81752. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81753. */
  81754. byteOffset?: number;
  81755. /**
  81756. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81757. */
  81758. componentType: AccessorComponentType;
  81759. }
  81760. /**
  81761. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81762. */
  81763. interface IAccessorSparseValues extends IProperty {
  81764. /**
  81765. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81766. */
  81767. bufferView: number;
  81768. /**
  81769. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81770. */
  81771. byteOffset?: number;
  81772. }
  81773. /**
  81774. * Sparse storage of attributes that deviate from their initialization value
  81775. */
  81776. interface IAccessorSparse extends IProperty {
  81777. /**
  81778. * The number of attributes encoded in this sparse accessor
  81779. */
  81780. count: number;
  81781. /**
  81782. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81783. */
  81784. indices: IAccessorSparseIndices;
  81785. /**
  81786. * 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
  81787. */
  81788. values: IAccessorSparseValues;
  81789. }
  81790. /**
  81791. * 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
  81792. */
  81793. interface IAccessor extends IChildRootProperty {
  81794. /**
  81795. * The index of the bufferview
  81796. */
  81797. bufferView?: number;
  81798. /**
  81799. * The offset relative to the start of the bufferView in bytes
  81800. */
  81801. byteOffset?: number;
  81802. /**
  81803. * The datatype of components in the attribute
  81804. */
  81805. componentType: AccessorComponentType;
  81806. /**
  81807. * Specifies whether integer data values should be normalized
  81808. */
  81809. normalized?: boolean;
  81810. /**
  81811. * The number of attributes referenced by this accessor
  81812. */
  81813. count: number;
  81814. /**
  81815. * Specifies if the attribute is a scalar, vector, or matrix
  81816. */
  81817. type: AccessorType;
  81818. /**
  81819. * Maximum value of each component in this attribute
  81820. */
  81821. max?: number[];
  81822. /**
  81823. * Minimum value of each component in this attribute
  81824. */
  81825. min?: number[];
  81826. /**
  81827. * Sparse storage of attributes that deviate from their initialization value
  81828. */
  81829. sparse?: IAccessorSparse;
  81830. }
  81831. /**
  81832. * Targets an animation's sampler at a node's property
  81833. */
  81834. interface IAnimationChannel extends IProperty {
  81835. /**
  81836. * The index of a sampler in this animation used to compute the value for the target
  81837. */
  81838. sampler: number;
  81839. /**
  81840. * The index of the node and TRS property to target
  81841. */
  81842. target: IAnimationChannelTarget;
  81843. }
  81844. /**
  81845. * The index of the node and TRS property that an animation channel targets
  81846. */
  81847. interface IAnimationChannelTarget extends IProperty {
  81848. /**
  81849. * The index of the node to target
  81850. */
  81851. node: number;
  81852. /**
  81853. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81854. */
  81855. path: AnimationChannelTargetPath;
  81856. }
  81857. /**
  81858. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81859. */
  81860. interface IAnimationSampler extends IProperty {
  81861. /**
  81862. * The index of an accessor containing keyframe input values, e.g., time
  81863. */
  81864. input: number;
  81865. /**
  81866. * Interpolation algorithm
  81867. */
  81868. interpolation?: AnimationSamplerInterpolation;
  81869. /**
  81870. * The index of an accessor, containing keyframe output values
  81871. */
  81872. output: number;
  81873. }
  81874. /**
  81875. * A keyframe animation
  81876. */
  81877. interface IAnimation extends IChildRootProperty {
  81878. /**
  81879. * An array of channels, each of which targets an animation's sampler at a node's property
  81880. */
  81881. channels: IAnimationChannel[];
  81882. /**
  81883. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81884. */
  81885. samplers: IAnimationSampler[];
  81886. }
  81887. /**
  81888. * Metadata about the glTF asset
  81889. */
  81890. interface IAsset extends IChildRootProperty {
  81891. /**
  81892. * A copyright message suitable for display to credit the content creator
  81893. */
  81894. copyright?: string;
  81895. /**
  81896. * Tool that generated this glTF model. Useful for debugging
  81897. */
  81898. generator?: string;
  81899. /**
  81900. * The glTF version that this asset targets
  81901. */
  81902. version: string;
  81903. /**
  81904. * The minimum glTF version that this asset targets
  81905. */
  81906. minVersion?: string;
  81907. }
  81908. /**
  81909. * A buffer points to binary geometry, animation, or skins
  81910. */
  81911. interface IBuffer extends IChildRootProperty {
  81912. /**
  81913. * 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
  81914. */
  81915. uri?: string;
  81916. /**
  81917. * The length of the buffer in bytes
  81918. */
  81919. byteLength: number;
  81920. }
  81921. /**
  81922. * A view into a buffer generally representing a subset of the buffer
  81923. */
  81924. interface IBufferView extends IChildRootProperty {
  81925. /**
  81926. * The index of the buffer
  81927. */
  81928. buffer: number;
  81929. /**
  81930. * The offset into the buffer in bytes
  81931. */
  81932. byteOffset?: number;
  81933. /**
  81934. * The lenth of the bufferView in bytes
  81935. */
  81936. byteLength: number;
  81937. /**
  81938. * The stride, in bytes
  81939. */
  81940. byteStride?: number;
  81941. }
  81942. /**
  81943. * An orthographic camera containing properties to create an orthographic projection matrix
  81944. */
  81945. interface ICameraOrthographic extends IProperty {
  81946. /**
  81947. * The floating-point horizontal magnification of the view. Must not be zero
  81948. */
  81949. xmag: number;
  81950. /**
  81951. * The floating-point vertical magnification of the view. Must not be zero
  81952. */
  81953. ymag: number;
  81954. /**
  81955. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81956. */
  81957. zfar: number;
  81958. /**
  81959. * The floating-point distance to the near clipping plane
  81960. */
  81961. znear: number;
  81962. }
  81963. /**
  81964. * A perspective camera containing properties to create a perspective projection matrix
  81965. */
  81966. interface ICameraPerspective extends IProperty {
  81967. /**
  81968. * The floating-point aspect ratio of the field of view
  81969. */
  81970. aspectRatio?: number;
  81971. /**
  81972. * The floating-point vertical field of view in radians
  81973. */
  81974. yfov: number;
  81975. /**
  81976. * The floating-point distance to the far clipping plane
  81977. */
  81978. zfar?: number;
  81979. /**
  81980. * The floating-point distance to the near clipping plane
  81981. */
  81982. znear: number;
  81983. }
  81984. /**
  81985. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81986. */
  81987. interface ICamera extends IChildRootProperty {
  81988. /**
  81989. * An orthographic camera containing properties to create an orthographic projection matrix
  81990. */
  81991. orthographic?: ICameraOrthographic;
  81992. /**
  81993. * A perspective camera containing properties to create a perspective projection matrix
  81994. */
  81995. perspective?: ICameraPerspective;
  81996. /**
  81997. * Specifies if the camera uses a perspective or orthographic projection
  81998. */
  81999. type: CameraType;
  82000. }
  82001. /**
  82002. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82003. */
  82004. interface IImage extends IChildRootProperty {
  82005. /**
  82006. * 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
  82007. */
  82008. uri?: string;
  82009. /**
  82010. * The image's MIME type
  82011. */
  82012. mimeType?: ImageMimeType;
  82013. /**
  82014. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82015. */
  82016. bufferView?: number;
  82017. }
  82018. /**
  82019. * Material Normal Texture Info
  82020. */
  82021. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82022. /**
  82023. * The scalar multiplier applied to each normal vector of the normal texture
  82024. */
  82025. scale?: number;
  82026. }
  82027. /**
  82028. * Material Occlusion Texture Info
  82029. */
  82030. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82031. /**
  82032. * A scalar multiplier controlling the amount of occlusion applied
  82033. */
  82034. strength?: number;
  82035. }
  82036. /**
  82037. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82038. */
  82039. interface IMaterialPbrMetallicRoughness {
  82040. /**
  82041. * The material's base color factor
  82042. */
  82043. baseColorFactor?: number[];
  82044. /**
  82045. * The base color texture
  82046. */
  82047. baseColorTexture?: ITextureInfo;
  82048. /**
  82049. * The metalness of the material
  82050. */
  82051. metallicFactor?: number;
  82052. /**
  82053. * The roughness of the material
  82054. */
  82055. roughnessFactor?: number;
  82056. /**
  82057. * The metallic-roughness texture
  82058. */
  82059. metallicRoughnessTexture?: ITextureInfo;
  82060. }
  82061. /**
  82062. * The material appearance of a primitive
  82063. */
  82064. interface IMaterial extends IChildRootProperty {
  82065. /**
  82066. * 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
  82067. */
  82068. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82069. /**
  82070. * The normal map texture
  82071. */
  82072. normalTexture?: IMaterialNormalTextureInfo;
  82073. /**
  82074. * The occlusion map texture
  82075. */
  82076. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82077. /**
  82078. * The emissive map texture
  82079. */
  82080. emissiveTexture?: ITextureInfo;
  82081. /**
  82082. * 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
  82083. */
  82084. emissiveFactor?: number[];
  82085. /**
  82086. * The alpha rendering mode of the material
  82087. */
  82088. alphaMode?: MaterialAlphaMode;
  82089. /**
  82090. * The alpha cutoff value of the material
  82091. */
  82092. alphaCutoff?: number;
  82093. /**
  82094. * Specifies whether the material is double sided
  82095. */
  82096. doubleSided?: boolean;
  82097. }
  82098. /**
  82099. * Geometry to be rendered with the given material
  82100. */
  82101. interface IMeshPrimitive extends IProperty {
  82102. /**
  82103. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82104. */
  82105. attributes: {
  82106. [name: string]: number;
  82107. };
  82108. /**
  82109. * The index of the accessor that contains the indices
  82110. */
  82111. indices?: number;
  82112. /**
  82113. * The index of the material to apply to this primitive when rendering
  82114. */
  82115. material?: number;
  82116. /**
  82117. * The type of primitives to render. All valid values correspond to WebGL enums
  82118. */
  82119. mode?: MeshPrimitiveMode;
  82120. /**
  82121. * 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
  82122. */
  82123. targets?: {
  82124. [name: string]: number;
  82125. }[];
  82126. }
  82127. /**
  82128. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82129. */
  82130. interface IMesh extends IChildRootProperty {
  82131. /**
  82132. * An array of primitives, each defining geometry to be rendered with a material
  82133. */
  82134. primitives: IMeshPrimitive[];
  82135. /**
  82136. * Array of weights to be applied to the Morph Targets
  82137. */
  82138. weights?: number[];
  82139. }
  82140. /**
  82141. * A node in the node hierarchy
  82142. */
  82143. interface INode extends IChildRootProperty {
  82144. /**
  82145. * The index of the camera referenced by this node
  82146. */
  82147. camera?: number;
  82148. /**
  82149. * The indices of this node's children
  82150. */
  82151. children?: number[];
  82152. /**
  82153. * The index of the skin referenced by this node
  82154. */
  82155. skin?: number;
  82156. /**
  82157. * A floating-point 4x4 transformation matrix stored in column-major order
  82158. */
  82159. matrix?: number[];
  82160. /**
  82161. * The index of the mesh in this node
  82162. */
  82163. mesh?: number;
  82164. /**
  82165. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82166. */
  82167. rotation?: number[];
  82168. /**
  82169. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82170. */
  82171. scale?: number[];
  82172. /**
  82173. * The node's translation along the x, y, and z axes
  82174. */
  82175. translation?: number[];
  82176. /**
  82177. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82178. */
  82179. weights?: number[];
  82180. }
  82181. /**
  82182. * Texture sampler properties for filtering and wrapping modes
  82183. */
  82184. interface ISampler extends IChildRootProperty {
  82185. /**
  82186. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82187. */
  82188. magFilter?: TextureMagFilter;
  82189. /**
  82190. * Minification filter. All valid values correspond to WebGL enums
  82191. */
  82192. minFilter?: TextureMinFilter;
  82193. /**
  82194. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82195. */
  82196. wrapS?: TextureWrapMode;
  82197. /**
  82198. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82199. */
  82200. wrapT?: TextureWrapMode;
  82201. }
  82202. /**
  82203. * The root nodes of a scene
  82204. */
  82205. interface IScene extends IChildRootProperty {
  82206. /**
  82207. * The indices of each root node
  82208. */
  82209. nodes: number[];
  82210. }
  82211. /**
  82212. * Joints and matrices defining a skin
  82213. */
  82214. interface ISkin extends IChildRootProperty {
  82215. /**
  82216. * 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
  82217. */
  82218. inverseBindMatrices?: number;
  82219. /**
  82220. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82221. */
  82222. skeleton?: number;
  82223. /**
  82224. * 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)
  82225. */
  82226. joints: number[];
  82227. }
  82228. /**
  82229. * A texture and its sampler
  82230. */
  82231. interface ITexture extends IChildRootProperty {
  82232. /**
  82233. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82234. */
  82235. sampler?: number;
  82236. /**
  82237. * The index of the image used by this texture
  82238. */
  82239. source: number;
  82240. }
  82241. /**
  82242. * Reference to a texture
  82243. */
  82244. interface ITextureInfo extends IProperty {
  82245. /**
  82246. * The index of the texture
  82247. */
  82248. index: number;
  82249. /**
  82250. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82251. */
  82252. texCoord?: number;
  82253. }
  82254. /**
  82255. * The root object for a glTF asset
  82256. */
  82257. interface IGLTF extends IProperty {
  82258. /**
  82259. * An array of accessors. An accessor is a typed view into a bufferView
  82260. */
  82261. accessors?: IAccessor[];
  82262. /**
  82263. * An array of keyframe animations
  82264. */
  82265. animations?: IAnimation[];
  82266. /**
  82267. * Metadata about the glTF asset
  82268. */
  82269. asset: IAsset;
  82270. /**
  82271. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82272. */
  82273. buffers?: IBuffer[];
  82274. /**
  82275. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82276. */
  82277. bufferViews?: IBufferView[];
  82278. /**
  82279. * An array of cameras
  82280. */
  82281. cameras?: ICamera[];
  82282. /**
  82283. * Names of glTF extensions used somewhere in this asset
  82284. */
  82285. extensionsUsed?: string[];
  82286. /**
  82287. * Names of glTF extensions required to properly load this asset
  82288. */
  82289. extensionsRequired?: string[];
  82290. /**
  82291. * An array of images. An image defines data used to create a texture
  82292. */
  82293. images?: IImage[];
  82294. /**
  82295. * An array of materials. A material defines the appearance of a primitive
  82296. */
  82297. materials?: IMaterial[];
  82298. /**
  82299. * An array of meshes. A mesh is a set of primitives to be rendered
  82300. */
  82301. meshes?: IMesh[];
  82302. /**
  82303. * An array of nodes
  82304. */
  82305. nodes?: INode[];
  82306. /**
  82307. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82308. */
  82309. samplers?: ISampler[];
  82310. /**
  82311. * The index of the default scene
  82312. */
  82313. scene?: number;
  82314. /**
  82315. * An array of scenes
  82316. */
  82317. scenes?: IScene[];
  82318. /**
  82319. * An array of skins. A skin is defined by joints and matrices
  82320. */
  82321. skins?: ISkin[];
  82322. /**
  82323. * An array of textures
  82324. */
  82325. textures?: ITexture[];
  82326. }
  82327. /**
  82328. * The glTF validation results
  82329. * @ignore
  82330. */
  82331. interface IGLTFValidationResults {
  82332. info: {
  82333. generator: string;
  82334. hasAnimations: boolean;
  82335. hasDefaultScene: boolean;
  82336. hasMaterials: boolean;
  82337. hasMorphTargets: boolean;
  82338. hasSkins: boolean;
  82339. hasTextures: boolean;
  82340. maxAttributesUsed: number;
  82341. primitivesCount: number
  82342. };
  82343. issues: {
  82344. messages: Array<string>;
  82345. numErrors: number;
  82346. numHints: number;
  82347. numInfos: number;
  82348. numWarnings: number;
  82349. truncated: boolean
  82350. };
  82351. mimeType: string;
  82352. uri: string;
  82353. validatedAt: string;
  82354. validatorVersion: string;
  82355. }
  82356. /**
  82357. * The glTF validation options
  82358. */
  82359. interface IGLTFValidationOptions {
  82360. /** Uri to use */
  82361. uri?: string;
  82362. /** Function used to load external resources */
  82363. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82364. /** Boolean indicating that we need to validate accessor data */
  82365. validateAccessorData?: boolean;
  82366. /** max number of issues allowed */
  82367. maxIssues?: number;
  82368. /** Ignored issues */
  82369. ignoredIssues?: Array<string>;
  82370. /** Value to override severy settings */
  82371. severityOverrides?: Object;
  82372. }
  82373. /**
  82374. * The glTF validator object
  82375. * @ignore
  82376. */
  82377. interface IGLTFValidator {
  82378. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82379. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82380. }
  82381. }
  82382. declare module BABYLON {
  82383. /** @hidden */
  82384. export var cellPixelShader: {
  82385. name: string;
  82386. shader: string;
  82387. };
  82388. }
  82389. declare module BABYLON {
  82390. /** @hidden */
  82391. export var cellVertexShader: {
  82392. name: string;
  82393. shader: string;
  82394. };
  82395. }
  82396. declare module BABYLON {
  82397. export class CellMaterial extends BABYLON.PushMaterial {
  82398. private _diffuseTexture;
  82399. diffuseTexture: BABYLON.BaseTexture;
  82400. diffuseColor: BABYLON.Color3;
  82401. _computeHighLevel: boolean;
  82402. computeHighLevel: boolean;
  82403. private _disableLighting;
  82404. disableLighting: boolean;
  82405. private _maxSimultaneousLights;
  82406. maxSimultaneousLights: number;
  82407. constructor(name: string, scene: BABYLON.Scene);
  82408. needAlphaBlending(): boolean;
  82409. needAlphaTesting(): boolean;
  82410. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82411. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82412. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82413. getAnimatables(): BABYLON.IAnimatable[];
  82414. getActiveTextures(): BABYLON.BaseTexture[];
  82415. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82416. dispose(forceDisposeEffect?: boolean): void;
  82417. getClassName(): string;
  82418. clone(name: string): CellMaterial;
  82419. serialize(): any;
  82420. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82421. }
  82422. }
  82423. declare module BABYLON {
  82424. export class CustomShaderStructure {
  82425. FragmentStore: string;
  82426. VertexStore: string;
  82427. constructor();
  82428. }
  82429. export class ShaderSpecialParts {
  82430. constructor();
  82431. Fragment_Begin: string;
  82432. Fragment_Definitions: string;
  82433. Fragment_MainBegin: string;
  82434. Fragment_Custom_Diffuse: string;
  82435. Fragment_Before_Lights: string;
  82436. Fragment_Before_Fog: string;
  82437. Fragment_Custom_Alpha: string;
  82438. Fragment_Before_FragColor: string;
  82439. Vertex_Begin: string;
  82440. Vertex_Definitions: string;
  82441. Vertex_MainBegin: string;
  82442. Vertex_Before_PositionUpdated: string;
  82443. Vertex_Before_NormalUpdated: string;
  82444. Vertex_After_WorldPosComputed: string;
  82445. Vertex_MainEnd: string;
  82446. }
  82447. export class CustomMaterial extends BABYLON.StandardMaterial {
  82448. static ShaderIndexer: number;
  82449. CustomParts: ShaderSpecialParts;
  82450. _isCreatedShader: boolean;
  82451. _createdShaderName: string;
  82452. _customUniform: string[];
  82453. _newUniforms: string[];
  82454. _newUniformInstances: {
  82455. [name: string]: any;
  82456. };
  82457. _newSamplerInstances: {
  82458. [name: string]: BABYLON.Texture;
  82459. };
  82460. _customAttributes: string[];
  82461. FragmentShader: string;
  82462. VertexShader: string;
  82463. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82464. ReviewUniform(name: string, arr: string[]): string[];
  82465. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82466. constructor(name: string, scene: BABYLON.Scene);
  82467. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82468. AddAttribute(name: string): CustomMaterial;
  82469. Fragment_Begin(shaderPart: string): CustomMaterial;
  82470. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82471. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82472. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82473. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82474. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82475. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82476. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82477. Vertex_Begin(shaderPart: string): CustomMaterial;
  82478. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82479. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82480. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82481. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82482. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82483. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82484. }
  82485. }
  82486. declare module BABYLON {
  82487. export class ShaderAlebdoParts {
  82488. constructor();
  82489. Fragment_Begin: string;
  82490. Fragment_Definitions: string;
  82491. Fragment_MainBegin: string;
  82492. Fragment_Custom_Albedo: string;
  82493. Fragment_Before_Lights: string;
  82494. Fragment_Custom_MetallicRoughness: string;
  82495. Fragment_Custom_MicroSurface: string;
  82496. Fragment_Before_Fog: string;
  82497. Fragment_Custom_Alpha: string;
  82498. Fragment_Before_FragColor: string;
  82499. Vertex_Begin: string;
  82500. Vertex_Definitions: string;
  82501. Vertex_MainBegin: string;
  82502. Vertex_Before_PositionUpdated: string;
  82503. Vertex_Before_NormalUpdated: string;
  82504. Vertex_After_WorldPosComputed: string;
  82505. Vertex_MainEnd: string;
  82506. }
  82507. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82508. static ShaderIndexer: number;
  82509. CustomParts: ShaderAlebdoParts;
  82510. _isCreatedShader: boolean;
  82511. _createdShaderName: string;
  82512. _customUniform: string[];
  82513. _newUniforms: string[];
  82514. _newUniformInstances: {
  82515. [name: string]: any;
  82516. };
  82517. _newSamplerInstances: {
  82518. [name: string]: BABYLON.Texture;
  82519. };
  82520. _customAttributes: string[];
  82521. FragmentShader: string;
  82522. VertexShader: string;
  82523. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82524. ReviewUniform(name: string, arr: string[]): string[];
  82525. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82526. constructor(name: string, scene: BABYLON.Scene);
  82527. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82528. AddAttribute(name: string): PBRCustomMaterial;
  82529. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82530. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82531. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82532. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82533. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82534. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82535. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82536. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82537. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82538. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82539. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82540. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82541. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82542. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82543. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82544. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82545. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82546. }
  82547. }
  82548. declare module BABYLON {
  82549. /** @hidden */
  82550. export var firePixelShader: {
  82551. name: string;
  82552. shader: string;
  82553. };
  82554. }
  82555. declare module BABYLON {
  82556. /** @hidden */
  82557. export var fireVertexShader: {
  82558. name: string;
  82559. shader: string;
  82560. };
  82561. }
  82562. declare module BABYLON {
  82563. export class FireMaterial extends BABYLON.PushMaterial {
  82564. private _diffuseTexture;
  82565. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82566. private _distortionTexture;
  82567. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82568. private _opacityTexture;
  82569. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82570. diffuseColor: BABYLON.Color3;
  82571. speed: number;
  82572. private _scaledDiffuse;
  82573. private _lastTime;
  82574. constructor(name: string, scene: BABYLON.Scene);
  82575. needAlphaBlending(): boolean;
  82576. needAlphaTesting(): boolean;
  82577. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82578. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82579. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82580. getAnimatables(): BABYLON.IAnimatable[];
  82581. getActiveTextures(): BABYLON.BaseTexture[];
  82582. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82583. getClassName(): string;
  82584. dispose(forceDisposeEffect?: boolean): void;
  82585. clone(name: string): FireMaterial;
  82586. serialize(): any;
  82587. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82588. }
  82589. }
  82590. declare module BABYLON {
  82591. /** @hidden */
  82592. export var furPixelShader: {
  82593. name: string;
  82594. shader: string;
  82595. };
  82596. }
  82597. declare module BABYLON {
  82598. /** @hidden */
  82599. export var furVertexShader: {
  82600. name: string;
  82601. shader: string;
  82602. };
  82603. }
  82604. declare module BABYLON {
  82605. export class FurMaterial extends BABYLON.PushMaterial {
  82606. private _diffuseTexture;
  82607. diffuseTexture: BABYLON.BaseTexture;
  82608. private _heightTexture;
  82609. heightTexture: BABYLON.BaseTexture;
  82610. diffuseColor: BABYLON.Color3;
  82611. furLength: number;
  82612. furAngle: number;
  82613. furColor: BABYLON.Color3;
  82614. furOffset: number;
  82615. furSpacing: number;
  82616. furGravity: BABYLON.Vector3;
  82617. furSpeed: number;
  82618. furDensity: number;
  82619. furOcclusion: number;
  82620. furTexture: BABYLON.DynamicTexture;
  82621. private _disableLighting;
  82622. disableLighting: boolean;
  82623. private _maxSimultaneousLights;
  82624. maxSimultaneousLights: number;
  82625. highLevelFur: boolean;
  82626. _meshes: BABYLON.AbstractMesh[];
  82627. private _furTime;
  82628. constructor(name: string, scene: BABYLON.Scene);
  82629. get furTime(): number;
  82630. set furTime(furTime: number);
  82631. needAlphaBlending(): boolean;
  82632. needAlphaTesting(): boolean;
  82633. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82634. updateFur(): void;
  82635. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82636. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82637. getAnimatables(): BABYLON.IAnimatable[];
  82638. getActiveTextures(): BABYLON.BaseTexture[];
  82639. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82640. dispose(forceDisposeEffect?: boolean): void;
  82641. clone(name: string): FurMaterial;
  82642. serialize(): any;
  82643. getClassName(): string;
  82644. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82645. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82646. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82647. }
  82648. }
  82649. declare module BABYLON {
  82650. /** @hidden */
  82651. export var gradientPixelShader: {
  82652. name: string;
  82653. shader: string;
  82654. };
  82655. }
  82656. declare module BABYLON {
  82657. /** @hidden */
  82658. export var gradientVertexShader: {
  82659. name: string;
  82660. shader: string;
  82661. };
  82662. }
  82663. declare module BABYLON {
  82664. export class GradientMaterial extends BABYLON.PushMaterial {
  82665. private _maxSimultaneousLights;
  82666. maxSimultaneousLights: number;
  82667. topColor: BABYLON.Color3;
  82668. topColorAlpha: number;
  82669. bottomColor: BABYLON.Color3;
  82670. bottomColorAlpha: number;
  82671. offset: number;
  82672. scale: number;
  82673. smoothness: number;
  82674. private _disableLighting;
  82675. disableLighting: boolean;
  82676. constructor(name: string, scene: BABYLON.Scene);
  82677. needAlphaBlending(): boolean;
  82678. needAlphaTesting(): boolean;
  82679. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82680. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82681. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82682. getAnimatables(): BABYLON.IAnimatable[];
  82683. dispose(forceDisposeEffect?: boolean): void;
  82684. clone(name: string): GradientMaterial;
  82685. serialize(): any;
  82686. getClassName(): string;
  82687. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82688. }
  82689. }
  82690. declare module BABYLON {
  82691. /** @hidden */
  82692. export var gridPixelShader: {
  82693. name: string;
  82694. shader: string;
  82695. };
  82696. }
  82697. declare module BABYLON {
  82698. /** @hidden */
  82699. export var gridVertexShader: {
  82700. name: string;
  82701. shader: string;
  82702. };
  82703. }
  82704. declare module BABYLON {
  82705. /**
  82706. * The grid materials allows you to wrap any shape with a grid.
  82707. * Colors are customizable.
  82708. */
  82709. export class GridMaterial extends BABYLON.PushMaterial {
  82710. /**
  82711. * Main color of the grid (e.g. between lines)
  82712. */
  82713. mainColor: BABYLON.Color3;
  82714. /**
  82715. * Color of the grid lines.
  82716. */
  82717. lineColor: BABYLON.Color3;
  82718. /**
  82719. * The scale of the grid compared to unit.
  82720. */
  82721. gridRatio: number;
  82722. /**
  82723. * Allows setting an offset for the grid lines.
  82724. */
  82725. gridOffset: BABYLON.Vector3;
  82726. /**
  82727. * The frequency of thicker lines.
  82728. */
  82729. majorUnitFrequency: number;
  82730. /**
  82731. * The visibility of minor units in the grid.
  82732. */
  82733. minorUnitVisibility: number;
  82734. /**
  82735. * The grid opacity outside of the lines.
  82736. */
  82737. opacity: number;
  82738. /**
  82739. * Determine RBG output is premultiplied by alpha value.
  82740. */
  82741. preMultiplyAlpha: boolean;
  82742. private _opacityTexture;
  82743. opacityTexture: BABYLON.BaseTexture;
  82744. private _gridControl;
  82745. /**
  82746. * constructor
  82747. * @param name The name given to the material in order to identify it afterwards.
  82748. * @param scene The scene the material is used in.
  82749. */
  82750. constructor(name: string, scene: BABYLON.Scene);
  82751. /**
  82752. * Returns wehter or not the grid requires alpha blending.
  82753. */
  82754. needAlphaBlending(): boolean;
  82755. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82756. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82757. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82758. /**
  82759. * Dispose the material and its associated resources.
  82760. * @param forceDisposeEffect will also dispose the used effect when true
  82761. */
  82762. dispose(forceDisposeEffect?: boolean): void;
  82763. clone(name: string): GridMaterial;
  82764. serialize(): any;
  82765. getClassName(): string;
  82766. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82767. }
  82768. }
  82769. declare module BABYLON {
  82770. /** @hidden */
  82771. export var lavaPixelShader: {
  82772. name: string;
  82773. shader: string;
  82774. };
  82775. }
  82776. declare module BABYLON {
  82777. /** @hidden */
  82778. export var lavaVertexShader: {
  82779. name: string;
  82780. shader: string;
  82781. };
  82782. }
  82783. declare module BABYLON {
  82784. export class LavaMaterial extends BABYLON.PushMaterial {
  82785. private _diffuseTexture;
  82786. diffuseTexture: BABYLON.BaseTexture;
  82787. noiseTexture: BABYLON.BaseTexture;
  82788. fogColor: BABYLON.Color3;
  82789. speed: number;
  82790. movingSpeed: number;
  82791. lowFrequencySpeed: number;
  82792. fogDensity: number;
  82793. private _lastTime;
  82794. diffuseColor: BABYLON.Color3;
  82795. private _disableLighting;
  82796. disableLighting: boolean;
  82797. private _unlit;
  82798. unlit: boolean;
  82799. private _maxSimultaneousLights;
  82800. maxSimultaneousLights: number;
  82801. private _scaledDiffuse;
  82802. constructor(name: string, scene: BABYLON.Scene);
  82803. needAlphaBlending(): boolean;
  82804. needAlphaTesting(): boolean;
  82805. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82806. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82807. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82808. getAnimatables(): BABYLON.IAnimatable[];
  82809. getActiveTextures(): BABYLON.BaseTexture[];
  82810. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82811. dispose(forceDisposeEffect?: boolean): void;
  82812. clone(name: string): LavaMaterial;
  82813. serialize(): any;
  82814. getClassName(): string;
  82815. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82816. }
  82817. }
  82818. declare module BABYLON {
  82819. /** @hidden */
  82820. export var mixPixelShader: {
  82821. name: string;
  82822. shader: string;
  82823. };
  82824. }
  82825. declare module BABYLON {
  82826. /** @hidden */
  82827. export var mixVertexShader: {
  82828. name: string;
  82829. shader: string;
  82830. };
  82831. }
  82832. declare module BABYLON {
  82833. export class MixMaterial extends BABYLON.PushMaterial {
  82834. /**
  82835. * Mix textures
  82836. */
  82837. private _mixTexture1;
  82838. mixTexture1: BABYLON.BaseTexture;
  82839. private _mixTexture2;
  82840. mixTexture2: BABYLON.BaseTexture;
  82841. /**
  82842. * Diffuse textures
  82843. */
  82844. private _diffuseTexture1;
  82845. diffuseTexture1: BABYLON.Texture;
  82846. private _diffuseTexture2;
  82847. diffuseTexture2: BABYLON.Texture;
  82848. private _diffuseTexture3;
  82849. diffuseTexture3: BABYLON.Texture;
  82850. private _diffuseTexture4;
  82851. diffuseTexture4: BABYLON.Texture;
  82852. private _diffuseTexture5;
  82853. diffuseTexture5: BABYLON.Texture;
  82854. private _diffuseTexture6;
  82855. diffuseTexture6: BABYLON.Texture;
  82856. private _diffuseTexture7;
  82857. diffuseTexture7: BABYLON.Texture;
  82858. private _diffuseTexture8;
  82859. diffuseTexture8: BABYLON.Texture;
  82860. /**
  82861. * Uniforms
  82862. */
  82863. diffuseColor: BABYLON.Color3;
  82864. specularColor: BABYLON.Color3;
  82865. specularPower: number;
  82866. private _disableLighting;
  82867. disableLighting: boolean;
  82868. private _maxSimultaneousLights;
  82869. maxSimultaneousLights: number;
  82870. constructor(name: string, scene: BABYLON.Scene);
  82871. needAlphaBlending(): boolean;
  82872. needAlphaTesting(): boolean;
  82873. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82874. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82875. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82876. getAnimatables(): BABYLON.IAnimatable[];
  82877. getActiveTextures(): BABYLON.BaseTexture[];
  82878. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82879. dispose(forceDisposeEffect?: boolean): void;
  82880. clone(name: string): MixMaterial;
  82881. serialize(): any;
  82882. getClassName(): string;
  82883. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82884. }
  82885. }
  82886. declare module BABYLON {
  82887. /** @hidden */
  82888. export var normalPixelShader: {
  82889. name: string;
  82890. shader: string;
  82891. };
  82892. }
  82893. declare module BABYLON {
  82894. /** @hidden */
  82895. export var normalVertexShader: {
  82896. name: string;
  82897. shader: string;
  82898. };
  82899. }
  82900. declare module BABYLON {
  82901. export class NormalMaterial extends BABYLON.PushMaterial {
  82902. private _diffuseTexture;
  82903. diffuseTexture: BABYLON.BaseTexture;
  82904. diffuseColor: BABYLON.Color3;
  82905. private _disableLighting;
  82906. disableLighting: boolean;
  82907. private _maxSimultaneousLights;
  82908. maxSimultaneousLights: number;
  82909. constructor(name: string, scene: BABYLON.Scene);
  82910. needAlphaBlending(): boolean;
  82911. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): 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. clone(name: string): NormalMaterial;
  82921. serialize(): any;
  82922. getClassName(): string;
  82923. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82924. }
  82925. }
  82926. declare module BABYLON {
  82927. /** @hidden */
  82928. export var shadowOnlyPixelShader: {
  82929. name: string;
  82930. shader: string;
  82931. };
  82932. }
  82933. declare module BABYLON {
  82934. /** @hidden */
  82935. export var shadowOnlyVertexShader: {
  82936. name: string;
  82937. shader: string;
  82938. };
  82939. }
  82940. declare module BABYLON {
  82941. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82942. private _activeLight;
  82943. private _needAlphaBlending;
  82944. constructor(name: string, scene: BABYLON.Scene);
  82945. shadowColor: BABYLON.Color3;
  82946. needAlphaBlending(): boolean;
  82947. needAlphaTesting(): boolean;
  82948. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82949. get activeLight(): BABYLON.IShadowLight;
  82950. set activeLight(light: BABYLON.IShadowLight);
  82951. private _getFirstShadowLightForMesh;
  82952. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82953. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82954. clone(name: string): ShadowOnlyMaterial;
  82955. serialize(): any;
  82956. getClassName(): string;
  82957. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82958. }
  82959. }
  82960. declare module BABYLON {
  82961. /** @hidden */
  82962. export var simplePixelShader: {
  82963. name: string;
  82964. shader: string;
  82965. };
  82966. }
  82967. declare module BABYLON {
  82968. /** @hidden */
  82969. export var simpleVertexShader: {
  82970. name: string;
  82971. shader: string;
  82972. };
  82973. }
  82974. declare module BABYLON {
  82975. export class SimpleMaterial extends BABYLON.PushMaterial {
  82976. private _diffuseTexture;
  82977. diffuseTexture: BABYLON.BaseTexture;
  82978. diffuseColor: BABYLON.Color3;
  82979. private _disableLighting;
  82980. disableLighting: boolean;
  82981. private _maxSimultaneousLights;
  82982. maxSimultaneousLights: number;
  82983. constructor(name: string, scene: BABYLON.Scene);
  82984. needAlphaBlending(): boolean;
  82985. needAlphaTesting(): boolean;
  82986. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82987. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82988. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82989. getAnimatables(): BABYLON.IAnimatable[];
  82990. getActiveTextures(): BABYLON.BaseTexture[];
  82991. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82992. dispose(forceDisposeEffect?: boolean): void;
  82993. clone(name: string): SimpleMaterial;
  82994. serialize(): any;
  82995. getClassName(): string;
  82996. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82997. }
  82998. }
  82999. declare module BABYLON {
  83000. /** @hidden */
  83001. export var skyPixelShader: {
  83002. name: string;
  83003. shader: string;
  83004. };
  83005. }
  83006. declare module BABYLON {
  83007. /** @hidden */
  83008. export var skyVertexShader: {
  83009. name: string;
  83010. shader: string;
  83011. };
  83012. }
  83013. declare module BABYLON {
  83014. /**
  83015. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83016. * @see https://doc.babylonjs.com/extensions/sky
  83017. */
  83018. export class SkyMaterial extends BABYLON.PushMaterial {
  83019. /**
  83020. * Defines the overall luminance of sky in interval ]0, 1[.
  83021. */
  83022. luminance: number;
  83023. /**
  83024. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83025. */
  83026. turbidity: number;
  83027. /**
  83028. * Defines the sky appearance (light intensity).
  83029. */
  83030. rayleigh: number;
  83031. /**
  83032. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83033. */
  83034. mieCoefficient: number;
  83035. /**
  83036. * Defines the amount of haze particles following the Mie scattering theory.
  83037. */
  83038. mieDirectionalG: number;
  83039. /**
  83040. * Defines the distance of the sun according to the active scene camera.
  83041. */
  83042. distance: number;
  83043. /**
  83044. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83045. * "inclined".
  83046. */
  83047. inclination: number;
  83048. /**
  83049. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83050. * an object direction and a reference direction.
  83051. */
  83052. azimuth: number;
  83053. /**
  83054. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83055. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83056. */
  83057. sunPosition: BABYLON.Vector3;
  83058. /**
  83059. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83060. * .sunPosition property.
  83061. */
  83062. useSunPosition: boolean;
  83063. /**
  83064. * Defines an offset vector used to get a horizon offset.
  83065. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83066. */
  83067. cameraOffset: BABYLON.Vector3;
  83068. private _cameraPosition;
  83069. /**
  83070. * Instantiates a new sky material.
  83071. * This material allows to create dynamic and texture free
  83072. * effects for skyboxes by taking care of the atmosphere state.
  83073. * @see https://doc.babylonjs.com/extensions/sky
  83074. * @param name Define the name of the material in the scene
  83075. * @param scene Define the scene the material belong to
  83076. */
  83077. constructor(name: string, scene: BABYLON.Scene);
  83078. /**
  83079. * Specifies if the material will require alpha blending
  83080. * @returns a boolean specifying if alpha blending is needed
  83081. */
  83082. needAlphaBlending(): boolean;
  83083. /**
  83084. * Specifies if this material should be rendered in alpha test mode
  83085. * @returns false as the sky material doesn't need alpha testing.
  83086. */
  83087. needAlphaTesting(): boolean;
  83088. /**
  83089. * Get the texture used for alpha test purpose.
  83090. * @returns null as the sky material has no texture.
  83091. */
  83092. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83093. /**
  83094. * Get if the submesh is ready to be used and all its information available.
  83095. * Child classes can use it to update shaders
  83096. * @param mesh defines the mesh to check
  83097. * @param subMesh defines which submesh to check
  83098. * @param useInstances specifies that instances should be used
  83099. * @returns a boolean indicating that the submesh is ready or not
  83100. */
  83101. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83102. /**
  83103. * Binds the submesh to this material by preparing the effect and shader to draw
  83104. * @param world defines the world transformation matrix
  83105. * @param mesh defines the mesh containing the submesh
  83106. * @param subMesh defines the submesh to bind the material to
  83107. */
  83108. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83109. /**
  83110. * Get the list of animatables in the material.
  83111. * @returns the list of animatables object used in the material
  83112. */
  83113. getAnimatables(): BABYLON.IAnimatable[];
  83114. /**
  83115. * Disposes the material
  83116. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83117. */
  83118. dispose(forceDisposeEffect?: boolean): void;
  83119. /**
  83120. * Makes a duplicate of the material, and gives it a new name
  83121. * @param name defines the new name for the duplicated material
  83122. * @returns the cloned material
  83123. */
  83124. clone(name: string): SkyMaterial;
  83125. /**
  83126. * Serializes this material in a JSON representation
  83127. * @returns the serialized material object
  83128. */
  83129. serialize(): any;
  83130. /**
  83131. * Gets the current class name of the material e.g. "SkyMaterial"
  83132. * Mainly use in serialization.
  83133. * @returns the class name
  83134. */
  83135. getClassName(): string;
  83136. /**
  83137. * Creates a sky material from parsed material data
  83138. * @param source defines the JSON representation of the material
  83139. * @param scene defines the hosting scene
  83140. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83141. * @returns a new sky material
  83142. */
  83143. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83144. }
  83145. }
  83146. declare module BABYLON {
  83147. /** @hidden */
  83148. export var terrainPixelShader: {
  83149. name: string;
  83150. shader: string;
  83151. };
  83152. }
  83153. declare module BABYLON {
  83154. /** @hidden */
  83155. export var terrainVertexShader: {
  83156. name: string;
  83157. shader: string;
  83158. };
  83159. }
  83160. declare module BABYLON {
  83161. export class TerrainMaterial extends BABYLON.PushMaterial {
  83162. private _mixTexture;
  83163. mixTexture: BABYLON.BaseTexture;
  83164. private _diffuseTexture1;
  83165. diffuseTexture1: BABYLON.Texture;
  83166. private _diffuseTexture2;
  83167. diffuseTexture2: BABYLON.Texture;
  83168. private _diffuseTexture3;
  83169. diffuseTexture3: BABYLON.Texture;
  83170. private _bumpTexture1;
  83171. bumpTexture1: BABYLON.Texture;
  83172. private _bumpTexture2;
  83173. bumpTexture2: BABYLON.Texture;
  83174. private _bumpTexture3;
  83175. bumpTexture3: BABYLON.Texture;
  83176. diffuseColor: BABYLON.Color3;
  83177. specularColor: BABYLON.Color3;
  83178. specularPower: number;
  83179. private _disableLighting;
  83180. disableLighting: boolean;
  83181. private _maxSimultaneousLights;
  83182. maxSimultaneousLights: number;
  83183. constructor(name: string, scene: BABYLON.Scene);
  83184. needAlphaBlending(): boolean;
  83185. needAlphaTesting(): boolean;
  83186. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83187. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83188. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83189. getAnimatables(): BABYLON.IAnimatable[];
  83190. getActiveTextures(): BABYLON.BaseTexture[];
  83191. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83192. dispose(forceDisposeEffect?: boolean): void;
  83193. clone(name: string): TerrainMaterial;
  83194. serialize(): any;
  83195. getClassName(): string;
  83196. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83197. }
  83198. }
  83199. declare module BABYLON {
  83200. /** @hidden */
  83201. export var triplanarPixelShader: {
  83202. name: string;
  83203. shader: string;
  83204. };
  83205. }
  83206. declare module BABYLON {
  83207. /** @hidden */
  83208. export var triplanarVertexShader: {
  83209. name: string;
  83210. shader: string;
  83211. };
  83212. }
  83213. declare module BABYLON {
  83214. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83215. mixTexture: BABYLON.BaseTexture;
  83216. private _diffuseTextureX;
  83217. diffuseTextureX: BABYLON.BaseTexture;
  83218. private _diffuseTextureY;
  83219. diffuseTextureY: BABYLON.BaseTexture;
  83220. private _diffuseTextureZ;
  83221. diffuseTextureZ: BABYLON.BaseTexture;
  83222. private _normalTextureX;
  83223. normalTextureX: BABYLON.BaseTexture;
  83224. private _normalTextureY;
  83225. normalTextureY: BABYLON.BaseTexture;
  83226. private _normalTextureZ;
  83227. normalTextureZ: BABYLON.BaseTexture;
  83228. tileSize: number;
  83229. diffuseColor: BABYLON.Color3;
  83230. specularColor: BABYLON.Color3;
  83231. specularPower: number;
  83232. private _disableLighting;
  83233. disableLighting: boolean;
  83234. private _maxSimultaneousLights;
  83235. maxSimultaneousLights: number;
  83236. constructor(name: string, scene: BABYLON.Scene);
  83237. needAlphaBlending(): boolean;
  83238. needAlphaTesting(): boolean;
  83239. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83240. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83241. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83242. getAnimatables(): BABYLON.IAnimatable[];
  83243. getActiveTextures(): BABYLON.BaseTexture[];
  83244. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83245. dispose(forceDisposeEffect?: boolean): void;
  83246. clone(name: string): TriPlanarMaterial;
  83247. serialize(): any;
  83248. getClassName(): string;
  83249. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83250. }
  83251. }
  83252. declare module BABYLON {
  83253. /** @hidden */
  83254. export var waterPixelShader: {
  83255. name: string;
  83256. shader: string;
  83257. };
  83258. }
  83259. declare module BABYLON {
  83260. /** @hidden */
  83261. export var waterVertexShader: {
  83262. name: string;
  83263. shader: string;
  83264. };
  83265. }
  83266. declare module BABYLON {
  83267. export class WaterMaterial extends BABYLON.PushMaterial {
  83268. renderTargetSize: BABYLON.Vector2;
  83269. private _bumpTexture;
  83270. bumpTexture: BABYLON.BaseTexture;
  83271. diffuseColor: BABYLON.Color3;
  83272. specularColor: BABYLON.Color3;
  83273. specularPower: number;
  83274. private _disableLighting;
  83275. disableLighting: boolean;
  83276. private _maxSimultaneousLights;
  83277. maxSimultaneousLights: number;
  83278. /**
  83279. * @param {number}: Represents the wind force
  83280. */
  83281. windForce: number;
  83282. /**
  83283. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83284. */
  83285. windDirection: BABYLON.Vector2;
  83286. /**
  83287. * @param {number}: Wave height, represents the height of the waves
  83288. */
  83289. waveHeight: number;
  83290. /**
  83291. * @param {number}: Bump height, represents the bump height related to the bump map
  83292. */
  83293. bumpHeight: number;
  83294. /**
  83295. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83296. */
  83297. private _bumpSuperimpose;
  83298. bumpSuperimpose: boolean;
  83299. /**
  83300. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83301. */
  83302. private _fresnelSeparate;
  83303. fresnelSeparate: boolean;
  83304. /**
  83305. * @param {boolean}: bump Waves modify the reflection.
  83306. */
  83307. private _bumpAffectsReflection;
  83308. bumpAffectsReflection: boolean;
  83309. /**
  83310. * @param {number}: The water color blended with the refraction (near)
  83311. */
  83312. waterColor: BABYLON.Color3;
  83313. /**
  83314. * @param {number}: The blend factor related to the water color
  83315. */
  83316. colorBlendFactor: number;
  83317. /**
  83318. * @param {number}: The water color blended with the reflection (far)
  83319. */
  83320. waterColor2: BABYLON.Color3;
  83321. /**
  83322. * @param {number}: The blend factor related to the water color (reflection, far)
  83323. */
  83324. colorBlendFactor2: number;
  83325. /**
  83326. * @param {number}: Represents the maximum length of a wave
  83327. */
  83328. waveLength: number;
  83329. /**
  83330. * @param {number}: Defines the waves speed
  83331. */
  83332. waveSpeed: number;
  83333. /**
  83334. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83335. * will avoid calculating useless pixels in the pixel shader of the water material.
  83336. */
  83337. disableClipPlane: boolean;
  83338. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83339. private _mesh;
  83340. private _refractionRTT;
  83341. private _reflectionRTT;
  83342. private _reflectionTransform;
  83343. private _lastTime;
  83344. private _lastDeltaTime;
  83345. private _useLogarithmicDepth;
  83346. private _waitingRenderList;
  83347. private _imageProcessingConfiguration;
  83348. private _imageProcessingObserver;
  83349. /**
  83350. * Gets a boolean indicating that current material needs to register RTT
  83351. */
  83352. get hasRenderTargetTextures(): boolean;
  83353. /**
  83354. * Constructor
  83355. */
  83356. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83357. get useLogarithmicDepth(): boolean;
  83358. set useLogarithmicDepth(value: boolean);
  83359. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83360. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83361. addToRenderList(node: any): void;
  83362. enableRenderTargets(enable: boolean): void;
  83363. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83364. get renderTargetsEnabled(): boolean;
  83365. needAlphaBlending(): boolean;
  83366. needAlphaTesting(): boolean;
  83367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83370. private _createRenderTargets;
  83371. getAnimatables(): BABYLON.IAnimatable[];
  83372. getActiveTextures(): BABYLON.BaseTexture[];
  83373. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83374. dispose(forceDisposeEffect?: boolean): void;
  83375. clone(name: string): WaterMaterial;
  83376. serialize(): any;
  83377. getClassName(): string;
  83378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83379. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83380. }
  83381. }
  83382. declare module BABYLON {
  83383. /** @hidden */
  83384. export var asciiartPixelShader: {
  83385. name: string;
  83386. shader: string;
  83387. };
  83388. }
  83389. declare module BABYLON {
  83390. /**
  83391. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83392. *
  83393. * It basically takes care rendering the font front the given font size to a texture.
  83394. * This is used later on in the postprocess.
  83395. */
  83396. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83397. private _font;
  83398. private _text;
  83399. private _charSize;
  83400. /**
  83401. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83402. */
  83403. get charSize(): number;
  83404. /**
  83405. * Create a new instance of the Ascii Art FontTexture class
  83406. * @param name the name of the texture
  83407. * @param font the font to use, use the W3C CSS notation
  83408. * @param text the caracter set to use in the rendering.
  83409. * @param scene the scene that owns the texture
  83410. */
  83411. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83412. /**
  83413. * Gets the max char width of a font.
  83414. * @param font the font to use, use the W3C CSS notation
  83415. * @return the max char width
  83416. */
  83417. private getFontWidth;
  83418. /**
  83419. * Gets the max char height of a font.
  83420. * @param font the font to use, use the W3C CSS notation
  83421. * @return the max char height
  83422. */
  83423. private getFontHeight;
  83424. /**
  83425. * Clones the current AsciiArtTexture.
  83426. * @return the clone of the texture.
  83427. */
  83428. clone(): AsciiArtFontTexture;
  83429. /**
  83430. * Parses a json object representing the texture and returns an instance of it.
  83431. * @param source the source JSON representation
  83432. * @param scene the scene to create the texture for
  83433. * @return the parsed texture
  83434. */
  83435. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83436. }
  83437. /**
  83438. * Option available in the Ascii Art Post Process.
  83439. */
  83440. export interface IAsciiArtPostProcessOptions {
  83441. /**
  83442. * The font to use following the w3c font definition.
  83443. */
  83444. font?: string;
  83445. /**
  83446. * The character set to use in the postprocess.
  83447. */
  83448. characterSet?: string;
  83449. /**
  83450. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83451. * This number is defined between 0 and 1;
  83452. */
  83453. mixToTile?: number;
  83454. /**
  83455. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83456. * This number is defined between 0 and 1;
  83457. */
  83458. mixToNormal?: number;
  83459. }
  83460. /**
  83461. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83462. *
  83463. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83464. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83465. */
  83466. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83467. /**
  83468. * The font texture used to render the char in the post process.
  83469. */
  83470. private _asciiArtFontTexture;
  83471. /**
  83472. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83473. * This number is defined between 0 and 1;
  83474. */
  83475. mixToTile: number;
  83476. /**
  83477. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83478. * This number is defined between 0 and 1;
  83479. */
  83480. mixToNormal: number;
  83481. /**
  83482. * Instantiates a new Ascii Art Post Process.
  83483. * @param name the name to give to the postprocess
  83484. * @camera the camera to apply the post process to.
  83485. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83486. */
  83487. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83488. }
  83489. }
  83490. declare module BABYLON {
  83491. /** @hidden */
  83492. export var digitalrainPixelShader: {
  83493. name: string;
  83494. shader: string;
  83495. };
  83496. }
  83497. declare module BABYLON {
  83498. /**
  83499. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83500. *
  83501. * It basically takes care rendering the font front the given font size to a texture.
  83502. * This is used later on in the postprocess.
  83503. */
  83504. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83505. private _font;
  83506. private _text;
  83507. private _charSize;
  83508. /**
  83509. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83510. */
  83511. get charSize(): number;
  83512. /**
  83513. * Create a new instance of the Digital Rain FontTexture class
  83514. * @param name the name of the texture
  83515. * @param font the font to use, use the W3C CSS notation
  83516. * @param text the caracter set to use in the rendering.
  83517. * @param scene the scene that owns the texture
  83518. */
  83519. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83520. /**
  83521. * Gets the max char width of a font.
  83522. * @param font the font to use, use the W3C CSS notation
  83523. * @return the max char width
  83524. */
  83525. private getFontWidth;
  83526. /**
  83527. * Gets the max char height of a font.
  83528. * @param font the font to use, use the W3C CSS notation
  83529. * @return the max char height
  83530. */
  83531. private getFontHeight;
  83532. /**
  83533. * Clones the current DigitalRainFontTexture.
  83534. * @return the clone of the texture.
  83535. */
  83536. clone(): DigitalRainFontTexture;
  83537. /**
  83538. * Parses a json object representing the texture and returns an instance of it.
  83539. * @param source the source JSON representation
  83540. * @param scene the scene to create the texture for
  83541. * @return the parsed texture
  83542. */
  83543. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83544. }
  83545. /**
  83546. * Option available in the Digital Rain Post Process.
  83547. */
  83548. export interface IDigitalRainPostProcessOptions {
  83549. /**
  83550. * The font to use following the w3c font definition.
  83551. */
  83552. font?: string;
  83553. /**
  83554. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83555. * This number is defined between 0 and 1;
  83556. */
  83557. mixToTile?: number;
  83558. /**
  83559. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83560. * This number is defined between 0 and 1;
  83561. */
  83562. mixToNormal?: number;
  83563. }
  83564. /**
  83565. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83566. *
  83567. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83568. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83569. */
  83570. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83571. /**
  83572. * The font texture used to render the char in the post process.
  83573. */
  83574. private _digitalRainFontTexture;
  83575. /**
  83576. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83577. * This number is defined between 0 and 1;
  83578. */
  83579. mixToTile: number;
  83580. /**
  83581. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83582. * This number is defined between 0 and 1;
  83583. */
  83584. mixToNormal: number;
  83585. /**
  83586. * Instantiates a new Digital Rain Post Process.
  83587. * @param name the name to give to the postprocess
  83588. * @camera the camera to apply the post process to.
  83589. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83590. */
  83591. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83592. }
  83593. }
  83594. declare module BABYLON {
  83595. /** @hidden */
  83596. export var brickProceduralTexturePixelShader: {
  83597. name: string;
  83598. shader: string;
  83599. };
  83600. }
  83601. declare module BABYLON {
  83602. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83603. private _numberOfBricksHeight;
  83604. private _numberOfBricksWidth;
  83605. private _jointColor;
  83606. private _brickColor;
  83607. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83608. updateShaderUniforms(): void;
  83609. get numberOfBricksHeight(): number;
  83610. set numberOfBricksHeight(value: number);
  83611. get numberOfBricksWidth(): number;
  83612. set numberOfBricksWidth(value: number);
  83613. get jointColor(): BABYLON.Color3;
  83614. set jointColor(value: BABYLON.Color3);
  83615. get brickColor(): BABYLON.Color3;
  83616. set brickColor(value: BABYLON.Color3);
  83617. /**
  83618. * Serializes this brick procedural texture
  83619. * @returns a serialized brick procedural texture object
  83620. */
  83621. serialize(): any;
  83622. /**
  83623. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83624. * @param parsedTexture defines parsed texture data
  83625. * @param scene defines the current scene
  83626. * @param rootUrl defines the root URL containing brick procedural texture information
  83627. * @returns a parsed Brick Procedural BABYLON.Texture
  83628. */
  83629. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83630. }
  83631. }
  83632. declare module BABYLON {
  83633. /** @hidden */
  83634. export var cloudProceduralTexturePixelShader: {
  83635. name: string;
  83636. shader: string;
  83637. };
  83638. }
  83639. declare module BABYLON {
  83640. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83641. private _skyColor;
  83642. private _cloudColor;
  83643. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83644. updateShaderUniforms(): void;
  83645. get skyColor(): BABYLON.Color4;
  83646. set skyColor(value: BABYLON.Color4);
  83647. get cloudColor(): BABYLON.Color4;
  83648. set cloudColor(value: BABYLON.Color4);
  83649. /**
  83650. * Serializes this cloud procedural texture
  83651. * @returns a serialized cloud procedural texture object
  83652. */
  83653. serialize(): any;
  83654. /**
  83655. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83656. * @param parsedTexture defines parsed texture data
  83657. * @param scene defines the current scene
  83658. * @param rootUrl defines the root URL containing cloud procedural texture information
  83659. * @returns a parsed Cloud Procedural BABYLON.Texture
  83660. */
  83661. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83662. }
  83663. }
  83664. declare module BABYLON {
  83665. /** @hidden */
  83666. export var fireProceduralTexturePixelShader: {
  83667. name: string;
  83668. shader: string;
  83669. };
  83670. }
  83671. declare module BABYLON {
  83672. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83673. private _time;
  83674. private _speed;
  83675. private _autoGenerateTime;
  83676. private _fireColors;
  83677. private _alphaThreshold;
  83678. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83679. updateShaderUniforms(): void;
  83680. render(useCameraPostProcess?: boolean): void;
  83681. static get PurpleFireColors(): BABYLON.Color3[];
  83682. static get GreenFireColors(): BABYLON.Color3[];
  83683. static get RedFireColors(): BABYLON.Color3[];
  83684. static get BlueFireColors(): BABYLON.Color3[];
  83685. get autoGenerateTime(): boolean;
  83686. set autoGenerateTime(value: boolean);
  83687. get fireColors(): BABYLON.Color3[];
  83688. set fireColors(value: BABYLON.Color3[]);
  83689. get time(): number;
  83690. set time(value: number);
  83691. get speed(): BABYLON.Vector2;
  83692. set speed(value: BABYLON.Vector2);
  83693. get alphaThreshold(): number;
  83694. set alphaThreshold(value: number);
  83695. /**
  83696. * Serializes this fire procedural texture
  83697. * @returns a serialized fire procedural texture object
  83698. */
  83699. serialize(): any;
  83700. /**
  83701. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83702. * @param parsedTexture defines parsed texture data
  83703. * @param scene defines the current scene
  83704. * @param rootUrl defines the root URL containing fire procedural texture information
  83705. * @returns a parsed Fire Procedural BABYLON.Texture
  83706. */
  83707. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83708. }
  83709. }
  83710. declare module BABYLON {
  83711. /** @hidden */
  83712. export var grassProceduralTexturePixelShader: {
  83713. name: string;
  83714. shader: string;
  83715. };
  83716. }
  83717. declare module BABYLON {
  83718. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83719. private _grassColors;
  83720. private _groundColor;
  83721. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83722. updateShaderUniforms(): void;
  83723. get grassColors(): BABYLON.Color3[];
  83724. set grassColors(value: BABYLON.Color3[]);
  83725. get groundColor(): BABYLON.Color3;
  83726. set groundColor(value: BABYLON.Color3);
  83727. /**
  83728. * Serializes this grass procedural texture
  83729. * @returns a serialized grass procedural texture object
  83730. */
  83731. serialize(): any;
  83732. /**
  83733. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83734. * @param parsedTexture defines parsed texture data
  83735. * @param scene defines the current scene
  83736. * @param rootUrl defines the root URL containing grass procedural texture information
  83737. * @returns a parsed Grass Procedural BABYLON.Texture
  83738. */
  83739. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83740. }
  83741. }
  83742. declare module BABYLON {
  83743. /** @hidden */
  83744. export var marbleProceduralTexturePixelShader: {
  83745. name: string;
  83746. shader: string;
  83747. };
  83748. }
  83749. declare module BABYLON {
  83750. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83751. private _numberOfTilesHeight;
  83752. private _numberOfTilesWidth;
  83753. private _amplitude;
  83754. private _jointColor;
  83755. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83756. updateShaderUniforms(): void;
  83757. get numberOfTilesHeight(): number;
  83758. set numberOfTilesHeight(value: number);
  83759. get amplitude(): number;
  83760. set amplitude(value: number);
  83761. get numberOfTilesWidth(): number;
  83762. set numberOfTilesWidth(value: number);
  83763. get jointColor(): BABYLON.Color3;
  83764. set jointColor(value: BABYLON.Color3);
  83765. /**
  83766. * Serializes this marble procedural texture
  83767. * @returns a serialized marble procedural texture object
  83768. */
  83769. serialize(): any;
  83770. /**
  83771. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83772. * @param parsedTexture defines parsed texture data
  83773. * @param scene defines the current scene
  83774. * @param rootUrl defines the root URL containing marble procedural texture information
  83775. * @returns a parsed Marble Procedural BABYLON.Texture
  83776. */
  83777. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83778. }
  83779. }
  83780. declare module BABYLON {
  83781. /** @hidden */
  83782. export var normalMapProceduralTexturePixelShader: {
  83783. name: string;
  83784. shader: string;
  83785. };
  83786. }
  83787. declare module BABYLON {
  83788. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83789. private _baseTexture;
  83790. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83791. updateShaderUniforms(): void;
  83792. render(useCameraPostProcess?: boolean): void;
  83793. resize(size: any, generateMipMaps: any): void;
  83794. get baseTexture(): BABYLON.Texture;
  83795. set baseTexture(texture: BABYLON.Texture);
  83796. /**
  83797. * Serializes this normal map procedural texture
  83798. * @returns a serialized normal map procedural texture object
  83799. */
  83800. serialize(): any;
  83801. /**
  83802. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83803. * @param parsedTexture defines parsed texture data
  83804. * @param scene defines the current scene
  83805. * @param rootUrl defines the root URL containing normal map procedural texture information
  83806. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83807. */
  83808. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83809. }
  83810. }
  83811. declare module BABYLON {
  83812. /** @hidden */
  83813. export var perlinNoiseProceduralTexturePixelShader: {
  83814. name: string;
  83815. shader: string;
  83816. };
  83817. }
  83818. declare module BABYLON {
  83819. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83820. time: number;
  83821. timeScale: number;
  83822. translationSpeed: number;
  83823. private _currentTranslation;
  83824. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83825. updateShaderUniforms(): void;
  83826. render(useCameraPostProcess?: boolean): void;
  83827. resize(size: any, generateMipMaps: any): void;
  83828. /**
  83829. * Serializes this perlin noise procedural texture
  83830. * @returns a serialized perlin noise procedural texture object
  83831. */
  83832. serialize(): any;
  83833. /**
  83834. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83835. * @param parsedTexture defines parsed texture data
  83836. * @param scene defines the current scene
  83837. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83838. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83839. */
  83840. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83841. }
  83842. }
  83843. declare module BABYLON {
  83844. /** @hidden */
  83845. export var roadProceduralTexturePixelShader: {
  83846. name: string;
  83847. shader: string;
  83848. };
  83849. }
  83850. declare module BABYLON {
  83851. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83852. private _roadColor;
  83853. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83854. updateShaderUniforms(): void;
  83855. get roadColor(): BABYLON.Color3;
  83856. set roadColor(value: BABYLON.Color3);
  83857. /**
  83858. * Serializes this road procedural texture
  83859. * @returns a serialized road procedural texture object
  83860. */
  83861. serialize(): any;
  83862. /**
  83863. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83864. * @param parsedTexture defines parsed texture data
  83865. * @param scene defines the current scene
  83866. * @param rootUrl defines the root URL containing road procedural texture information
  83867. * @returns a parsed Road Procedural BABYLON.Texture
  83868. */
  83869. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83870. }
  83871. }
  83872. declare module BABYLON {
  83873. /** @hidden */
  83874. export var starfieldProceduralTexturePixelShader: {
  83875. name: string;
  83876. shader: string;
  83877. };
  83878. }
  83879. declare module BABYLON {
  83880. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83881. private _time;
  83882. private _alpha;
  83883. private _beta;
  83884. private _zoom;
  83885. private _formuparam;
  83886. private _stepsize;
  83887. private _tile;
  83888. private _brightness;
  83889. private _darkmatter;
  83890. private _distfading;
  83891. private _saturation;
  83892. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83893. updateShaderUniforms(): void;
  83894. get time(): number;
  83895. set time(value: number);
  83896. get alpha(): number;
  83897. set alpha(value: number);
  83898. get beta(): number;
  83899. set beta(value: number);
  83900. get formuparam(): number;
  83901. set formuparam(value: number);
  83902. get stepsize(): number;
  83903. set stepsize(value: number);
  83904. get zoom(): number;
  83905. set zoom(value: number);
  83906. get tile(): number;
  83907. set tile(value: number);
  83908. get brightness(): number;
  83909. set brightness(value: number);
  83910. get darkmatter(): number;
  83911. set darkmatter(value: number);
  83912. get distfading(): number;
  83913. set distfading(value: number);
  83914. get saturation(): number;
  83915. set saturation(value: number);
  83916. /**
  83917. * Serializes this starfield procedural texture
  83918. * @returns a serialized starfield procedural texture object
  83919. */
  83920. serialize(): any;
  83921. /**
  83922. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83923. * @param parsedTexture defines parsed texture data
  83924. * @param scene defines the current scene
  83925. * @param rootUrl defines the root URL containing startfield procedural texture information
  83926. * @returns a parsed Starfield Procedural BABYLON.Texture
  83927. */
  83928. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83929. }
  83930. }
  83931. declare module BABYLON {
  83932. /** @hidden */
  83933. export var woodProceduralTexturePixelShader: {
  83934. name: string;
  83935. shader: string;
  83936. };
  83937. }
  83938. declare module BABYLON {
  83939. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83940. private _ampScale;
  83941. private _woodColor;
  83942. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83943. updateShaderUniforms(): void;
  83944. get ampScale(): number;
  83945. set ampScale(value: number);
  83946. get woodColor(): BABYLON.Color3;
  83947. set woodColor(value: BABYLON.Color3);
  83948. /**
  83949. * Serializes this wood procedural texture
  83950. * @returns a serialized wood procedural texture object
  83951. */
  83952. serialize(): any;
  83953. /**
  83954. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83955. * @param parsedTexture defines parsed texture data
  83956. * @param scene defines the current scene
  83957. * @param rootUrl defines the root URL containing wood procedural texture information
  83958. * @returns a parsed Wood Procedural BABYLON.Texture
  83959. */
  83960. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83961. }
  83962. }