documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400
  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. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10307. subMeshFaceId: number;
  10308. /** Id of the the submesh that was picked */
  10309. subMeshId: number;
  10310. /** If a sprite was picked, this will be the sprite the pick collided with */
  10311. pickedSprite: Nullable<Sprite>;
  10312. /**
  10313. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10314. */
  10315. originMesh: Nullable<AbstractMesh>;
  10316. /**
  10317. * The ray that was used to perform the picking.
  10318. */
  10319. ray: Nullable<Ray>;
  10320. /**
  10321. * Gets the normal correspodning to the face the pick collided with
  10322. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10323. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10324. * @returns The normal correspodning to the face the pick collided with
  10325. */
  10326. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10327. /**
  10328. * Gets the texture coordinates of where the pick occured
  10329. * @returns the vector containing the coordnates of the texture
  10330. */
  10331. getTextureCoordinates(): Nullable<Vector2>;
  10332. }
  10333. }
  10334. declare module BABYLON {
  10335. /**
  10336. * Class representing a ray with position and direction
  10337. */
  10338. export class Ray {
  10339. /** origin point */
  10340. origin: Vector3;
  10341. /** direction */
  10342. direction: Vector3;
  10343. /** length of the ray */
  10344. length: number;
  10345. private static readonly TmpVector3;
  10346. private _tmpRay;
  10347. /**
  10348. * Creates a new ray
  10349. * @param origin origin point
  10350. * @param direction direction
  10351. * @param length length of the ray
  10352. */
  10353. constructor(
  10354. /** origin point */
  10355. origin: Vector3,
  10356. /** direction */
  10357. direction: Vector3,
  10358. /** length of the ray */
  10359. length?: number);
  10360. /**
  10361. * Checks if the ray intersects a box
  10362. * This does not account for the ray lenght by design to improve perfs.
  10363. * @param minimum bound of the box
  10364. * @param maximum bound of the box
  10365. * @param intersectionTreshold extra extend to be added to the box in all direction
  10366. * @returns if the box was hit
  10367. */
  10368. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10369. /**
  10370. * Checks if the ray intersects a box
  10371. * This does not account for the ray lenght by design to improve perfs.
  10372. * @param box the bounding box to check
  10373. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10374. * @returns if the box was hit
  10375. */
  10376. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10377. /**
  10378. * If the ray hits a sphere
  10379. * @param sphere the bounding sphere to check
  10380. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10381. * @returns true if it hits the sphere
  10382. */
  10383. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10384. /**
  10385. * If the ray hits a triange
  10386. * @param vertex0 triangle vertex
  10387. * @param vertex1 triangle vertex
  10388. * @param vertex2 triangle vertex
  10389. * @returns intersection information if hit
  10390. */
  10391. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10392. /**
  10393. * Checks if ray intersects a plane
  10394. * @param plane the plane to check
  10395. * @returns the distance away it was hit
  10396. */
  10397. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10398. /**
  10399. * Calculate the intercept of a ray on a given axis
  10400. * @param axis to check 'x' | 'y' | 'z'
  10401. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10402. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10403. */
  10404. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10405. /**
  10406. * Checks if ray intersects a mesh
  10407. * @param mesh the mesh to check
  10408. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10409. * @returns picking info of the intersecton
  10410. */
  10411. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10412. /**
  10413. * Checks if ray intersects a mesh
  10414. * @param meshes the meshes to check
  10415. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10416. * @param results array to store result in
  10417. * @returns Array of picking infos
  10418. */
  10419. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10420. private _comparePickingInfo;
  10421. private static smallnum;
  10422. private static rayl;
  10423. /**
  10424. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10425. * @param sega the first point of the segment to test the intersection against
  10426. * @param segb the second point of the segment to test the intersection against
  10427. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10428. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10429. */
  10430. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10431. /**
  10432. * Update the ray from viewport position
  10433. * @param x position
  10434. * @param y y position
  10435. * @param viewportWidth viewport width
  10436. * @param viewportHeight viewport height
  10437. * @param world world matrix
  10438. * @param view view matrix
  10439. * @param projection projection matrix
  10440. * @returns this ray updated
  10441. */
  10442. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10443. /**
  10444. * Creates a ray with origin and direction of 0,0,0
  10445. * @returns the new ray
  10446. */
  10447. static Zero(): Ray;
  10448. /**
  10449. * Creates a new ray from screen space and viewport
  10450. * @param x position
  10451. * @param y y position
  10452. * @param viewportWidth viewport width
  10453. * @param viewportHeight viewport height
  10454. * @param world world matrix
  10455. * @param view view matrix
  10456. * @param projection projection matrix
  10457. * @returns new ray
  10458. */
  10459. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10460. /**
  10461. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10462. * transformed to the given world matrix.
  10463. * @param origin The origin point
  10464. * @param end The end point
  10465. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10466. * @returns the new ray
  10467. */
  10468. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10469. /**
  10470. * Transforms a ray by a matrix
  10471. * @param ray ray to transform
  10472. * @param matrix matrix to apply
  10473. * @returns the resulting new ray
  10474. */
  10475. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10476. /**
  10477. * Transforms a ray by a matrix
  10478. * @param ray ray to transform
  10479. * @param matrix matrix to apply
  10480. * @param result ray to store result in
  10481. */
  10482. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10483. /**
  10484. * Unproject a ray from screen space to object space
  10485. * @param sourceX defines the screen space x coordinate to use
  10486. * @param sourceY defines the screen space y coordinate to use
  10487. * @param viewportWidth defines the current width of the viewport
  10488. * @param viewportHeight defines the current height of the viewport
  10489. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10490. * @param view defines the view matrix to use
  10491. * @param projection defines the projection matrix to use
  10492. */
  10493. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10494. }
  10495. /**
  10496. * Type used to define predicate used to select faces when a mesh intersection is detected
  10497. */
  10498. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10499. interface Scene {
  10500. /** @hidden */
  10501. _tempPickingRay: Nullable<Ray>;
  10502. /** @hidden */
  10503. _cachedRayForTransform: Ray;
  10504. /** @hidden */
  10505. _pickWithRayInverseMatrix: Matrix;
  10506. /** @hidden */
  10507. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10508. /** @hidden */
  10509. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10510. }
  10511. }
  10512. declare module BABYLON {
  10513. /**
  10514. * Groups all the scene component constants in one place to ease maintenance.
  10515. * @hidden
  10516. */
  10517. export class SceneComponentConstants {
  10518. static readonly NAME_EFFECTLAYER: string;
  10519. static readonly NAME_LAYER: string;
  10520. static readonly NAME_LENSFLARESYSTEM: string;
  10521. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10522. static readonly NAME_PARTICLESYSTEM: string;
  10523. static readonly NAME_GAMEPAD: string;
  10524. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10525. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10526. static readonly NAME_DEPTHRENDERER: string;
  10527. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10528. static readonly NAME_SPRITE: string;
  10529. static readonly NAME_OUTLINERENDERER: string;
  10530. static readonly NAME_PROCEDURALTEXTURE: string;
  10531. static readonly NAME_SHADOWGENERATOR: string;
  10532. static readonly NAME_OCTREE: string;
  10533. static readonly NAME_PHYSICSENGINE: string;
  10534. static readonly NAME_AUDIO: string;
  10535. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10536. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10539. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10541. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10543. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10546. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10548. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10549. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10550. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10553. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10554. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10555. static readonly STEP_AFTERRENDER_AUDIO: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10559. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10560. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10561. static readonly STEP_POINTERMOVE_SPRITE: number;
  10562. static readonly STEP_POINTERDOWN_SPRITE: number;
  10563. static readonly STEP_POINTERUP_SPRITE: number;
  10564. }
  10565. /**
  10566. * This represents a scene component.
  10567. *
  10568. * This is used to decouple the dependency the scene is having on the different workloads like
  10569. * layers, post processes...
  10570. */
  10571. export interface ISceneComponent {
  10572. /**
  10573. * The name of the component. Each component must have a unique name.
  10574. */
  10575. name: string;
  10576. /**
  10577. * The scene the component belongs to.
  10578. */
  10579. scene: Scene;
  10580. /**
  10581. * Register the component to one instance of a scene.
  10582. */
  10583. register(): void;
  10584. /**
  10585. * Rebuilds the elements related to this component in case of
  10586. * context lost for instance.
  10587. */
  10588. rebuild(): void;
  10589. /**
  10590. * Disposes the component and the associated ressources.
  10591. */
  10592. dispose(): void;
  10593. }
  10594. /**
  10595. * This represents a SERIALIZABLE scene component.
  10596. *
  10597. * This extends Scene Component to add Serialization methods on top.
  10598. */
  10599. export interface ISceneSerializableComponent extends ISceneComponent {
  10600. /**
  10601. * Adds all the elements from the container to the scene
  10602. * @param container the container holding the elements
  10603. */
  10604. addFromContainer(container: AbstractScene): void;
  10605. /**
  10606. * Removes all the elements in the container from the scene
  10607. * @param container contains the elements to remove
  10608. * @param dispose if the removed element should be disposed (default: false)
  10609. */
  10610. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10611. /**
  10612. * Serializes the component data to the specified json object
  10613. * @param serializationObject The object to serialize to
  10614. */
  10615. serialize(serializationObject: any): void;
  10616. }
  10617. /**
  10618. * Strong typing of a Mesh related stage step action
  10619. */
  10620. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10621. /**
  10622. * Strong typing of a Evaluate Sub Mesh related stage step action
  10623. */
  10624. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10625. /**
  10626. * Strong typing of a Active Mesh related stage step action
  10627. */
  10628. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10629. /**
  10630. * Strong typing of a Camera related stage step action
  10631. */
  10632. export type CameraStageAction = (camera: Camera) => void;
  10633. /**
  10634. * Strong typing of a Camera Frame buffer related stage step action
  10635. */
  10636. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10637. /**
  10638. * Strong typing of a Render Target related stage step action
  10639. */
  10640. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10641. /**
  10642. * Strong typing of a RenderingGroup related stage step action
  10643. */
  10644. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10645. /**
  10646. * Strong typing of a Mesh Render related stage step action
  10647. */
  10648. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10649. /**
  10650. * Strong typing of a simple stage step action
  10651. */
  10652. export type SimpleStageAction = () => void;
  10653. /**
  10654. * Strong typing of a render target action.
  10655. */
  10656. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10657. /**
  10658. * Strong typing of a pointer move action.
  10659. */
  10660. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10661. /**
  10662. * Strong typing of a pointer up/down action.
  10663. */
  10664. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10665. /**
  10666. * Representation of a stage in the scene (Basically a list of ordered steps)
  10667. * @hidden
  10668. */
  10669. export class Stage<T extends Function> extends Array<{
  10670. index: number;
  10671. component: ISceneComponent;
  10672. action: T;
  10673. }> {
  10674. /**
  10675. * Hide ctor from the rest of the world.
  10676. * @param items The items to add.
  10677. */
  10678. private constructor();
  10679. /**
  10680. * Creates a new Stage.
  10681. * @returns A new instance of a Stage
  10682. */
  10683. static Create<T extends Function>(): Stage<T>;
  10684. /**
  10685. * Registers a step in an ordered way in the targeted stage.
  10686. * @param index Defines the position to register the step in
  10687. * @param component Defines the component attached to the step
  10688. * @param action Defines the action to launch during the step
  10689. */
  10690. registerStep(index: number, component: ISceneComponent, action: T): void;
  10691. /**
  10692. * Clears all the steps from the stage.
  10693. */
  10694. clear(): void;
  10695. }
  10696. }
  10697. declare module BABYLON {
  10698. interface Scene {
  10699. /** @hidden */
  10700. _pointerOverSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _pickedDownSprite: Nullable<Sprite>;
  10703. /** @hidden */
  10704. _tempSpritePickingRay: Nullable<Ray>;
  10705. /**
  10706. * All of the sprite managers added to this scene
  10707. * @see http://doc.babylonjs.com/babylon101/sprites
  10708. */
  10709. spriteManagers: Array<ISpriteManager>;
  10710. /**
  10711. * An event triggered when sprites rendering is about to start
  10712. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10713. */
  10714. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10715. /**
  10716. * An event triggered when sprites rendering is done
  10717. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10718. */
  10719. onAfterSpritesRenderingObservable: Observable<Scene>;
  10720. /** @hidden */
  10721. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10722. /** Launch a ray to try to pick a sprite in the scene
  10723. * @param x position on screen
  10724. * @param y position on screen
  10725. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10726. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10727. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10728. * @returns a PickingInfo
  10729. */
  10730. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10731. /** Use the given ray to pick a sprite in the scene
  10732. * @param ray The ray (in world space) to use to pick meshes
  10733. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10734. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10735. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10736. * @returns a PickingInfo
  10737. */
  10738. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10739. /** @hidden */
  10740. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10741. /** Launch a ray to try to pick sprites in the scene
  10742. * @param x position on screen
  10743. * @param y position on screen
  10744. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10745. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10746. * @returns a PickingInfo array
  10747. */
  10748. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10749. /** Use the given ray to pick sprites in the scene
  10750. * @param ray The ray (in world space) to use to pick meshes
  10751. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10752. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10753. * @returns a PickingInfo array
  10754. */
  10755. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10756. /**
  10757. * Force the sprite under the pointer
  10758. * @param sprite defines the sprite to use
  10759. */
  10760. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10761. /**
  10762. * Gets the sprite under the pointer
  10763. * @returns a Sprite or null if no sprite is under the pointer
  10764. */
  10765. getPointerOverSprite(): Nullable<Sprite>;
  10766. }
  10767. /**
  10768. * Defines the sprite scene component responsible to manage sprites
  10769. * in a given scene.
  10770. */
  10771. export class SpriteSceneComponent implements ISceneComponent {
  10772. /**
  10773. * The component name helpfull to identify the component in the list of scene components.
  10774. */
  10775. readonly name: string;
  10776. /**
  10777. * The scene the component belongs to.
  10778. */
  10779. scene: Scene;
  10780. /** @hidden */
  10781. private _spritePredicate;
  10782. /**
  10783. * Creates a new instance of the component for the given scene
  10784. * @param scene Defines the scene to register the component in
  10785. */
  10786. constructor(scene: Scene);
  10787. /**
  10788. * Registers the component in a given scene
  10789. */
  10790. register(): void;
  10791. /**
  10792. * Rebuilds the elements related to this component in case of
  10793. * context lost for instance.
  10794. */
  10795. rebuild(): void;
  10796. /**
  10797. * Disposes the component and the associated ressources.
  10798. */
  10799. dispose(): void;
  10800. private _pickSpriteButKeepRay;
  10801. private _pointerMove;
  10802. private _pointerDown;
  10803. private _pointerUp;
  10804. }
  10805. }
  10806. declare module BABYLON {
  10807. /** @hidden */
  10808. export var fogFragmentDeclaration: {
  10809. name: string;
  10810. shader: string;
  10811. };
  10812. }
  10813. declare module BABYLON {
  10814. /** @hidden */
  10815. export var fogFragment: {
  10816. name: string;
  10817. shader: string;
  10818. };
  10819. }
  10820. declare module BABYLON {
  10821. /** @hidden */
  10822. export var spritesPixelShader: {
  10823. name: string;
  10824. shader: string;
  10825. };
  10826. }
  10827. declare module BABYLON {
  10828. /** @hidden */
  10829. export var fogVertexDeclaration: {
  10830. name: string;
  10831. shader: string;
  10832. };
  10833. }
  10834. declare module BABYLON {
  10835. /** @hidden */
  10836. export var spritesVertexShader: {
  10837. name: string;
  10838. shader: string;
  10839. };
  10840. }
  10841. declare module BABYLON {
  10842. /**
  10843. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10844. */
  10845. export interface ISpriteManager extends IDisposable {
  10846. /**
  10847. * Gets manager's name
  10848. */
  10849. name: string;
  10850. /**
  10851. * Restricts the camera to viewing objects with the same layerMask.
  10852. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10853. */
  10854. layerMask: number;
  10855. /**
  10856. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10857. */
  10858. isPickable: boolean;
  10859. /**
  10860. * Gets the hosting scene
  10861. */
  10862. scene: Scene;
  10863. /**
  10864. * Specifies the rendering group id for this mesh (0 by default)
  10865. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10866. */
  10867. renderingGroupId: number;
  10868. /**
  10869. * Defines the list of sprites managed by the manager.
  10870. */
  10871. sprites: Array<Sprite>;
  10872. /**
  10873. * Gets or sets the spritesheet texture
  10874. */
  10875. texture: Texture;
  10876. /** Defines the default width of a cell in the spritesheet */
  10877. cellWidth: number;
  10878. /** Defines the default height of a cell in the spritesheet */
  10879. cellHeight: number;
  10880. /**
  10881. * Tests the intersection of a sprite with a specific ray.
  10882. * @param ray The ray we are sending to test the collision
  10883. * @param camera The camera space we are sending rays in
  10884. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10885. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10886. * @returns picking info or null.
  10887. */
  10888. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10889. /**
  10890. * Intersects the sprites with a ray
  10891. * @param ray defines the ray to intersect with
  10892. * @param camera defines the current active camera
  10893. * @param predicate defines a predicate used to select candidate sprites
  10894. * @returns null if no hit or a PickingInfo array
  10895. */
  10896. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10897. /**
  10898. * Renders the list of sprites on screen.
  10899. */
  10900. render(): void;
  10901. }
  10902. /**
  10903. * Class used to manage multiple sprites on the same spritesheet
  10904. * @see http://doc.babylonjs.com/babylon101/sprites
  10905. */
  10906. export class SpriteManager implements ISpriteManager {
  10907. /** defines the manager's name */
  10908. name: string;
  10909. /** Define the Url to load snippets */
  10910. static SnippetUrl: string;
  10911. /** Snippet ID if the manager was created from the snippet server */
  10912. snippetId: string;
  10913. /** Gets the list of sprites */
  10914. sprites: Sprite[];
  10915. /** Gets or sets the rendering group id (0 by default) */
  10916. renderingGroupId: number;
  10917. /** Gets or sets camera layer mask */
  10918. layerMask: number;
  10919. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10920. fogEnabled: boolean;
  10921. /** Gets or sets a boolean indicating if the sprites are pickable */
  10922. isPickable: boolean;
  10923. /** Defines the default width of a cell in the spritesheet */
  10924. cellWidth: number;
  10925. /** Defines the default height of a cell in the spritesheet */
  10926. cellHeight: number;
  10927. /** Associative array from JSON sprite data file */
  10928. private _cellData;
  10929. /** Array of sprite names from JSON sprite data file */
  10930. private _spriteMap;
  10931. /** True when packed cell data from JSON file is ready*/
  10932. private _packedAndReady;
  10933. private _textureContent;
  10934. /**
  10935. * An event triggered when the manager is disposed.
  10936. */
  10937. onDisposeObservable: Observable<SpriteManager>;
  10938. private _onDisposeObserver;
  10939. /**
  10940. * Callback called when the manager is disposed
  10941. */
  10942. set onDispose(callback: () => void);
  10943. private _capacity;
  10944. private _fromPacked;
  10945. private _spriteTexture;
  10946. private _epsilon;
  10947. private _scene;
  10948. private _vertexData;
  10949. private _buffer;
  10950. private _vertexBuffers;
  10951. private _indexBuffer;
  10952. private _effectBase;
  10953. private _effectFog;
  10954. /**
  10955. * Gets or sets the unique id of the sprite
  10956. */
  10957. uniqueId: number;
  10958. /**
  10959. * Gets the array of sprites
  10960. */
  10961. get children(): Sprite[];
  10962. /**
  10963. * Gets the hosting scene
  10964. */
  10965. get scene(): Scene;
  10966. /**
  10967. * Gets the capacity of the manager
  10968. */
  10969. get capacity(): number;
  10970. /**
  10971. * Gets or sets the spritesheet texture
  10972. */
  10973. get texture(): Texture;
  10974. set texture(value: Texture);
  10975. private _blendMode;
  10976. /**
  10977. * Blend mode use to render the particle, it can be any of
  10978. * the static Constants.ALPHA_x properties provided in this class.
  10979. * Default value is Constants.ALPHA_COMBINE
  10980. */
  10981. get blendMode(): number;
  10982. set blendMode(blendMode: number);
  10983. /** Disables writing to the depth buffer when rendering the sprites.
  10984. * It can be handy to disable depth writing when using textures without alpha channel
  10985. * and setting some specific blend modes.
  10986. */
  10987. disableDepthWrite: boolean;
  10988. /**
  10989. * Creates a new sprite manager
  10990. * @param name defines the manager's name
  10991. * @param imgUrl defines the sprite sheet url
  10992. * @param capacity defines the maximum allowed number of sprites
  10993. * @param cellSize defines the size of a sprite cell
  10994. * @param scene defines the hosting scene
  10995. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10996. * @param samplingMode defines the smapling mode to use with spritesheet
  10997. * @param fromPacked set to false; do not alter
  10998. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10999. */
  11000. constructor(
  11001. /** defines the manager's name */
  11002. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11003. /**
  11004. * Returns the string "SpriteManager"
  11005. * @returns "SpriteManager"
  11006. */
  11007. getClassName(): string;
  11008. private _makePacked;
  11009. private _appendSpriteVertex;
  11010. private _checkTextureAlpha;
  11011. /**
  11012. * Intersects the sprites with a ray
  11013. * @param ray defines the ray to intersect with
  11014. * @param camera defines the current active camera
  11015. * @param predicate defines a predicate used to select candidate sprites
  11016. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11017. * @returns null if no hit or a PickingInfo
  11018. */
  11019. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11020. /**
  11021. * Intersects the sprites with a ray
  11022. * @param ray defines the ray to intersect with
  11023. * @param camera defines the current active camera
  11024. * @param predicate defines a predicate used to select candidate sprites
  11025. * @returns null if no hit or a PickingInfo array
  11026. */
  11027. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11028. /**
  11029. * Render all child sprites
  11030. */
  11031. render(): void;
  11032. /**
  11033. * Release associated resources
  11034. */
  11035. dispose(): void;
  11036. /**
  11037. * Serializes the sprite manager to a JSON object
  11038. * @param serializeTexture defines if the texture must be serialized as well
  11039. * @returns the JSON object
  11040. */
  11041. serialize(serializeTexture?: boolean): any;
  11042. /**
  11043. * Parses a JSON object to create a new sprite manager.
  11044. * @param parsedManager The JSON object to parse
  11045. * @param scene The scene to create the sprite managerin
  11046. * @param rootUrl The root url to use to load external dependencies like texture
  11047. * @returns the new sprite manager
  11048. */
  11049. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11050. /**
  11051. * Creates a sprite manager from a snippet saved in a remote file
  11052. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11053. * @param url defines the url to load from
  11054. * @param scene defines the hosting scene
  11055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11056. * @returns a promise that will resolve to the new sprite manager
  11057. */
  11058. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11059. /**
  11060. * Creates a sprite manager from a snippet saved by the sprite editor
  11061. * @param snippetId defines the snippet to load
  11062. * @param scene defines the hosting scene
  11063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11064. * @returns a promise that will resolve to the new sprite manager
  11065. */
  11066. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11067. }
  11068. }
  11069. declare module BABYLON {
  11070. /** Interface used by value gradients (color, factor, ...) */
  11071. export interface IValueGradient {
  11072. /**
  11073. * Gets or sets the gradient value (between 0 and 1)
  11074. */
  11075. gradient: number;
  11076. }
  11077. /** Class used to store color4 gradient */
  11078. export class ColorGradient implements IValueGradient {
  11079. /**
  11080. * Gets or sets the gradient value (between 0 and 1)
  11081. */
  11082. gradient: number;
  11083. /**
  11084. * Gets or sets first associated color
  11085. */
  11086. color1: Color4;
  11087. /**
  11088. * Gets or sets second associated color
  11089. */
  11090. color2?: Color4 | undefined;
  11091. /**
  11092. * Creates a new color4 gradient
  11093. * @param gradient gets or sets the gradient value (between 0 and 1)
  11094. * @param color1 gets or sets first associated color
  11095. * @param color2 gets or sets first second color
  11096. */
  11097. constructor(
  11098. /**
  11099. * Gets or sets the gradient value (between 0 and 1)
  11100. */
  11101. gradient: number,
  11102. /**
  11103. * Gets or sets first associated color
  11104. */
  11105. color1: Color4,
  11106. /**
  11107. * Gets or sets second associated color
  11108. */
  11109. color2?: Color4 | undefined);
  11110. /**
  11111. * Will get a color picked randomly between color1 and color2.
  11112. * If color2 is undefined then color1 will be used
  11113. * @param result defines the target Color4 to store the result in
  11114. */
  11115. getColorToRef(result: Color4): void;
  11116. }
  11117. /** Class used to store color 3 gradient */
  11118. export class Color3Gradient implements IValueGradient {
  11119. /**
  11120. * Gets or sets the gradient value (between 0 and 1)
  11121. */
  11122. gradient: number;
  11123. /**
  11124. * Gets or sets the associated color
  11125. */
  11126. color: Color3;
  11127. /**
  11128. * Creates a new color3 gradient
  11129. * @param gradient gets or sets the gradient value (between 0 and 1)
  11130. * @param color gets or sets associated color
  11131. */
  11132. constructor(
  11133. /**
  11134. * Gets or sets the gradient value (between 0 and 1)
  11135. */
  11136. gradient: number,
  11137. /**
  11138. * Gets or sets the associated color
  11139. */
  11140. color: Color3);
  11141. }
  11142. /** Class used to store factor gradient */
  11143. export class FactorGradient implements IValueGradient {
  11144. /**
  11145. * Gets or sets the gradient value (between 0 and 1)
  11146. */
  11147. gradient: number;
  11148. /**
  11149. * Gets or sets first associated factor
  11150. */
  11151. factor1: number;
  11152. /**
  11153. * Gets or sets second associated factor
  11154. */
  11155. factor2?: number | undefined;
  11156. /**
  11157. * Creates a new factor gradient
  11158. * @param gradient gets or sets the gradient value (between 0 and 1)
  11159. * @param factor1 gets or sets first associated factor
  11160. * @param factor2 gets or sets second associated factor
  11161. */
  11162. constructor(
  11163. /**
  11164. * Gets or sets the gradient value (between 0 and 1)
  11165. */
  11166. gradient: number,
  11167. /**
  11168. * Gets or sets first associated factor
  11169. */
  11170. factor1: number,
  11171. /**
  11172. * Gets or sets second associated factor
  11173. */
  11174. factor2?: number | undefined);
  11175. /**
  11176. * Will get a number picked randomly between factor1 and factor2.
  11177. * If factor2 is undefined then factor1 will be used
  11178. * @returns the picked number
  11179. */
  11180. getFactor(): number;
  11181. }
  11182. /**
  11183. * Helper used to simplify some generic gradient tasks
  11184. */
  11185. export class GradientHelper {
  11186. /**
  11187. * Gets the current gradient from an array of IValueGradient
  11188. * @param ratio defines the current ratio to get
  11189. * @param gradients defines the array of IValueGradient
  11190. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11191. */
  11192. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11193. }
  11194. }
  11195. declare module BABYLON {
  11196. interface ThinEngine {
  11197. /**
  11198. * Creates a dynamic texture
  11199. * @param width defines the width of the texture
  11200. * @param height defines the height of the texture
  11201. * @param generateMipMaps defines if the engine should generate the mip levels
  11202. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11203. * @returns the dynamic texture inside an InternalTexture
  11204. */
  11205. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11206. /**
  11207. * Update the content of a dynamic texture
  11208. * @param texture defines the texture to update
  11209. * @param canvas defines the canvas containing the source
  11210. * @param invertY defines if data must be stored with Y axis inverted
  11211. * @param premulAlpha defines if alpha is stored as premultiplied
  11212. * @param format defines the format of the data
  11213. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11214. */
  11215. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11216. }
  11217. }
  11218. declare module BABYLON {
  11219. /**
  11220. * Helper class used to generate a canvas to manipulate images
  11221. */
  11222. export class CanvasGenerator {
  11223. /**
  11224. * Create a new canvas (or offscreen canvas depending on the context)
  11225. * @param width defines the expected width
  11226. * @param height defines the expected height
  11227. * @return a new canvas or offscreen canvas
  11228. */
  11229. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11230. }
  11231. }
  11232. declare module BABYLON {
  11233. /**
  11234. * A class extending Texture allowing drawing on a texture
  11235. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11236. */
  11237. export class DynamicTexture extends Texture {
  11238. private _generateMipMaps;
  11239. private _canvas;
  11240. private _context;
  11241. /**
  11242. * Creates a DynamicTexture
  11243. * @param name defines the name of the texture
  11244. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  11245. * @param scene defines the scene where you want the texture
  11246. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11247. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11248. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11249. */
  11250. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11251. /**
  11252. * Get the current class name of the texture useful for serialization or dynamic coding.
  11253. * @returns "DynamicTexture"
  11254. */
  11255. getClassName(): string;
  11256. /**
  11257. * Gets the current state of canRescale
  11258. */
  11259. get canRescale(): boolean;
  11260. private _recreate;
  11261. /**
  11262. * Scales the texture
  11263. * @param ratio the scale factor to apply to both width and height
  11264. */
  11265. scale(ratio: number): void;
  11266. /**
  11267. * Resizes the texture
  11268. * @param width the new width
  11269. * @param height the new height
  11270. */
  11271. scaleTo(width: number, height: number): void;
  11272. /**
  11273. * Gets the context of the canvas used by the texture
  11274. * @returns the canvas context of the dynamic texture
  11275. */
  11276. getContext(): CanvasRenderingContext2D;
  11277. /**
  11278. * Clears the texture
  11279. */
  11280. clear(): void;
  11281. /**
  11282. * Updates the texture
  11283. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11284. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11285. */
  11286. update(invertY?: boolean, premulAlpha?: boolean): void;
  11287. /**
  11288. * Draws text onto the texture
  11289. * @param text defines the text to be drawn
  11290. * @param x defines the placement of the text from the left
  11291. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11292. * @param font defines the font to be used with font-style, font-size, font-name
  11293. * @param color defines the color used for the text
  11294. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11295. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11296. * @param update defines whether texture is immediately update (default is true)
  11297. */
  11298. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11299. /**
  11300. * Clones the texture
  11301. * @returns the clone of the texture.
  11302. */
  11303. clone(): DynamicTexture;
  11304. /**
  11305. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11306. * @returns a serialized dynamic texture object
  11307. */
  11308. serialize(): any;
  11309. /** @hidden */
  11310. _rebuild(): void;
  11311. }
  11312. }
  11313. declare module BABYLON {
  11314. interface ThinEngine {
  11315. /**
  11316. * Creates a raw texture
  11317. * @param data defines the data to store in the texture
  11318. * @param width defines the width of the texture
  11319. * @param height defines the height of the texture
  11320. * @param format defines the format of the data
  11321. * @param generateMipMaps defines if the engine should generate the mip levels
  11322. * @param invertY defines if data must be stored with Y axis inverted
  11323. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11324. * @param compression defines the compression used (null by default)
  11325. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11326. * @returns the raw texture inside an InternalTexture
  11327. */
  11328. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11329. /**
  11330. * Update a raw texture
  11331. * @param texture defines the texture to update
  11332. * @param data defines the data to store in the texture
  11333. * @param format defines the format of the data
  11334. * @param invertY defines if data must be stored with Y axis inverted
  11335. */
  11336. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11337. /**
  11338. * Update a raw texture
  11339. * @param texture defines the texture to update
  11340. * @param data defines the data to store in the texture
  11341. * @param format defines the format of the data
  11342. * @param invertY defines if data must be stored with Y axis inverted
  11343. * @param compression defines the compression used (null by default)
  11344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11345. */
  11346. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11347. /**
  11348. * Creates a new raw cube texture
  11349. * @param data defines the array of data to use to create each face
  11350. * @param size defines the size of the textures
  11351. * @param format defines the format of the data
  11352. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11353. * @param generateMipMaps defines if the engine should generate the mip levels
  11354. * @param invertY defines if data must be stored with Y axis inverted
  11355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11356. * @param compression defines the compression used (null by default)
  11357. * @returns the cube texture as an InternalTexture
  11358. */
  11359. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11360. /**
  11361. * Update a raw cube texture
  11362. * @param texture defines the texture to udpdate
  11363. * @param data defines the data to store
  11364. * @param format defines the data format
  11365. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11366. * @param invertY defines if data must be stored with Y axis inverted
  11367. */
  11368. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11369. /**
  11370. * Update a raw cube texture
  11371. * @param texture defines the texture to udpdate
  11372. * @param data defines the data to store
  11373. * @param format defines the data format
  11374. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11375. * @param invertY defines if data must be stored with Y axis inverted
  11376. * @param compression defines the compression used (null by default)
  11377. */
  11378. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11379. /**
  11380. * Update a raw cube texture
  11381. * @param texture defines the texture to udpdate
  11382. * @param data defines the data to store
  11383. * @param format defines the data format
  11384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11385. * @param invertY defines if data must be stored with Y axis inverted
  11386. * @param compression defines the compression used (null by default)
  11387. * @param level defines which level of the texture to update
  11388. */
  11389. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11390. /**
  11391. * Creates a new raw cube texture from a specified url
  11392. * @param url defines the url where the data is located
  11393. * @param scene defines the current scene
  11394. * @param size defines the size of the textures
  11395. * @param format defines the format of the data
  11396. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11397. * @param noMipmap defines if the engine should avoid generating the mip levels
  11398. * @param callback defines a callback used to extract texture data from loaded data
  11399. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11400. * @param onLoad defines a callback called when texture is loaded
  11401. * @param onError defines a callback called if there is an error
  11402. * @returns the cube texture as an InternalTexture
  11403. */
  11404. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11405. /**
  11406. * Creates a new raw cube texture from a specified url
  11407. * @param url defines the url where the data is located
  11408. * @param scene defines the current scene
  11409. * @param size defines the size of the textures
  11410. * @param format defines the format of the data
  11411. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11412. * @param noMipmap defines if the engine should avoid generating the mip levels
  11413. * @param callback defines a callback used to extract texture data from loaded data
  11414. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11415. * @param onLoad defines a callback called when texture is loaded
  11416. * @param onError defines a callback called if there is an error
  11417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11418. * @param invertY defines if data must be stored with Y axis inverted
  11419. * @returns the cube texture as an InternalTexture
  11420. */
  11421. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11422. /**
  11423. * Creates a new raw 3D texture
  11424. * @param data defines the data used to create the texture
  11425. * @param width defines the width of the texture
  11426. * @param height defines the height of the texture
  11427. * @param depth defines the depth of the texture
  11428. * @param format defines the format of the texture
  11429. * @param generateMipMaps defines if the engine must generate mip levels
  11430. * @param invertY defines if data must be stored with Y axis inverted
  11431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11432. * @param compression defines the compressed used (can be null)
  11433. * @param textureType defines the compressed used (can be null)
  11434. * @returns a new raw 3D texture (stored in an InternalTexture)
  11435. */
  11436. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11437. /**
  11438. * Update a raw 3D texture
  11439. * @param texture defines the texture to update
  11440. * @param data defines the data to store
  11441. * @param format defines the data format
  11442. * @param invertY defines if data must be stored with Y axis inverted
  11443. */
  11444. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11445. /**
  11446. * Update a raw 3D texture
  11447. * @param texture defines the texture to update
  11448. * @param data defines the data to store
  11449. * @param format defines the data format
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @param compression defines the used compression (can be null)
  11452. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11453. */
  11454. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11455. /**
  11456. * Creates a new raw 2D array texture
  11457. * @param data defines the data used to create the texture
  11458. * @param width defines the width of the texture
  11459. * @param height defines the height of the texture
  11460. * @param depth defines the number of layers of the texture
  11461. * @param format defines the format of the texture
  11462. * @param generateMipMaps defines if the engine must generate mip levels
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11465. * @param compression defines the compressed used (can be null)
  11466. * @param textureType defines the compressed used (can be null)
  11467. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11468. */
  11469. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11470. /**
  11471. * Update a raw 2D array texture
  11472. * @param texture defines the texture to update
  11473. * @param data defines the data to store
  11474. * @param format defines the data format
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. */
  11477. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11478. /**
  11479. * Update a raw 2D array texture
  11480. * @param texture defines the texture to update
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @param compression defines the used compression (can be null)
  11485. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11486. */
  11487. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11488. }
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Raw texture can help creating a texture directly from an array of data.
  11493. * This can be super useful if you either get the data from an uncompressed source or
  11494. * if you wish to create your texture pixel by pixel.
  11495. */
  11496. export class RawTexture extends Texture {
  11497. /**
  11498. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11499. */
  11500. format: number;
  11501. /**
  11502. * Instantiates a new RawTexture.
  11503. * Raw texture can help creating a texture directly from an array of data.
  11504. * This can be super useful if you either get the data from an uncompressed source or
  11505. * if you wish to create your texture pixel by pixel.
  11506. * @param data define the array of data to use to create the texture
  11507. * @param width define the width of the texture
  11508. * @param height define the height of the texture
  11509. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11510. * @param scene define the scene the texture belongs to
  11511. * @param generateMipMaps define whether mip maps should be generated or not
  11512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11514. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11515. */
  11516. constructor(data: ArrayBufferView, width: number, height: number,
  11517. /**
  11518. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11519. */
  11520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11521. /**
  11522. * Updates the texture underlying data.
  11523. * @param data Define the new data of the texture
  11524. */
  11525. update(data: ArrayBufferView): void;
  11526. /**
  11527. * Creates a luminance texture from some data.
  11528. * @param data Define the texture data
  11529. * @param width Define the width of the texture
  11530. * @param height Define the height of the texture
  11531. * @param scene Define the scene the texture belongs to
  11532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11535. * @returns the luminance texture
  11536. */
  11537. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11538. /**
  11539. * Creates a luminance alpha texture from some data.
  11540. * @param data Define the texture data
  11541. * @param width Define the width of the texture
  11542. * @param height Define the height of the texture
  11543. * @param scene Define the scene the texture belongs to
  11544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11547. * @returns the luminance alpha texture
  11548. */
  11549. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11550. /**
  11551. * Creates an alpha texture from some data.
  11552. * @param data Define the texture data
  11553. * @param width Define the width of the texture
  11554. * @param height Define the height of the texture
  11555. * @param scene Define the scene the texture belongs to
  11556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11559. * @returns the alpha texture
  11560. */
  11561. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11562. /**
  11563. * Creates a RGB texture from some data.
  11564. * @param data Define the texture data
  11565. * @param width Define the width of the texture
  11566. * @param height Define the height of the texture
  11567. * @param scene Define the scene the texture belongs to
  11568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11572. * @returns the RGB alpha texture
  11573. */
  11574. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11575. /**
  11576. * Creates a RGBA texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param scene Define the scene the texture belongs to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. * @returns the RGBA texture
  11586. */
  11587. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11588. /**
  11589. * Creates a R texture from some data.
  11590. * @param data Define the texture data
  11591. * @param width Define the width of the texture
  11592. * @param height Define the height of the texture
  11593. * @param scene Define the scene the texture belongs to
  11594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11598. * @returns the R texture
  11599. */
  11600. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11601. }
  11602. }
  11603. declare module BABYLON {
  11604. interface AbstractScene {
  11605. /**
  11606. * The list of procedural textures added to the scene
  11607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11608. */
  11609. proceduralTextures: Array<ProceduralTexture>;
  11610. }
  11611. /**
  11612. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11613. * in a given scene.
  11614. */
  11615. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11616. /**
  11617. * The component name helpfull to identify the component in the list of scene components.
  11618. */
  11619. readonly name: string;
  11620. /**
  11621. * The scene the component belongs to.
  11622. */
  11623. scene: Scene;
  11624. /**
  11625. * Creates a new instance of the component for the given scene
  11626. * @param scene Defines the scene to register the component in
  11627. */
  11628. constructor(scene: Scene);
  11629. /**
  11630. * Registers the component in a given scene
  11631. */
  11632. register(): void;
  11633. /**
  11634. * Rebuilds the elements related to this component in case of
  11635. * context lost for instance.
  11636. */
  11637. rebuild(): void;
  11638. /**
  11639. * Disposes the component and the associated ressources.
  11640. */
  11641. dispose(): void;
  11642. private _beforeClear;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. interface ThinEngine {
  11647. /**
  11648. * Creates a new render target cube texture
  11649. * @param size defines the size of the texture
  11650. * @param options defines the options used to create the texture
  11651. * @returns a new render target cube texture stored in an InternalTexture
  11652. */
  11653. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11654. }
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var proceduralVertexShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /**
  11665. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11666. * This is the base class of any Procedural texture and contains most of the shareable code.
  11667. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11668. */
  11669. export class ProceduralTexture extends Texture {
  11670. isCube: boolean;
  11671. /**
  11672. * Define if the texture is enabled or not (disabled texture will not render)
  11673. */
  11674. isEnabled: boolean;
  11675. /**
  11676. * Define if the texture must be cleared before rendering (default is true)
  11677. */
  11678. autoClear: boolean;
  11679. /**
  11680. * Callback called when the texture is generated
  11681. */
  11682. onGenerated: () => void;
  11683. /**
  11684. * Event raised when the texture is generated
  11685. */
  11686. onGeneratedObservable: Observable<ProceduralTexture>;
  11687. /** @hidden */
  11688. _generateMipMaps: boolean;
  11689. /** @hidden **/
  11690. _effect: Effect;
  11691. /** @hidden */
  11692. _textures: {
  11693. [key: string]: Texture;
  11694. };
  11695. /** @hidden */
  11696. protected _fallbackTexture: Nullable<Texture>;
  11697. private _size;
  11698. private _currentRefreshId;
  11699. private _frameId;
  11700. private _refreshRate;
  11701. private _vertexBuffers;
  11702. private _indexBuffer;
  11703. private _uniforms;
  11704. private _samplers;
  11705. private _fragment;
  11706. private _floats;
  11707. private _ints;
  11708. private _floatsArrays;
  11709. private _colors3;
  11710. private _colors4;
  11711. private _vectors2;
  11712. private _vectors3;
  11713. private _matrices;
  11714. private _fallbackTextureUsed;
  11715. private _fullEngine;
  11716. private _cachedDefines;
  11717. private _contentUpdateId;
  11718. private _contentData;
  11719. /**
  11720. * Instantiates a new procedural texture.
  11721. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11722. * This is the base class of any Procedural texture and contains most of the shareable code.
  11723. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11724. * @param name Define the name of the texture
  11725. * @param size Define the size of the texture to create
  11726. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11727. * @param scene Define the scene the texture belongs to
  11728. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11729. * @param generateMipMaps Define if the texture should creates mip maps or not
  11730. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11731. */
  11732. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11733. /**
  11734. * The effect that is created when initializing the post process.
  11735. * @returns The created effect corresponding the the postprocess.
  11736. */
  11737. getEffect(): Effect;
  11738. /**
  11739. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11740. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11741. */
  11742. getContent(): Nullable<ArrayBufferView>;
  11743. private _createIndexBuffer;
  11744. /** @hidden */
  11745. _rebuild(): void;
  11746. /**
  11747. * Resets the texture in order to recreate its associated resources.
  11748. * This can be called in case of context loss
  11749. */
  11750. reset(): void;
  11751. protected _getDefines(): string;
  11752. /**
  11753. * Is the texture ready to be used ? (rendered at least once)
  11754. * @returns true if ready, otherwise, false.
  11755. */
  11756. isReady(): boolean;
  11757. /**
  11758. * Resets the refresh counter of the texture and start bak from scratch.
  11759. * Could be useful to regenerate the texture if it is setup to render only once.
  11760. */
  11761. resetRefreshCounter(): void;
  11762. /**
  11763. * Set the fragment shader to use in order to render the texture.
  11764. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11765. */
  11766. setFragment(fragment: any): void;
  11767. /**
  11768. * Define the refresh rate of the texture or the rendering frequency.
  11769. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11770. */
  11771. get refreshRate(): number;
  11772. set refreshRate(value: number);
  11773. /** @hidden */
  11774. _shouldRender(): boolean;
  11775. /**
  11776. * Get the size the texture is rendering at.
  11777. * @returns the size (texture is always squared)
  11778. */
  11779. getRenderSize(): number;
  11780. /**
  11781. * Resize the texture to new value.
  11782. * @param size Define the new size the texture should have
  11783. * @param generateMipMaps Define whether the new texture should create mip maps
  11784. */
  11785. resize(size: number, generateMipMaps: boolean): void;
  11786. private _checkUniform;
  11787. /**
  11788. * Set a texture in the shader program used to render.
  11789. * @param name Define the name of the uniform samplers as defined in the shader
  11790. * @param texture Define the texture to bind to this sampler
  11791. * @return the texture itself allowing "fluent" like uniform updates
  11792. */
  11793. setTexture(name: string, texture: Texture): ProceduralTexture;
  11794. /**
  11795. * Set a float in the shader.
  11796. * @param name Define the name of the uniform as defined in the shader
  11797. * @param value Define the value to give to the uniform
  11798. * @return the texture itself allowing "fluent" like uniform updates
  11799. */
  11800. setFloat(name: string, value: number): ProceduralTexture;
  11801. /**
  11802. * Set a int in the shader.
  11803. * @param name Define the name of the uniform as defined in the shader
  11804. * @param value Define the value to give to the uniform
  11805. * @return the texture itself allowing "fluent" like uniform updates
  11806. */
  11807. setInt(name: string, value: number): ProceduralTexture;
  11808. /**
  11809. * Set an array of floats in the shader.
  11810. * @param name Define the name of the uniform as defined in the shader
  11811. * @param value Define the value to give to the uniform
  11812. * @return the texture itself allowing "fluent" like uniform updates
  11813. */
  11814. setFloats(name: string, value: number[]): ProceduralTexture;
  11815. /**
  11816. * Set a vec3 in the shader from a Color3.
  11817. * @param name Define the name of the uniform as defined in the shader
  11818. * @param value Define the value to give to the uniform
  11819. * @return the texture itself allowing "fluent" like uniform updates
  11820. */
  11821. setColor3(name: string, value: Color3): ProceduralTexture;
  11822. /**
  11823. * Set a vec4 in the shader from a Color4.
  11824. * @param name Define the name of the uniform as defined in the shader
  11825. * @param value Define the value to give to the uniform
  11826. * @return the texture itself allowing "fluent" like uniform updates
  11827. */
  11828. setColor4(name: string, value: Color4): ProceduralTexture;
  11829. /**
  11830. * Set a vec2 in the shader from a Vector2.
  11831. * @param name Define the name of the uniform as defined in the shader
  11832. * @param value Define the value to give to the uniform
  11833. * @return the texture itself allowing "fluent" like uniform updates
  11834. */
  11835. setVector2(name: string, value: Vector2): ProceduralTexture;
  11836. /**
  11837. * Set a vec3 in the shader from a Vector3.
  11838. * @param name Define the name of the uniform as defined in the shader
  11839. * @param value Define the value to give to the uniform
  11840. * @return the texture itself allowing "fluent" like uniform updates
  11841. */
  11842. setVector3(name: string, value: Vector3): ProceduralTexture;
  11843. /**
  11844. * Set a mat4 in the shader from a MAtrix.
  11845. * @param name Define the name of the uniform as defined in the shader
  11846. * @param value Define the value to give to the uniform
  11847. * @return the texture itself allowing "fluent" like uniform updates
  11848. */
  11849. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11850. /**
  11851. * Render the texture to its associated render target.
  11852. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11853. */
  11854. render(useCameraPostProcess?: boolean): void;
  11855. /**
  11856. * Clone the texture.
  11857. * @returns the cloned texture
  11858. */
  11859. clone(): ProceduralTexture;
  11860. /**
  11861. * Dispose the texture and release its asoociated resources.
  11862. */
  11863. dispose(): void;
  11864. }
  11865. }
  11866. declare module BABYLON {
  11867. /**
  11868. * This represents the base class for particle system in Babylon.
  11869. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11870. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11871. * @example https://doc.babylonjs.com/babylon101/particles
  11872. */
  11873. export class BaseParticleSystem {
  11874. /**
  11875. * Source color is added to the destination color without alpha affecting the result
  11876. */
  11877. static BLENDMODE_ONEONE: number;
  11878. /**
  11879. * Blend current color and particle color using particle’s alpha
  11880. */
  11881. static BLENDMODE_STANDARD: number;
  11882. /**
  11883. * Add current color and particle color multiplied by particle’s alpha
  11884. */
  11885. static BLENDMODE_ADD: number;
  11886. /**
  11887. * Multiply current color with particle color
  11888. */
  11889. static BLENDMODE_MULTIPLY: number;
  11890. /**
  11891. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11892. */
  11893. static BLENDMODE_MULTIPLYADD: number;
  11894. /**
  11895. * List of animations used by the particle system.
  11896. */
  11897. animations: Animation[];
  11898. /**
  11899. * Gets or sets the unique id of the particle system
  11900. */
  11901. uniqueId: number;
  11902. /**
  11903. * The id of the Particle system.
  11904. */
  11905. id: string;
  11906. /**
  11907. * The friendly name of the Particle system.
  11908. */
  11909. name: string;
  11910. /**
  11911. * Snippet ID if the particle system was created from the snippet server
  11912. */
  11913. snippetId: string;
  11914. /**
  11915. * The rendering group used by the Particle system to chose when to render.
  11916. */
  11917. renderingGroupId: number;
  11918. /**
  11919. * The emitter represents the Mesh or position we are attaching the particle system to.
  11920. */
  11921. emitter: Nullable<AbstractMesh | Vector3>;
  11922. /**
  11923. * The maximum number of particles to emit per frame
  11924. */
  11925. emitRate: number;
  11926. /**
  11927. * If you want to launch only a few particles at once, that can be done, as well.
  11928. */
  11929. manualEmitCount: number;
  11930. /**
  11931. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11932. */
  11933. updateSpeed: number;
  11934. /**
  11935. * The amount of time the particle system is running (depends of the overall update speed).
  11936. */
  11937. targetStopDuration: number;
  11938. /**
  11939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11940. */
  11941. disposeOnStop: boolean;
  11942. /**
  11943. * Minimum power of emitting particles.
  11944. */
  11945. minEmitPower: number;
  11946. /**
  11947. * Maximum power of emitting particles.
  11948. */
  11949. maxEmitPower: number;
  11950. /**
  11951. * Minimum life time of emitting particles.
  11952. */
  11953. minLifeTime: number;
  11954. /**
  11955. * Maximum life time of emitting particles.
  11956. */
  11957. maxLifeTime: number;
  11958. /**
  11959. * Minimum Size of emitting particles.
  11960. */
  11961. minSize: number;
  11962. /**
  11963. * Maximum Size of emitting particles.
  11964. */
  11965. maxSize: number;
  11966. /**
  11967. * Minimum scale of emitting particles on X axis.
  11968. */
  11969. minScaleX: number;
  11970. /**
  11971. * Maximum scale of emitting particles on X axis.
  11972. */
  11973. maxScaleX: number;
  11974. /**
  11975. * Minimum scale of emitting particles on Y axis.
  11976. */
  11977. minScaleY: number;
  11978. /**
  11979. * Maximum scale of emitting particles on Y axis.
  11980. */
  11981. maxScaleY: number;
  11982. /**
  11983. * Gets or sets the minimal initial rotation in radians.
  11984. */
  11985. minInitialRotation: number;
  11986. /**
  11987. * Gets or sets the maximal initial rotation in radians.
  11988. */
  11989. maxInitialRotation: number;
  11990. /**
  11991. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11992. */
  11993. minAngularSpeed: number;
  11994. /**
  11995. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11996. */
  11997. maxAngularSpeed: number;
  11998. /**
  11999. * The texture used to render each particle. (this can be a spritesheet)
  12000. */
  12001. particleTexture: Nullable<Texture>;
  12002. /**
  12003. * The layer mask we are rendering the particles through.
  12004. */
  12005. layerMask: number;
  12006. /**
  12007. * This can help using your own shader to render the particle system.
  12008. * The according effect will be created
  12009. */
  12010. customShader: any;
  12011. /**
  12012. * By default particle system starts as soon as they are created. This prevents the
  12013. * automatic start to happen and let you decide when to start emitting particles.
  12014. */
  12015. preventAutoStart: boolean;
  12016. private _noiseTexture;
  12017. /**
  12018. * Gets or sets a texture used to add random noise to particle positions
  12019. */
  12020. get noiseTexture(): Nullable<ProceduralTexture>;
  12021. set noiseTexture(value: Nullable<ProceduralTexture>);
  12022. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12023. noiseStrength: Vector3;
  12024. /**
  12025. * Callback triggered when the particle animation is ending.
  12026. */
  12027. onAnimationEnd: Nullable<() => void>;
  12028. /**
  12029. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12030. */
  12031. blendMode: number;
  12032. /**
  12033. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12034. * to override the particles.
  12035. */
  12036. forceDepthWrite: boolean;
  12037. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12038. preWarmCycles: number;
  12039. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12040. preWarmStepOffset: number;
  12041. /**
  12042. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12043. */
  12044. spriteCellChangeSpeed: number;
  12045. /**
  12046. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12047. */
  12048. startSpriteCellID: number;
  12049. /**
  12050. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12051. */
  12052. endSpriteCellID: number;
  12053. /**
  12054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12055. */
  12056. spriteCellWidth: number;
  12057. /**
  12058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12059. */
  12060. spriteCellHeight: number;
  12061. /**
  12062. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12063. */
  12064. spriteRandomStartCell: boolean;
  12065. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12066. translationPivot: Vector2;
  12067. /** @hidden */
  12068. protected _isAnimationSheetEnabled: boolean;
  12069. /**
  12070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12071. */
  12072. beginAnimationOnStart: boolean;
  12073. /**
  12074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12075. */
  12076. beginAnimationFrom: number;
  12077. /**
  12078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12079. */
  12080. beginAnimationTo: number;
  12081. /**
  12082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12083. */
  12084. beginAnimationLoop: boolean;
  12085. /**
  12086. * Gets or sets a world offset applied to all particles
  12087. */
  12088. worldOffset: Vector3;
  12089. /**
  12090. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12091. */
  12092. get isAnimationSheetEnabled(): boolean;
  12093. set isAnimationSheetEnabled(value: boolean);
  12094. /**
  12095. * Get hosting scene
  12096. * @returns the scene
  12097. */
  12098. getScene(): Scene;
  12099. /**
  12100. * You can use gravity if you want to give an orientation to your particles.
  12101. */
  12102. gravity: Vector3;
  12103. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12104. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12105. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12106. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12107. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12108. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12109. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12110. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12111. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12112. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12113. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12114. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12115. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12116. /**
  12117. * Defines the delay in milliseconds before starting the system (0 by default)
  12118. */
  12119. startDelay: number;
  12120. /**
  12121. * Gets the current list of drag gradients.
  12122. * You must use addDragGradient and removeDragGradient to udpate this list
  12123. * @returns the list of drag gradients
  12124. */
  12125. getDragGradients(): Nullable<Array<FactorGradient>>;
  12126. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12127. limitVelocityDamping: number;
  12128. /**
  12129. * Gets the current list of limit velocity gradients.
  12130. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12131. * @returns the list of limit velocity gradients
  12132. */
  12133. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of color gradients.
  12136. * You must use addColorGradient and removeColorGradient to udpate this list
  12137. * @returns the list of color gradients
  12138. */
  12139. getColorGradients(): Nullable<Array<ColorGradient>>;
  12140. /**
  12141. * Gets the current list of size gradients.
  12142. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12143. * @returns the list of size gradients
  12144. */
  12145. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Gets the current list of color remap gradients.
  12148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12149. * @returns the list of color remap gradients
  12150. */
  12151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12152. /**
  12153. * Gets the current list of alpha remap gradients.
  12154. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12155. * @returns the list of alpha remap gradients
  12156. */
  12157. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12158. /**
  12159. * Gets the current list of life time gradients.
  12160. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12161. * @returns the list of life time gradients
  12162. */
  12163. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12164. /**
  12165. * Gets the current list of angular speed gradients.
  12166. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12167. * @returns the list of angular speed gradients
  12168. */
  12169. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12170. /**
  12171. * Gets the current list of velocity gradients.
  12172. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12173. * @returns the list of velocity gradients
  12174. */
  12175. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12176. /**
  12177. * Gets the current list of start size gradients.
  12178. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12179. * @returns the list of start size gradients
  12180. */
  12181. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12182. /**
  12183. * Gets the current list of emit rate gradients.
  12184. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12185. * @returns the list of emit rate gradients
  12186. */
  12187. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12188. /**
  12189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12190. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12191. */
  12192. get direction1(): Vector3;
  12193. set direction1(value: Vector3);
  12194. /**
  12195. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12196. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12197. */
  12198. get direction2(): Vector3;
  12199. set direction2(value: Vector3);
  12200. /**
  12201. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12203. */
  12204. get minEmitBox(): Vector3;
  12205. set minEmitBox(value: Vector3);
  12206. /**
  12207. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12208. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12209. */
  12210. get maxEmitBox(): Vector3;
  12211. set maxEmitBox(value: Vector3);
  12212. /**
  12213. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12214. */
  12215. color1: Color4;
  12216. /**
  12217. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12218. */
  12219. color2: Color4;
  12220. /**
  12221. * Color the particle will have at the end of its lifetime
  12222. */
  12223. colorDead: Color4;
  12224. /**
  12225. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12226. */
  12227. textureMask: Color4;
  12228. /**
  12229. * The particle emitter type defines the emitter used by the particle system.
  12230. * It can be for example box, sphere, or cone...
  12231. */
  12232. particleEmitterType: IParticleEmitterType;
  12233. /** @hidden */
  12234. _isSubEmitter: boolean;
  12235. /**
  12236. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12237. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12238. */
  12239. billboardMode: number;
  12240. protected _isBillboardBased: boolean;
  12241. /**
  12242. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12243. */
  12244. get isBillboardBased(): boolean;
  12245. set isBillboardBased(value: boolean);
  12246. /**
  12247. * The scene the particle system belongs to.
  12248. */
  12249. protected _scene: Scene;
  12250. /**
  12251. * Local cache of defines for image processing.
  12252. */
  12253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12254. /**
  12255. * Default configuration related to image processing available in the standard Material.
  12256. */
  12257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12258. /**
  12259. * Gets the image processing configuration used either in this material.
  12260. */
  12261. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12262. /**
  12263. * Sets the Default image processing configuration used either in the this material.
  12264. *
  12265. * If sets to null, the scene one is in use.
  12266. */
  12267. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12268. /**
  12269. * Attaches a new image processing configuration to the Standard Material.
  12270. * @param configuration
  12271. */
  12272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12273. /** @hidden */
  12274. protected _reset(): void;
  12275. /** @hidden */
  12276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12277. /**
  12278. * Instantiates a particle system.
  12279. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12280. * @param name The name of the particle system
  12281. */
  12282. constructor(name: string);
  12283. /**
  12284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12287. * @returns the emitter
  12288. */
  12289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12290. /**
  12291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12292. * @param radius The radius of the hemisphere to emit from
  12293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12294. * @returns the emitter
  12295. */
  12296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12297. /**
  12298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12299. * @param radius The radius of the sphere to emit from
  12300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12301. * @returns the emitter
  12302. */
  12303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12304. /**
  12305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12306. * @param radius The radius of the sphere to emit from
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12309. * @returns the emitter
  12310. */
  12311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12314. * @param radius The radius of the emission cylinder
  12315. * @param height The height of the emission cylinder
  12316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12318. * @returns the emitter
  12319. */
  12320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12321. /**
  12322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12323. * @param radius The radius of the cylinder to emit from
  12324. * @param height The height of the emission cylinder
  12325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12328. * @returns the emitter
  12329. */
  12330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12331. /**
  12332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12333. * @param radius The radius of the cone to emit from
  12334. * @param angle The base angle of the cone
  12335. * @returns the emitter
  12336. */
  12337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12338. /**
  12339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12344. * @returns the emitter
  12345. */
  12346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12347. }
  12348. }
  12349. declare module BABYLON {
  12350. /**
  12351. * Type of sub emitter
  12352. */
  12353. export enum SubEmitterType {
  12354. /**
  12355. * Attached to the particle over it's lifetime
  12356. */
  12357. ATTACHED = 0,
  12358. /**
  12359. * Created when the particle dies
  12360. */
  12361. END = 1
  12362. }
  12363. /**
  12364. * Sub emitter class used to emit particles from an existing particle
  12365. */
  12366. export class SubEmitter {
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem;
  12371. /**
  12372. * Type of the submitter (Default: END)
  12373. */
  12374. type: SubEmitterType;
  12375. /**
  12376. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12377. * Note: This only is supported when using an emitter of type Mesh
  12378. */
  12379. inheritDirection: boolean;
  12380. /**
  12381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12382. */
  12383. inheritedVelocityAmount: number;
  12384. /**
  12385. * Creates a sub emitter
  12386. * @param particleSystem the particle system to be used by the sub emitter
  12387. */
  12388. constructor(
  12389. /**
  12390. * the particle system to be used by the sub emitter
  12391. */
  12392. particleSystem: ParticleSystem);
  12393. /**
  12394. * Clones the sub emitter
  12395. * @returns the cloned sub emitter
  12396. */
  12397. clone(): SubEmitter;
  12398. /**
  12399. * Serialize current object to a JSON object
  12400. * @returns the serialized object
  12401. */
  12402. serialize(): any;
  12403. /** @hidden */
  12404. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12405. /**
  12406. * Creates a new SubEmitter from a serialized JSON version
  12407. * @param serializationObject defines the JSON object to read from
  12408. * @param scene defines the hosting scene
  12409. * @param rootUrl defines the rootUrl for data loading
  12410. * @returns a new SubEmitter
  12411. */
  12412. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12413. /** Release associated resources */
  12414. dispose(): void;
  12415. }
  12416. }
  12417. declare module BABYLON {
  12418. /** @hidden */
  12419. export var imageProcessingDeclaration: {
  12420. name: string;
  12421. shader: string;
  12422. };
  12423. }
  12424. declare module BABYLON {
  12425. /** @hidden */
  12426. export var imageProcessingFunctions: {
  12427. name: string;
  12428. shader: string;
  12429. };
  12430. }
  12431. declare module BABYLON {
  12432. /** @hidden */
  12433. export var particlesPixelShader: {
  12434. name: string;
  12435. shader: string;
  12436. };
  12437. }
  12438. declare module BABYLON {
  12439. /** @hidden */
  12440. export var particlesVertexShader: {
  12441. name: string;
  12442. shader: string;
  12443. };
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * This represents a particle system in Babylon.
  12448. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12449. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12450. * @example https://doc.babylonjs.com/babylon101/particles
  12451. */
  12452. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12453. /**
  12454. * Billboard mode will only apply to Y axis
  12455. */
  12456. static readonly BILLBOARDMODE_Y: number;
  12457. /**
  12458. * Billboard mode will apply to all axes
  12459. */
  12460. static readonly BILLBOARDMODE_ALL: number;
  12461. /**
  12462. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12463. */
  12464. static readonly BILLBOARDMODE_STRETCHED: number;
  12465. /**
  12466. * This function can be defined to provide custom update for active particles.
  12467. * This function will be called instead of regular update (age, position, color, etc.).
  12468. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12469. */
  12470. updateFunction: (particles: Particle[]) => void;
  12471. private _emitterWorldMatrix;
  12472. /**
  12473. * This function can be defined to specify initial direction for every new particle.
  12474. * It by default use the emitterType defined function
  12475. */
  12476. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12477. /**
  12478. * This function can be defined to specify initial position for every new particle.
  12479. * It by default use the emitterType defined function
  12480. */
  12481. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12482. /**
  12483. * @hidden
  12484. */
  12485. _inheritedVelocityOffset: Vector3;
  12486. /**
  12487. * An event triggered when the system is disposed
  12488. */
  12489. onDisposeObservable: Observable<IParticleSystem>;
  12490. private _onDisposeObserver;
  12491. /**
  12492. * Sets a callback that will be triggered when the system is disposed
  12493. */
  12494. set onDispose(callback: () => void);
  12495. private _particles;
  12496. private _epsilon;
  12497. private _capacity;
  12498. private _stockParticles;
  12499. private _newPartsExcess;
  12500. private _vertexData;
  12501. private _vertexBuffer;
  12502. private _vertexBuffers;
  12503. private _spriteBuffer;
  12504. private _indexBuffer;
  12505. private _effect;
  12506. private _customEffect;
  12507. private _cachedDefines;
  12508. private _scaledColorStep;
  12509. private _colorDiff;
  12510. private _scaledDirection;
  12511. private _scaledGravity;
  12512. private _currentRenderId;
  12513. private _alive;
  12514. private _useInstancing;
  12515. private _started;
  12516. private _stopped;
  12517. private _actualFrame;
  12518. private _scaledUpdateSpeed;
  12519. private _vertexBufferSize;
  12520. /** @hidden */
  12521. _currentEmitRateGradient: Nullable<FactorGradient>;
  12522. /** @hidden */
  12523. _currentEmitRate1: number;
  12524. /** @hidden */
  12525. _currentEmitRate2: number;
  12526. /** @hidden */
  12527. _currentStartSizeGradient: Nullable<FactorGradient>;
  12528. /** @hidden */
  12529. _currentStartSize1: number;
  12530. /** @hidden */
  12531. _currentStartSize2: number;
  12532. private readonly _rawTextureWidth;
  12533. private _rampGradientsTexture;
  12534. private _useRampGradients;
  12535. /** Gets or sets a boolean indicating that ramp gradients must be used
  12536. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12537. */
  12538. get useRampGradients(): boolean;
  12539. set useRampGradients(value: boolean);
  12540. /**
  12541. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12542. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12543. */
  12544. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12545. private _subEmitters;
  12546. /**
  12547. * @hidden
  12548. * If the particle systems emitter should be disposed when the particle system is disposed
  12549. */
  12550. _disposeEmitterOnDispose: boolean;
  12551. /**
  12552. * The current active Sub-systems, this property is used by the root particle system only.
  12553. */
  12554. activeSubSystems: Array<ParticleSystem>;
  12555. /**
  12556. * Specifies if the particles are updated in emitter local space or world space
  12557. */
  12558. isLocal: boolean;
  12559. private _rootParticleSystem;
  12560. /**
  12561. * Gets the current list of active particles
  12562. */
  12563. get particles(): Particle[];
  12564. /**
  12565. * Gets the number of particles active at the same time.
  12566. * @returns The number of active particles.
  12567. */
  12568. getActiveCount(): number;
  12569. /**
  12570. * Returns the string "ParticleSystem"
  12571. * @returns a string containing the class name
  12572. */
  12573. getClassName(): string;
  12574. /**
  12575. * Gets a boolean indicating that the system is stopping
  12576. * @returns true if the system is currently stopping
  12577. */
  12578. isStopping(): boolean;
  12579. /**
  12580. * Gets the custom effect used to render the particles
  12581. * @param blendMode Blend mode for which the effect should be retrieved
  12582. * @returns The effect
  12583. */
  12584. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12585. /**
  12586. * Sets the custom effect used to render the particles
  12587. * @param effect The effect to set
  12588. * @param blendMode Blend mode for which the effect should be set
  12589. */
  12590. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12591. /** @hidden */
  12592. private _onBeforeDrawParticlesObservable;
  12593. /**
  12594. * Observable that will be called just before the particles are drawn
  12595. */
  12596. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12597. /**
  12598. * Gets the name of the particle vertex shader
  12599. */
  12600. get vertexShaderName(): string;
  12601. /**
  12602. * Instantiates a particle system.
  12603. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12604. * @param name The name of the particle system
  12605. * @param capacity The max number of particles alive at the same time
  12606. * @param scene The scene the particle system belongs to
  12607. * @param customEffect a custom effect used to change the way particles are rendered by default
  12608. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12609. * @param epsilon Offset used to render the particles
  12610. */
  12611. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12612. private _addFactorGradient;
  12613. private _removeFactorGradient;
  12614. /**
  12615. * Adds a new life time gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param factor defines the life time factor to affect to the specified gradient
  12618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12619. * @returns the current particle system
  12620. */
  12621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific life time gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new size gradient
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the size factor to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific size gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeSizeGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new color remap gradient
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param min defines the color remap minimal range
  12646. * @param max defines the color remap maximal range
  12647. * @returns the current particle system
  12648. */
  12649. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific color remap gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeColorRemapGradient(gradient: number): IParticleSystem;
  12656. /**
  12657. * Adds a new alpha remap gradient
  12658. * @param gradient defines the gradient to use (between 0 and 1)
  12659. * @param min defines the alpha remap minimal range
  12660. * @param max defines the alpha remap maximal range
  12661. * @returns the current particle system
  12662. */
  12663. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12664. /**
  12665. * Remove a specific alpha remap gradient
  12666. * @param gradient defines the gradient to remove
  12667. * @returns the current particle system
  12668. */
  12669. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12670. /**
  12671. * Adds a new angular speed gradient
  12672. * @param gradient defines the gradient to use (between 0 and 1)
  12673. * @param factor defines the angular speed to affect to the specified gradient
  12674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12675. * @returns the current particle system
  12676. */
  12677. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12678. /**
  12679. * Remove a specific angular speed gradient
  12680. * @param gradient defines the gradient to remove
  12681. * @returns the current particle system
  12682. */
  12683. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12684. /**
  12685. * Adds a new velocity gradient
  12686. * @param gradient defines the gradient to use (between 0 and 1)
  12687. * @param factor defines the velocity to affect to the specified gradient
  12688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12689. * @returns the current particle system
  12690. */
  12691. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12692. /**
  12693. * Remove a specific velocity gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeVelocityGradient(gradient: number): IParticleSystem;
  12698. /**
  12699. * Adds a new limit velocity gradient
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param factor defines the limit velocity value to affect to the specified gradient
  12702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12703. * @returns the current particle system
  12704. */
  12705. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12706. /**
  12707. * Remove a specific limit velocity gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns the current particle system
  12710. */
  12711. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12712. /**
  12713. * Adds a new drag gradient
  12714. * @param gradient defines the gradient to use (between 0 and 1)
  12715. * @param factor defines the drag value to affect to the specified gradient
  12716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12717. * @returns the current particle system
  12718. */
  12719. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12720. /**
  12721. * Remove a specific drag gradient
  12722. * @param gradient defines the gradient to remove
  12723. * @returns the current particle system
  12724. */
  12725. removeDragGradient(gradient: number): IParticleSystem;
  12726. /**
  12727. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12728. * @param gradient defines the gradient to use (between 0 and 1)
  12729. * @param factor defines the emit rate value to affect to the specified gradient
  12730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12731. * @returns the current particle system
  12732. */
  12733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12734. /**
  12735. * Remove a specific emit rate gradient
  12736. * @param gradient defines the gradient to remove
  12737. * @returns the current particle system
  12738. */
  12739. removeEmitRateGradient(gradient: number): IParticleSystem;
  12740. /**
  12741. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12742. * @param gradient defines the gradient to use (between 0 and 1)
  12743. * @param factor defines the start size value to affect to the specified gradient
  12744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12745. * @returns the current particle system
  12746. */
  12747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12748. /**
  12749. * Remove a specific start size gradient
  12750. * @param gradient defines the gradient to remove
  12751. * @returns the current particle system
  12752. */
  12753. removeStartSizeGradient(gradient: number): IParticleSystem;
  12754. private _createRampGradientTexture;
  12755. /**
  12756. * Gets the current list of ramp gradients.
  12757. * You must use addRampGradient and removeRampGradient to udpate this list
  12758. * @returns the list of ramp gradients
  12759. */
  12760. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12761. /** Force the system to rebuild all gradients that need to be resync */
  12762. forceRefreshGradients(): void;
  12763. private _syncRampGradientTexture;
  12764. /**
  12765. * Adds a new ramp gradient used to remap particle colors
  12766. * @param gradient defines the gradient to use (between 0 and 1)
  12767. * @param color defines the color to affect to the specified gradient
  12768. * @returns the current particle system
  12769. */
  12770. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12771. /**
  12772. * Remove a specific ramp gradient
  12773. * @param gradient defines the gradient to remove
  12774. * @returns the current particle system
  12775. */
  12776. removeRampGradient(gradient: number): ParticleSystem;
  12777. /**
  12778. * Adds a new color gradient
  12779. * @param gradient defines the gradient to use (between 0 and 1)
  12780. * @param color1 defines the color to affect to the specified gradient
  12781. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12782. * @returns this particle system
  12783. */
  12784. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12785. /**
  12786. * Remove a specific color gradient
  12787. * @param gradient defines the gradient to remove
  12788. * @returns this particle system
  12789. */
  12790. removeColorGradient(gradient: number): IParticleSystem;
  12791. private _fetchR;
  12792. protected _reset(): void;
  12793. private _resetEffect;
  12794. private _createVertexBuffers;
  12795. private _createIndexBuffer;
  12796. /**
  12797. * Gets the maximum number of particles active at the same time.
  12798. * @returns The max number of active particles.
  12799. */
  12800. getCapacity(): number;
  12801. /**
  12802. * Gets whether there are still active particles in the system.
  12803. * @returns True if it is alive, otherwise false.
  12804. */
  12805. isAlive(): boolean;
  12806. /**
  12807. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12808. * @returns True if it has been started, otherwise false.
  12809. */
  12810. isStarted(): boolean;
  12811. private _prepareSubEmitterInternalArray;
  12812. /**
  12813. * Starts the particle system and begins to emit
  12814. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12815. */
  12816. start(delay?: number): void;
  12817. /**
  12818. * Stops the particle system.
  12819. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12820. */
  12821. stop(stopSubEmitters?: boolean): void;
  12822. /**
  12823. * Remove all active particles
  12824. */
  12825. reset(): void;
  12826. /**
  12827. * @hidden (for internal use only)
  12828. */
  12829. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12830. /**
  12831. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12832. * Its lifetime will start back at 0.
  12833. */
  12834. recycleParticle: (particle: Particle) => void;
  12835. private _stopSubEmitters;
  12836. private _createParticle;
  12837. private _removeFromRoot;
  12838. private _emitFromParticle;
  12839. private _update;
  12840. /** @hidden */
  12841. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12842. /** @hidden */
  12843. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12844. /**
  12845. * Fill the defines array according to the current settings of the particle system
  12846. * @param defines Array to be updated
  12847. * @param blendMode blend mode to take into account when updating the array
  12848. */
  12849. fillDefines(defines: Array<string>, blendMode: number): void;
  12850. /**
  12851. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12852. * @param uniforms Uniforms array to fill
  12853. * @param attributes Attributes array to fill
  12854. * @param samplers Samplers array to fill
  12855. */
  12856. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12857. /** @hidden */
  12858. private _getEffect;
  12859. /**
  12860. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12861. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12862. */
  12863. animate(preWarmOnly?: boolean): void;
  12864. private _appendParticleVertices;
  12865. /**
  12866. * Rebuilds the particle system.
  12867. */
  12868. rebuild(): void;
  12869. /**
  12870. * Is this system ready to be used/rendered
  12871. * @return true if the system is ready
  12872. */
  12873. isReady(): boolean;
  12874. private _render;
  12875. /**
  12876. * Renders the particle system in its current state.
  12877. * @returns the current number of particles
  12878. */
  12879. render(): number;
  12880. /**
  12881. * Disposes the particle system and free the associated resources
  12882. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12883. */
  12884. dispose(disposeTexture?: boolean): void;
  12885. /**
  12886. * Clones the particle system.
  12887. * @param name The name of the cloned object
  12888. * @param newEmitter The new emitter to use
  12889. * @returns the cloned particle system
  12890. */
  12891. clone(name: string, newEmitter: any): ParticleSystem;
  12892. /**
  12893. * Serializes the particle system to a JSON object
  12894. * @param serializeTexture defines if the texture must be serialized as well
  12895. * @returns the JSON object
  12896. */
  12897. serialize(serializeTexture?: boolean): any;
  12898. /** @hidden */
  12899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12900. /** @hidden */
  12901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12902. /**
  12903. * Parses a JSON object to create a particle system.
  12904. * @param parsedParticleSystem The JSON object to parse
  12905. * @param scene The scene to create the particle system in
  12906. * @param rootUrl The root url to use to load external dependencies like texture
  12907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12908. * @returns the Parsed particle system
  12909. */
  12910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12911. }
  12912. }
  12913. declare module BABYLON {
  12914. /**
  12915. * A particle represents one of the element emitted by a particle system.
  12916. * This is mainly define by its coordinates, direction, velocity and age.
  12917. */
  12918. export class Particle {
  12919. /**
  12920. * The particle system the particle belongs to.
  12921. */
  12922. particleSystem: ParticleSystem;
  12923. private static _Count;
  12924. /**
  12925. * Unique ID of the particle
  12926. */
  12927. id: number;
  12928. /**
  12929. * The world position of the particle in the scene.
  12930. */
  12931. position: Vector3;
  12932. /**
  12933. * The world direction of the particle in the scene.
  12934. */
  12935. direction: Vector3;
  12936. /**
  12937. * The color of the particle.
  12938. */
  12939. color: Color4;
  12940. /**
  12941. * The color change of the particle per step.
  12942. */
  12943. colorStep: Color4;
  12944. /**
  12945. * Defines how long will the life of the particle be.
  12946. */
  12947. lifeTime: number;
  12948. /**
  12949. * The current age of the particle.
  12950. */
  12951. age: number;
  12952. /**
  12953. * The current size of the particle.
  12954. */
  12955. size: number;
  12956. /**
  12957. * The current scale of the particle.
  12958. */
  12959. scale: Vector2;
  12960. /**
  12961. * The current angle of the particle.
  12962. */
  12963. angle: number;
  12964. /**
  12965. * Defines how fast is the angle changing.
  12966. */
  12967. angularSpeed: number;
  12968. /**
  12969. * Defines the cell index used by the particle to be rendered from a sprite.
  12970. */
  12971. cellIndex: number;
  12972. /**
  12973. * The information required to support color remapping
  12974. */
  12975. remapData: Vector4;
  12976. /** @hidden */
  12977. _randomCellOffset?: number;
  12978. /** @hidden */
  12979. _initialDirection: Nullable<Vector3>;
  12980. /** @hidden */
  12981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12982. /** @hidden */
  12983. _initialStartSpriteCellID: number;
  12984. /** @hidden */
  12985. _initialEndSpriteCellID: number;
  12986. /** @hidden */
  12987. _currentColorGradient: Nullable<ColorGradient>;
  12988. /** @hidden */
  12989. _currentColor1: Color4;
  12990. /** @hidden */
  12991. _currentColor2: Color4;
  12992. /** @hidden */
  12993. _currentSizeGradient: Nullable<FactorGradient>;
  12994. /** @hidden */
  12995. _currentSize1: number;
  12996. /** @hidden */
  12997. _currentSize2: number;
  12998. /** @hidden */
  12999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13000. /** @hidden */
  13001. _currentAngularSpeed1: number;
  13002. /** @hidden */
  13003. _currentAngularSpeed2: number;
  13004. /** @hidden */
  13005. _currentVelocityGradient: Nullable<FactorGradient>;
  13006. /** @hidden */
  13007. _currentVelocity1: number;
  13008. /** @hidden */
  13009. _currentVelocity2: number;
  13010. /** @hidden */
  13011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13012. /** @hidden */
  13013. _currentLimitVelocity1: number;
  13014. /** @hidden */
  13015. _currentLimitVelocity2: number;
  13016. /** @hidden */
  13017. _currentDragGradient: Nullable<FactorGradient>;
  13018. /** @hidden */
  13019. _currentDrag1: number;
  13020. /** @hidden */
  13021. _currentDrag2: number;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates1: Vector3;
  13024. /** @hidden */
  13025. _randomNoiseCoordinates2: Vector3;
  13026. /** @hidden */
  13027. _localPosition?: Vector3;
  13028. /**
  13029. * Creates a new instance Particle
  13030. * @param particleSystem the particle system the particle belongs to
  13031. */
  13032. constructor(
  13033. /**
  13034. * The particle system the particle belongs to.
  13035. */
  13036. particleSystem: ParticleSystem);
  13037. private updateCellInfoFromSystem;
  13038. /**
  13039. * Defines how the sprite cell index is updated for the particle
  13040. */
  13041. updateCellIndex(): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13044. /** @hidden */
  13045. _inheritParticleInfoToSubEmitters(): void;
  13046. /** @hidden */
  13047. _reset(): void;
  13048. /**
  13049. * Copy the properties of particle to another one.
  13050. * @param other the particle to copy the information to.
  13051. */
  13052. copyTo(other: Particle): void;
  13053. }
  13054. }
  13055. declare module BABYLON {
  13056. /**
  13057. * Particle emitter represents a volume emitting particles.
  13058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13059. */
  13060. export interface IParticleEmitterType {
  13061. /**
  13062. * Called by the particle System when the direction is computed for the created particle.
  13063. * @param worldMatrix is the world matrix of the particle system
  13064. * @param directionToUpdate is the direction vector to update with the result
  13065. * @param particle is the particle we are computed the direction for
  13066. * @param isLocal defines if the direction should be set in local space
  13067. */
  13068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13069. /**
  13070. * Called by the particle System when the position is computed for the created particle.
  13071. * @param worldMatrix is the world matrix of the particle system
  13072. * @param positionToUpdate is the position vector to update with the result
  13073. * @param particle is the particle we are computed the position for
  13074. * @param isLocal defines if the position should be set in local space
  13075. */
  13076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13077. /**
  13078. * Clones the current emitter and returns a copy of it
  13079. * @returns the new emitter
  13080. */
  13081. clone(): IParticleEmitterType;
  13082. /**
  13083. * Called by the GPUParticleSystem to setup the update shader
  13084. * @param effect defines the update shader
  13085. */
  13086. applyToShader(effect: Effect): void;
  13087. /**
  13088. * Returns a string to use to update the GPU particles update shader
  13089. * @returns the effect defines string
  13090. */
  13091. getEffectDefines(): string;
  13092. /**
  13093. * Returns a string representing the class name
  13094. * @returns a string containing the class name
  13095. */
  13096. getClassName(): string;
  13097. /**
  13098. * Serializes the particle system to a JSON object.
  13099. * @returns the JSON object
  13100. */
  13101. serialize(): any;
  13102. /**
  13103. * Parse properties from a JSON object
  13104. * @param serializationObject defines the JSON object
  13105. * @param scene defines the hosting scene
  13106. */
  13107. parse(serializationObject: any, scene: Scene): void;
  13108. }
  13109. }
  13110. declare module BABYLON {
  13111. /**
  13112. * Particle emitter emitting particles from the inside of a box.
  13113. * It emits the particles randomly between 2 given directions.
  13114. */
  13115. export class BoxParticleEmitter implements IParticleEmitterType {
  13116. /**
  13117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13118. */
  13119. direction1: Vector3;
  13120. /**
  13121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13122. */
  13123. direction2: Vector3;
  13124. /**
  13125. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13126. */
  13127. minEmitBox: Vector3;
  13128. /**
  13129. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13130. */
  13131. maxEmitBox: Vector3;
  13132. /**
  13133. * Creates a new instance BoxParticleEmitter
  13134. */
  13135. constructor();
  13136. /**
  13137. * Called by the particle System when the direction is computed for the created particle.
  13138. * @param worldMatrix is the world matrix of the particle system
  13139. * @param directionToUpdate is the direction vector to update with the result
  13140. * @param particle is the particle we are computed the direction for
  13141. * @param isLocal defines if the direction should be set in local space
  13142. */
  13143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13144. /**
  13145. * Called by the particle System when the position is computed for the created particle.
  13146. * @param worldMatrix is the world matrix of the particle system
  13147. * @param positionToUpdate is the position vector to update with the result
  13148. * @param particle is the particle we are computed the position for
  13149. * @param isLocal defines if the position should be set in local space
  13150. */
  13151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13152. /**
  13153. * Clones the current emitter and returns a copy of it
  13154. * @returns the new emitter
  13155. */
  13156. clone(): BoxParticleEmitter;
  13157. /**
  13158. * Called by the GPUParticleSystem to setup the update shader
  13159. * @param effect defines the update shader
  13160. */
  13161. applyToShader(effect: Effect): void;
  13162. /**
  13163. * Returns a string to use to update the GPU particles update shader
  13164. * @returns a string containng the defines string
  13165. */
  13166. getEffectDefines(): string;
  13167. /**
  13168. * Returns the string "BoxParticleEmitter"
  13169. * @returns a string containing the class name
  13170. */
  13171. getClassName(): string;
  13172. /**
  13173. * Serializes the particle system to a JSON object.
  13174. * @returns the JSON object
  13175. */
  13176. serialize(): any;
  13177. /**
  13178. * Parse properties from a JSON object
  13179. * @param serializationObject defines the JSON object
  13180. */
  13181. parse(serializationObject: any): void;
  13182. }
  13183. }
  13184. declare module BABYLON {
  13185. /**
  13186. * Particle emitter emitting particles from the inside of a cone.
  13187. * It emits the particles alongside the cone volume from the base to the particle.
  13188. * The emission direction might be randomized.
  13189. */
  13190. export class ConeParticleEmitter implements IParticleEmitterType {
  13191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13192. directionRandomizer: number;
  13193. private _radius;
  13194. private _angle;
  13195. private _height;
  13196. /**
  13197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13198. */
  13199. radiusRange: number;
  13200. /**
  13201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13202. */
  13203. heightRange: number;
  13204. /**
  13205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13206. */
  13207. emitFromSpawnPointOnly: boolean;
  13208. /**
  13209. * Gets or sets the radius of the emission cone
  13210. */
  13211. get radius(): number;
  13212. set radius(value: number);
  13213. /**
  13214. * Gets or sets the angle of the emission cone
  13215. */
  13216. get angle(): number;
  13217. set angle(value: number);
  13218. private _buildHeight;
  13219. /**
  13220. * Creates a new instance ConeParticleEmitter
  13221. * @param radius the radius of the emission cone (1 by default)
  13222. * @param angle the cone base angle (PI by default)
  13223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13224. */
  13225. constructor(radius?: number, angle?: number,
  13226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13227. directionRandomizer?: number);
  13228. /**
  13229. * Called by the particle System when the direction is computed for the created particle.
  13230. * @param worldMatrix is the world matrix of the particle system
  13231. * @param directionToUpdate is the direction vector to update with the result
  13232. * @param particle is the particle we are computed the direction for
  13233. * @param isLocal defines if the direction should be set in local space
  13234. */
  13235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13236. /**
  13237. * Called by the particle System when the position is computed for the created particle.
  13238. * @param worldMatrix is the world matrix of the particle system
  13239. * @param positionToUpdate is the position vector to update with the result
  13240. * @param particle is the particle we are computed the position for
  13241. * @param isLocal defines if the position should be set in local space
  13242. */
  13243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13244. /**
  13245. * Clones the current emitter and returns a copy of it
  13246. * @returns the new emitter
  13247. */
  13248. clone(): ConeParticleEmitter;
  13249. /**
  13250. * Called by the GPUParticleSystem to setup the update shader
  13251. * @param effect defines the update shader
  13252. */
  13253. applyToShader(effect: Effect): void;
  13254. /**
  13255. * Returns a string to use to update the GPU particles update shader
  13256. * @returns a string containng the defines string
  13257. */
  13258. getEffectDefines(): string;
  13259. /**
  13260. * Returns the string "ConeParticleEmitter"
  13261. * @returns a string containing the class name
  13262. */
  13263. getClassName(): string;
  13264. /**
  13265. * Serializes the particle system to a JSON object.
  13266. * @returns the JSON object
  13267. */
  13268. serialize(): any;
  13269. /**
  13270. * Parse properties from a JSON object
  13271. * @param serializationObject defines the JSON object
  13272. */
  13273. parse(serializationObject: any): void;
  13274. }
  13275. }
  13276. declare module BABYLON {
  13277. /**
  13278. * Particle emitter emitting particles from the inside of a cylinder.
  13279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13280. */
  13281. export class CylinderParticleEmitter implements IParticleEmitterType {
  13282. /**
  13283. * The radius of the emission cylinder.
  13284. */
  13285. radius: number;
  13286. /**
  13287. * The height of the emission cylinder.
  13288. */
  13289. height: number;
  13290. /**
  13291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13292. */
  13293. radiusRange: number;
  13294. /**
  13295. * How much to randomize the particle direction [0-1].
  13296. */
  13297. directionRandomizer: number;
  13298. /**
  13299. * Creates a new instance CylinderParticleEmitter
  13300. * @param radius the radius of the emission cylinder (1 by default)
  13301. * @param height the height of the emission cylinder (1 by default)
  13302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13304. */
  13305. constructor(
  13306. /**
  13307. * The radius of the emission cylinder.
  13308. */
  13309. radius?: number,
  13310. /**
  13311. * The height of the emission cylinder.
  13312. */
  13313. height?: number,
  13314. /**
  13315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13316. */
  13317. radiusRange?: number,
  13318. /**
  13319. * How much to randomize the particle direction [0-1].
  13320. */
  13321. directionRandomizer?: number);
  13322. /**
  13323. * Called by the particle System when the direction is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param directionToUpdate is the direction vector to update with the result
  13326. * @param particle is the particle we are computed the direction for
  13327. * @param isLocal defines if the direction should be set in local space
  13328. */
  13329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Called by the particle System when the position is computed for the created particle.
  13332. * @param worldMatrix is the world matrix of the particle system
  13333. * @param positionToUpdate is the position vector to update with the result
  13334. * @param particle is the particle we are computed the position for
  13335. * @param isLocal defines if the position should be set in local space
  13336. */
  13337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13338. /**
  13339. * Clones the current emitter and returns a copy of it
  13340. * @returns the new emitter
  13341. */
  13342. clone(): CylinderParticleEmitter;
  13343. /**
  13344. * Called by the GPUParticleSystem to setup the update shader
  13345. * @param effect defines the update shader
  13346. */
  13347. applyToShader(effect: Effect): void;
  13348. /**
  13349. * Returns a string to use to update the GPU particles update shader
  13350. * @returns a string containng the defines string
  13351. */
  13352. getEffectDefines(): string;
  13353. /**
  13354. * Returns the string "CylinderParticleEmitter"
  13355. * @returns a string containing the class name
  13356. */
  13357. getClassName(): string;
  13358. /**
  13359. * Serializes the particle system to a JSON object.
  13360. * @returns the JSON object
  13361. */
  13362. serialize(): any;
  13363. /**
  13364. * Parse properties from a JSON object
  13365. * @param serializationObject defines the JSON object
  13366. */
  13367. parse(serializationObject: any): void;
  13368. }
  13369. /**
  13370. * Particle emitter emitting particles from the inside of a cylinder.
  13371. * It emits the particles randomly between two vectors.
  13372. */
  13373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13374. /**
  13375. * The min limit of the emission direction.
  13376. */
  13377. direction1: Vector3;
  13378. /**
  13379. * The max limit of the emission direction.
  13380. */
  13381. direction2: Vector3;
  13382. /**
  13383. * Creates a new instance CylinderDirectedParticleEmitter
  13384. * @param radius the radius of the emission cylinder (1 by default)
  13385. * @param height the height of the emission cylinder (1 by default)
  13386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13387. * @param direction1 the min limit of the emission direction (up vector by default)
  13388. * @param direction2 the max limit of the emission direction (up vector by default)
  13389. */
  13390. constructor(radius?: number, height?: number, radiusRange?: number,
  13391. /**
  13392. * The min limit of the emission direction.
  13393. */
  13394. direction1?: Vector3,
  13395. /**
  13396. * The max limit of the emission direction.
  13397. */
  13398. direction2?: Vector3);
  13399. /**
  13400. * Called by the particle System when the direction is computed for the created particle.
  13401. * @param worldMatrix is the world matrix of the particle system
  13402. * @param directionToUpdate is the direction vector to update with the result
  13403. * @param particle is the particle we are computed the direction for
  13404. */
  13405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13406. /**
  13407. * Clones the current emitter and returns a copy of it
  13408. * @returns the new emitter
  13409. */
  13410. clone(): CylinderDirectedParticleEmitter;
  13411. /**
  13412. * Called by the GPUParticleSystem to setup the update shader
  13413. * @param effect defines the update shader
  13414. */
  13415. applyToShader(effect: Effect): void;
  13416. /**
  13417. * Returns a string to use to update the GPU particles update shader
  13418. * @returns a string containng the defines string
  13419. */
  13420. getEffectDefines(): string;
  13421. /**
  13422. * Returns the string "CylinderDirectedParticleEmitter"
  13423. * @returns a string containing the class name
  13424. */
  13425. getClassName(): string;
  13426. /**
  13427. * Serializes the particle system to a JSON object.
  13428. * @returns the JSON object
  13429. */
  13430. serialize(): any;
  13431. /**
  13432. * Parse properties from a JSON object
  13433. * @param serializationObject defines the JSON object
  13434. */
  13435. parse(serializationObject: any): void;
  13436. }
  13437. }
  13438. declare module BABYLON {
  13439. /**
  13440. * Particle emitter emitting particles from the inside of a hemisphere.
  13441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13442. */
  13443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13444. /**
  13445. * The radius of the emission hemisphere.
  13446. */
  13447. radius: number;
  13448. /**
  13449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13450. */
  13451. radiusRange: number;
  13452. /**
  13453. * How much to randomize the particle direction [0-1].
  13454. */
  13455. directionRandomizer: number;
  13456. /**
  13457. * Creates a new instance HemisphericParticleEmitter
  13458. * @param radius the radius of the emission hemisphere (1 by default)
  13459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13461. */
  13462. constructor(
  13463. /**
  13464. * The radius of the emission hemisphere.
  13465. */
  13466. radius?: number,
  13467. /**
  13468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13469. */
  13470. radiusRange?: number,
  13471. /**
  13472. * How much to randomize the particle direction [0-1].
  13473. */
  13474. directionRandomizer?: number);
  13475. /**
  13476. * Called by the particle System when the direction is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param directionToUpdate is the direction vector to update with the result
  13479. * @param particle is the particle we are computed the direction for
  13480. * @param isLocal defines if the direction should be set in local space
  13481. */
  13482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Called by the particle System when the position is computed for the created particle.
  13485. * @param worldMatrix is the world matrix of the particle system
  13486. * @param positionToUpdate is the position vector to update with the result
  13487. * @param particle is the particle we are computed the position for
  13488. * @param isLocal defines if the position should be set in local space
  13489. */
  13490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13491. /**
  13492. * Clones the current emitter and returns a copy of it
  13493. * @returns the new emitter
  13494. */
  13495. clone(): HemisphericParticleEmitter;
  13496. /**
  13497. * Called by the GPUParticleSystem to setup the update shader
  13498. * @param effect defines the update shader
  13499. */
  13500. applyToShader(effect: Effect): void;
  13501. /**
  13502. * Returns a string to use to update the GPU particles update shader
  13503. * @returns a string containng the defines string
  13504. */
  13505. getEffectDefines(): string;
  13506. /**
  13507. * Returns the string "HemisphericParticleEmitter"
  13508. * @returns a string containing the class name
  13509. */
  13510. getClassName(): string;
  13511. /**
  13512. * Serializes the particle system to a JSON object.
  13513. * @returns the JSON object
  13514. */
  13515. serialize(): any;
  13516. /**
  13517. * Parse properties from a JSON object
  13518. * @param serializationObject defines the JSON object
  13519. */
  13520. parse(serializationObject: any): void;
  13521. }
  13522. }
  13523. declare module BABYLON {
  13524. /**
  13525. * Particle emitter emitting particles from a point.
  13526. * It emits the particles randomly between 2 given directions.
  13527. */
  13528. export class PointParticleEmitter implements IParticleEmitterType {
  13529. /**
  13530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13531. */
  13532. direction1: Vector3;
  13533. /**
  13534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13535. */
  13536. direction2: Vector3;
  13537. /**
  13538. * Creates a new instance PointParticleEmitter
  13539. */
  13540. constructor();
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): PointParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "PointParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module BABYLON {
  13590. /**
  13591. * Particle emitter emitting particles from the inside of a sphere.
  13592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13593. */
  13594. export class SphereParticleEmitter implements IParticleEmitterType {
  13595. /**
  13596. * The radius of the emission sphere.
  13597. */
  13598. radius: number;
  13599. /**
  13600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13601. */
  13602. radiusRange: number;
  13603. /**
  13604. * How much to randomize the particle direction [0-1].
  13605. */
  13606. directionRandomizer: number;
  13607. /**
  13608. * Creates a new instance SphereParticleEmitter
  13609. * @param radius the radius of the emission sphere (1 by default)
  13610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13612. */
  13613. constructor(
  13614. /**
  13615. * The radius of the emission sphere.
  13616. */
  13617. radius?: number,
  13618. /**
  13619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13620. */
  13621. radiusRange?: number,
  13622. /**
  13623. * How much to randomize the particle direction [0-1].
  13624. */
  13625. directionRandomizer?: number);
  13626. /**
  13627. * Called by the particle System when the direction is computed for the created particle.
  13628. * @param worldMatrix is the world matrix of the particle system
  13629. * @param directionToUpdate is the direction vector to update with the result
  13630. * @param particle is the particle we are computed the direction for
  13631. * @param isLocal defines if the direction should be set in local space
  13632. */
  13633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13634. /**
  13635. * Called by the particle System when the position is computed for the created particle.
  13636. * @param worldMatrix is the world matrix of the particle system
  13637. * @param positionToUpdate is the position vector to update with the result
  13638. * @param particle is the particle we are computed the position for
  13639. * @param isLocal defines if the position should be set in local space
  13640. */
  13641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13642. /**
  13643. * Clones the current emitter and returns a copy of it
  13644. * @returns the new emitter
  13645. */
  13646. clone(): SphereParticleEmitter;
  13647. /**
  13648. * Called by the GPUParticleSystem to setup the update shader
  13649. * @param effect defines the update shader
  13650. */
  13651. applyToShader(effect: Effect): void;
  13652. /**
  13653. * Returns a string to use to update the GPU particles update shader
  13654. * @returns a string containng the defines string
  13655. */
  13656. getEffectDefines(): string;
  13657. /**
  13658. * Returns the string "SphereParticleEmitter"
  13659. * @returns a string containing the class name
  13660. */
  13661. getClassName(): string;
  13662. /**
  13663. * Serializes the particle system to a JSON object.
  13664. * @returns the JSON object
  13665. */
  13666. serialize(): any;
  13667. /**
  13668. * Parse properties from a JSON object
  13669. * @param serializationObject defines the JSON object
  13670. */
  13671. parse(serializationObject: any): void;
  13672. }
  13673. /**
  13674. * Particle emitter emitting particles from the inside of a sphere.
  13675. * It emits the particles randomly between two vectors.
  13676. */
  13677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13678. /**
  13679. * The min limit of the emission direction.
  13680. */
  13681. direction1: Vector3;
  13682. /**
  13683. * The max limit of the emission direction.
  13684. */
  13685. direction2: Vector3;
  13686. /**
  13687. * Creates a new instance SphereDirectedParticleEmitter
  13688. * @param radius the radius of the emission sphere (1 by default)
  13689. * @param direction1 the min limit of the emission direction (up vector by default)
  13690. * @param direction2 the max limit of the emission direction (up vector by default)
  13691. */
  13692. constructor(radius?: number,
  13693. /**
  13694. * The min limit of the emission direction.
  13695. */
  13696. direction1?: Vector3,
  13697. /**
  13698. * The max limit of the emission direction.
  13699. */
  13700. direction2?: Vector3);
  13701. /**
  13702. * Called by the particle System when the direction is computed for the created particle.
  13703. * @param worldMatrix is the world matrix of the particle system
  13704. * @param directionToUpdate is the direction vector to update with the result
  13705. * @param particle is the particle we are computed the direction for
  13706. */
  13707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): SphereDirectedParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "SphereDirectedParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a custom list of positions.
  13743. */
  13744. export class CustomParticleEmitter implements IParticleEmitterType {
  13745. /**
  13746. * Gets or sets the position generator that will create the inital position of each particle.
  13747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13748. */
  13749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13750. /**
  13751. * Gets or sets the destination generator that will create the final destination of each particle.
  13752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13753. */
  13754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13755. /**
  13756. * Creates a new instance CustomParticleEmitter
  13757. */
  13758. constructor();
  13759. /**
  13760. * Called by the particle System when the direction is computed for the created particle.
  13761. * @param worldMatrix is the world matrix of the particle system
  13762. * @param directionToUpdate is the direction vector to update with the result
  13763. * @param particle is the particle we are computed the direction for
  13764. * @param isLocal defines if the direction should be set in local space
  13765. */
  13766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13767. /**
  13768. * Called by the particle System when the position is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param positionToUpdate is the position vector to update with the result
  13771. * @param particle is the particle we are computed the position for
  13772. * @param isLocal defines if the position should be set in local space
  13773. */
  13774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Clones the current emitter and returns a copy of it
  13777. * @returns the new emitter
  13778. */
  13779. clone(): CustomParticleEmitter;
  13780. /**
  13781. * Called by the GPUParticleSystem to setup the update shader
  13782. * @param effect defines the update shader
  13783. */
  13784. applyToShader(effect: Effect): void;
  13785. /**
  13786. * Returns a string to use to update the GPU particles update shader
  13787. * @returns a string containng the defines string
  13788. */
  13789. getEffectDefines(): string;
  13790. /**
  13791. * Returns the string "PointParticleEmitter"
  13792. * @returns a string containing the class name
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Serializes the particle system to a JSON object.
  13797. * @returns the JSON object
  13798. */
  13799. serialize(): any;
  13800. /**
  13801. * Parse properties from a JSON object
  13802. * @param serializationObject defines the JSON object
  13803. */
  13804. parse(serializationObject: any): void;
  13805. }
  13806. }
  13807. declare module BABYLON {
  13808. /**
  13809. * Particle emitter emitting particles from the inside of a box.
  13810. * It emits the particles randomly between 2 given directions.
  13811. */
  13812. export class MeshParticleEmitter implements IParticleEmitterType {
  13813. private _indices;
  13814. private _positions;
  13815. private _normals;
  13816. private _storedNormal;
  13817. private _mesh;
  13818. /**
  13819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13820. */
  13821. direction1: Vector3;
  13822. /**
  13823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13824. */
  13825. direction2: Vector3;
  13826. /**
  13827. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13828. */
  13829. useMeshNormalsForDirection: boolean;
  13830. /** Defines the mesh to use as source */
  13831. get mesh(): Nullable<AbstractMesh>;
  13832. set mesh(value: Nullable<AbstractMesh>);
  13833. /**
  13834. * Creates a new instance MeshParticleEmitter
  13835. * @param mesh defines the mesh to use as source
  13836. */
  13837. constructor(mesh?: Nullable<AbstractMesh>);
  13838. /**
  13839. * Called by the particle System when the direction is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param directionToUpdate is the direction vector to update with the result
  13842. * @param particle is the particle we are computed the direction for
  13843. * @param isLocal defines if the direction should be set in local space
  13844. */
  13845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Called by the particle System when the position is computed for the created particle.
  13848. * @param worldMatrix is the world matrix of the particle system
  13849. * @param positionToUpdate is the position vector to update with the result
  13850. * @param particle is the particle we are computed the position for
  13851. * @param isLocal defines if the position should be set in local space
  13852. */
  13853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13854. /**
  13855. * Clones the current emitter and returns a copy of it
  13856. * @returns the new emitter
  13857. */
  13858. clone(): MeshParticleEmitter;
  13859. /**
  13860. * Called by the GPUParticleSystem to setup the update shader
  13861. * @param effect defines the update shader
  13862. */
  13863. applyToShader(effect: Effect): void;
  13864. /**
  13865. * Returns a string to use to update the GPU particles update shader
  13866. * @returns a string containng the defines string
  13867. */
  13868. getEffectDefines(): string;
  13869. /**
  13870. * Returns the string "BoxParticleEmitter"
  13871. * @returns a string containing the class name
  13872. */
  13873. getClassName(): string;
  13874. /**
  13875. * Serializes the particle system to a JSON object.
  13876. * @returns the JSON object
  13877. */
  13878. serialize(): any;
  13879. /**
  13880. * Parse properties from a JSON object
  13881. * @param serializationObject defines the JSON object
  13882. * @param scene defines the hosting scene
  13883. */
  13884. parse(serializationObject: any, scene: Scene): void;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Interface representing a particle system in Babylon.js.
  13890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13892. */
  13893. export interface IParticleSystem {
  13894. /**
  13895. * List of animations used by the particle system.
  13896. */
  13897. animations: Animation[];
  13898. /**
  13899. * The id of the Particle system.
  13900. */
  13901. id: string;
  13902. /**
  13903. * The name of the Particle system.
  13904. */
  13905. name: string;
  13906. /**
  13907. * The emitter represents the Mesh or position we are attaching the particle system to.
  13908. */
  13909. emitter: Nullable<AbstractMesh | Vector3>;
  13910. /**
  13911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13912. */
  13913. isBillboardBased: boolean;
  13914. /**
  13915. * The rendering group used by the Particle system to chose when to render.
  13916. */
  13917. renderingGroupId: number;
  13918. /**
  13919. * The layer mask we are rendering the particles through.
  13920. */
  13921. layerMask: number;
  13922. /**
  13923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13924. */
  13925. updateSpeed: number;
  13926. /**
  13927. * The amount of time the particle system is running (depends of the overall update speed).
  13928. */
  13929. targetStopDuration: number;
  13930. /**
  13931. * The texture used to render each particle. (this can be a spritesheet)
  13932. */
  13933. particleTexture: Nullable<Texture>;
  13934. /**
  13935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13936. */
  13937. blendMode: number;
  13938. /**
  13939. * Minimum life time of emitting particles.
  13940. */
  13941. minLifeTime: number;
  13942. /**
  13943. * Maximum life time of emitting particles.
  13944. */
  13945. maxLifeTime: number;
  13946. /**
  13947. * Minimum Size of emitting particles.
  13948. */
  13949. minSize: number;
  13950. /**
  13951. * Maximum Size of emitting particles.
  13952. */
  13953. maxSize: number;
  13954. /**
  13955. * Minimum scale of emitting particles on X axis.
  13956. */
  13957. minScaleX: number;
  13958. /**
  13959. * Maximum scale of emitting particles on X axis.
  13960. */
  13961. maxScaleX: number;
  13962. /**
  13963. * Minimum scale of emitting particles on Y axis.
  13964. */
  13965. minScaleY: number;
  13966. /**
  13967. * Maximum scale of emitting particles on Y axis.
  13968. */
  13969. maxScaleY: number;
  13970. /**
  13971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13972. */
  13973. color1: Color4;
  13974. /**
  13975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13976. */
  13977. color2: Color4;
  13978. /**
  13979. * Color the particle will have at the end of its lifetime.
  13980. */
  13981. colorDead: Color4;
  13982. /**
  13983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13984. */
  13985. emitRate: number;
  13986. /**
  13987. * You can use gravity if you want to give an orientation to your particles.
  13988. */
  13989. gravity: Vector3;
  13990. /**
  13991. * Minimum power of emitting particles.
  13992. */
  13993. minEmitPower: number;
  13994. /**
  13995. * Maximum power of emitting particles.
  13996. */
  13997. maxEmitPower: number;
  13998. /**
  13999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14000. */
  14001. minAngularSpeed: number;
  14002. /**
  14003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14004. */
  14005. maxAngularSpeed: number;
  14006. /**
  14007. * Gets or sets the minimal initial rotation in radians.
  14008. */
  14009. minInitialRotation: number;
  14010. /**
  14011. * Gets or sets the maximal initial rotation in radians.
  14012. */
  14013. maxInitialRotation: number;
  14014. /**
  14015. * The particle emitter type defines the emitter used by the particle system.
  14016. * It can be for example box, sphere, or cone...
  14017. */
  14018. particleEmitterType: Nullable<IParticleEmitterType>;
  14019. /**
  14020. * Defines the delay in milliseconds before starting the system (0 by default)
  14021. */
  14022. startDelay: number;
  14023. /**
  14024. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14025. */
  14026. preWarmCycles: number;
  14027. /**
  14028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14029. */
  14030. preWarmStepOffset: number;
  14031. /**
  14032. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14033. */
  14034. spriteCellChangeSpeed: number;
  14035. /**
  14036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14037. */
  14038. startSpriteCellID: number;
  14039. /**
  14040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14041. */
  14042. endSpriteCellID: number;
  14043. /**
  14044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14045. */
  14046. spriteCellWidth: number;
  14047. /**
  14048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14049. */
  14050. spriteCellHeight: number;
  14051. /**
  14052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14053. */
  14054. spriteRandomStartCell: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14057. */
  14058. isAnimationSheetEnabled: boolean;
  14059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14060. translationPivot: Vector2;
  14061. /**
  14062. * Gets or sets a texture used to add random noise to particle positions
  14063. */
  14064. noiseTexture: Nullable<BaseTexture>;
  14065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14066. noiseStrength: Vector3;
  14067. /**
  14068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14070. */
  14071. billboardMode: number;
  14072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14073. limitVelocityDamping: number;
  14074. /**
  14075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14076. */
  14077. beginAnimationOnStart: boolean;
  14078. /**
  14079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14080. */
  14081. beginAnimationFrom: number;
  14082. /**
  14083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14084. */
  14085. beginAnimationTo: number;
  14086. /**
  14087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14088. */
  14089. beginAnimationLoop: boolean;
  14090. /**
  14091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14092. */
  14093. disposeOnStop: boolean;
  14094. /**
  14095. * Specifies if the particles are updated in emitter local space or world space
  14096. */
  14097. isLocal: boolean;
  14098. /** Snippet ID if the particle system was created from the snippet server */
  14099. snippetId: string;
  14100. /**
  14101. * Gets the maximum number of particles active at the same time.
  14102. * @returns The max number of active particles.
  14103. */
  14104. getCapacity(): number;
  14105. /**
  14106. * Gets the number of particles active at the same time.
  14107. * @returns The number of active particles.
  14108. */
  14109. getActiveCount(): number;
  14110. /**
  14111. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14112. * @returns True if it has been started, otherwise false.
  14113. */
  14114. isStarted(): boolean;
  14115. /**
  14116. * Animates the particle system for this frame.
  14117. */
  14118. animate(): void;
  14119. /**
  14120. * Renders the particle system in its current state.
  14121. * @returns the current number of particles
  14122. */
  14123. render(): number;
  14124. /**
  14125. * Dispose the particle system and frees its associated resources.
  14126. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14127. */
  14128. dispose(disposeTexture?: boolean): void;
  14129. /**
  14130. * An event triggered when the system is disposed
  14131. */
  14132. onDisposeObservable: Observable<IParticleSystem>;
  14133. /**
  14134. * Clones the particle system.
  14135. * @param name The name of the cloned object
  14136. * @param newEmitter The new emitter to use
  14137. * @returns the cloned particle system
  14138. */
  14139. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14140. /**
  14141. * Serializes the particle system to a JSON object
  14142. * @param serializeTexture defines if the texture must be serialized as well
  14143. * @returns the JSON object
  14144. */
  14145. serialize(serializeTexture: boolean): any;
  14146. /**
  14147. * Rebuild the particle system
  14148. */
  14149. rebuild(): void;
  14150. /** Force the system to rebuild all gradients that need to be resync */
  14151. forceRefreshGradients(): void;
  14152. /**
  14153. * Starts the particle system and begins to emit
  14154. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14155. */
  14156. start(delay?: number): void;
  14157. /**
  14158. * Stops the particle system.
  14159. */
  14160. stop(): void;
  14161. /**
  14162. * Remove all active particles
  14163. */
  14164. reset(): void;
  14165. /**
  14166. * Gets a boolean indicating that the system is stopping
  14167. * @returns true if the system is currently stopping
  14168. */
  14169. isStopping(): boolean;
  14170. /**
  14171. * Is this system ready to be used/rendered
  14172. * @return true if the system is ready
  14173. */
  14174. isReady(): boolean;
  14175. /**
  14176. * Returns the string "ParticleSystem"
  14177. * @returns a string containing the class name
  14178. */
  14179. getClassName(): string;
  14180. /**
  14181. * Gets the custom effect used to render the particles
  14182. * @param blendMode Blend mode for which the effect should be retrieved
  14183. * @returns The effect
  14184. */
  14185. getCustomEffect(blendMode: number): Nullable<Effect>;
  14186. /**
  14187. * Sets the custom effect used to render the particles
  14188. * @param effect The effect to set
  14189. * @param blendMode Blend mode for which the effect should be set
  14190. */
  14191. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14192. /**
  14193. * Fill the defines array according to the current settings of the particle system
  14194. * @param defines Array to be updated
  14195. * @param blendMode blend mode to take into account when updating the array
  14196. */
  14197. fillDefines(defines: Array<string>, blendMode: number): void;
  14198. /**
  14199. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14200. * @param uniforms Uniforms array to fill
  14201. * @param attributes Attributes array to fill
  14202. * @param samplers Samplers array to fill
  14203. */
  14204. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14205. /**
  14206. * Observable that will be called just before the particles are drawn
  14207. */
  14208. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14209. /**
  14210. * Gets the name of the particle vertex shader
  14211. */
  14212. vertexShaderName: string;
  14213. /**
  14214. * Adds a new color gradient
  14215. * @param gradient defines the gradient to use (between 0 and 1)
  14216. * @param color1 defines the color to affect to the specified gradient
  14217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14218. * @returns the current particle system
  14219. */
  14220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14221. /**
  14222. * Remove a specific color gradient
  14223. * @param gradient defines the gradient to remove
  14224. * @returns the current particle system
  14225. */
  14226. removeColorGradient(gradient: number): IParticleSystem;
  14227. /**
  14228. * Adds a new size gradient
  14229. * @param gradient defines the gradient to use (between 0 and 1)
  14230. * @param factor defines the size factor to affect to the specified gradient
  14231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14232. * @returns the current particle system
  14233. */
  14234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14235. /**
  14236. * Remove a specific size gradient
  14237. * @param gradient defines the gradient to remove
  14238. * @returns the current particle system
  14239. */
  14240. removeSizeGradient(gradient: number): IParticleSystem;
  14241. /**
  14242. * Gets the current list of color gradients.
  14243. * You must use addColorGradient and removeColorGradient to udpate this list
  14244. * @returns the list of color gradients
  14245. */
  14246. getColorGradients(): Nullable<Array<ColorGradient>>;
  14247. /**
  14248. * Gets the current list of size gradients.
  14249. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14250. * @returns the list of size gradients
  14251. */
  14252. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Gets the current list of angular speed gradients.
  14255. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14256. * @returns the list of angular speed gradients
  14257. */
  14258. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14259. /**
  14260. * Adds a new angular speed gradient
  14261. * @param gradient defines the gradient to use (between 0 and 1)
  14262. * @param factor defines the angular speed to affect to the specified gradient
  14263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14264. * @returns the current particle system
  14265. */
  14266. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14267. /**
  14268. * Remove a specific angular speed gradient
  14269. * @param gradient defines the gradient to remove
  14270. * @returns the current particle system
  14271. */
  14272. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14273. /**
  14274. * Gets the current list of velocity gradients.
  14275. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14276. * @returns the list of velocity gradients
  14277. */
  14278. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14279. /**
  14280. * Adds a new velocity gradient
  14281. * @param gradient defines the gradient to use (between 0 and 1)
  14282. * @param factor defines the velocity to affect to the specified gradient
  14283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14284. * @returns the current particle system
  14285. */
  14286. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14287. /**
  14288. * Remove a specific velocity gradient
  14289. * @param gradient defines the gradient to remove
  14290. * @returns the current particle system
  14291. */
  14292. removeVelocityGradient(gradient: number): IParticleSystem;
  14293. /**
  14294. * Gets the current list of limit velocity gradients.
  14295. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14296. * @returns the list of limit velocity gradients
  14297. */
  14298. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Adds a new limit velocity gradient
  14301. * @param gradient defines the gradient to use (between 0 and 1)
  14302. * @param factor defines the limit velocity to affect to the specified gradient
  14303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14304. * @returns the current particle system
  14305. */
  14306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14307. /**
  14308. * Remove a specific limit velocity gradient
  14309. * @param gradient defines the gradient to remove
  14310. * @returns the current particle system
  14311. */
  14312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14313. /**
  14314. * Adds a new drag gradient
  14315. * @param gradient defines the gradient to use (between 0 and 1)
  14316. * @param factor defines the drag to affect to the specified gradient
  14317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14318. * @returns the current particle system
  14319. */
  14320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14321. /**
  14322. * Remove a specific drag gradient
  14323. * @param gradient defines the gradient to remove
  14324. * @returns the current particle system
  14325. */
  14326. removeDragGradient(gradient: number): IParticleSystem;
  14327. /**
  14328. * Gets the current list of drag gradients.
  14329. * You must use addDragGradient and removeDragGradient to udpate this list
  14330. * @returns the list of drag gradients
  14331. */
  14332. getDragGradients(): Nullable<Array<FactorGradient>>;
  14333. /**
  14334. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14335. * @param gradient defines the gradient to use (between 0 and 1)
  14336. * @param factor defines the emit rate to affect to the specified gradient
  14337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14338. * @returns the current particle system
  14339. */
  14340. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14341. /**
  14342. * Remove a specific emit rate gradient
  14343. * @param gradient defines the gradient to remove
  14344. * @returns the current particle system
  14345. */
  14346. removeEmitRateGradient(gradient: number): IParticleSystem;
  14347. /**
  14348. * Gets the current list of emit rate gradients.
  14349. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14350. * @returns the list of emit rate gradients
  14351. */
  14352. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14353. /**
  14354. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14355. * @param gradient defines the gradient to use (between 0 and 1)
  14356. * @param factor defines the start size to affect to the specified gradient
  14357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14358. * @returns the current particle system
  14359. */
  14360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14361. /**
  14362. * Remove a specific start size gradient
  14363. * @param gradient defines the gradient to remove
  14364. * @returns the current particle system
  14365. */
  14366. removeStartSizeGradient(gradient: number): IParticleSystem;
  14367. /**
  14368. * Gets the current list of start size gradients.
  14369. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14370. * @returns the list of start size gradients
  14371. */
  14372. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Adds a new life time gradient
  14375. * @param gradient defines the gradient to use (between 0 and 1)
  14376. * @param factor defines the life time factor to affect to the specified gradient
  14377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14378. * @returns the current particle system
  14379. */
  14380. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14381. /**
  14382. * Remove a specific life time gradient
  14383. * @param gradient defines the gradient to remove
  14384. * @returns the current particle system
  14385. */
  14386. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14387. /**
  14388. * Gets the current list of life time gradients.
  14389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14390. * @returns the list of life time gradients
  14391. */
  14392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14393. /**
  14394. * Gets the current list of color gradients.
  14395. * You must use addColorGradient and removeColorGradient to udpate this list
  14396. * @returns the list of color gradients
  14397. */
  14398. getColorGradients(): Nullable<Array<ColorGradient>>;
  14399. /**
  14400. * Adds a new ramp gradient used to remap particle colors
  14401. * @param gradient defines the gradient to use (between 0 and 1)
  14402. * @param color defines the color to affect to the specified gradient
  14403. * @returns the current particle system
  14404. */
  14405. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14406. /**
  14407. * Gets the current list of ramp gradients.
  14408. * You must use addRampGradient and removeRampGradient to udpate this list
  14409. * @returns the list of ramp gradients
  14410. */
  14411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14412. /** Gets or sets a boolean indicating that ramp gradients must be used
  14413. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14414. */
  14415. useRampGradients: boolean;
  14416. /**
  14417. * Adds a new color remap gradient
  14418. * @param gradient defines the gradient to use (between 0 and 1)
  14419. * @param min defines the color remap minimal range
  14420. * @param max defines the color remap maximal range
  14421. * @returns the current particle system
  14422. */
  14423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of color remap gradients.
  14426. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14427. * @returns the list of color remap gradients
  14428. */
  14429. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Adds a new alpha remap gradient
  14432. * @param gradient defines the gradient to use (between 0 and 1)
  14433. * @param min defines the alpha remap minimal range
  14434. * @param max defines the alpha remap maximal range
  14435. * @returns the current particle system
  14436. */
  14437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14438. /**
  14439. * Gets the current list of alpha remap gradients.
  14440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14441. * @returns the list of alpha remap gradients
  14442. */
  14443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14444. /**
  14445. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14448. * @returns the emitter
  14449. */
  14450. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14451. /**
  14452. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14453. * @param radius The radius of the hemisphere to emit from
  14454. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14455. * @returns the emitter
  14456. */
  14457. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14458. /**
  14459. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14460. * @param radius The radius of the sphere to emit from
  14461. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14462. * @returns the emitter
  14463. */
  14464. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14465. /**
  14466. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14467. * @param radius The radius of the sphere to emit from
  14468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14470. * @returns the emitter
  14471. */
  14472. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14473. /**
  14474. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14475. * @param radius The radius of the emission cylinder
  14476. * @param height The height of the emission cylinder
  14477. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14478. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14479. * @returns the emitter
  14480. */
  14481. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14482. /**
  14483. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14484. * @param radius The radius of the cylinder to emit from
  14485. * @param height The height of the emission cylinder
  14486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14489. * @returns the emitter
  14490. */
  14491. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14492. /**
  14493. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14494. * @param radius The radius of the cone to emit from
  14495. * @param angle The base angle of the cone
  14496. * @returns the emitter
  14497. */
  14498. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14499. /**
  14500. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14503. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14504. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14505. * @returns the emitter
  14506. */
  14507. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14508. /**
  14509. * Get hosting scene
  14510. * @returns the scene
  14511. */
  14512. getScene(): Scene;
  14513. }
  14514. }
  14515. declare module BABYLON {
  14516. /**
  14517. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14518. * @see https://doc.babylonjs.com/how_to/transformnode
  14519. */
  14520. export class TransformNode extends Node {
  14521. /**
  14522. * Object will not rotate to face the camera
  14523. */
  14524. static BILLBOARDMODE_NONE: number;
  14525. /**
  14526. * Object will rotate to face the camera but only on the x axis
  14527. */
  14528. static BILLBOARDMODE_X: number;
  14529. /**
  14530. * Object will rotate to face the camera but only on the y axis
  14531. */
  14532. static BILLBOARDMODE_Y: number;
  14533. /**
  14534. * Object will rotate to face the camera but only on the z axis
  14535. */
  14536. static BILLBOARDMODE_Z: number;
  14537. /**
  14538. * Object will rotate to face the camera
  14539. */
  14540. static BILLBOARDMODE_ALL: number;
  14541. /**
  14542. * Object will rotate to face the camera's position instead of orientation
  14543. */
  14544. static BILLBOARDMODE_USE_POSITION: number;
  14545. private _forward;
  14546. private _forwardInverted;
  14547. private _up;
  14548. private _right;
  14549. private _rightInverted;
  14550. private _position;
  14551. private _rotation;
  14552. private _rotationQuaternion;
  14553. protected _scaling: Vector3;
  14554. protected _isDirty: boolean;
  14555. private _transformToBoneReferal;
  14556. private _isAbsoluteSynced;
  14557. private _billboardMode;
  14558. /**
  14559. * Gets or sets the billboard mode. Default is 0.
  14560. *
  14561. * | Value | Type | Description |
  14562. * | --- | --- | --- |
  14563. * | 0 | BILLBOARDMODE_NONE | |
  14564. * | 1 | BILLBOARDMODE_X | |
  14565. * | 2 | BILLBOARDMODE_Y | |
  14566. * | 4 | BILLBOARDMODE_Z | |
  14567. * | 7 | BILLBOARDMODE_ALL | |
  14568. *
  14569. */
  14570. get billboardMode(): number;
  14571. set billboardMode(value: number);
  14572. private _preserveParentRotationForBillboard;
  14573. /**
  14574. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14575. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14576. */
  14577. get preserveParentRotationForBillboard(): boolean;
  14578. set preserveParentRotationForBillboard(value: boolean);
  14579. /**
  14580. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14581. */
  14582. scalingDeterminant: number;
  14583. private _infiniteDistance;
  14584. /**
  14585. * Gets or sets the distance of the object to max, often used by skybox
  14586. */
  14587. get infiniteDistance(): boolean;
  14588. set infiniteDistance(value: boolean);
  14589. /**
  14590. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14591. * By default the system will update normals to compensate
  14592. */
  14593. ignoreNonUniformScaling: boolean;
  14594. /**
  14595. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14596. */
  14597. reIntegrateRotationIntoRotationQuaternion: boolean;
  14598. /** @hidden */
  14599. _poseMatrix: Nullable<Matrix>;
  14600. /** @hidden */
  14601. _localMatrix: Matrix;
  14602. private _usePivotMatrix;
  14603. private _absolutePosition;
  14604. private _absoluteScaling;
  14605. private _absoluteRotationQuaternion;
  14606. private _pivotMatrix;
  14607. private _pivotMatrixInverse;
  14608. protected _postMultiplyPivotMatrix: boolean;
  14609. protected _isWorldMatrixFrozen: boolean;
  14610. /** @hidden */
  14611. _indexInSceneTransformNodesArray: number;
  14612. /**
  14613. * An event triggered after the world matrix is updated
  14614. */
  14615. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14616. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14617. /**
  14618. * Gets a string identifying the name of the class
  14619. * @returns "TransformNode" string
  14620. */
  14621. getClassName(): string;
  14622. /**
  14623. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14624. */
  14625. get position(): Vector3;
  14626. set position(newPosition: Vector3);
  14627. /**
  14628. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14629. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14630. */
  14631. get rotation(): Vector3;
  14632. set rotation(newRotation: Vector3);
  14633. /**
  14634. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14635. */
  14636. get scaling(): Vector3;
  14637. set scaling(newScaling: Vector3);
  14638. /**
  14639. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14640. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14641. */
  14642. get rotationQuaternion(): Nullable<Quaternion>;
  14643. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14644. /**
  14645. * The forward direction of that transform in world space.
  14646. */
  14647. get forward(): Vector3;
  14648. /**
  14649. * The up direction of that transform in world space.
  14650. */
  14651. get up(): Vector3;
  14652. /**
  14653. * The right direction of that transform in world space.
  14654. */
  14655. get right(): Vector3;
  14656. /**
  14657. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14658. * @param matrix the matrix to copy the pose from
  14659. * @returns this TransformNode.
  14660. */
  14661. updatePoseMatrix(matrix: Matrix): TransformNode;
  14662. /**
  14663. * Returns the mesh Pose matrix.
  14664. * @returns the pose matrix
  14665. */
  14666. getPoseMatrix(): Matrix;
  14667. /** @hidden */
  14668. _isSynchronized(): boolean;
  14669. /** @hidden */
  14670. _initCache(): void;
  14671. /**
  14672. * Flag the transform node as dirty (Forcing it to update everything)
  14673. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14674. * @returns this transform node
  14675. */
  14676. markAsDirty(property: string): TransformNode;
  14677. /**
  14678. * Returns the current mesh absolute position.
  14679. * Returns a Vector3.
  14680. */
  14681. get absolutePosition(): Vector3;
  14682. /**
  14683. * Returns the current mesh absolute scaling.
  14684. * Returns a Vector3.
  14685. */
  14686. get absoluteScaling(): Vector3;
  14687. /**
  14688. * Returns the current mesh absolute rotation.
  14689. * Returns a Quaternion.
  14690. */
  14691. get absoluteRotationQuaternion(): Quaternion;
  14692. /**
  14693. * Sets a new matrix to apply before all other transformation
  14694. * @param matrix defines the transform matrix
  14695. * @returns the current TransformNode
  14696. */
  14697. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14698. /**
  14699. * Sets a new pivot matrix to the current node
  14700. * @param matrix defines the new pivot matrix to use
  14701. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14702. * @returns the current TransformNode
  14703. */
  14704. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14705. /**
  14706. * Returns the mesh pivot matrix.
  14707. * Default : Identity.
  14708. * @returns the matrix
  14709. */
  14710. getPivotMatrix(): Matrix;
  14711. /**
  14712. * Instantiate (when possible) or clone that node with its hierarchy
  14713. * @param newParent defines the new parent to use for the instance (or clone)
  14714. * @param options defines options to configure how copy is done
  14715. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14716. * @returns an instance (or a clone) of the current node with its hiearchy
  14717. */
  14718. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14719. doNotInstantiate: boolean;
  14720. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14721. /**
  14722. * Prevents the World matrix to be computed any longer
  14723. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14724. * @returns the TransformNode.
  14725. */
  14726. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14727. /**
  14728. * Allows back the World matrix computation.
  14729. * @returns the TransformNode.
  14730. */
  14731. unfreezeWorldMatrix(): this;
  14732. /**
  14733. * True if the World matrix has been frozen.
  14734. */
  14735. get isWorldMatrixFrozen(): boolean;
  14736. /**
  14737. * Retuns the mesh absolute position in the World.
  14738. * @returns a Vector3.
  14739. */
  14740. getAbsolutePosition(): Vector3;
  14741. /**
  14742. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14743. * @param absolutePosition the absolute position to set
  14744. * @returns the TransformNode.
  14745. */
  14746. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14747. /**
  14748. * Sets the mesh position in its local space.
  14749. * @param vector3 the position to set in localspace
  14750. * @returns the TransformNode.
  14751. */
  14752. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14753. /**
  14754. * Returns the mesh position in the local space from the current World matrix values.
  14755. * @returns a new Vector3.
  14756. */
  14757. getPositionExpressedInLocalSpace(): Vector3;
  14758. /**
  14759. * Translates the mesh along the passed Vector3 in its local space.
  14760. * @param vector3 the distance to translate in localspace
  14761. * @returns the TransformNode.
  14762. */
  14763. locallyTranslate(vector3: Vector3): TransformNode;
  14764. private static _lookAtVectorCache;
  14765. /**
  14766. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14767. * @param targetPoint the position (must be in same space as current mesh) to look at
  14768. * @param yawCor optional yaw (y-axis) correction in radians
  14769. * @param pitchCor optional pitch (x-axis) correction in radians
  14770. * @param rollCor optional roll (z-axis) correction in radians
  14771. * @param space the choosen space of the target
  14772. * @returns the TransformNode.
  14773. */
  14774. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14775. /**
  14776. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14777. * This Vector3 is expressed in the World space.
  14778. * @param localAxis axis to rotate
  14779. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14780. */
  14781. getDirection(localAxis: Vector3): Vector3;
  14782. /**
  14783. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14784. * localAxis is expressed in the mesh local space.
  14785. * result is computed in the Wordl space from the mesh World matrix.
  14786. * @param localAxis axis to rotate
  14787. * @param result the resulting transformnode
  14788. * @returns this TransformNode.
  14789. */
  14790. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14791. /**
  14792. * Sets this transform node rotation to the given local axis.
  14793. * @param localAxis the axis in local space
  14794. * @param yawCor optional yaw (y-axis) correction in radians
  14795. * @param pitchCor optional pitch (x-axis) correction in radians
  14796. * @param rollCor optional roll (z-axis) correction in radians
  14797. * @returns this TransformNode
  14798. */
  14799. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14800. /**
  14801. * Sets a new pivot point to the current node
  14802. * @param point defines the new pivot point to use
  14803. * @param space defines if the point is in world or local space (local by default)
  14804. * @returns the current TransformNode
  14805. */
  14806. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14807. /**
  14808. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14809. * @returns the pivot point
  14810. */
  14811. getPivotPoint(): Vector3;
  14812. /**
  14813. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14814. * @param result the vector3 to store the result
  14815. * @returns this TransformNode.
  14816. */
  14817. getPivotPointToRef(result: Vector3): TransformNode;
  14818. /**
  14819. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14820. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14821. */
  14822. getAbsolutePivotPoint(): Vector3;
  14823. /**
  14824. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14825. * @param result vector3 to store the result
  14826. * @returns this TransformNode.
  14827. */
  14828. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14829. /**
  14830. * Defines the passed node as the parent of the current node.
  14831. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14832. * @see https://doc.babylonjs.com/how_to/parenting
  14833. * @param node the node ot set as the parent
  14834. * @returns this TransformNode.
  14835. */
  14836. setParent(node: Nullable<Node>): TransformNode;
  14837. private _nonUniformScaling;
  14838. /**
  14839. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14840. */
  14841. get nonUniformScaling(): boolean;
  14842. /** @hidden */
  14843. _updateNonUniformScalingState(value: boolean): boolean;
  14844. /**
  14845. * Attach the current TransformNode to another TransformNode associated with a bone
  14846. * @param bone Bone affecting the TransformNode
  14847. * @param affectedTransformNode TransformNode associated with the bone
  14848. * @returns this object
  14849. */
  14850. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14851. /**
  14852. * Detach the transform node if its associated with a bone
  14853. * @returns this object
  14854. */
  14855. detachFromBone(): TransformNode;
  14856. private static _rotationAxisCache;
  14857. /**
  14858. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14859. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14860. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14861. * The passed axis is also normalized.
  14862. * @param axis the axis to rotate around
  14863. * @param amount the amount to rotate in radians
  14864. * @param space Space to rotate in (Default: local)
  14865. * @returns the TransformNode.
  14866. */
  14867. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14868. /**
  14869. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14870. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14871. * The passed axis is also normalized. .
  14872. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14873. * @param point the point to rotate around
  14874. * @param axis the axis to rotate around
  14875. * @param amount the amount to rotate in radians
  14876. * @returns the TransformNode
  14877. */
  14878. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14879. /**
  14880. * Translates the mesh along the axis vector for the passed distance in the given space.
  14881. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14882. * @param axis the axis to translate in
  14883. * @param distance the distance to translate
  14884. * @param space Space to rotate in (Default: local)
  14885. * @returns the TransformNode.
  14886. */
  14887. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14888. /**
  14889. * Adds a rotation step to the mesh current rotation.
  14890. * x, y, z are Euler angles expressed in radians.
  14891. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14892. * This means this rotation is made in the mesh local space only.
  14893. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14894. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14895. * ```javascript
  14896. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14897. * ```
  14898. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14899. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14900. * @param x Rotation to add
  14901. * @param y Rotation to add
  14902. * @param z Rotation to add
  14903. * @returns the TransformNode.
  14904. */
  14905. addRotation(x: number, y: number, z: number): TransformNode;
  14906. /**
  14907. * @hidden
  14908. */
  14909. protected _getEffectiveParent(): Nullable<Node>;
  14910. /**
  14911. * Computes the world matrix of the node
  14912. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14913. * @returns the world matrix
  14914. */
  14915. computeWorldMatrix(force?: boolean): Matrix;
  14916. /**
  14917. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14918. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14919. */
  14920. resetLocalMatrix(independentOfChildren?: boolean): void;
  14921. protected _afterComputeWorldMatrix(): void;
  14922. /**
  14923. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14924. * @param func callback function to add
  14925. *
  14926. * @returns the TransformNode.
  14927. */
  14928. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14929. /**
  14930. * Removes a registered callback function.
  14931. * @param func callback function to remove
  14932. * @returns the TransformNode.
  14933. */
  14934. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14935. /**
  14936. * Gets the position of the current mesh in camera space
  14937. * @param camera defines the camera to use
  14938. * @returns a position
  14939. */
  14940. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14941. /**
  14942. * Returns the distance from the mesh to the active camera
  14943. * @param camera defines the camera to use
  14944. * @returns the distance
  14945. */
  14946. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14947. /**
  14948. * Clone the current transform node
  14949. * @param name Name of the new clone
  14950. * @param newParent New parent for the clone
  14951. * @param doNotCloneChildren Do not clone children hierarchy
  14952. * @returns the new transform node
  14953. */
  14954. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14955. /**
  14956. * Serializes the objects information.
  14957. * @param currentSerializationObject defines the object to serialize in
  14958. * @returns the serialized object
  14959. */
  14960. serialize(currentSerializationObject?: any): any;
  14961. /**
  14962. * Returns a new TransformNode object parsed from the source provided.
  14963. * @param parsedTransformNode is the source.
  14964. * @param scene the scne the object belongs to
  14965. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14966. * @returns a new TransformNode object parsed from the source provided.
  14967. */
  14968. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14969. /**
  14970. * Get all child-transformNodes of this node
  14971. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14972. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14973. * @returns an array of TransformNode
  14974. */
  14975. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14976. /**
  14977. * Releases resources associated with this transform node.
  14978. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14979. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14980. */
  14981. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14982. /**
  14983. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14984. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14985. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14986. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14987. * @returns the current mesh
  14988. */
  14989. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14990. private _syncAbsoluteScalingAndRotation;
  14991. }
  14992. }
  14993. declare module BABYLON {
  14994. /**
  14995. * Class used to override all child animations of a given target
  14996. */
  14997. export class AnimationPropertiesOverride {
  14998. /**
  14999. * Gets or sets a value indicating if animation blending must be used
  15000. */
  15001. enableBlending: boolean;
  15002. /**
  15003. * Gets or sets the blending speed to use when enableBlending is true
  15004. */
  15005. blendingSpeed: number;
  15006. /**
  15007. * Gets or sets the default loop mode to use
  15008. */
  15009. loopMode: number;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Class used to store bone information
  15015. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15016. */
  15017. export class Bone extends Node {
  15018. /**
  15019. * defines the bone name
  15020. */
  15021. name: string;
  15022. private static _tmpVecs;
  15023. private static _tmpQuat;
  15024. private static _tmpMats;
  15025. /**
  15026. * Gets the list of child bones
  15027. */
  15028. children: Bone[];
  15029. /** Gets the animations associated with this bone */
  15030. animations: Animation[];
  15031. /**
  15032. * Gets or sets bone length
  15033. */
  15034. length: number;
  15035. /**
  15036. * @hidden Internal only
  15037. * Set this value to map this bone to a different index in the transform matrices
  15038. * Set this value to -1 to exclude the bone from the transform matrices
  15039. */
  15040. _index: Nullable<number>;
  15041. private _skeleton;
  15042. private _localMatrix;
  15043. private _restPose;
  15044. private _baseMatrix;
  15045. private _absoluteTransform;
  15046. private _invertedAbsoluteTransform;
  15047. private _parent;
  15048. private _scalingDeterminant;
  15049. private _worldTransform;
  15050. private _localScaling;
  15051. private _localRotation;
  15052. private _localPosition;
  15053. private _needToDecompose;
  15054. private _needToCompose;
  15055. /** @hidden */
  15056. _linkedTransformNode: Nullable<TransformNode>;
  15057. /** @hidden */
  15058. _waitingTransformNodeId: Nullable<string>;
  15059. /** @hidden */
  15060. get _matrix(): Matrix;
  15061. /** @hidden */
  15062. set _matrix(value: Matrix);
  15063. /**
  15064. * Create a new bone
  15065. * @param name defines the bone name
  15066. * @param skeleton defines the parent skeleton
  15067. * @param parentBone defines the parent (can be null if the bone is the root)
  15068. * @param localMatrix defines the local matrix
  15069. * @param restPose defines the rest pose matrix
  15070. * @param baseMatrix defines the base matrix
  15071. * @param index defines index of the bone in the hiearchy
  15072. */
  15073. constructor(
  15074. /**
  15075. * defines the bone name
  15076. */
  15077. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15078. /**
  15079. * Gets the current object class name.
  15080. * @return the class name
  15081. */
  15082. getClassName(): string;
  15083. /**
  15084. * Gets the parent skeleton
  15085. * @returns a skeleton
  15086. */
  15087. getSkeleton(): Skeleton;
  15088. /**
  15089. * Gets parent bone
  15090. * @returns a bone or null if the bone is the root of the bone hierarchy
  15091. */
  15092. getParent(): Nullable<Bone>;
  15093. /**
  15094. * Returns an array containing the root bones
  15095. * @returns an array containing the root bones
  15096. */
  15097. getChildren(): Array<Bone>;
  15098. /**
  15099. * Gets the node index in matrix array generated for rendering
  15100. * @returns the node index
  15101. */
  15102. getIndex(): number;
  15103. /**
  15104. * Sets the parent bone
  15105. * @param parent defines the parent (can be null if the bone is the root)
  15106. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15107. */
  15108. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15109. /**
  15110. * Gets the local matrix
  15111. * @returns a matrix
  15112. */
  15113. getLocalMatrix(): Matrix;
  15114. /**
  15115. * Gets the base matrix (initial matrix which remains unchanged)
  15116. * @returns a matrix
  15117. */
  15118. getBaseMatrix(): Matrix;
  15119. /**
  15120. * Gets the rest pose matrix
  15121. * @returns a matrix
  15122. */
  15123. getRestPose(): Matrix;
  15124. /**
  15125. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15126. */
  15127. getWorldMatrix(): Matrix;
  15128. /**
  15129. * Sets the local matrix to rest pose matrix
  15130. */
  15131. returnToRest(): void;
  15132. /**
  15133. * Gets the inverse of the absolute transform matrix.
  15134. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15135. * @returns a matrix
  15136. */
  15137. getInvertedAbsoluteTransform(): Matrix;
  15138. /**
  15139. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15140. * @returns a matrix
  15141. */
  15142. getAbsoluteTransform(): Matrix;
  15143. /**
  15144. * Links with the given transform node.
  15145. * The local matrix of this bone is copied from the transform node every frame.
  15146. * @param transformNode defines the transform node to link to
  15147. */
  15148. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15149. /**
  15150. * Gets the node used to drive the bone's transformation
  15151. * @returns a transform node or null
  15152. */
  15153. getTransformNode(): Nullable<TransformNode>;
  15154. /** Gets or sets current position (in local space) */
  15155. get position(): Vector3;
  15156. set position(newPosition: Vector3);
  15157. /** Gets or sets current rotation (in local space) */
  15158. get rotation(): Vector3;
  15159. set rotation(newRotation: Vector3);
  15160. /** Gets or sets current rotation quaternion (in local space) */
  15161. get rotationQuaternion(): Quaternion;
  15162. set rotationQuaternion(newRotation: Quaternion);
  15163. /** Gets or sets current scaling (in local space) */
  15164. get scaling(): Vector3;
  15165. set scaling(newScaling: Vector3);
  15166. /**
  15167. * Gets the animation properties override
  15168. */
  15169. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15170. private _decompose;
  15171. private _compose;
  15172. /**
  15173. * Update the base and local matrices
  15174. * @param matrix defines the new base or local matrix
  15175. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15176. * @param updateLocalMatrix defines if the local matrix should be updated
  15177. */
  15178. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15179. /** @hidden */
  15180. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15181. /**
  15182. * Flag the bone as dirty (Forcing it to update everything)
  15183. */
  15184. markAsDirty(): void;
  15185. /** @hidden */
  15186. _markAsDirtyAndCompose(): void;
  15187. private _markAsDirtyAndDecompose;
  15188. /**
  15189. * Translate the bone in local or world space
  15190. * @param vec The amount to translate the bone
  15191. * @param space The space that the translation is in
  15192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15193. */
  15194. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15195. /**
  15196. * Set the postion of the bone in local or world space
  15197. * @param position The position to set the bone
  15198. * @param space The space that the position is in
  15199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15200. */
  15201. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15202. /**
  15203. * Set the absolute position of the bone (world space)
  15204. * @param position The position to set the bone
  15205. * @param mesh The mesh that this bone is attached to
  15206. */
  15207. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15208. /**
  15209. * Scale the bone on the x, y and z axes (in local space)
  15210. * @param x The amount to scale the bone on the x axis
  15211. * @param y The amount to scale the bone on the y axis
  15212. * @param z The amount to scale the bone on the z axis
  15213. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15214. */
  15215. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15216. /**
  15217. * Set the bone scaling in local space
  15218. * @param scale defines the scaling vector
  15219. */
  15220. setScale(scale: Vector3): void;
  15221. /**
  15222. * Gets the current scaling in local space
  15223. * @returns the current scaling vector
  15224. */
  15225. getScale(): Vector3;
  15226. /**
  15227. * Gets the current scaling in local space and stores it in a target vector
  15228. * @param result defines the target vector
  15229. */
  15230. getScaleToRef(result: Vector3): void;
  15231. /**
  15232. * Set the yaw, pitch, and roll of the bone in local or world space
  15233. * @param yaw The rotation of the bone on the y axis
  15234. * @param pitch The rotation of the bone on the x axis
  15235. * @param roll The rotation of the bone on the z axis
  15236. * @param space The space that the axes of rotation are in
  15237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15238. */
  15239. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15240. /**
  15241. * Add a rotation to the bone on an axis in local or world space
  15242. * @param axis The axis to rotate the bone on
  15243. * @param amount The amount to rotate the bone
  15244. * @param space The space that the axis is in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. */
  15247. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15248. /**
  15249. * Set the rotation of the bone to a particular axis angle in local or world space
  15250. * @param axis The axis to rotate the bone on
  15251. * @param angle The angle that the bone should be rotated to
  15252. * @param space The space that the axis is in
  15253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15254. */
  15255. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15256. /**
  15257. * Set the euler rotation of the bone in local of world space
  15258. * @param rotation The euler rotation that the bone should be set to
  15259. * @param space The space that the rotation is in
  15260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15261. */
  15262. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15263. /**
  15264. * Set the quaternion rotation of the bone in local of world space
  15265. * @param quat The quaternion rotation that the bone should be set to
  15266. * @param space The space that the rotation is in
  15267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15268. */
  15269. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15270. /**
  15271. * Set the rotation matrix of the bone in local of world space
  15272. * @param rotMat The rotation matrix that the bone should be set to
  15273. * @param space The space that the rotation is in
  15274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15275. */
  15276. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15277. private _rotateWithMatrix;
  15278. private _getNegativeRotationToRef;
  15279. /**
  15280. * Get the position of the bone in local or world space
  15281. * @param space The space that the returned position is in
  15282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15283. * @returns The position of the bone
  15284. */
  15285. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15286. /**
  15287. * Copy the position of the bone to a vector3 in local or world space
  15288. * @param space The space that the returned position is in
  15289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15290. * @param result The vector3 to copy the position to
  15291. */
  15292. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15293. /**
  15294. * Get the absolute position of the bone (world space)
  15295. * @param mesh The mesh that this bone is attached to
  15296. * @returns The absolute position of the bone
  15297. */
  15298. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15299. /**
  15300. * Copy the absolute position of the bone (world space) to the result param
  15301. * @param mesh The mesh that this bone is attached to
  15302. * @param result The vector3 to copy the absolute position to
  15303. */
  15304. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15305. /**
  15306. * Compute the absolute transforms of this bone and its children
  15307. */
  15308. computeAbsoluteTransforms(): void;
  15309. /**
  15310. * Get the world direction from an axis that is in the local space of the bone
  15311. * @param localAxis The local direction that is used to compute the world direction
  15312. * @param mesh The mesh that this bone is attached to
  15313. * @returns The world direction
  15314. */
  15315. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15316. /**
  15317. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15318. * @param localAxis The local direction that is used to compute the world direction
  15319. * @param mesh The mesh that this bone is attached to
  15320. * @param result The vector3 that the world direction will be copied to
  15321. */
  15322. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15323. /**
  15324. * Get the euler rotation of the bone in local or world space
  15325. * @param space The space that the rotation should be in
  15326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15327. * @returns The euler rotation
  15328. */
  15329. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15330. /**
  15331. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15332. * @param space The space that the rotation should be in
  15333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15334. * @param result The vector3 that the rotation should be copied to
  15335. */
  15336. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15337. /**
  15338. * Get the quaternion rotation of the bone in either local or world space
  15339. * @param space The space that the rotation should be in
  15340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15341. * @returns The quaternion rotation
  15342. */
  15343. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15344. /**
  15345. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15346. * @param space The space that the rotation should be in
  15347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15348. * @param result The quaternion that the rotation should be copied to
  15349. */
  15350. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15351. /**
  15352. * Get the rotation matrix of the bone in local or world space
  15353. * @param space The space that the rotation should be in
  15354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15355. * @returns The rotation matrix
  15356. */
  15357. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15358. /**
  15359. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15360. * @param space The space that the rotation should be in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. * @param result The quaternion that the rotation should be copied to
  15363. */
  15364. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15365. /**
  15366. * Get the world position of a point that is in the local space of the bone
  15367. * @param position The local position
  15368. * @param mesh The mesh that this bone is attached to
  15369. * @returns The world position
  15370. */
  15371. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15372. /**
  15373. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15374. * @param position The local position
  15375. * @param mesh The mesh that this bone is attached to
  15376. * @param result The vector3 that the world position should be copied to
  15377. */
  15378. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15379. /**
  15380. * Get the local position of a point that is in world space
  15381. * @param position The world position
  15382. * @param mesh The mesh that this bone is attached to
  15383. * @returns The local position
  15384. */
  15385. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15386. /**
  15387. * Get the local position of a point that is in world space and copy it to the result param
  15388. * @param position The world position
  15389. * @param mesh The mesh that this bone is attached to
  15390. * @param result The vector3 that the local position should be copied to
  15391. */
  15392. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15393. }
  15394. }
  15395. declare module BABYLON {
  15396. /**
  15397. * Defines a runtime animation
  15398. */
  15399. export class RuntimeAnimation {
  15400. private _events;
  15401. /**
  15402. * The current frame of the runtime animation
  15403. */
  15404. private _currentFrame;
  15405. /**
  15406. * The animation used by the runtime animation
  15407. */
  15408. private _animation;
  15409. /**
  15410. * The target of the runtime animation
  15411. */
  15412. private _target;
  15413. /**
  15414. * The initiating animatable
  15415. */
  15416. private _host;
  15417. /**
  15418. * The original value of the runtime animation
  15419. */
  15420. private _originalValue;
  15421. /**
  15422. * The original blend value of the runtime animation
  15423. */
  15424. private _originalBlendValue;
  15425. /**
  15426. * The offsets cache of the runtime animation
  15427. */
  15428. private _offsetsCache;
  15429. /**
  15430. * The high limits cache of the runtime animation
  15431. */
  15432. private _highLimitsCache;
  15433. /**
  15434. * Specifies if the runtime animation has been stopped
  15435. */
  15436. private _stopped;
  15437. /**
  15438. * The blending factor of the runtime animation
  15439. */
  15440. private _blendingFactor;
  15441. /**
  15442. * The BabylonJS scene
  15443. */
  15444. private _scene;
  15445. /**
  15446. * The current value of the runtime animation
  15447. */
  15448. private _currentValue;
  15449. /** @hidden */
  15450. _animationState: _IAnimationState;
  15451. /**
  15452. * The active target of the runtime animation
  15453. */
  15454. private _activeTargets;
  15455. private _currentActiveTarget;
  15456. private _directTarget;
  15457. /**
  15458. * The target path of the runtime animation
  15459. */
  15460. private _targetPath;
  15461. /**
  15462. * The weight of the runtime animation
  15463. */
  15464. private _weight;
  15465. /**
  15466. * The ratio offset of the runtime animation
  15467. */
  15468. private _ratioOffset;
  15469. /**
  15470. * The previous delay of the runtime animation
  15471. */
  15472. private _previousDelay;
  15473. /**
  15474. * The previous ratio of the runtime animation
  15475. */
  15476. private _previousRatio;
  15477. private _enableBlending;
  15478. private _keys;
  15479. private _minFrame;
  15480. private _maxFrame;
  15481. private _minValue;
  15482. private _maxValue;
  15483. private _targetIsArray;
  15484. /**
  15485. * Gets the current frame of the runtime animation
  15486. */
  15487. get currentFrame(): number;
  15488. /**
  15489. * Gets the weight of the runtime animation
  15490. */
  15491. get weight(): number;
  15492. /**
  15493. * Gets the current value of the runtime animation
  15494. */
  15495. get currentValue(): any;
  15496. /**
  15497. * Gets the target path of the runtime animation
  15498. */
  15499. get targetPath(): string;
  15500. /**
  15501. * Gets the actual target of the runtime animation
  15502. */
  15503. get target(): any;
  15504. /**
  15505. * Gets the additive state of the runtime animation
  15506. */
  15507. get isAdditive(): boolean;
  15508. /** @hidden */
  15509. _onLoop: () => void;
  15510. /**
  15511. * Create a new RuntimeAnimation object
  15512. * @param target defines the target of the animation
  15513. * @param animation defines the source animation object
  15514. * @param scene defines the hosting scene
  15515. * @param host defines the initiating Animatable
  15516. */
  15517. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15518. private _preparePath;
  15519. /**
  15520. * Gets the animation from the runtime animation
  15521. */
  15522. get animation(): Animation;
  15523. /**
  15524. * Resets the runtime animation to the beginning
  15525. * @param restoreOriginal defines whether to restore the target property to the original value
  15526. */
  15527. reset(restoreOriginal?: boolean): void;
  15528. /**
  15529. * Specifies if the runtime animation is stopped
  15530. * @returns Boolean specifying if the runtime animation is stopped
  15531. */
  15532. isStopped(): boolean;
  15533. /**
  15534. * Disposes of the runtime animation
  15535. */
  15536. dispose(): void;
  15537. /**
  15538. * Apply the interpolated value to the target
  15539. * @param currentValue defines the value computed by the animation
  15540. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15541. */
  15542. setValue(currentValue: any, weight: number): void;
  15543. private _getOriginalValues;
  15544. private _setValue;
  15545. /**
  15546. * Gets the loop pmode of the runtime animation
  15547. * @returns Loop Mode
  15548. */
  15549. private _getCorrectLoopMode;
  15550. /**
  15551. * Move the current animation to a given frame
  15552. * @param frame defines the frame to move to
  15553. */
  15554. goToFrame(frame: number): void;
  15555. /**
  15556. * @hidden Internal use only
  15557. */
  15558. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15559. /**
  15560. * Execute the current animation
  15561. * @param delay defines the delay to add to the current frame
  15562. * @param from defines the lower bound of the animation range
  15563. * @param to defines the upper bound of the animation range
  15564. * @param loop defines if the current animation must loop
  15565. * @param speedRatio defines the current speed ratio
  15566. * @param weight defines the weight of the animation (default is -1 so no weight)
  15567. * @param onLoop optional callback called when animation loops
  15568. * @returns a boolean indicating if the animation is running
  15569. */
  15570. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15571. }
  15572. }
  15573. declare module BABYLON {
  15574. /**
  15575. * Class used to store an actual running animation
  15576. */
  15577. export class Animatable {
  15578. /** defines the target object */
  15579. target: any;
  15580. /** defines the starting frame number (default is 0) */
  15581. fromFrame: number;
  15582. /** defines the ending frame number (default is 100) */
  15583. toFrame: number;
  15584. /** defines if the animation must loop (default is false) */
  15585. loopAnimation: boolean;
  15586. /** defines a callback to call when animation ends if it is not looping */
  15587. onAnimationEnd?: (() => void) | null | undefined;
  15588. /** defines a callback to call when animation loops */
  15589. onAnimationLoop?: (() => void) | null | undefined;
  15590. /** defines whether the animation should be evaluated additively */
  15591. isAdditive: boolean;
  15592. private _localDelayOffset;
  15593. private _pausedDelay;
  15594. private _runtimeAnimations;
  15595. private _paused;
  15596. private _scene;
  15597. private _speedRatio;
  15598. private _weight;
  15599. private _syncRoot;
  15600. /**
  15601. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15602. * This will only apply for non looping animation (default is true)
  15603. */
  15604. disposeOnEnd: boolean;
  15605. /**
  15606. * Gets a boolean indicating if the animation has started
  15607. */
  15608. animationStarted: boolean;
  15609. /**
  15610. * Observer raised when the animation ends
  15611. */
  15612. onAnimationEndObservable: Observable<Animatable>;
  15613. /**
  15614. * Observer raised when the animation loops
  15615. */
  15616. onAnimationLoopObservable: Observable<Animatable>;
  15617. /**
  15618. * Gets the root Animatable used to synchronize and normalize animations
  15619. */
  15620. get syncRoot(): Nullable<Animatable>;
  15621. /**
  15622. * Gets the current frame of the first RuntimeAnimation
  15623. * Used to synchronize Animatables
  15624. */
  15625. get masterFrame(): number;
  15626. /**
  15627. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15628. */
  15629. get weight(): number;
  15630. set weight(value: number);
  15631. /**
  15632. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15633. */
  15634. get speedRatio(): number;
  15635. set speedRatio(value: number);
  15636. /**
  15637. * Creates a new Animatable
  15638. * @param scene defines the hosting scene
  15639. * @param target defines the target object
  15640. * @param fromFrame defines the starting frame number (default is 0)
  15641. * @param toFrame defines the ending frame number (default is 100)
  15642. * @param loopAnimation defines if the animation must loop (default is false)
  15643. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15644. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15645. * @param animations defines a group of animation to add to the new Animatable
  15646. * @param onAnimationLoop defines a callback to call when animation loops
  15647. * @param isAdditive defines whether the animation should be evaluated additively
  15648. */
  15649. constructor(scene: Scene,
  15650. /** defines the target object */
  15651. target: any,
  15652. /** defines the starting frame number (default is 0) */
  15653. fromFrame?: number,
  15654. /** defines the ending frame number (default is 100) */
  15655. toFrame?: number,
  15656. /** defines if the animation must loop (default is false) */
  15657. loopAnimation?: boolean, speedRatio?: number,
  15658. /** defines a callback to call when animation ends if it is not looping */
  15659. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15660. /** defines a callback to call when animation loops */
  15661. onAnimationLoop?: (() => void) | null | undefined,
  15662. /** defines whether the animation should be evaluated additively */
  15663. isAdditive?: boolean);
  15664. /**
  15665. * Synchronize and normalize current Animatable with a source Animatable
  15666. * This is useful when using animation weights and when animations are not of the same length
  15667. * @param root defines the root Animatable to synchronize with
  15668. * @returns the current Animatable
  15669. */
  15670. syncWith(root: Animatable): Animatable;
  15671. /**
  15672. * Gets the list of runtime animations
  15673. * @returns an array of RuntimeAnimation
  15674. */
  15675. getAnimations(): RuntimeAnimation[];
  15676. /**
  15677. * Adds more animations to the current animatable
  15678. * @param target defines the target of the animations
  15679. * @param animations defines the new animations to add
  15680. */
  15681. appendAnimations(target: any, animations: Animation[]): void;
  15682. /**
  15683. * Gets the source animation for a specific property
  15684. * @param property defines the propertyu to look for
  15685. * @returns null or the source animation for the given property
  15686. */
  15687. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15688. /**
  15689. * Gets the runtime animation for a specific property
  15690. * @param property defines the propertyu to look for
  15691. * @returns null or the runtime animation for the given property
  15692. */
  15693. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15694. /**
  15695. * Resets the animatable to its original state
  15696. */
  15697. reset(): void;
  15698. /**
  15699. * Allows the animatable to blend with current running animations
  15700. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15701. * @param blendingSpeed defines the blending speed to use
  15702. */
  15703. enableBlending(blendingSpeed: number): void;
  15704. /**
  15705. * Disable animation blending
  15706. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15707. */
  15708. disableBlending(): void;
  15709. /**
  15710. * Jump directly to a given frame
  15711. * @param frame defines the frame to jump to
  15712. */
  15713. goToFrame(frame: number): void;
  15714. /**
  15715. * Pause the animation
  15716. */
  15717. pause(): void;
  15718. /**
  15719. * Restart the animation
  15720. */
  15721. restart(): void;
  15722. private _raiseOnAnimationEnd;
  15723. /**
  15724. * Stop and delete the current animation
  15725. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15726. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15727. */
  15728. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15729. /**
  15730. * Wait asynchronously for the animation to end
  15731. * @returns a promise which will be fullfilled when the animation ends
  15732. */
  15733. waitAsync(): Promise<Animatable>;
  15734. /** @hidden */
  15735. _animate(delay: number): boolean;
  15736. }
  15737. interface Scene {
  15738. /** @hidden */
  15739. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15740. /** @hidden */
  15741. _processLateAnimationBindingsForMatrices(holder: {
  15742. totalWeight: number;
  15743. totalAdditiveWeight: number;
  15744. animations: RuntimeAnimation[];
  15745. additiveAnimations: RuntimeAnimation[];
  15746. originalValue: Matrix;
  15747. }): any;
  15748. /** @hidden */
  15749. _processLateAnimationBindingsForQuaternions(holder: {
  15750. totalWeight: number;
  15751. totalAdditiveWeight: number;
  15752. animations: RuntimeAnimation[];
  15753. additiveAnimations: RuntimeAnimation[];
  15754. originalValue: Quaternion;
  15755. }, refQuaternion: Quaternion): Quaternion;
  15756. /** @hidden */
  15757. _processLateAnimationBindings(): void;
  15758. /**
  15759. * Will start the animation sequence of a given target
  15760. * @param target defines the target
  15761. * @param from defines from which frame should animation start
  15762. * @param to defines until which frame should animation run.
  15763. * @param weight defines the weight to apply to the animation (1.0 by default)
  15764. * @param loop defines if the animation loops
  15765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15766. * @param onAnimationEnd defines the function to be executed when the animation ends
  15767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15769. * @param onAnimationLoop defines the callback to call when an animation loops
  15770. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15771. * @returns the animatable object created for this animation
  15772. */
  15773. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15774. /**
  15775. * Will start the animation sequence of a given target
  15776. * @param target defines the target
  15777. * @param from defines from which frame should animation start
  15778. * @param to defines until which frame should animation run.
  15779. * @param loop defines if the animation loops
  15780. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15781. * @param onAnimationEnd defines the function to be executed when the animation ends
  15782. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15783. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15784. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15785. * @param onAnimationLoop defines the callback to call when an animation loops
  15786. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15787. * @returns the animatable object created for this animation
  15788. */
  15789. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15790. /**
  15791. * Will start the animation sequence of a given target and its hierarchy
  15792. * @param target defines the target
  15793. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15794. * @param from defines from which frame should animation start
  15795. * @param to defines until which frame should animation run.
  15796. * @param loop defines if the animation loops
  15797. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15798. * @param onAnimationEnd defines the function to be executed when the animation ends
  15799. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15800. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15802. * @param onAnimationLoop defines the callback to call when an animation loops
  15803. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15804. * @returns the list of created animatables
  15805. */
  15806. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15807. /**
  15808. * Begin a new animation on a given node
  15809. * @param target defines the target where the animation will take place
  15810. * @param animations defines the list of animations to start
  15811. * @param from defines the initial value
  15812. * @param to defines the final value
  15813. * @param loop defines if you want animation to loop (off by default)
  15814. * @param speedRatio defines the speed ratio to apply to all animations
  15815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15816. * @param onAnimationLoop defines the callback to call when an animation loops
  15817. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15818. * @returns the list of created animatables
  15819. */
  15820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15821. /**
  15822. * Begin a new animation on a given node and its hierarchy
  15823. * @param target defines the root node where the animation will take place
  15824. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15825. * @param animations defines the list of animations to start
  15826. * @param from defines the initial value
  15827. * @param to defines the final value
  15828. * @param loop defines if you want animation to loop (off by default)
  15829. * @param speedRatio defines the speed ratio to apply to all animations
  15830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15831. * @param onAnimationLoop defines the callback to call when an animation loops
  15832. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15833. * @returns the list of animatables created for all nodes
  15834. */
  15835. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15836. /**
  15837. * Gets the animatable associated with a specific target
  15838. * @param target defines the target of the animatable
  15839. * @returns the required animatable if found
  15840. */
  15841. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15842. /**
  15843. * Gets all animatables associated with a given target
  15844. * @param target defines the target to look animatables for
  15845. * @returns an array of Animatables
  15846. */
  15847. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15848. /**
  15849. * Stops and removes all animations that have been applied to the scene
  15850. */
  15851. stopAllAnimations(): void;
  15852. /**
  15853. * Gets the current delta time used by animation engine
  15854. */
  15855. deltaTime: number;
  15856. }
  15857. interface Bone {
  15858. /**
  15859. * Copy an animation range from another bone
  15860. * @param source defines the source bone
  15861. * @param rangeName defines the range name to copy
  15862. * @param frameOffset defines the frame offset
  15863. * @param rescaleAsRequired defines if rescaling must be applied if required
  15864. * @param skelDimensionsRatio defines the scaling ratio
  15865. * @returns true if operation was successful
  15866. */
  15867. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15868. }
  15869. }
  15870. declare module BABYLON {
  15871. /**
  15872. * Class used to handle skinning animations
  15873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15874. */
  15875. export class Skeleton implements IAnimatable {
  15876. /** defines the skeleton name */
  15877. name: string;
  15878. /** defines the skeleton Id */
  15879. id: string;
  15880. /**
  15881. * Defines the list of child bones
  15882. */
  15883. bones: Bone[];
  15884. /**
  15885. * Defines an estimate of the dimension of the skeleton at rest
  15886. */
  15887. dimensionsAtRest: Vector3;
  15888. /**
  15889. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15890. */
  15891. needInitialSkinMatrix: boolean;
  15892. /**
  15893. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15894. */
  15895. overrideMesh: Nullable<AbstractMesh>;
  15896. /**
  15897. * Gets the list of animations attached to this skeleton
  15898. */
  15899. animations: Array<Animation>;
  15900. private _scene;
  15901. private _isDirty;
  15902. private _transformMatrices;
  15903. private _transformMatrixTexture;
  15904. private _meshesWithPoseMatrix;
  15905. private _animatables;
  15906. private _identity;
  15907. private _synchronizedWithMesh;
  15908. private _ranges;
  15909. private _lastAbsoluteTransformsUpdateId;
  15910. private _canUseTextureForBones;
  15911. private _uniqueId;
  15912. /** @hidden */
  15913. _numBonesWithLinkedTransformNode: number;
  15914. /** @hidden */
  15915. _hasWaitingData: Nullable<boolean>;
  15916. /**
  15917. * Specifies if the skeleton should be serialized
  15918. */
  15919. doNotSerialize: boolean;
  15920. private _useTextureToStoreBoneMatrices;
  15921. /**
  15922. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15923. * Please note that this option is not available if the hardware does not support it
  15924. */
  15925. get useTextureToStoreBoneMatrices(): boolean;
  15926. set useTextureToStoreBoneMatrices(value: boolean);
  15927. private _animationPropertiesOverride;
  15928. /**
  15929. * Gets or sets the animation properties override
  15930. */
  15931. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15932. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15933. /**
  15934. * List of inspectable custom properties (used by the Inspector)
  15935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15936. */
  15937. inspectableCustomProperties: IInspectable[];
  15938. /**
  15939. * An observable triggered before computing the skeleton's matrices
  15940. */
  15941. onBeforeComputeObservable: Observable<Skeleton>;
  15942. /**
  15943. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15944. */
  15945. get isUsingTextureForMatrices(): boolean;
  15946. /**
  15947. * Gets the unique ID of this skeleton
  15948. */
  15949. get uniqueId(): number;
  15950. /**
  15951. * Creates a new skeleton
  15952. * @param name defines the skeleton name
  15953. * @param id defines the skeleton Id
  15954. * @param scene defines the hosting scene
  15955. */
  15956. constructor(
  15957. /** defines the skeleton name */
  15958. name: string,
  15959. /** defines the skeleton Id */
  15960. id: string, scene: Scene);
  15961. /**
  15962. * Gets the current object class name.
  15963. * @return the class name
  15964. */
  15965. getClassName(): string;
  15966. /**
  15967. * Returns an array containing the root bones
  15968. * @returns an array containing the root bones
  15969. */
  15970. getChildren(): Array<Bone>;
  15971. /**
  15972. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15973. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15974. * @returns a Float32Array containing matrices data
  15975. */
  15976. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15977. /**
  15978. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15979. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15980. * @returns a raw texture containing the data
  15981. */
  15982. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15983. /**
  15984. * Gets the current hosting scene
  15985. * @returns a scene object
  15986. */
  15987. getScene(): Scene;
  15988. /**
  15989. * Gets a string representing the current skeleton data
  15990. * @param fullDetails defines a boolean indicating if we want a verbose version
  15991. * @returns a string representing the current skeleton data
  15992. */
  15993. toString(fullDetails?: boolean): string;
  15994. /**
  15995. * Get bone's index searching by name
  15996. * @param name defines bone's name to search for
  15997. * @return the indice of the bone. Returns -1 if not found
  15998. */
  15999. getBoneIndexByName(name: string): number;
  16000. /**
  16001. * Creater a new animation range
  16002. * @param name defines the name of the range
  16003. * @param from defines the start key
  16004. * @param to defines the end key
  16005. */
  16006. createAnimationRange(name: string, from: number, to: number): void;
  16007. /**
  16008. * Delete a specific animation range
  16009. * @param name defines the name of the range
  16010. * @param deleteFrames defines if frames must be removed as well
  16011. */
  16012. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16013. /**
  16014. * Gets a specific animation range
  16015. * @param name defines the name of the range to look for
  16016. * @returns the requested animation range or null if not found
  16017. */
  16018. getAnimationRange(name: string): Nullable<AnimationRange>;
  16019. /**
  16020. * Gets the list of all animation ranges defined on this skeleton
  16021. * @returns an array
  16022. */
  16023. getAnimationRanges(): Nullable<AnimationRange>[];
  16024. /**
  16025. * Copy animation range from a source skeleton.
  16026. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16027. * @param source defines the source skeleton
  16028. * @param name defines the name of the range to copy
  16029. * @param rescaleAsRequired defines if rescaling must be applied if required
  16030. * @returns true if operation was successful
  16031. */
  16032. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16033. /**
  16034. * Forces the skeleton to go to rest pose
  16035. */
  16036. returnToRest(): void;
  16037. private _getHighestAnimationFrame;
  16038. /**
  16039. * Begin a specific animation range
  16040. * @param name defines the name of the range to start
  16041. * @param loop defines if looping must be turned on (false by default)
  16042. * @param speedRatio defines the speed ratio to apply (1 by default)
  16043. * @param onAnimationEnd defines a callback which will be called when animation will end
  16044. * @returns a new animatable
  16045. */
  16046. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16047. /**
  16048. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16049. * @param skeleton defines the Skeleton containing the animation range to convert
  16050. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16051. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16052. * @returns the original skeleton
  16053. */
  16054. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16055. /** @hidden */
  16056. _markAsDirty(): void;
  16057. /** @hidden */
  16058. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. /** @hidden */
  16060. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16061. private _computeTransformMatrices;
  16062. /**
  16063. * Build all resources required to render a skeleton
  16064. */
  16065. prepare(): void;
  16066. /**
  16067. * Gets the list of animatables currently running for this skeleton
  16068. * @returns an array of animatables
  16069. */
  16070. getAnimatables(): IAnimatable[];
  16071. /**
  16072. * Clone the current skeleton
  16073. * @param name defines the name of the new skeleton
  16074. * @param id defines the id of the new skeleton
  16075. * @returns the new skeleton
  16076. */
  16077. clone(name: string, id?: string): Skeleton;
  16078. /**
  16079. * Enable animation blending for this skeleton
  16080. * @param blendingSpeed defines the blending speed to apply
  16081. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16082. */
  16083. enableBlending(blendingSpeed?: number): void;
  16084. /**
  16085. * Releases all resources associated with the current skeleton
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Serialize the skeleton in a JSON object
  16090. * @returns a JSON object
  16091. */
  16092. serialize(): any;
  16093. /**
  16094. * Creates a new skeleton from serialized data
  16095. * @param parsedSkeleton defines the serialized data
  16096. * @param scene defines the hosting scene
  16097. * @returns a new skeleton
  16098. */
  16099. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16100. /**
  16101. * Compute all node absolute transforms
  16102. * @param forceUpdate defines if computation must be done even if cache is up to date
  16103. */
  16104. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16105. /**
  16106. * Gets the root pose matrix
  16107. * @returns a matrix
  16108. */
  16109. getPoseMatrix(): Nullable<Matrix>;
  16110. /**
  16111. * Sorts bones per internal index
  16112. */
  16113. sortBones(): void;
  16114. private _sortBones;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Creates an instance based on a source mesh.
  16120. */
  16121. export class InstancedMesh extends AbstractMesh {
  16122. private _sourceMesh;
  16123. private _currentLOD;
  16124. /** @hidden */
  16125. _indexInSourceMeshInstanceArray: number;
  16126. constructor(name: string, source: Mesh);
  16127. /**
  16128. * Returns the string "InstancedMesh".
  16129. */
  16130. getClassName(): string;
  16131. /** Gets the list of lights affecting that mesh */
  16132. get lightSources(): Light[];
  16133. _resyncLightSources(): void;
  16134. _resyncLightSource(light: Light): void;
  16135. _removeLightSource(light: Light, dispose: boolean): void;
  16136. /**
  16137. * If the source mesh receives shadows
  16138. */
  16139. get receiveShadows(): boolean;
  16140. /**
  16141. * The material of the source mesh
  16142. */
  16143. get material(): Nullable<Material>;
  16144. /**
  16145. * Visibility of the source mesh
  16146. */
  16147. get visibility(): number;
  16148. /**
  16149. * Skeleton of the source mesh
  16150. */
  16151. get skeleton(): Nullable<Skeleton>;
  16152. /**
  16153. * Rendering ground id of the source mesh
  16154. */
  16155. get renderingGroupId(): number;
  16156. set renderingGroupId(value: number);
  16157. /**
  16158. * Returns the total number of vertices (integer).
  16159. */
  16160. getTotalVertices(): number;
  16161. /**
  16162. * Returns a positive integer : the total number of indices in this mesh geometry.
  16163. * @returns the numner of indices or zero if the mesh has no geometry.
  16164. */
  16165. getTotalIndices(): number;
  16166. /**
  16167. * The source mesh of the instance
  16168. */
  16169. get sourceMesh(): Mesh;
  16170. /**
  16171. * Creates a new InstancedMesh object from the mesh model.
  16172. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16173. * @param name defines the name of the new instance
  16174. * @returns a new InstancedMesh
  16175. */
  16176. createInstance(name: string): InstancedMesh;
  16177. /**
  16178. * Is this node ready to be used/rendered
  16179. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16180. * @return {boolean} is it ready
  16181. */
  16182. isReady(completeCheck?: boolean): boolean;
  16183. /**
  16184. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16185. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16186. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16187. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16188. */
  16189. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16190. /**
  16191. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16192. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16193. * The `data` are either a numeric array either a Float32Array.
  16194. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16195. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16196. * Note that a new underlying VertexBuffer object is created each call.
  16197. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16198. *
  16199. * Possible `kind` values :
  16200. * - VertexBuffer.PositionKind
  16201. * - VertexBuffer.UVKind
  16202. * - VertexBuffer.UV2Kind
  16203. * - VertexBuffer.UV3Kind
  16204. * - VertexBuffer.UV4Kind
  16205. * - VertexBuffer.UV5Kind
  16206. * - VertexBuffer.UV6Kind
  16207. * - VertexBuffer.ColorKind
  16208. * - VertexBuffer.MatricesIndicesKind
  16209. * - VertexBuffer.MatricesIndicesExtraKind
  16210. * - VertexBuffer.MatricesWeightsKind
  16211. * - VertexBuffer.MatricesWeightsExtraKind
  16212. *
  16213. * Returns the Mesh.
  16214. */
  16215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16216. /**
  16217. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16218. * If the mesh has no geometry, it is simply returned as it is.
  16219. * The `data` are either a numeric array either a Float32Array.
  16220. * No new underlying VertexBuffer object is created.
  16221. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16222. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16223. *
  16224. * Possible `kind` values :
  16225. * - VertexBuffer.PositionKind
  16226. * - VertexBuffer.UVKind
  16227. * - VertexBuffer.UV2Kind
  16228. * - VertexBuffer.UV3Kind
  16229. * - VertexBuffer.UV4Kind
  16230. * - VertexBuffer.UV5Kind
  16231. * - VertexBuffer.UV6Kind
  16232. * - VertexBuffer.ColorKind
  16233. * - VertexBuffer.MatricesIndicesKind
  16234. * - VertexBuffer.MatricesIndicesExtraKind
  16235. * - VertexBuffer.MatricesWeightsKind
  16236. * - VertexBuffer.MatricesWeightsExtraKind
  16237. *
  16238. * Returns the Mesh.
  16239. */
  16240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16241. /**
  16242. * Sets the mesh indices.
  16243. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16244. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16245. * This method creates a new index buffer each call.
  16246. * Returns the Mesh.
  16247. */
  16248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16249. /**
  16250. * Boolean : True if the mesh owns the requested kind of data.
  16251. */
  16252. isVerticesDataPresent(kind: string): boolean;
  16253. /**
  16254. * Returns an array of indices (IndicesArray).
  16255. */
  16256. getIndices(): Nullable<IndicesArray>;
  16257. get _positions(): Nullable<Vector3[]>;
  16258. /**
  16259. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16260. * This means the mesh underlying bounding box and sphere are recomputed.
  16261. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16262. * @returns the current mesh
  16263. */
  16264. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16265. /** @hidden */
  16266. _preActivate(): InstancedMesh;
  16267. /** @hidden */
  16268. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16269. /** @hidden */
  16270. _postActivate(): void;
  16271. getWorldMatrix(): Matrix;
  16272. get isAnInstance(): boolean;
  16273. /**
  16274. * Returns the current associated LOD AbstractMesh.
  16275. */
  16276. getLOD(camera: Camera): AbstractMesh;
  16277. /** @hidden */
  16278. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16279. /** @hidden */
  16280. _syncSubMeshes(): InstancedMesh;
  16281. /** @hidden */
  16282. _generatePointsArray(): boolean;
  16283. /**
  16284. * Creates a new InstancedMesh from the current mesh.
  16285. * - name (string) : the cloned mesh name
  16286. * - newParent (optional Node) : the optional Node to parent the clone to.
  16287. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16288. *
  16289. * Returns the clone.
  16290. */
  16291. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16292. /**
  16293. * Disposes the InstancedMesh.
  16294. * Returns nothing.
  16295. */
  16296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16297. }
  16298. interface Mesh {
  16299. /**
  16300. * Register a custom buffer that will be instanced
  16301. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16302. * @param kind defines the buffer kind
  16303. * @param stride defines the stride in floats
  16304. */
  16305. registerInstancedBuffer(kind: string, stride: number): void;
  16306. /**
  16307. * true to use the edge renderer for all instances of this mesh
  16308. */
  16309. edgesShareWithInstances: boolean;
  16310. /** @hidden */
  16311. _userInstancedBuffersStorage: {
  16312. data: {
  16313. [key: string]: Float32Array;
  16314. };
  16315. sizes: {
  16316. [key: string]: number;
  16317. };
  16318. vertexBuffers: {
  16319. [key: string]: Nullable<VertexBuffer>;
  16320. };
  16321. strides: {
  16322. [key: string]: number;
  16323. };
  16324. };
  16325. }
  16326. interface AbstractMesh {
  16327. /**
  16328. * Object used to store instanced buffers defined by user
  16329. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16330. */
  16331. instancedBuffers: {
  16332. [key: string]: any;
  16333. };
  16334. }
  16335. }
  16336. declare module BABYLON {
  16337. /**
  16338. * Defines the options associated with the creation of a shader material.
  16339. */
  16340. export interface IShaderMaterialOptions {
  16341. /**
  16342. * Does the material work in alpha blend mode
  16343. */
  16344. needAlphaBlending: boolean;
  16345. /**
  16346. * Does the material work in alpha test mode
  16347. */
  16348. needAlphaTesting: boolean;
  16349. /**
  16350. * The list of attribute names used in the shader
  16351. */
  16352. attributes: string[];
  16353. /**
  16354. * The list of unifrom names used in the shader
  16355. */
  16356. uniforms: string[];
  16357. /**
  16358. * The list of UBO names used in the shader
  16359. */
  16360. uniformBuffers: string[];
  16361. /**
  16362. * The list of sampler names used in the shader
  16363. */
  16364. samplers: string[];
  16365. /**
  16366. * The list of defines used in the shader
  16367. */
  16368. defines: string[];
  16369. }
  16370. /**
  16371. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16372. *
  16373. * This returned material effects how the mesh will look based on the code in the shaders.
  16374. *
  16375. * @see http://doc.babylonjs.com/how_to/shader_material
  16376. */
  16377. export class ShaderMaterial extends Material {
  16378. private _shaderPath;
  16379. private _options;
  16380. private _textures;
  16381. private _textureArrays;
  16382. private _floats;
  16383. private _ints;
  16384. private _floatsArrays;
  16385. private _colors3;
  16386. private _colors3Arrays;
  16387. private _colors4;
  16388. private _colors4Arrays;
  16389. private _vectors2;
  16390. private _vectors3;
  16391. private _vectors4;
  16392. private _matrices;
  16393. private _matrixArrays;
  16394. private _matrices3x3;
  16395. private _matrices2x2;
  16396. private _vectors2Arrays;
  16397. private _vectors3Arrays;
  16398. private _vectors4Arrays;
  16399. private _cachedWorldViewMatrix;
  16400. private _cachedWorldViewProjectionMatrix;
  16401. private _renderId;
  16402. private _multiview;
  16403. private _cachedDefines;
  16404. /** Define the Url to load snippets */
  16405. static SnippetUrl: string;
  16406. /** Snippet ID if the material was created from the snippet server */
  16407. snippetId: string;
  16408. /**
  16409. * Instantiate a new shader material.
  16410. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16411. * This returned material effects how the mesh will look based on the code in the shaders.
  16412. * @see http://doc.babylonjs.com/how_to/shader_material
  16413. * @param name Define the name of the material in the scene
  16414. * @param scene Define the scene the material belongs to
  16415. * @param shaderPath Defines the route to the shader code in one of three ways:
  16416. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16417. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16418. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16419. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16420. * @param options Define the options used to create the shader
  16421. */
  16422. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16423. /**
  16424. * Gets the shader path used to define the shader code
  16425. * It can be modified to trigger a new compilation
  16426. */
  16427. get shaderPath(): any;
  16428. /**
  16429. * Sets the shader path used to define the shader code
  16430. * It can be modified to trigger a new compilation
  16431. */
  16432. set shaderPath(shaderPath: any);
  16433. /**
  16434. * Gets the options used to compile the shader.
  16435. * They can be modified to trigger a new compilation
  16436. */
  16437. get options(): IShaderMaterialOptions;
  16438. /**
  16439. * Gets the current class name of the material e.g. "ShaderMaterial"
  16440. * Mainly use in serialization.
  16441. * @returns the class name
  16442. */
  16443. getClassName(): string;
  16444. /**
  16445. * Specifies if the material will require alpha blending
  16446. * @returns a boolean specifying if alpha blending is needed
  16447. */
  16448. needAlphaBlending(): boolean;
  16449. /**
  16450. * Specifies if this material should be rendered in alpha test mode
  16451. * @returns a boolean specifying if an alpha test is needed.
  16452. */
  16453. needAlphaTesting(): boolean;
  16454. private _checkUniform;
  16455. /**
  16456. * Set a texture in the shader.
  16457. * @param name Define the name of the uniform samplers as defined in the shader
  16458. * @param texture Define the texture to bind to this sampler
  16459. * @return the material itself allowing "fluent" like uniform updates
  16460. */
  16461. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16462. /**
  16463. * Set a texture array in the shader.
  16464. * @param name Define the name of the uniform sampler array as defined in the shader
  16465. * @param textures Define the list of textures to bind to this sampler
  16466. * @return the material itself allowing "fluent" like uniform updates
  16467. */
  16468. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16469. /**
  16470. * Set a float in the shader.
  16471. * @param name Define the name of the uniform as defined in the shader
  16472. * @param value Define the value to give to the uniform
  16473. * @return the material itself allowing "fluent" like uniform updates
  16474. */
  16475. setFloat(name: string, value: number): ShaderMaterial;
  16476. /**
  16477. * Set a int in the shader.
  16478. * @param name Define the name of the uniform as defined in the shader
  16479. * @param value Define the value to give to the uniform
  16480. * @return the material itself allowing "fluent" like uniform updates
  16481. */
  16482. setInt(name: string, value: number): ShaderMaterial;
  16483. /**
  16484. * Set an array of floats in the shader.
  16485. * @param name Define the name of the uniform as defined in the shader
  16486. * @param value Define the value to give to the uniform
  16487. * @return the material itself allowing "fluent" like uniform updates
  16488. */
  16489. setFloats(name: string, value: number[]): ShaderMaterial;
  16490. /**
  16491. * Set a vec3 in the shader from a Color3.
  16492. * @param name Define the name of the uniform as defined in the shader
  16493. * @param value Define the value to give to the uniform
  16494. * @return the material itself allowing "fluent" like uniform updates
  16495. */
  16496. setColor3(name: string, value: Color3): ShaderMaterial;
  16497. /**
  16498. * Set a vec3 array in the shader from a Color3 array.
  16499. * @param name Define the name of the uniform as defined in the shader
  16500. * @param value Define the value to give to the uniform
  16501. * @return the material itself allowing "fluent" like uniform updates
  16502. */
  16503. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16504. /**
  16505. * Set a vec4 in the shader from a Color4.
  16506. * @param name Define the name of the uniform as defined in the shader
  16507. * @param value Define the value to give to the uniform
  16508. * @return the material itself allowing "fluent" like uniform updates
  16509. */
  16510. setColor4(name: string, value: Color4): ShaderMaterial;
  16511. /**
  16512. * Set a vec4 array in the shader from a Color4 array.
  16513. * @param name Define the name of the uniform as defined in the shader
  16514. * @param value Define the value to give to the uniform
  16515. * @return the material itself allowing "fluent" like uniform updates
  16516. */
  16517. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16518. /**
  16519. * Set a vec2 in the shader from a Vector2.
  16520. * @param name Define the name of the uniform as defined in the shader
  16521. * @param value Define the value to give to the uniform
  16522. * @return the material itself allowing "fluent" like uniform updates
  16523. */
  16524. setVector2(name: string, value: Vector2): ShaderMaterial;
  16525. /**
  16526. * Set a vec3 in the shader from a Vector3.
  16527. * @param name Define the name of the uniform as defined in the shader
  16528. * @param value Define the value to give to the uniform
  16529. * @return the material itself allowing "fluent" like uniform updates
  16530. */
  16531. setVector3(name: string, value: Vector3): ShaderMaterial;
  16532. /**
  16533. * Set a vec4 in the shader from a Vector4.
  16534. * @param name Define the name of the uniform as defined in the shader
  16535. * @param value Define the value to give to the uniform
  16536. * @return the material itself allowing "fluent" like uniform updates
  16537. */
  16538. setVector4(name: string, value: Vector4): ShaderMaterial;
  16539. /**
  16540. * Set a mat4 in the shader from a Matrix.
  16541. * @param name Define the name of the uniform as defined in the shader
  16542. * @param value Define the value to give to the uniform
  16543. * @return the material itself allowing "fluent" like uniform updates
  16544. */
  16545. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16546. /**
  16547. * Set a float32Array in the shader from a matrix array.
  16548. * @param name Define the name of the uniform as defined in the shader
  16549. * @param value Define the value to give to the uniform
  16550. * @return the material itself allowing "fluent" like uniform updates
  16551. */
  16552. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16553. /**
  16554. * Set a mat3 in the shader from a Float32Array.
  16555. * @param name Define the name of the uniform as defined in the shader
  16556. * @param value Define the value to give to the uniform
  16557. * @return the material itself allowing "fluent" like uniform updates
  16558. */
  16559. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16560. /**
  16561. * Set a mat2 in the shader from a Float32Array.
  16562. * @param name Define the name of the uniform as defined in the shader
  16563. * @param value Define the value to give to the uniform
  16564. * @return the material itself allowing "fluent" like uniform updates
  16565. */
  16566. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16567. /**
  16568. * Set a vec2 array in the shader from a number array.
  16569. * @param name Define the name of the uniform as defined in the shader
  16570. * @param value Define the value to give to the uniform
  16571. * @return the material itself allowing "fluent" like uniform updates
  16572. */
  16573. setArray2(name: string, value: number[]): ShaderMaterial;
  16574. /**
  16575. * Set a vec3 array in the shader from a number array.
  16576. * @param name Define the name of the uniform as defined in the shader
  16577. * @param value Define the value to give to the uniform
  16578. * @return the material itself allowing "fluent" like uniform updates
  16579. */
  16580. setArray3(name: string, value: number[]): ShaderMaterial;
  16581. /**
  16582. * Set a vec4 array in the shader from a number array.
  16583. * @param name Define the name of the uniform as defined in the shader
  16584. * @param value Define the value to give to the uniform
  16585. * @return the material itself allowing "fluent" like uniform updates
  16586. */
  16587. setArray4(name: string, value: number[]): ShaderMaterial;
  16588. private _checkCache;
  16589. /**
  16590. * Specifies that the submesh is ready to be used
  16591. * @param mesh defines the mesh to check
  16592. * @param subMesh defines which submesh to check
  16593. * @param useInstances specifies that instances should be used
  16594. * @returns a boolean indicating that the submesh is ready or not
  16595. */
  16596. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16597. /**
  16598. * Checks if the material is ready to render the requested mesh
  16599. * @param mesh Define the mesh to render
  16600. * @param useInstances Define whether or not the material is used with instances
  16601. * @returns true if ready, otherwise false
  16602. */
  16603. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16604. /**
  16605. * Binds the world matrix to the material
  16606. * @param world defines the world transformation matrix
  16607. * @param effectOverride - If provided, use this effect instead of internal effect
  16608. */
  16609. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16610. /**
  16611. * Binds the submesh to this material by preparing the effect and shader to draw
  16612. * @param world defines the world transformation matrix
  16613. * @param mesh defines the mesh containing the submesh
  16614. * @param subMesh defines the submesh to bind the material to
  16615. */
  16616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16617. /**
  16618. * Binds the material to the mesh
  16619. * @param world defines the world transformation matrix
  16620. * @param mesh defines the mesh to bind the material to
  16621. * @param effectOverride - If provided, use this effect instead of internal effect
  16622. */
  16623. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16624. protected _afterBind(mesh?: Mesh): void;
  16625. /**
  16626. * Gets the active textures from the material
  16627. * @returns an array of textures
  16628. */
  16629. getActiveTextures(): BaseTexture[];
  16630. /**
  16631. * Specifies if the material uses a texture
  16632. * @param texture defines the texture to check against the material
  16633. * @returns a boolean specifying if the material uses the texture
  16634. */
  16635. hasTexture(texture: BaseTexture): boolean;
  16636. /**
  16637. * Makes a duplicate of the material, and gives it a new name
  16638. * @param name defines the new name for the duplicated material
  16639. * @returns the cloned material
  16640. */
  16641. clone(name: string): ShaderMaterial;
  16642. /**
  16643. * Disposes the material
  16644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16647. */
  16648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16649. /**
  16650. * Serializes this material in a JSON representation
  16651. * @returns the serialized material object
  16652. */
  16653. serialize(): any;
  16654. /**
  16655. * Creates a shader material from parsed shader material data
  16656. * @param source defines the JSON represnetation of the material
  16657. * @param scene defines the hosting scene
  16658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16659. * @returns a new material
  16660. */
  16661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16662. /**
  16663. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16664. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16665. * @param url defines the url to load from
  16666. * @param scene defines the hosting scene
  16667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16668. * @returns a promise that will resolve to the new ShaderMaterial
  16669. */
  16670. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16671. /**
  16672. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16673. * @param snippetId defines the snippet to load
  16674. * @param scene defines the hosting scene
  16675. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16676. * @returns a promise that will resolve to the new ShaderMaterial
  16677. */
  16678. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16679. }
  16680. }
  16681. declare module BABYLON {
  16682. /** @hidden */
  16683. export var colorPixelShader: {
  16684. name: string;
  16685. shader: string;
  16686. };
  16687. }
  16688. declare module BABYLON {
  16689. /** @hidden */
  16690. export var colorVertexShader: {
  16691. name: string;
  16692. shader: string;
  16693. };
  16694. }
  16695. declare module BABYLON {
  16696. /**
  16697. * Line mesh
  16698. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16699. */
  16700. export class LinesMesh extends Mesh {
  16701. /**
  16702. * If vertex color should be applied to the mesh
  16703. */
  16704. readonly useVertexColor?: boolean | undefined;
  16705. /**
  16706. * If vertex alpha should be applied to the mesh
  16707. */
  16708. readonly useVertexAlpha?: boolean | undefined;
  16709. /**
  16710. * Color of the line (Default: White)
  16711. */
  16712. color: Color3;
  16713. /**
  16714. * Alpha of the line (Default: 1)
  16715. */
  16716. alpha: number;
  16717. /**
  16718. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16719. * This margin is expressed in world space coordinates, so its value may vary.
  16720. * Default value is 0.1
  16721. */
  16722. intersectionThreshold: number;
  16723. private _colorShader;
  16724. private color4;
  16725. /**
  16726. * Creates a new LinesMesh
  16727. * @param name defines the name
  16728. * @param scene defines the hosting scene
  16729. * @param parent defines the parent mesh if any
  16730. * @param source defines the optional source LinesMesh used to clone data from
  16731. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16732. * When false, achieved by calling a clone(), also passing False.
  16733. * This will make creation of children, recursive.
  16734. * @param useVertexColor defines if this LinesMesh supports vertex color
  16735. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16736. */
  16737. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16738. /**
  16739. * If vertex color should be applied to the mesh
  16740. */
  16741. useVertexColor?: boolean | undefined,
  16742. /**
  16743. * If vertex alpha should be applied to the mesh
  16744. */
  16745. useVertexAlpha?: boolean | undefined);
  16746. private _addClipPlaneDefine;
  16747. private _removeClipPlaneDefine;
  16748. isReady(): boolean;
  16749. /**
  16750. * Returns the string "LineMesh"
  16751. */
  16752. getClassName(): string;
  16753. /**
  16754. * @hidden
  16755. */
  16756. get material(): Material;
  16757. /**
  16758. * @hidden
  16759. */
  16760. set material(value: Material);
  16761. /**
  16762. * @hidden
  16763. */
  16764. get checkCollisions(): boolean;
  16765. /** @hidden */
  16766. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16767. /** @hidden */
  16768. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16769. /**
  16770. * Disposes of the line mesh
  16771. * @param doNotRecurse If children should be disposed
  16772. */
  16773. dispose(doNotRecurse?: boolean): void;
  16774. /**
  16775. * Returns a new LineMesh object cloned from the current one.
  16776. */
  16777. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16778. /**
  16779. * Creates a new InstancedLinesMesh object from the mesh model.
  16780. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16781. * @param name defines the name of the new instance
  16782. * @returns a new InstancedLinesMesh
  16783. */
  16784. createInstance(name: string): InstancedLinesMesh;
  16785. }
  16786. /**
  16787. * Creates an instance based on a source LinesMesh
  16788. */
  16789. export class InstancedLinesMesh extends InstancedMesh {
  16790. /**
  16791. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16792. * This margin is expressed in world space coordinates, so its value may vary.
  16793. * Initilized with the intersectionThreshold value of the source LinesMesh
  16794. */
  16795. intersectionThreshold: number;
  16796. constructor(name: string, source: LinesMesh);
  16797. /**
  16798. * Returns the string "InstancedLinesMesh".
  16799. */
  16800. getClassName(): string;
  16801. }
  16802. }
  16803. declare module BABYLON {
  16804. /** @hidden */
  16805. export var linePixelShader: {
  16806. name: string;
  16807. shader: string;
  16808. };
  16809. }
  16810. declare module BABYLON {
  16811. /** @hidden */
  16812. export var lineVertexShader: {
  16813. name: string;
  16814. shader: string;
  16815. };
  16816. }
  16817. declare module BABYLON {
  16818. interface Scene {
  16819. /** @hidden */
  16820. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16821. }
  16822. interface AbstractMesh {
  16823. /**
  16824. * Gets the edgesRenderer associated with the mesh
  16825. */
  16826. edgesRenderer: Nullable<EdgesRenderer>;
  16827. }
  16828. interface LinesMesh {
  16829. /**
  16830. * Enables the edge rendering mode on the mesh.
  16831. * This mode makes the mesh edges visible
  16832. * @param epsilon defines the maximal distance between two angles to detect a face
  16833. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16834. * @returns the currentAbstractMesh
  16835. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16836. */
  16837. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16838. }
  16839. interface InstancedLinesMesh {
  16840. /**
  16841. * Enables the edge rendering mode on the mesh.
  16842. * This mode makes the mesh edges visible
  16843. * @param epsilon defines the maximal distance between two angles to detect a face
  16844. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16845. * @returns the current InstancedLinesMesh
  16846. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16847. */
  16848. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16849. }
  16850. /**
  16851. * Defines the minimum contract an Edges renderer should follow.
  16852. */
  16853. export interface IEdgesRenderer extends IDisposable {
  16854. /**
  16855. * Gets or sets a boolean indicating if the edgesRenderer is active
  16856. */
  16857. isEnabled: boolean;
  16858. /**
  16859. * Renders the edges of the attached mesh,
  16860. */
  16861. render(): void;
  16862. /**
  16863. * Checks wether or not the edges renderer is ready to render.
  16864. * @return true if ready, otherwise false.
  16865. */
  16866. isReady(): boolean;
  16867. /**
  16868. * List of instances to render in case the source mesh has instances
  16869. */
  16870. customInstances: SmartArray<Matrix>;
  16871. }
  16872. /**
  16873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16874. */
  16875. export class EdgesRenderer implements IEdgesRenderer {
  16876. /**
  16877. * Define the size of the edges with an orthographic camera
  16878. */
  16879. edgesWidthScalerForOrthographic: number;
  16880. /**
  16881. * Define the size of the edges with a perspective camera
  16882. */
  16883. edgesWidthScalerForPerspective: number;
  16884. protected _source: AbstractMesh;
  16885. protected _linesPositions: number[];
  16886. protected _linesNormals: number[];
  16887. protected _linesIndices: number[];
  16888. protected _epsilon: number;
  16889. protected _indicesCount: number;
  16890. protected _lineShader: ShaderMaterial;
  16891. protected _ib: DataBuffer;
  16892. protected _buffers: {
  16893. [key: string]: Nullable<VertexBuffer>;
  16894. };
  16895. protected _buffersForInstances: {
  16896. [key: string]: Nullable<VertexBuffer>;
  16897. };
  16898. protected _checkVerticesInsteadOfIndices: boolean;
  16899. private _meshRebuildObserver;
  16900. private _meshDisposeObserver;
  16901. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16902. isEnabled: boolean;
  16903. /**
  16904. * List of instances to render in case the source mesh has instances
  16905. */
  16906. customInstances: SmartArray<Matrix>;
  16907. private static GetShader;
  16908. /**
  16909. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16910. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16911. * @param source Mesh used to create edges
  16912. * @param epsilon sum of angles in adjacency to check for edge
  16913. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16914. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16915. */
  16916. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16917. protected _prepareRessources(): void;
  16918. /** @hidden */
  16919. _rebuild(): void;
  16920. /**
  16921. * Releases the required resources for the edges renderer
  16922. */
  16923. dispose(): void;
  16924. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16925. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16926. /**
  16927. * Checks if the pair of p0 and p1 is en edge
  16928. * @param faceIndex
  16929. * @param edge
  16930. * @param faceNormals
  16931. * @param p0
  16932. * @param p1
  16933. * @private
  16934. */
  16935. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16936. /**
  16937. * push line into the position, normal and index buffer
  16938. * @protected
  16939. */
  16940. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16941. /**
  16942. * Generates lines edges from adjacencjes
  16943. * @private
  16944. */
  16945. _generateEdgesLines(): void;
  16946. /**
  16947. * Checks wether or not the edges renderer is ready to render.
  16948. * @return true if ready, otherwise false.
  16949. */
  16950. isReady(): boolean;
  16951. /**
  16952. * Renders the edges of the attached mesh,
  16953. */
  16954. render(): void;
  16955. }
  16956. /**
  16957. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16958. */
  16959. export class LineEdgesRenderer extends EdgesRenderer {
  16960. /**
  16961. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16962. * @param source LineMesh used to generate edges
  16963. * @param epsilon not important (specified angle for edge detection)
  16964. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16965. */
  16966. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16967. /**
  16968. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16969. */
  16970. _generateEdgesLines(): void;
  16971. }
  16972. }
  16973. declare module BABYLON {
  16974. /**
  16975. * This represents the object necessary to create a rendering group.
  16976. * This is exclusively used and created by the rendering manager.
  16977. * To modify the behavior, you use the available helpers in your scene or meshes.
  16978. * @hidden
  16979. */
  16980. export class RenderingGroup {
  16981. index: number;
  16982. private static _zeroVector;
  16983. private _scene;
  16984. private _opaqueSubMeshes;
  16985. private _transparentSubMeshes;
  16986. private _alphaTestSubMeshes;
  16987. private _depthOnlySubMeshes;
  16988. private _particleSystems;
  16989. private _spriteManagers;
  16990. private _opaqueSortCompareFn;
  16991. private _alphaTestSortCompareFn;
  16992. private _transparentSortCompareFn;
  16993. private _renderOpaque;
  16994. private _renderAlphaTest;
  16995. private _renderTransparent;
  16996. /** @hidden */
  16997. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16998. onBeforeTransparentRendering: () => void;
  16999. /**
  17000. * Set the opaque sort comparison function.
  17001. * If null the sub meshes will be render in the order they were created
  17002. */
  17003. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17004. /**
  17005. * Set the alpha test sort comparison function.
  17006. * If null the sub meshes will be render in the order they were created
  17007. */
  17008. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17009. /**
  17010. * Set the transparent sort comparison function.
  17011. * If null the sub meshes will be render in the order they were created
  17012. */
  17013. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17014. /**
  17015. * Creates a new rendering group.
  17016. * @param index The rendering group index
  17017. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17018. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17019. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17020. */
  17021. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17022. /**
  17023. * Render all the sub meshes contained in the group.
  17024. * @param customRenderFunction Used to override the default render behaviour of the group.
  17025. * @returns true if rendered some submeshes.
  17026. */
  17027. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17028. /**
  17029. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17030. * @param subMeshes The submeshes to render
  17031. */
  17032. private renderOpaqueSorted;
  17033. /**
  17034. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17035. * @param subMeshes The submeshes to render
  17036. */
  17037. private renderAlphaTestSorted;
  17038. /**
  17039. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17040. * @param subMeshes The submeshes to render
  17041. */
  17042. private renderTransparentSorted;
  17043. /**
  17044. * Renders the submeshes in a specified order.
  17045. * @param subMeshes The submeshes to sort before render
  17046. * @param sortCompareFn The comparison function use to sort
  17047. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17048. * @param transparent Specifies to activate blending if true
  17049. */
  17050. private static renderSorted;
  17051. /**
  17052. * Renders the submeshes in the order they were dispatched (no sort applied).
  17053. * @param subMeshes The submeshes to render
  17054. */
  17055. private static renderUnsorted;
  17056. /**
  17057. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17058. * are rendered back to front if in the same alpha index.
  17059. *
  17060. * @param a The first submesh
  17061. * @param b The second submesh
  17062. * @returns The result of the comparison
  17063. */
  17064. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17065. /**
  17066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17067. * are rendered back to front.
  17068. *
  17069. * @param a The first submesh
  17070. * @param b The second submesh
  17071. * @returns The result of the comparison
  17072. */
  17073. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17074. /**
  17075. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17076. * are rendered front to back (prevent overdraw).
  17077. *
  17078. * @param a The first submesh
  17079. * @param b The second submesh
  17080. * @returns The result of the comparison
  17081. */
  17082. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17083. /**
  17084. * Resets the different lists of submeshes to prepare a new frame.
  17085. */
  17086. prepare(): void;
  17087. dispose(): void;
  17088. /**
  17089. * Inserts the submesh in its correct queue depending on its material.
  17090. * @param subMesh The submesh to dispatch
  17091. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17092. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17093. */
  17094. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17095. dispatchSprites(spriteManager: ISpriteManager): void;
  17096. dispatchParticles(particleSystem: IParticleSystem): void;
  17097. private _renderParticles;
  17098. private _renderSprites;
  17099. }
  17100. }
  17101. declare module BABYLON {
  17102. /**
  17103. * Interface describing the different options available in the rendering manager
  17104. * regarding Auto Clear between groups.
  17105. */
  17106. export interface IRenderingManagerAutoClearSetup {
  17107. /**
  17108. * Defines whether or not autoclear is enable.
  17109. */
  17110. autoClear: boolean;
  17111. /**
  17112. * Defines whether or not to autoclear the depth buffer.
  17113. */
  17114. depth: boolean;
  17115. /**
  17116. * Defines whether or not to autoclear the stencil buffer.
  17117. */
  17118. stencil: boolean;
  17119. }
  17120. /**
  17121. * This class is used by the onRenderingGroupObservable
  17122. */
  17123. export class RenderingGroupInfo {
  17124. /**
  17125. * The Scene that being rendered
  17126. */
  17127. scene: Scene;
  17128. /**
  17129. * The camera currently used for the rendering pass
  17130. */
  17131. camera: Nullable<Camera>;
  17132. /**
  17133. * The ID of the renderingGroup being processed
  17134. */
  17135. renderingGroupId: number;
  17136. }
  17137. /**
  17138. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17139. * It is enable to manage the different groups as well as the different necessary sort functions.
  17140. * This should not be used directly aside of the few static configurations
  17141. */
  17142. export class RenderingManager {
  17143. /**
  17144. * The max id used for rendering groups (not included)
  17145. */
  17146. static MAX_RENDERINGGROUPS: number;
  17147. /**
  17148. * The min id used for rendering groups (included)
  17149. */
  17150. static MIN_RENDERINGGROUPS: number;
  17151. /**
  17152. * Used to globally prevent autoclearing scenes.
  17153. */
  17154. static AUTOCLEAR: boolean;
  17155. /**
  17156. * @hidden
  17157. */
  17158. _useSceneAutoClearSetup: boolean;
  17159. private _scene;
  17160. private _renderingGroups;
  17161. private _depthStencilBufferAlreadyCleaned;
  17162. private _autoClearDepthStencil;
  17163. private _customOpaqueSortCompareFn;
  17164. private _customAlphaTestSortCompareFn;
  17165. private _customTransparentSortCompareFn;
  17166. private _renderingGroupInfo;
  17167. /**
  17168. * Instantiates a new rendering group for a particular scene
  17169. * @param scene Defines the scene the groups belongs to
  17170. */
  17171. constructor(scene: Scene);
  17172. private _clearDepthStencilBuffer;
  17173. /**
  17174. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17175. * @hidden
  17176. */
  17177. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17178. /**
  17179. * Resets the different information of the group to prepare a new frame
  17180. * @hidden
  17181. */
  17182. reset(): void;
  17183. /**
  17184. * Dispose and release the group and its associated resources.
  17185. * @hidden
  17186. */
  17187. dispose(): void;
  17188. /**
  17189. * Clear the info related to rendering groups preventing retention points during dispose.
  17190. */
  17191. freeRenderingGroups(): void;
  17192. private _prepareRenderingGroup;
  17193. /**
  17194. * Add a sprite manager to the rendering manager in order to render it this frame.
  17195. * @param spriteManager Define the sprite manager to render
  17196. */
  17197. dispatchSprites(spriteManager: ISpriteManager): void;
  17198. /**
  17199. * Add a particle system to the rendering manager in order to render it this frame.
  17200. * @param particleSystem Define the particle system to render
  17201. */
  17202. dispatchParticles(particleSystem: IParticleSystem): void;
  17203. /**
  17204. * Add a submesh to the manager in order to render it this frame
  17205. * @param subMesh The submesh to dispatch
  17206. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17207. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17208. */
  17209. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17210. /**
  17211. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17212. * This allowed control for front to back rendering or reversly depending of the special needs.
  17213. *
  17214. * @param renderingGroupId The rendering group id corresponding to its index
  17215. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17216. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17217. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17218. */
  17219. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17220. /**
  17221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17222. *
  17223. * @param renderingGroupId The rendering group id corresponding to its index
  17224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17225. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17226. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17227. */
  17228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17229. /**
  17230. * Gets the current auto clear configuration for one rendering group of the rendering
  17231. * manager.
  17232. * @param index the rendering group index to get the information for
  17233. * @returns The auto clear setup for the requested rendering group
  17234. */
  17235. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17236. }
  17237. }
  17238. declare module BABYLON {
  17239. /**
  17240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17241. */
  17242. export interface ICustomShaderOptions {
  17243. /**
  17244. * Gets or sets the custom shader name to use
  17245. */
  17246. shaderName: string;
  17247. /**
  17248. * The list of attribute names used in the shader
  17249. */
  17250. attributes?: string[];
  17251. /**
  17252. * The list of unifrom names used in the shader
  17253. */
  17254. uniforms?: string[];
  17255. /**
  17256. * The list of sampler names used in the shader
  17257. */
  17258. samplers?: string[];
  17259. /**
  17260. * The list of defines used in the shader
  17261. */
  17262. defines?: string[];
  17263. }
  17264. /**
  17265. * Interface to implement to create a shadow generator compatible with BJS.
  17266. */
  17267. export interface IShadowGenerator {
  17268. /**
  17269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17270. * @returns The render target texture if present otherwise, null
  17271. */
  17272. getShadowMap(): Nullable<RenderTargetTexture>;
  17273. /**
  17274. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17275. * @param subMesh The submesh we want to render in the shadow map
  17276. * @param useInstances Defines wether will draw in the map using instances
  17277. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17278. * @returns true if ready otherwise, false
  17279. */
  17280. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17281. /**
  17282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17283. * @param defines Defines of the material we want to update
  17284. * @param lightIndex Index of the light in the enabled light list of the material
  17285. */
  17286. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17287. /**
  17288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17289. * defined in the generator but impacting the effect).
  17290. * It implies the unifroms available on the materials are the standard BJS ones.
  17291. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17292. * @param effect The effect we are binfing the information for
  17293. */
  17294. bindShadowLight(lightIndex: string, effect: Effect): void;
  17295. /**
  17296. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17297. * (eq to shadow prjection matrix * light transform matrix)
  17298. * @returns The transform matrix used to create the shadow map
  17299. */
  17300. getTransformMatrix(): Matrix;
  17301. /**
  17302. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17303. * Cube and 2D textures for instance.
  17304. */
  17305. recreateShadowMap(): void;
  17306. /**
  17307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17308. * @param onCompiled Callback triggered at the and of the effects compilation
  17309. * @param options Sets of optional options forcing the compilation with different modes
  17310. */
  17311. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17312. useInstances: boolean;
  17313. }>): void;
  17314. /**
  17315. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17316. * @param options Sets of optional options forcing the compilation with different modes
  17317. * @returns A promise that resolves when the compilation completes
  17318. */
  17319. forceCompilationAsync(options?: Partial<{
  17320. useInstances: boolean;
  17321. }>): Promise<void>;
  17322. /**
  17323. * Serializes the shadow generator setup to a json object.
  17324. * @returns The serialized JSON object
  17325. */
  17326. serialize(): any;
  17327. /**
  17328. * Disposes the Shadow map and related Textures and effects.
  17329. */
  17330. dispose(): void;
  17331. }
  17332. /**
  17333. * Default implementation IShadowGenerator.
  17334. * This is the main object responsible of generating shadows in the framework.
  17335. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17336. */
  17337. export class ShadowGenerator implements IShadowGenerator {
  17338. /**
  17339. * Name of the shadow generator class
  17340. */
  17341. static CLASSNAME: string;
  17342. /**
  17343. * Shadow generator mode None: no filtering applied.
  17344. */
  17345. static readonly FILTER_NONE: number;
  17346. /**
  17347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17349. */
  17350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17351. /**
  17352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17354. */
  17355. static readonly FILTER_POISSONSAMPLING: number;
  17356. /**
  17357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17359. */
  17360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17361. /**
  17362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17363. * edge artifacts on steep falloff.
  17364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17365. */
  17366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17367. /**
  17368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17369. * edge artifacts on steep falloff.
  17370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17371. */
  17372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17373. /**
  17374. * Shadow generator mode PCF: Percentage Closer Filtering
  17375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17377. */
  17378. static readonly FILTER_PCF: number;
  17379. /**
  17380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17382. * Contact Hardening
  17383. */
  17384. static readonly FILTER_PCSS: number;
  17385. /**
  17386. * Reserved for PCF and PCSS
  17387. * Highest Quality.
  17388. *
  17389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17390. *
  17391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17392. */
  17393. static readonly QUALITY_HIGH: number;
  17394. /**
  17395. * Reserved for PCF and PCSS
  17396. * Good tradeoff for quality/perf cross devices
  17397. *
  17398. * Execute PCF on a 3*3 kernel.
  17399. *
  17400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17401. */
  17402. static readonly QUALITY_MEDIUM: number;
  17403. /**
  17404. * Reserved for PCF and PCSS
  17405. * The lowest quality but the fastest.
  17406. *
  17407. * Execute PCF on a 1*1 kernel.
  17408. *
  17409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17410. */
  17411. static readonly QUALITY_LOW: number;
  17412. /** Gets or sets the custom shader name to use */
  17413. customShaderOptions: ICustomShaderOptions;
  17414. /**
  17415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17416. */
  17417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17418. /**
  17419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17420. */
  17421. onAfterShadowMapRenderObservable: Observable<Effect>;
  17422. /**
  17423. * Observable triggered before a mesh is rendered in the shadow map.
  17424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17425. */
  17426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17427. /**
  17428. * Observable triggered after a mesh is rendered in the shadow map.
  17429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17430. */
  17431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17432. protected _bias: number;
  17433. /**
  17434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17435. */
  17436. get bias(): number;
  17437. /**
  17438. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17439. */
  17440. set bias(bias: number);
  17441. protected _normalBias: number;
  17442. /**
  17443. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17444. */
  17445. get normalBias(): number;
  17446. /**
  17447. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17448. */
  17449. set normalBias(normalBias: number);
  17450. protected _blurBoxOffset: number;
  17451. /**
  17452. * Gets the blur box offset: offset applied during the blur pass.
  17453. * Only useful if useKernelBlur = false
  17454. */
  17455. get blurBoxOffset(): number;
  17456. /**
  17457. * Sets the blur box offset: offset applied during the blur pass.
  17458. * Only useful if useKernelBlur = false
  17459. */
  17460. set blurBoxOffset(value: number);
  17461. protected _blurScale: number;
  17462. /**
  17463. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17464. * 2 means half of the size.
  17465. */
  17466. get blurScale(): number;
  17467. /**
  17468. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17469. * 2 means half of the size.
  17470. */
  17471. set blurScale(value: number);
  17472. protected _blurKernel: number;
  17473. /**
  17474. * Gets the blur kernel: kernel size of the blur pass.
  17475. * Only useful if useKernelBlur = true
  17476. */
  17477. get blurKernel(): number;
  17478. /**
  17479. * Sets the blur kernel: kernel size of the blur pass.
  17480. * Only useful if useKernelBlur = true
  17481. */
  17482. set blurKernel(value: number);
  17483. protected _useKernelBlur: boolean;
  17484. /**
  17485. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17486. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17487. */
  17488. get useKernelBlur(): boolean;
  17489. /**
  17490. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17491. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17492. */
  17493. set useKernelBlur(value: boolean);
  17494. protected _depthScale: number;
  17495. /**
  17496. * Gets the depth scale used in ESM mode.
  17497. */
  17498. get depthScale(): number;
  17499. /**
  17500. * Sets the depth scale used in ESM mode.
  17501. * This can override the scale stored on the light.
  17502. */
  17503. set depthScale(value: number);
  17504. protected _validateFilter(filter: number): number;
  17505. protected _filter: number;
  17506. /**
  17507. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17508. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17509. */
  17510. get filter(): number;
  17511. /**
  17512. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17513. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17514. */
  17515. set filter(value: number);
  17516. /**
  17517. * Gets if the current filter is set to Poisson Sampling.
  17518. */
  17519. get usePoissonSampling(): boolean;
  17520. /**
  17521. * Sets the current filter to Poisson Sampling.
  17522. */
  17523. set usePoissonSampling(value: boolean);
  17524. /**
  17525. * Gets if the current filter is set to ESM.
  17526. */
  17527. get useExponentialShadowMap(): boolean;
  17528. /**
  17529. * Sets the current filter is to ESM.
  17530. */
  17531. set useExponentialShadowMap(value: boolean);
  17532. /**
  17533. * Gets if the current filter is set to filtered ESM.
  17534. */
  17535. get useBlurExponentialShadowMap(): boolean;
  17536. /**
  17537. * Gets if the current filter is set to filtered ESM.
  17538. */
  17539. set useBlurExponentialShadowMap(value: boolean);
  17540. /**
  17541. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17542. * exponential to prevent steep falloff artifacts).
  17543. */
  17544. get useCloseExponentialShadowMap(): boolean;
  17545. /**
  17546. * Sets the current filter to "close ESM" (using the inverse of the
  17547. * exponential to prevent steep falloff artifacts).
  17548. */
  17549. set useCloseExponentialShadowMap(value: boolean);
  17550. /**
  17551. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17552. * exponential to prevent steep falloff artifacts).
  17553. */
  17554. get useBlurCloseExponentialShadowMap(): boolean;
  17555. /**
  17556. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17557. * exponential to prevent steep falloff artifacts).
  17558. */
  17559. set useBlurCloseExponentialShadowMap(value: boolean);
  17560. /**
  17561. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17562. */
  17563. get usePercentageCloserFiltering(): boolean;
  17564. /**
  17565. * Sets the current filter to "PCF" (percentage closer filtering).
  17566. */
  17567. set usePercentageCloserFiltering(value: boolean);
  17568. protected _filteringQuality: number;
  17569. /**
  17570. * Gets the PCF or PCSS Quality.
  17571. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17572. */
  17573. get filteringQuality(): number;
  17574. /**
  17575. * Sets the PCF or PCSS Quality.
  17576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17577. */
  17578. set filteringQuality(filteringQuality: number);
  17579. /**
  17580. * Gets if the current filter is set to "PCSS" (contact hardening).
  17581. */
  17582. get useContactHardeningShadow(): boolean;
  17583. /**
  17584. * Sets the current filter to "PCSS" (contact hardening).
  17585. */
  17586. set useContactHardeningShadow(value: boolean);
  17587. protected _contactHardeningLightSizeUVRatio: number;
  17588. /**
  17589. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17590. * Using a ratio helps keeping shape stability independently of the map size.
  17591. *
  17592. * It does not account for the light projection as it was having too much
  17593. * instability during the light setup or during light position changes.
  17594. *
  17595. * Only valid if useContactHardeningShadow is true.
  17596. */
  17597. get contactHardeningLightSizeUVRatio(): number;
  17598. /**
  17599. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17600. * Using a ratio helps keeping shape stability independently of the map size.
  17601. *
  17602. * It does not account for the light projection as it was having too much
  17603. * instability during the light setup or during light position changes.
  17604. *
  17605. * Only valid if useContactHardeningShadow is true.
  17606. */
  17607. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17608. protected _darkness: number;
  17609. /** Gets or sets the actual darkness of a shadow */
  17610. get darkness(): number;
  17611. set darkness(value: number);
  17612. /**
  17613. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17614. * 0 means strongest and 1 would means no shadow.
  17615. * @returns the darkness.
  17616. */
  17617. getDarkness(): number;
  17618. /**
  17619. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17620. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17621. * @returns the shadow generator allowing fluent coding.
  17622. */
  17623. setDarkness(darkness: number): ShadowGenerator;
  17624. protected _transparencyShadow: boolean;
  17625. /** Gets or sets the ability to have transparent shadow */
  17626. get transparencyShadow(): boolean;
  17627. set transparencyShadow(value: boolean);
  17628. /**
  17629. * Sets the ability to have transparent shadow (boolean).
  17630. * @param transparent True if transparent else False
  17631. * @returns the shadow generator allowing fluent coding
  17632. */
  17633. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17634. /**
  17635. * Enables or disables shadows with varying strength based on the transparency
  17636. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17637. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17638. * mesh.visibility * alphaTexture.a
  17639. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17640. */
  17641. enableSoftTransparentShadow: boolean;
  17642. protected _shadowMap: Nullable<RenderTargetTexture>;
  17643. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17644. /**
  17645. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17646. * @returns The render target texture if present otherwise, null
  17647. */
  17648. getShadowMap(): Nullable<RenderTargetTexture>;
  17649. /**
  17650. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17651. * @returns The render target texture if the shadow map is present otherwise, null
  17652. */
  17653. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17654. /**
  17655. * Gets the class name of that object
  17656. * @returns "ShadowGenerator"
  17657. */
  17658. getClassName(): string;
  17659. /**
  17660. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17661. * @param mesh Mesh to add
  17662. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17663. * @returns the Shadow Generator itself
  17664. */
  17665. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17666. /**
  17667. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17668. * @param mesh Mesh to remove
  17669. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17670. * @returns the Shadow Generator itself
  17671. */
  17672. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17673. /**
  17674. * Controls the extent to which the shadows fade out at the edge of the frustum
  17675. */
  17676. frustumEdgeFalloff: number;
  17677. protected _light: IShadowLight;
  17678. /**
  17679. * Returns the associated light object.
  17680. * @returns the light generating the shadow
  17681. */
  17682. getLight(): IShadowLight;
  17683. /**
  17684. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17685. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17686. * It might on the other hand introduce peter panning.
  17687. */
  17688. forceBackFacesOnly: boolean;
  17689. protected _scene: Scene;
  17690. protected _lightDirection: Vector3;
  17691. protected _effect: Effect;
  17692. protected _viewMatrix: Matrix;
  17693. protected _projectionMatrix: Matrix;
  17694. protected _transformMatrix: Matrix;
  17695. protected _cachedPosition: Vector3;
  17696. protected _cachedDirection: Vector3;
  17697. protected _cachedDefines: string;
  17698. protected _currentRenderID: number;
  17699. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17700. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17701. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17702. protected _blurPostProcesses: PostProcess[];
  17703. protected _mapSize: number;
  17704. protected _currentFaceIndex: number;
  17705. protected _currentFaceIndexCache: number;
  17706. protected _textureType: number;
  17707. protected _defaultTextureMatrix: Matrix;
  17708. protected _storedUniqueId: Nullable<number>;
  17709. /** @hidden */
  17710. static _SceneComponentInitialization: (scene: Scene) => void;
  17711. /**
  17712. * Creates a ShadowGenerator object.
  17713. * A ShadowGenerator is the required tool to use the shadows.
  17714. * Each light casting shadows needs to use its own ShadowGenerator.
  17715. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17716. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17717. * @param light The light object generating the shadows.
  17718. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17719. */
  17720. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17721. protected _initializeGenerator(): void;
  17722. protected _createTargetRenderTexture(): void;
  17723. protected _initializeShadowMap(): void;
  17724. protected _initializeBlurRTTAndPostProcesses(): void;
  17725. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17726. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17727. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17728. protected _applyFilterValues(): void;
  17729. /**
  17730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17731. * @param onCompiled Callback triggered at the and of the effects compilation
  17732. * @param options Sets of optional options forcing the compilation with different modes
  17733. */
  17734. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17735. useInstances: boolean;
  17736. }>): void;
  17737. /**
  17738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17739. * @param options Sets of optional options forcing the compilation with different modes
  17740. * @returns A promise that resolves when the compilation completes
  17741. */
  17742. forceCompilationAsync(options?: Partial<{
  17743. useInstances: boolean;
  17744. }>): Promise<void>;
  17745. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17746. private _prepareShadowDefines;
  17747. /**
  17748. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17749. * @param subMesh The submesh we want to render in the shadow map
  17750. * @param useInstances Defines wether will draw in the map using instances
  17751. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17752. * @returns true if ready otherwise, false
  17753. */
  17754. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17755. /**
  17756. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17757. * @param defines Defines of the material we want to update
  17758. * @param lightIndex Index of the light in the enabled light list of the material
  17759. */
  17760. prepareDefines(defines: any, lightIndex: number): void;
  17761. /**
  17762. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17763. * defined in the generator but impacting the effect).
  17764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17765. * @param effect The effect we are binfing the information for
  17766. */
  17767. bindShadowLight(lightIndex: string, effect: Effect): void;
  17768. /**
  17769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17770. * (eq to shadow prjection matrix * light transform matrix)
  17771. * @returns The transform matrix used to create the shadow map
  17772. */
  17773. getTransformMatrix(): Matrix;
  17774. /**
  17775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17776. * Cube and 2D textures for instance.
  17777. */
  17778. recreateShadowMap(): void;
  17779. protected _disposeBlurPostProcesses(): void;
  17780. protected _disposeRTTandPostProcesses(): void;
  17781. /**
  17782. * Disposes the ShadowGenerator.
  17783. * Returns nothing.
  17784. */
  17785. dispose(): void;
  17786. /**
  17787. * Serializes the shadow generator setup to a json object.
  17788. * @returns The serialized JSON object
  17789. */
  17790. serialize(): any;
  17791. /**
  17792. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17793. * @param parsedShadowGenerator The JSON object to parse
  17794. * @param scene The scene to create the shadow map for
  17795. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17796. * @returns The parsed shadow generator
  17797. */
  17798. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17799. }
  17800. }
  17801. declare module BABYLON {
  17802. /**
  17803. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17804. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17805. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17806. */
  17807. export abstract class Light extends Node {
  17808. /**
  17809. * Falloff Default: light is falling off following the material specification:
  17810. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17811. */
  17812. static readonly FALLOFF_DEFAULT: number;
  17813. /**
  17814. * Falloff Physical: light is falling off following the inverse squared distance law.
  17815. */
  17816. static readonly FALLOFF_PHYSICAL: number;
  17817. /**
  17818. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17819. * to enhance interoperability with other engines.
  17820. */
  17821. static readonly FALLOFF_GLTF: number;
  17822. /**
  17823. * Falloff Standard: light is falling off like in the standard material
  17824. * to enhance interoperability with other materials.
  17825. */
  17826. static readonly FALLOFF_STANDARD: number;
  17827. /**
  17828. * If every light affecting the material is in this lightmapMode,
  17829. * material.lightmapTexture adds or multiplies
  17830. * (depends on material.useLightmapAsShadowmap)
  17831. * after every other light calculations.
  17832. */
  17833. static readonly LIGHTMAP_DEFAULT: number;
  17834. /**
  17835. * material.lightmapTexture as only diffuse lighting from this light
  17836. * adds only specular lighting from this light
  17837. * adds dynamic shadows
  17838. */
  17839. static readonly LIGHTMAP_SPECULAR: number;
  17840. /**
  17841. * material.lightmapTexture as only lighting
  17842. * no light calculation from this light
  17843. * only adds dynamic shadows from this light
  17844. */
  17845. static readonly LIGHTMAP_SHADOWSONLY: number;
  17846. /**
  17847. * Each light type uses the default quantity according to its type:
  17848. * point/spot lights use luminous intensity
  17849. * directional lights use illuminance
  17850. */
  17851. static readonly INTENSITYMODE_AUTOMATIC: number;
  17852. /**
  17853. * lumen (lm)
  17854. */
  17855. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17856. /**
  17857. * candela (lm/sr)
  17858. */
  17859. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17860. /**
  17861. * lux (lm/m^2)
  17862. */
  17863. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17864. /**
  17865. * nit (cd/m^2)
  17866. */
  17867. static readonly INTENSITYMODE_LUMINANCE: number;
  17868. /**
  17869. * Light type const id of the point light.
  17870. */
  17871. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17872. /**
  17873. * Light type const id of the directional light.
  17874. */
  17875. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17876. /**
  17877. * Light type const id of the spot light.
  17878. */
  17879. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17880. /**
  17881. * Light type const id of the hemispheric light.
  17882. */
  17883. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17884. /**
  17885. * Diffuse gives the basic color to an object.
  17886. */
  17887. diffuse: Color3;
  17888. /**
  17889. * Specular produces a highlight color on an object.
  17890. * Note: This is note affecting PBR materials.
  17891. */
  17892. specular: Color3;
  17893. /**
  17894. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17895. * falling off base on range or angle.
  17896. * This can be set to any values in Light.FALLOFF_x.
  17897. *
  17898. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17899. * other types of materials.
  17900. */
  17901. falloffType: number;
  17902. /**
  17903. * Strength of the light.
  17904. * Note: By default it is define in the framework own unit.
  17905. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17906. */
  17907. intensity: number;
  17908. private _range;
  17909. protected _inverseSquaredRange: number;
  17910. /**
  17911. * Defines how far from the source the light is impacting in scene units.
  17912. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17913. */
  17914. get range(): number;
  17915. /**
  17916. * Defines how far from the source the light is impacting in scene units.
  17917. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17918. */
  17919. set range(value: number);
  17920. /**
  17921. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17922. * of light.
  17923. */
  17924. private _photometricScale;
  17925. private _intensityMode;
  17926. /**
  17927. * Gets the photometric scale used to interpret the intensity.
  17928. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17929. */
  17930. get intensityMode(): number;
  17931. /**
  17932. * Sets the photometric scale used to interpret the intensity.
  17933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17934. */
  17935. set intensityMode(value: number);
  17936. private _radius;
  17937. /**
  17938. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17939. */
  17940. get radius(): number;
  17941. /**
  17942. * sets the light radius used by PBR Materials to simulate soft area lights.
  17943. */
  17944. set radius(value: number);
  17945. private _renderPriority;
  17946. /**
  17947. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17948. * exceeding the number allowed of the materials.
  17949. */
  17950. renderPriority: number;
  17951. private _shadowEnabled;
  17952. /**
  17953. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17954. * the current shadow generator.
  17955. */
  17956. get shadowEnabled(): boolean;
  17957. /**
  17958. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17959. * the current shadow generator.
  17960. */
  17961. set shadowEnabled(value: boolean);
  17962. private _includedOnlyMeshes;
  17963. /**
  17964. * Gets the only meshes impacted by this light.
  17965. */
  17966. get includedOnlyMeshes(): AbstractMesh[];
  17967. /**
  17968. * Sets the only meshes impacted by this light.
  17969. */
  17970. set includedOnlyMeshes(value: AbstractMesh[]);
  17971. private _excludedMeshes;
  17972. /**
  17973. * Gets the meshes not impacted by this light.
  17974. */
  17975. get excludedMeshes(): AbstractMesh[];
  17976. /**
  17977. * Sets the meshes not impacted by this light.
  17978. */
  17979. set excludedMeshes(value: AbstractMesh[]);
  17980. private _excludeWithLayerMask;
  17981. /**
  17982. * Gets the layer id use to find what meshes are not impacted by the light.
  17983. * Inactive if 0
  17984. */
  17985. get excludeWithLayerMask(): number;
  17986. /**
  17987. * Sets the layer id use to find what meshes are not impacted by the light.
  17988. * Inactive if 0
  17989. */
  17990. set excludeWithLayerMask(value: number);
  17991. private _includeOnlyWithLayerMask;
  17992. /**
  17993. * Gets the layer id use to find what meshes are impacted by the light.
  17994. * Inactive if 0
  17995. */
  17996. get includeOnlyWithLayerMask(): number;
  17997. /**
  17998. * Sets the layer id use to find what meshes are impacted by the light.
  17999. * Inactive if 0
  18000. */
  18001. set includeOnlyWithLayerMask(value: number);
  18002. private _lightmapMode;
  18003. /**
  18004. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18005. */
  18006. get lightmapMode(): number;
  18007. /**
  18008. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18009. */
  18010. set lightmapMode(value: number);
  18011. /**
  18012. * Shadow generator associted to the light.
  18013. * @hidden Internal use only.
  18014. */
  18015. _shadowGenerator: Nullable<IShadowGenerator>;
  18016. /**
  18017. * @hidden Internal use only.
  18018. */
  18019. _excludedMeshesIds: string[];
  18020. /**
  18021. * @hidden Internal use only.
  18022. */
  18023. _includedOnlyMeshesIds: string[];
  18024. /**
  18025. * The current light unifom buffer.
  18026. * @hidden Internal use only.
  18027. */
  18028. _uniformBuffer: UniformBuffer;
  18029. /** @hidden */
  18030. _renderId: number;
  18031. /**
  18032. * Creates a Light object in the scene.
  18033. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18034. * @param name The firendly name of the light
  18035. * @param scene The scene the light belongs too
  18036. */
  18037. constructor(name: string, scene: Scene);
  18038. protected abstract _buildUniformLayout(): void;
  18039. /**
  18040. * Sets the passed Effect "effect" with the Light information.
  18041. * @param effect The effect to update
  18042. * @param lightIndex The index of the light in the effect to update
  18043. * @returns The light
  18044. */
  18045. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18046. /**
  18047. * Sets the passed Effect "effect" with the Light textures.
  18048. * @param effect The effect to update
  18049. * @param lightIndex The index of the light in the effect to update
  18050. * @returns The light
  18051. */
  18052. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18053. /**
  18054. * Binds the lights information from the scene to the effect for the given mesh.
  18055. * @param lightIndex Light index
  18056. * @param scene The scene where the light belongs to
  18057. * @param effect The effect we are binding the data to
  18058. * @param useSpecular Defines if specular is supported
  18059. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18060. */
  18061. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18062. /**
  18063. * Sets the passed Effect "effect" with the Light information.
  18064. * @param effect The effect to update
  18065. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18066. * @returns The light
  18067. */
  18068. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18069. /**
  18070. * Returns the string "Light".
  18071. * @returns the class name
  18072. */
  18073. getClassName(): string;
  18074. /** @hidden */
  18075. readonly _isLight: boolean;
  18076. /**
  18077. * Converts the light information to a readable string for debug purpose.
  18078. * @param fullDetails Supports for multiple levels of logging within scene loading
  18079. * @returns the human readable light info
  18080. */
  18081. toString(fullDetails?: boolean): string;
  18082. /** @hidden */
  18083. protected _syncParentEnabledState(): void;
  18084. /**
  18085. * Set the enabled state of this node.
  18086. * @param value - the new enabled state
  18087. */
  18088. setEnabled(value: boolean): void;
  18089. /**
  18090. * Returns the Light associated shadow generator if any.
  18091. * @return the associated shadow generator.
  18092. */
  18093. getShadowGenerator(): Nullable<IShadowGenerator>;
  18094. /**
  18095. * Returns a Vector3, the absolute light position in the World.
  18096. * @returns the world space position of the light
  18097. */
  18098. getAbsolutePosition(): Vector3;
  18099. /**
  18100. * Specifies if the light will affect the passed mesh.
  18101. * @param mesh The mesh to test against the light
  18102. * @return true the mesh is affected otherwise, false.
  18103. */
  18104. canAffectMesh(mesh: AbstractMesh): boolean;
  18105. /**
  18106. * Sort function to order lights for rendering.
  18107. * @param a First Light object to compare to second.
  18108. * @param b Second Light object to compare first.
  18109. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18110. */
  18111. static CompareLightsPriority(a: Light, b: Light): number;
  18112. /**
  18113. * Releases resources associated with this node.
  18114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18116. */
  18117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18118. /**
  18119. * Returns the light type ID (integer).
  18120. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18121. */
  18122. getTypeID(): number;
  18123. /**
  18124. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18125. * @returns the scaled intensity in intensity mode unit
  18126. */
  18127. getScaledIntensity(): number;
  18128. /**
  18129. * Returns a new Light object, named "name", from the current one.
  18130. * @param name The name of the cloned light
  18131. * @param newParent The parent of this light, if it has one
  18132. * @returns the new created light
  18133. */
  18134. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18135. /**
  18136. * Serializes the current light into a Serialization object.
  18137. * @returns the serialized object.
  18138. */
  18139. serialize(): any;
  18140. /**
  18141. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18142. * This new light is named "name" and added to the passed scene.
  18143. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18144. * @param name The friendly name of the light
  18145. * @param scene The scene the new light will belong to
  18146. * @returns the constructor function
  18147. */
  18148. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18149. /**
  18150. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18151. * @param parsedLight The JSON representation of the light
  18152. * @param scene The scene to create the parsed light in
  18153. * @returns the created light after parsing
  18154. */
  18155. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18156. private _hookArrayForExcluded;
  18157. private _hookArrayForIncludedOnly;
  18158. private _resyncMeshes;
  18159. /**
  18160. * Forces the meshes to update their light related information in their rendering used effects
  18161. * @hidden Internal Use Only
  18162. */
  18163. _markMeshesAsLightDirty(): void;
  18164. /**
  18165. * Recomputes the cached photometric scale if needed.
  18166. */
  18167. private _computePhotometricScale;
  18168. /**
  18169. * Returns the Photometric Scale according to the light type and intensity mode.
  18170. */
  18171. private _getPhotometricScale;
  18172. /**
  18173. * Reorder the light in the scene according to their defined priority.
  18174. * @hidden Internal Use Only
  18175. */
  18176. _reorderLightsInScene(): void;
  18177. /**
  18178. * Prepares the list of defines specific to the light type.
  18179. * @param defines the list of defines
  18180. * @param lightIndex defines the index of the light for the effect
  18181. */
  18182. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18183. }
  18184. }
  18185. declare module BABYLON {
  18186. /**
  18187. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18188. * This is the base of the follow, arc rotate cameras and Free camera
  18189. * @see http://doc.babylonjs.com/features/cameras
  18190. */
  18191. export class TargetCamera extends Camera {
  18192. private static _RigCamTransformMatrix;
  18193. private static _TargetTransformMatrix;
  18194. private static _TargetFocalPoint;
  18195. /**
  18196. * Define the current direction the camera is moving to
  18197. */
  18198. cameraDirection: Vector3;
  18199. /**
  18200. * Define the current rotation the camera is rotating to
  18201. */
  18202. cameraRotation: Vector2;
  18203. /**
  18204. * When set, the up vector of the camera will be updated by the rotation of the camera
  18205. */
  18206. updateUpVectorFromRotation: boolean;
  18207. private _tmpQuaternion;
  18208. /**
  18209. * Define the current rotation of the camera
  18210. */
  18211. rotation: Vector3;
  18212. /**
  18213. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18214. */
  18215. rotationQuaternion: Quaternion;
  18216. /**
  18217. * Define the current speed of the camera
  18218. */
  18219. speed: number;
  18220. /**
  18221. * Add constraint to the camera to prevent it to move freely in all directions and
  18222. * around all axis.
  18223. */
  18224. noRotationConstraint: boolean;
  18225. /**
  18226. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18227. * panning
  18228. */
  18229. invertRotation: boolean;
  18230. /**
  18231. * Speed multiplier for inverse camera panning
  18232. */
  18233. inverseRotationSpeed: number;
  18234. /**
  18235. * Define the current target of the camera as an object or a position.
  18236. */
  18237. lockedTarget: any;
  18238. /** @hidden */
  18239. _currentTarget: Vector3;
  18240. /** @hidden */
  18241. _initialFocalDistance: number;
  18242. /** @hidden */
  18243. _viewMatrix: Matrix;
  18244. /** @hidden */
  18245. _camMatrix: Matrix;
  18246. /** @hidden */
  18247. _cameraTransformMatrix: Matrix;
  18248. /** @hidden */
  18249. _cameraRotationMatrix: Matrix;
  18250. /** @hidden */
  18251. _referencePoint: Vector3;
  18252. /** @hidden */
  18253. _transformedReferencePoint: Vector3;
  18254. protected _globalCurrentTarget: Vector3;
  18255. protected _globalCurrentUpVector: Vector3;
  18256. /** @hidden */
  18257. _reset: () => void;
  18258. private _defaultUp;
  18259. /**
  18260. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18261. * This is the base of the follow, arc rotate cameras and Free camera
  18262. * @see http://doc.babylonjs.com/features/cameras
  18263. * @param name Defines the name of the camera in the scene
  18264. * @param position Defines the start position of the camera in the scene
  18265. * @param scene Defines the scene the camera belongs to
  18266. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18267. */
  18268. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18269. /**
  18270. * Gets the position in front of the camera at a given distance.
  18271. * @param distance The distance from the camera we want the position to be
  18272. * @returns the position
  18273. */
  18274. getFrontPosition(distance: number): Vector3;
  18275. /** @hidden */
  18276. _getLockedTargetPosition(): Nullable<Vector3>;
  18277. private _storedPosition;
  18278. private _storedRotation;
  18279. private _storedRotationQuaternion;
  18280. /**
  18281. * Store current camera state of the camera (fov, position, rotation, etc..)
  18282. * @returns the camera
  18283. */
  18284. storeState(): Camera;
  18285. /**
  18286. * Restored camera state. You must call storeState() first
  18287. * @returns whether it was successful or not
  18288. * @hidden
  18289. */
  18290. _restoreStateValues(): boolean;
  18291. /** @hidden */
  18292. _initCache(): void;
  18293. /** @hidden */
  18294. _updateCache(ignoreParentClass?: boolean): void;
  18295. /** @hidden */
  18296. _isSynchronizedViewMatrix(): boolean;
  18297. /** @hidden */
  18298. _computeLocalCameraSpeed(): number;
  18299. /**
  18300. * Defines the target the camera should look at.
  18301. * @param target Defines the new target as a Vector or a mesh
  18302. */
  18303. setTarget(target: Vector3): void;
  18304. /**
  18305. * Return the current target position of the camera. This value is expressed in local space.
  18306. * @returns the target position
  18307. */
  18308. getTarget(): Vector3;
  18309. /** @hidden */
  18310. _decideIfNeedsToMove(): boolean;
  18311. /** @hidden */
  18312. _updatePosition(): void;
  18313. /** @hidden */
  18314. _checkInputs(): void;
  18315. protected _updateCameraRotationMatrix(): void;
  18316. /**
  18317. * 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)
  18318. * @returns the current camera
  18319. */
  18320. private _rotateUpVectorWithCameraRotationMatrix;
  18321. private _cachedRotationZ;
  18322. private _cachedQuaternionRotationZ;
  18323. /** @hidden */
  18324. _getViewMatrix(): Matrix;
  18325. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18326. /**
  18327. * @hidden
  18328. */
  18329. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18330. /**
  18331. * @hidden
  18332. */
  18333. _updateRigCameras(): void;
  18334. private _getRigCamPositionAndTarget;
  18335. /**
  18336. * Gets the current object class name.
  18337. * @return the class name
  18338. */
  18339. getClassName(): string;
  18340. }
  18341. }
  18342. declare module BABYLON {
  18343. /**
  18344. * Gather the list of keyboard event types as constants.
  18345. */
  18346. export class KeyboardEventTypes {
  18347. /**
  18348. * The keydown event is fired when a key becomes active (pressed).
  18349. */
  18350. static readonly KEYDOWN: number;
  18351. /**
  18352. * The keyup event is fired when a key has been released.
  18353. */
  18354. static readonly KEYUP: number;
  18355. }
  18356. /**
  18357. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18358. */
  18359. export class KeyboardInfo {
  18360. /**
  18361. * Defines the type of event (KeyboardEventTypes)
  18362. */
  18363. type: number;
  18364. /**
  18365. * Defines the related dom event
  18366. */
  18367. event: KeyboardEvent;
  18368. /**
  18369. * Instantiates a new keyboard info.
  18370. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18371. * @param type Defines the type of event (KeyboardEventTypes)
  18372. * @param event Defines the related dom event
  18373. */
  18374. constructor(
  18375. /**
  18376. * Defines the type of event (KeyboardEventTypes)
  18377. */
  18378. type: number,
  18379. /**
  18380. * Defines the related dom event
  18381. */
  18382. event: KeyboardEvent);
  18383. }
  18384. /**
  18385. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18386. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18387. */
  18388. export class KeyboardInfoPre extends KeyboardInfo {
  18389. /**
  18390. * Defines the type of event (KeyboardEventTypes)
  18391. */
  18392. type: number;
  18393. /**
  18394. * Defines the related dom event
  18395. */
  18396. event: KeyboardEvent;
  18397. /**
  18398. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18399. */
  18400. skipOnPointerObservable: boolean;
  18401. /**
  18402. * Instantiates a new keyboard pre info.
  18403. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18404. * @param type Defines the type of event (KeyboardEventTypes)
  18405. * @param event Defines the related dom event
  18406. */
  18407. constructor(
  18408. /**
  18409. * Defines the type of event (KeyboardEventTypes)
  18410. */
  18411. type: number,
  18412. /**
  18413. * Defines the related dom event
  18414. */
  18415. event: KeyboardEvent);
  18416. }
  18417. }
  18418. declare module BABYLON {
  18419. /**
  18420. * Manage the keyboard inputs to control the movement of a free camera.
  18421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18422. */
  18423. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18424. /**
  18425. * Defines the camera the input is attached to.
  18426. */
  18427. camera: FreeCamera;
  18428. /**
  18429. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18430. */
  18431. keysUp: number[];
  18432. /**
  18433. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18434. */
  18435. keysUpward: number[];
  18436. /**
  18437. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18438. */
  18439. keysDown: number[];
  18440. /**
  18441. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18442. */
  18443. keysDownward: number[];
  18444. /**
  18445. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18446. */
  18447. keysLeft: number[];
  18448. /**
  18449. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18450. */
  18451. keysRight: number[];
  18452. private _keys;
  18453. private _onCanvasBlurObserver;
  18454. private _onKeyboardObserver;
  18455. private _engine;
  18456. private _scene;
  18457. /**
  18458. * Attach the input controls to a specific dom element to get the input from.
  18459. * @param element Defines the element the controls should be listened from
  18460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18461. */
  18462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18463. /**
  18464. * Detach the current controls from the specified dom element.
  18465. * @param element Defines the element to stop listening the inputs from
  18466. */
  18467. detachControl(element: Nullable<HTMLElement>): void;
  18468. /**
  18469. * Update the current camera state depending on the inputs that have been used this frame.
  18470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18471. */
  18472. checkInputs(): void;
  18473. /**
  18474. * Gets the class name of the current intput.
  18475. * @returns the class name
  18476. */
  18477. getClassName(): string;
  18478. /** @hidden */
  18479. _onLostFocus(): void;
  18480. /**
  18481. * Get the friendly name associated with the input class.
  18482. * @returns the input friendly name
  18483. */
  18484. getSimpleName(): string;
  18485. }
  18486. }
  18487. declare module BABYLON {
  18488. /**
  18489. * Gather the list of pointer event types as constants.
  18490. */
  18491. export class PointerEventTypes {
  18492. /**
  18493. * 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.
  18494. */
  18495. static readonly POINTERDOWN: number;
  18496. /**
  18497. * The pointerup event is fired when a pointer is no longer active.
  18498. */
  18499. static readonly POINTERUP: number;
  18500. /**
  18501. * The pointermove event is fired when a pointer changes coordinates.
  18502. */
  18503. static readonly POINTERMOVE: number;
  18504. /**
  18505. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18506. */
  18507. static readonly POINTERWHEEL: number;
  18508. /**
  18509. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18510. */
  18511. static readonly POINTERPICK: number;
  18512. /**
  18513. * The pointertap event is fired when a the object has been touched and released without drag.
  18514. */
  18515. static readonly POINTERTAP: number;
  18516. /**
  18517. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18518. */
  18519. static readonly POINTERDOUBLETAP: number;
  18520. }
  18521. /**
  18522. * Base class of pointer info types.
  18523. */
  18524. export class PointerInfoBase {
  18525. /**
  18526. * Defines the type of event (PointerEventTypes)
  18527. */
  18528. type: number;
  18529. /**
  18530. * Defines the related dom event
  18531. */
  18532. event: PointerEvent | MouseWheelEvent;
  18533. /**
  18534. * Instantiates the base class of pointers info.
  18535. * @param type Defines the type of event (PointerEventTypes)
  18536. * @param event Defines the related dom event
  18537. */
  18538. constructor(
  18539. /**
  18540. * Defines the type of event (PointerEventTypes)
  18541. */
  18542. type: number,
  18543. /**
  18544. * Defines the related dom event
  18545. */
  18546. event: PointerEvent | MouseWheelEvent);
  18547. }
  18548. /**
  18549. * This class is used to store pointer related info for the onPrePointerObservable event.
  18550. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18551. */
  18552. export class PointerInfoPre extends PointerInfoBase {
  18553. /**
  18554. * Ray from a pointer if availible (eg. 6dof controller)
  18555. */
  18556. ray: Nullable<Ray>;
  18557. /**
  18558. * Defines the local position of the pointer on the canvas.
  18559. */
  18560. localPosition: Vector2;
  18561. /**
  18562. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18563. */
  18564. skipOnPointerObservable: boolean;
  18565. /**
  18566. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18567. * @param type Defines the type of event (PointerEventTypes)
  18568. * @param event Defines the related dom event
  18569. * @param localX Defines the local x coordinates of the pointer when the event occured
  18570. * @param localY Defines the local y coordinates of the pointer when the event occured
  18571. */
  18572. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18573. }
  18574. /**
  18575. * This type contains all the data related to a pointer event in Babylon.js.
  18576. * 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.
  18577. */
  18578. export class PointerInfo extends PointerInfoBase {
  18579. /**
  18580. * Defines the picking info associated to the info (if any)\
  18581. */
  18582. pickInfo: Nullable<PickingInfo>;
  18583. /**
  18584. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18585. * @param type Defines the type of event (PointerEventTypes)
  18586. * @param event Defines the related dom event
  18587. * @param pickInfo Defines the picking info associated to the info (if any)\
  18588. */
  18589. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18590. /**
  18591. * Defines the picking info associated to the info (if any)\
  18592. */
  18593. pickInfo: Nullable<PickingInfo>);
  18594. }
  18595. /**
  18596. * Data relating to a touch event on the screen.
  18597. */
  18598. export interface PointerTouch {
  18599. /**
  18600. * X coordinate of touch.
  18601. */
  18602. x: number;
  18603. /**
  18604. * Y coordinate of touch.
  18605. */
  18606. y: number;
  18607. /**
  18608. * Id of touch. Unique for each finger.
  18609. */
  18610. pointerId: number;
  18611. /**
  18612. * Event type passed from DOM.
  18613. */
  18614. type: any;
  18615. }
  18616. }
  18617. declare module BABYLON {
  18618. /**
  18619. * Manage the mouse inputs to control the movement of a free camera.
  18620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18621. */
  18622. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18623. /**
  18624. * Define if touch is enabled in the mouse input
  18625. */
  18626. touchEnabled: boolean;
  18627. /**
  18628. * Defines the camera the input is attached to.
  18629. */
  18630. camera: FreeCamera;
  18631. /**
  18632. * Defines the buttons associated with the input to handle camera move.
  18633. */
  18634. buttons: number[];
  18635. /**
  18636. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18637. */
  18638. angularSensibility: number;
  18639. private _pointerInput;
  18640. private _onMouseMove;
  18641. private _observer;
  18642. private previousPosition;
  18643. /**
  18644. * Observable for when a pointer move event occurs containing the move offset
  18645. */
  18646. onPointerMovedObservable: Observable<{
  18647. offsetX: number;
  18648. offsetY: number;
  18649. }>;
  18650. /**
  18651. * @hidden
  18652. * If the camera should be rotated automatically based on pointer movement
  18653. */
  18654. _allowCameraRotation: boolean;
  18655. /**
  18656. * Manage the mouse inputs to control the movement of a free camera.
  18657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18658. * @param touchEnabled Defines if touch is enabled or not
  18659. */
  18660. constructor(
  18661. /**
  18662. * Define if touch is enabled in the mouse input
  18663. */
  18664. touchEnabled?: boolean);
  18665. /**
  18666. * Attach the input controls to a specific dom element to get the input from.
  18667. * @param element Defines the element the controls should be listened from
  18668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18669. */
  18670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18671. /**
  18672. * Called on JS contextmenu event.
  18673. * Override this method to provide functionality.
  18674. */
  18675. protected onContextMenu(evt: PointerEvent): void;
  18676. /**
  18677. * Detach the current controls from the specified dom element.
  18678. * @param element Defines the element to stop listening the inputs from
  18679. */
  18680. detachControl(element: Nullable<HTMLElement>): void;
  18681. /**
  18682. * Gets the class name of the current intput.
  18683. * @returns the class name
  18684. */
  18685. getClassName(): string;
  18686. /**
  18687. * Get the friendly name associated with the input class.
  18688. * @returns the input friendly name
  18689. */
  18690. getSimpleName(): string;
  18691. }
  18692. }
  18693. declare module BABYLON {
  18694. /**
  18695. * Manage the touch inputs to control the movement of a free camera.
  18696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18697. */
  18698. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18699. /**
  18700. * Defines the camera the input is attached to.
  18701. */
  18702. camera: FreeCamera;
  18703. /**
  18704. * Defines the touch sensibility for rotation.
  18705. * The higher the faster.
  18706. */
  18707. touchAngularSensibility: number;
  18708. /**
  18709. * Defines the touch sensibility for move.
  18710. * The higher the faster.
  18711. */
  18712. touchMoveSensibility: number;
  18713. private _offsetX;
  18714. private _offsetY;
  18715. private _pointerPressed;
  18716. private _pointerInput;
  18717. private _observer;
  18718. private _onLostFocus;
  18719. /**
  18720. * Attach the input controls to a specific dom element to get the input from.
  18721. * @param element Defines the element the controls should be listened from
  18722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18723. */
  18724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18725. /**
  18726. * Detach the current controls from the specified dom element.
  18727. * @param element Defines the element to stop listening the inputs from
  18728. */
  18729. detachControl(element: Nullable<HTMLElement>): void;
  18730. /**
  18731. * Update the current camera state depending on the inputs that have been used this frame.
  18732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18733. */
  18734. checkInputs(): void;
  18735. /**
  18736. * Gets the class name of the current intput.
  18737. * @returns the class name
  18738. */
  18739. getClassName(): string;
  18740. /**
  18741. * Get the friendly name associated with the input class.
  18742. * @returns the input friendly name
  18743. */
  18744. getSimpleName(): string;
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. /**
  18749. * Default Inputs manager for the FreeCamera.
  18750. * It groups all the default supported inputs for ease of use.
  18751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18752. */
  18753. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18754. /**
  18755. * @hidden
  18756. */
  18757. _mouseInput: Nullable<FreeCameraMouseInput>;
  18758. /**
  18759. * Instantiates a new FreeCameraInputsManager.
  18760. * @param camera Defines the camera the inputs belong to
  18761. */
  18762. constructor(camera: FreeCamera);
  18763. /**
  18764. * Add keyboard input support to the input manager.
  18765. * @returns the current input manager
  18766. */
  18767. addKeyboard(): FreeCameraInputsManager;
  18768. /**
  18769. * Add mouse input support to the input manager.
  18770. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18771. * @returns the current input manager
  18772. */
  18773. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18774. /**
  18775. * Removes the mouse input support from the manager
  18776. * @returns the current input manager
  18777. */
  18778. removeMouse(): FreeCameraInputsManager;
  18779. /**
  18780. * Add touch input support to the input manager.
  18781. * @returns the current input manager
  18782. */
  18783. addTouch(): FreeCameraInputsManager;
  18784. /**
  18785. * Remove all attached input methods from a camera
  18786. */
  18787. clear(): void;
  18788. }
  18789. }
  18790. declare module BABYLON {
  18791. /**
  18792. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18793. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18795. */
  18796. export class FreeCamera extends TargetCamera {
  18797. /**
  18798. * Define the collision ellipsoid of the camera.
  18799. * This is helpful to simulate a camera body like the player body around the camera
  18800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18801. */
  18802. ellipsoid: Vector3;
  18803. /**
  18804. * Define an offset for the position of the ellipsoid around the camera.
  18805. * This can be helpful to determine the center of the body near the gravity center of the body
  18806. * instead of its head.
  18807. */
  18808. ellipsoidOffset: Vector3;
  18809. /**
  18810. * Enable or disable collisions of the camera with the rest of the scene objects.
  18811. */
  18812. checkCollisions: boolean;
  18813. /**
  18814. * Enable or disable gravity on the camera.
  18815. */
  18816. applyGravity: boolean;
  18817. /**
  18818. * Define the input manager associated to the camera.
  18819. */
  18820. inputs: FreeCameraInputsManager;
  18821. /**
  18822. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18823. * Higher values reduce sensitivity.
  18824. */
  18825. get angularSensibility(): number;
  18826. /**
  18827. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18828. * Higher values reduce sensitivity.
  18829. */
  18830. set angularSensibility(value: number);
  18831. /**
  18832. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18833. */
  18834. get keysUp(): number[];
  18835. set keysUp(value: number[]);
  18836. /**
  18837. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18838. */
  18839. get keysUpward(): number[];
  18840. set keysUpward(value: number[]);
  18841. /**
  18842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18843. */
  18844. get keysDown(): number[];
  18845. set keysDown(value: number[]);
  18846. /**
  18847. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18848. */
  18849. get keysDownward(): number[];
  18850. set keysDownward(value: number[]);
  18851. /**
  18852. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18853. */
  18854. get keysLeft(): number[];
  18855. set keysLeft(value: number[]);
  18856. /**
  18857. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18858. */
  18859. get keysRight(): number[];
  18860. set keysRight(value: number[]);
  18861. /**
  18862. * Event raised when the camera collide with a mesh in the scene.
  18863. */
  18864. onCollide: (collidedMesh: AbstractMesh) => void;
  18865. private _collider;
  18866. private _needMoveForGravity;
  18867. private _oldPosition;
  18868. private _diffPosition;
  18869. private _newPosition;
  18870. /** @hidden */
  18871. _localDirection: Vector3;
  18872. /** @hidden */
  18873. _transformedDirection: Vector3;
  18874. /**
  18875. * Instantiates a Free Camera.
  18876. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18877. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18879. * @param name Define the name of the camera in the scene
  18880. * @param position Define the start position of the camera in the scene
  18881. * @param scene Define the scene the camera belongs to
  18882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18883. */
  18884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18885. /**
  18886. * Attached controls to the current camera.
  18887. * @param element Defines the element the controls should be listened from
  18888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18889. */
  18890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18891. /**
  18892. * Detach the current controls from the camera.
  18893. * The camera will stop reacting to inputs.
  18894. * @param element Defines the element to stop listening the inputs from
  18895. */
  18896. detachControl(element: HTMLElement): void;
  18897. private _collisionMask;
  18898. /**
  18899. * Define a collision mask to limit the list of object the camera can collide with
  18900. */
  18901. get collisionMask(): number;
  18902. set collisionMask(mask: number);
  18903. /** @hidden */
  18904. _collideWithWorld(displacement: Vector3): void;
  18905. private _onCollisionPositionChange;
  18906. /** @hidden */
  18907. _checkInputs(): void;
  18908. /** @hidden */
  18909. _decideIfNeedsToMove(): boolean;
  18910. /** @hidden */
  18911. _updatePosition(): void;
  18912. /**
  18913. * Destroy the camera and release the current resources hold by it.
  18914. */
  18915. dispose(): void;
  18916. /**
  18917. * Gets the current object class name.
  18918. * @return the class name
  18919. */
  18920. getClassName(): string;
  18921. }
  18922. }
  18923. declare module BABYLON {
  18924. /**
  18925. * Represents a gamepad control stick position
  18926. */
  18927. export class StickValues {
  18928. /**
  18929. * The x component of the control stick
  18930. */
  18931. x: number;
  18932. /**
  18933. * The y component of the control stick
  18934. */
  18935. y: number;
  18936. /**
  18937. * Initializes the gamepad x and y control stick values
  18938. * @param x The x component of the gamepad control stick value
  18939. * @param y The y component of the gamepad control stick value
  18940. */
  18941. constructor(
  18942. /**
  18943. * The x component of the control stick
  18944. */
  18945. x: number,
  18946. /**
  18947. * The y component of the control stick
  18948. */
  18949. y: number);
  18950. }
  18951. /**
  18952. * An interface which manages callbacks for gamepad button changes
  18953. */
  18954. export interface GamepadButtonChanges {
  18955. /**
  18956. * Called when a gamepad has been changed
  18957. */
  18958. changed: boolean;
  18959. /**
  18960. * Called when a gamepad press event has been triggered
  18961. */
  18962. pressChanged: boolean;
  18963. /**
  18964. * Called when a touch event has been triggered
  18965. */
  18966. touchChanged: boolean;
  18967. /**
  18968. * Called when a value has changed
  18969. */
  18970. valueChanged: boolean;
  18971. }
  18972. /**
  18973. * Represents a gamepad
  18974. */
  18975. export class Gamepad {
  18976. /**
  18977. * The id of the gamepad
  18978. */
  18979. id: string;
  18980. /**
  18981. * The index of the gamepad
  18982. */
  18983. index: number;
  18984. /**
  18985. * The browser gamepad
  18986. */
  18987. browserGamepad: any;
  18988. /**
  18989. * Specifies what type of gamepad this represents
  18990. */
  18991. type: number;
  18992. private _leftStick;
  18993. private _rightStick;
  18994. /** @hidden */
  18995. _isConnected: boolean;
  18996. private _leftStickAxisX;
  18997. private _leftStickAxisY;
  18998. private _rightStickAxisX;
  18999. private _rightStickAxisY;
  19000. /**
  19001. * Triggered when the left control stick has been changed
  19002. */
  19003. private _onleftstickchanged;
  19004. /**
  19005. * Triggered when the right control stick has been changed
  19006. */
  19007. private _onrightstickchanged;
  19008. /**
  19009. * Represents a gamepad controller
  19010. */
  19011. static GAMEPAD: number;
  19012. /**
  19013. * Represents a generic controller
  19014. */
  19015. static GENERIC: number;
  19016. /**
  19017. * Represents an XBox controller
  19018. */
  19019. static XBOX: number;
  19020. /**
  19021. * Represents a pose-enabled controller
  19022. */
  19023. static POSE_ENABLED: number;
  19024. /**
  19025. * Represents an Dual Shock controller
  19026. */
  19027. static DUALSHOCK: number;
  19028. /**
  19029. * Specifies whether the left control stick should be Y-inverted
  19030. */
  19031. protected _invertLeftStickY: boolean;
  19032. /**
  19033. * Specifies if the gamepad has been connected
  19034. */
  19035. get isConnected(): boolean;
  19036. /**
  19037. * Initializes the gamepad
  19038. * @param id The id of the gamepad
  19039. * @param index The index of the gamepad
  19040. * @param browserGamepad The browser gamepad
  19041. * @param leftStickX The x component of the left joystick
  19042. * @param leftStickY The y component of the left joystick
  19043. * @param rightStickX The x component of the right joystick
  19044. * @param rightStickY The y component of the right joystick
  19045. */
  19046. constructor(
  19047. /**
  19048. * The id of the gamepad
  19049. */
  19050. id: string,
  19051. /**
  19052. * The index of the gamepad
  19053. */
  19054. index: number,
  19055. /**
  19056. * The browser gamepad
  19057. */
  19058. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19059. /**
  19060. * Callback triggered when the left joystick has changed
  19061. * @param callback
  19062. */
  19063. onleftstickchanged(callback: (values: StickValues) => void): void;
  19064. /**
  19065. * Callback triggered when the right joystick has changed
  19066. * @param callback
  19067. */
  19068. onrightstickchanged(callback: (values: StickValues) => void): void;
  19069. /**
  19070. * Gets the left joystick
  19071. */
  19072. get leftStick(): StickValues;
  19073. /**
  19074. * Sets the left joystick values
  19075. */
  19076. set leftStick(newValues: StickValues);
  19077. /**
  19078. * Gets the right joystick
  19079. */
  19080. get rightStick(): StickValues;
  19081. /**
  19082. * Sets the right joystick value
  19083. */
  19084. set rightStick(newValues: StickValues);
  19085. /**
  19086. * Updates the gamepad joystick positions
  19087. */
  19088. update(): void;
  19089. /**
  19090. * Disposes the gamepad
  19091. */
  19092. dispose(): void;
  19093. }
  19094. /**
  19095. * Represents a generic gamepad
  19096. */
  19097. export class GenericPad extends Gamepad {
  19098. private _buttons;
  19099. private _onbuttondown;
  19100. private _onbuttonup;
  19101. /**
  19102. * Observable triggered when a button has been pressed
  19103. */
  19104. onButtonDownObservable: Observable<number>;
  19105. /**
  19106. * Observable triggered when a button has been released
  19107. */
  19108. onButtonUpObservable: Observable<number>;
  19109. /**
  19110. * Callback triggered when a button has been pressed
  19111. * @param callback Called when a button has been pressed
  19112. */
  19113. onbuttondown(callback: (buttonPressed: number) => void): void;
  19114. /**
  19115. * Callback triggered when a button has been released
  19116. * @param callback Called when a button has been released
  19117. */
  19118. onbuttonup(callback: (buttonReleased: number) => void): void;
  19119. /**
  19120. * Initializes the generic gamepad
  19121. * @param id The id of the generic gamepad
  19122. * @param index The index of the generic gamepad
  19123. * @param browserGamepad The browser gamepad
  19124. */
  19125. constructor(id: string, index: number, browserGamepad: any);
  19126. private _setButtonValue;
  19127. /**
  19128. * Updates the generic gamepad
  19129. */
  19130. update(): void;
  19131. /**
  19132. * Disposes the generic gamepad
  19133. */
  19134. dispose(): void;
  19135. }
  19136. }
  19137. declare module BABYLON {
  19138. /**
  19139. * Defines the types of pose enabled controllers that are supported
  19140. */
  19141. export enum PoseEnabledControllerType {
  19142. /**
  19143. * HTC Vive
  19144. */
  19145. VIVE = 0,
  19146. /**
  19147. * Oculus Rift
  19148. */
  19149. OCULUS = 1,
  19150. /**
  19151. * Windows mixed reality
  19152. */
  19153. WINDOWS = 2,
  19154. /**
  19155. * Samsung gear VR
  19156. */
  19157. GEAR_VR = 3,
  19158. /**
  19159. * Google Daydream
  19160. */
  19161. DAYDREAM = 4,
  19162. /**
  19163. * Generic
  19164. */
  19165. GENERIC = 5
  19166. }
  19167. /**
  19168. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19169. */
  19170. export interface MutableGamepadButton {
  19171. /**
  19172. * Value of the button/trigger
  19173. */
  19174. value: number;
  19175. /**
  19176. * If the button/trigger is currently touched
  19177. */
  19178. touched: boolean;
  19179. /**
  19180. * If the button/trigger is currently pressed
  19181. */
  19182. pressed: boolean;
  19183. }
  19184. /**
  19185. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19186. * @hidden
  19187. */
  19188. export interface ExtendedGamepadButton extends GamepadButton {
  19189. /**
  19190. * If the button/trigger is currently pressed
  19191. */
  19192. readonly pressed: boolean;
  19193. /**
  19194. * If the button/trigger is currently touched
  19195. */
  19196. readonly touched: boolean;
  19197. /**
  19198. * Value of the button/trigger
  19199. */
  19200. readonly value: number;
  19201. }
  19202. /** @hidden */
  19203. export interface _GamePadFactory {
  19204. /**
  19205. * Returns whether or not the current gamepad can be created for this type of controller.
  19206. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19207. * @returns true if it can be created, otherwise false
  19208. */
  19209. canCreate(gamepadInfo: any): boolean;
  19210. /**
  19211. * Creates a new instance of the Gamepad.
  19212. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19213. * @returns the new gamepad instance
  19214. */
  19215. create(gamepadInfo: any): Gamepad;
  19216. }
  19217. /**
  19218. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19219. */
  19220. export class PoseEnabledControllerHelper {
  19221. /** @hidden */
  19222. static _ControllerFactories: _GamePadFactory[];
  19223. /** @hidden */
  19224. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19225. /**
  19226. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19227. * @param vrGamepad the gamepad to initialized
  19228. * @returns a vr controller of the type the gamepad identified as
  19229. */
  19230. static InitiateController(vrGamepad: any): Gamepad;
  19231. }
  19232. /**
  19233. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19234. */
  19235. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19236. /**
  19237. * If the controller is used in a webXR session
  19238. */
  19239. isXR: boolean;
  19240. private _deviceRoomPosition;
  19241. private _deviceRoomRotationQuaternion;
  19242. /**
  19243. * The device position in babylon space
  19244. */
  19245. devicePosition: Vector3;
  19246. /**
  19247. * The device rotation in babylon space
  19248. */
  19249. deviceRotationQuaternion: Quaternion;
  19250. /**
  19251. * The scale factor of the device in babylon space
  19252. */
  19253. deviceScaleFactor: number;
  19254. /**
  19255. * (Likely devicePosition should be used instead) The device position in its room space
  19256. */
  19257. position: Vector3;
  19258. /**
  19259. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19260. */
  19261. rotationQuaternion: Quaternion;
  19262. /**
  19263. * The type of controller (Eg. Windows mixed reality)
  19264. */
  19265. controllerType: PoseEnabledControllerType;
  19266. protected _calculatedPosition: Vector3;
  19267. private _calculatedRotation;
  19268. /**
  19269. * The raw pose from the device
  19270. */
  19271. rawPose: DevicePose;
  19272. private _trackPosition;
  19273. private _maxRotationDistFromHeadset;
  19274. private _draggedRoomRotation;
  19275. /**
  19276. * @hidden
  19277. */
  19278. _disableTrackPosition(fixedPosition: Vector3): void;
  19279. /**
  19280. * Internal, the mesh attached to the controller
  19281. * @hidden
  19282. */
  19283. _mesh: Nullable<AbstractMesh>;
  19284. private _poseControlledCamera;
  19285. private _leftHandSystemQuaternion;
  19286. /**
  19287. * Internal, matrix used to convert room space to babylon space
  19288. * @hidden
  19289. */
  19290. _deviceToWorld: Matrix;
  19291. /**
  19292. * Node to be used when casting a ray from the controller
  19293. * @hidden
  19294. */
  19295. _pointingPoseNode: Nullable<TransformNode>;
  19296. /**
  19297. * Name of the child mesh that can be used to cast a ray from the controller
  19298. */
  19299. static readonly POINTING_POSE: string;
  19300. /**
  19301. * Creates a new PoseEnabledController from a gamepad
  19302. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19303. */
  19304. constructor(browserGamepad: any);
  19305. private _workingMatrix;
  19306. /**
  19307. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19308. */
  19309. update(): void;
  19310. /**
  19311. * Updates only the pose device and mesh without doing any button event checking
  19312. */
  19313. protected _updatePoseAndMesh(): void;
  19314. /**
  19315. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19316. * @param poseData raw pose fromthe device
  19317. */
  19318. updateFromDevice(poseData: DevicePose): void;
  19319. /**
  19320. * @hidden
  19321. */
  19322. _meshAttachedObservable: Observable<AbstractMesh>;
  19323. /**
  19324. * Attaches a mesh to the controller
  19325. * @param mesh the mesh to be attached
  19326. */
  19327. attachToMesh(mesh: AbstractMesh): void;
  19328. /**
  19329. * Attaches the controllers mesh to a camera
  19330. * @param camera the camera the mesh should be attached to
  19331. */
  19332. attachToPoseControlledCamera(camera: TargetCamera): void;
  19333. /**
  19334. * Disposes of the controller
  19335. */
  19336. dispose(): void;
  19337. /**
  19338. * The mesh that is attached to the controller
  19339. */
  19340. get mesh(): Nullable<AbstractMesh>;
  19341. /**
  19342. * Gets the ray of the controller in the direction the controller is pointing
  19343. * @param length the length the resulting ray should be
  19344. * @returns a ray in the direction the controller is pointing
  19345. */
  19346. getForwardRay(length?: number): Ray;
  19347. }
  19348. }
  19349. declare module BABYLON {
  19350. /**
  19351. * Defines the WebVRController object that represents controllers tracked in 3D space
  19352. */
  19353. export abstract class WebVRController extends PoseEnabledController {
  19354. /**
  19355. * Internal, the default controller model for the controller
  19356. */
  19357. protected _defaultModel: Nullable<AbstractMesh>;
  19358. /**
  19359. * Fired when the trigger state has changed
  19360. */
  19361. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19362. /**
  19363. * Fired when the main button state has changed
  19364. */
  19365. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19366. /**
  19367. * Fired when the secondary button state has changed
  19368. */
  19369. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19370. /**
  19371. * Fired when the pad state has changed
  19372. */
  19373. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19374. /**
  19375. * Fired when controllers stick values have changed
  19376. */
  19377. onPadValuesChangedObservable: Observable<StickValues>;
  19378. /**
  19379. * Array of button availible on the controller
  19380. */
  19381. protected _buttons: Array<MutableGamepadButton>;
  19382. private _onButtonStateChange;
  19383. /**
  19384. * Fired when a controller button's state has changed
  19385. * @param callback the callback containing the button that was modified
  19386. */
  19387. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19388. /**
  19389. * X and Y axis corresponding to the controllers joystick
  19390. */
  19391. pad: StickValues;
  19392. /**
  19393. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19394. */
  19395. hand: string;
  19396. /**
  19397. * The default controller model for the controller
  19398. */
  19399. get defaultModel(): Nullable<AbstractMesh>;
  19400. /**
  19401. * Creates a new WebVRController from a gamepad
  19402. * @param vrGamepad the gamepad that the WebVRController should be created from
  19403. */
  19404. constructor(vrGamepad: any);
  19405. /**
  19406. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19407. */
  19408. update(): void;
  19409. /**
  19410. * Function to be called when a button is modified
  19411. */
  19412. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19413. /**
  19414. * Loads a mesh and attaches it to the controller
  19415. * @param scene the scene the mesh should be added to
  19416. * @param meshLoaded callback for when the mesh has been loaded
  19417. */
  19418. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19419. private _setButtonValue;
  19420. private _changes;
  19421. private _checkChanges;
  19422. /**
  19423. * Disposes of th webVRCOntroller
  19424. */
  19425. dispose(): void;
  19426. }
  19427. }
  19428. declare module BABYLON {
  19429. /**
  19430. * The HemisphericLight simulates the ambient environment light,
  19431. * so the passed direction is the light reflection direction, not the incoming direction.
  19432. */
  19433. export class HemisphericLight extends Light {
  19434. /**
  19435. * The groundColor is the light in the opposite direction to the one specified during creation.
  19436. * 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.
  19437. */
  19438. groundColor: Color3;
  19439. /**
  19440. * The light reflection direction, not the incoming direction.
  19441. */
  19442. direction: Vector3;
  19443. /**
  19444. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19445. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19446. * The HemisphericLight can't cast shadows.
  19447. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19448. * @param name The friendly name of the light
  19449. * @param direction The direction of the light reflection
  19450. * @param scene The scene the light belongs to
  19451. */
  19452. constructor(name: string, direction: Vector3, scene: Scene);
  19453. protected _buildUniformLayout(): void;
  19454. /**
  19455. * Returns the string "HemisphericLight".
  19456. * @return The class name
  19457. */
  19458. getClassName(): string;
  19459. /**
  19460. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19461. * Returns the updated direction.
  19462. * @param target The target the direction should point to
  19463. * @return The computed direction
  19464. */
  19465. setDirectionToTarget(target: Vector3): Vector3;
  19466. /**
  19467. * Returns the shadow generator associated to the light.
  19468. * @returns Always null for hemispheric lights because it does not support shadows.
  19469. */
  19470. getShadowGenerator(): Nullable<IShadowGenerator>;
  19471. /**
  19472. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19473. * @param effect The effect to update
  19474. * @param lightIndex The index of the light in the effect to update
  19475. * @returns The hemispheric light
  19476. */
  19477. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19478. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19479. /**
  19480. * Computes the world matrix of the node
  19481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19482. * @param useWasUpdatedFlag defines a reserved property
  19483. * @returns the world matrix
  19484. */
  19485. computeWorldMatrix(): Matrix;
  19486. /**
  19487. * Returns the integer 3.
  19488. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19489. */
  19490. getTypeID(): number;
  19491. /**
  19492. * Prepares the list of defines specific to the light type.
  19493. * @param defines the list of defines
  19494. * @param lightIndex defines the index of the light for the effect
  19495. */
  19496. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19497. }
  19498. }
  19499. declare module BABYLON {
  19500. /** @hidden */
  19501. export var vrMultiviewToSingleviewPixelShader: {
  19502. name: string;
  19503. shader: string;
  19504. };
  19505. }
  19506. declare module BABYLON {
  19507. /**
  19508. * Renders to multiple views with a single draw call
  19509. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19510. */
  19511. export class MultiviewRenderTarget extends RenderTargetTexture {
  19512. /**
  19513. * Creates a multiview render target
  19514. * @param scene scene used with the render target
  19515. * @param size the size of the render target (used for each view)
  19516. */
  19517. constructor(scene: Scene, size?: number | {
  19518. width: number;
  19519. height: number;
  19520. } | {
  19521. ratio: number;
  19522. });
  19523. /**
  19524. * @hidden
  19525. * @param faceIndex the face index, if its a cube texture
  19526. */
  19527. _bindFrameBuffer(faceIndex?: number): void;
  19528. /**
  19529. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19530. * @returns the view count
  19531. */
  19532. getViewCount(): number;
  19533. }
  19534. }
  19535. declare module BABYLON {
  19536. interface Engine {
  19537. /**
  19538. * Creates a new multiview render target
  19539. * @param width defines the width of the texture
  19540. * @param height defines the height of the texture
  19541. * @returns the created multiview texture
  19542. */
  19543. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19544. /**
  19545. * Binds a multiview framebuffer to be drawn to
  19546. * @param multiviewTexture texture to bind
  19547. */
  19548. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19549. }
  19550. interface Camera {
  19551. /**
  19552. * @hidden
  19553. * 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)
  19554. */
  19555. _useMultiviewToSingleView: boolean;
  19556. /**
  19557. * @hidden
  19558. * 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)
  19559. */
  19560. _multiviewTexture: Nullable<RenderTargetTexture>;
  19561. /**
  19562. * @hidden
  19563. * ensures the multiview texture of the camera exists and has the specified width/height
  19564. * @param width height to set on the multiview texture
  19565. * @param height width to set on the multiview texture
  19566. */
  19567. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19568. }
  19569. interface Scene {
  19570. /** @hidden */
  19571. _transformMatrixR: Matrix;
  19572. /** @hidden */
  19573. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19574. /** @hidden */
  19575. _createMultiviewUbo(): void;
  19576. /** @hidden */
  19577. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19578. /** @hidden */
  19579. _renderMultiviewToSingleView(camera: Camera): void;
  19580. }
  19581. }
  19582. declare module BABYLON {
  19583. /**
  19584. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19585. * This will not be used for webXR as it supports displaying texture arrays directly
  19586. */
  19587. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19588. /**
  19589. * Initializes a VRMultiviewToSingleview
  19590. * @param name name of the post process
  19591. * @param camera camera to be applied to
  19592. * @param scaleFactor scaling factor to the size of the output texture
  19593. */
  19594. constructor(name: string, camera: Camera, scaleFactor: number);
  19595. }
  19596. }
  19597. declare module BABYLON {
  19598. /**
  19599. * Interface used to define additional presentation attributes
  19600. */
  19601. export interface IVRPresentationAttributes {
  19602. /**
  19603. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19604. */
  19605. highRefreshRate: boolean;
  19606. /**
  19607. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19608. */
  19609. foveationLevel: number;
  19610. }
  19611. interface Engine {
  19612. /** @hidden */
  19613. _vrDisplay: any;
  19614. /** @hidden */
  19615. _vrSupported: boolean;
  19616. /** @hidden */
  19617. _oldSize: Size;
  19618. /** @hidden */
  19619. _oldHardwareScaleFactor: number;
  19620. /** @hidden */
  19621. _vrExclusivePointerMode: boolean;
  19622. /** @hidden */
  19623. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19624. /** @hidden */
  19625. _onVRDisplayPointerRestricted: () => void;
  19626. /** @hidden */
  19627. _onVRDisplayPointerUnrestricted: () => void;
  19628. /** @hidden */
  19629. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19630. /** @hidden */
  19631. _onVrDisplayDisconnect: Nullable<() => void>;
  19632. /** @hidden */
  19633. _onVrDisplayPresentChange: Nullable<() => void>;
  19634. /**
  19635. * Observable signaled when VR display mode changes
  19636. */
  19637. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19638. /**
  19639. * Observable signaled when VR request present is complete
  19640. */
  19641. onVRRequestPresentComplete: Observable<boolean>;
  19642. /**
  19643. * Observable signaled when VR request present starts
  19644. */
  19645. onVRRequestPresentStart: Observable<Engine>;
  19646. /**
  19647. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19648. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19649. */
  19650. isInVRExclusivePointerMode: boolean;
  19651. /**
  19652. * Gets a boolean indicating if a webVR device was detected
  19653. * @returns true if a webVR device was detected
  19654. */
  19655. isVRDevicePresent(): boolean;
  19656. /**
  19657. * Gets the current webVR device
  19658. * @returns the current webVR device (or null)
  19659. */
  19660. getVRDevice(): any;
  19661. /**
  19662. * Initializes a webVR display and starts listening to display change events
  19663. * The onVRDisplayChangedObservable will be notified upon these changes
  19664. * @returns A promise containing a VRDisplay and if vr is supported
  19665. */
  19666. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19667. /** @hidden */
  19668. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19669. /**
  19670. * Gets or sets the presentation attributes used to configure VR rendering
  19671. */
  19672. vrPresentationAttributes?: IVRPresentationAttributes;
  19673. /**
  19674. * Call this function to switch to webVR mode
  19675. * Will do nothing if webVR is not supported or if there is no webVR device
  19676. * @param options the webvr options provided to the camera. mainly used for multiview
  19677. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19678. */
  19679. enableVR(options: WebVROptions): void;
  19680. /** @hidden */
  19681. _onVRFullScreenTriggered(): void;
  19682. }
  19683. }
  19684. declare module BABYLON {
  19685. /**
  19686. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19687. * IMPORTANT!! The data is right-hand data.
  19688. * @export
  19689. * @interface DevicePose
  19690. */
  19691. export interface DevicePose {
  19692. /**
  19693. * The position of the device, values in array are [x,y,z].
  19694. */
  19695. readonly position: Nullable<Float32Array>;
  19696. /**
  19697. * The linearVelocity of the device, values in array are [x,y,z].
  19698. */
  19699. readonly linearVelocity: Nullable<Float32Array>;
  19700. /**
  19701. * The linearAcceleration of the device, values in array are [x,y,z].
  19702. */
  19703. readonly linearAcceleration: Nullable<Float32Array>;
  19704. /**
  19705. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19706. */
  19707. readonly orientation: Nullable<Float32Array>;
  19708. /**
  19709. * The angularVelocity of the device, values in array are [x,y,z].
  19710. */
  19711. readonly angularVelocity: Nullable<Float32Array>;
  19712. /**
  19713. * The angularAcceleration of the device, values in array are [x,y,z].
  19714. */
  19715. readonly angularAcceleration: Nullable<Float32Array>;
  19716. }
  19717. /**
  19718. * Interface representing a pose controlled object in Babylon.
  19719. * A pose controlled object has both regular pose values as well as pose values
  19720. * from an external device such as a VR head mounted display
  19721. */
  19722. export interface PoseControlled {
  19723. /**
  19724. * The position of the object in babylon space.
  19725. */
  19726. position: Vector3;
  19727. /**
  19728. * The rotation quaternion of the object in babylon space.
  19729. */
  19730. rotationQuaternion: Quaternion;
  19731. /**
  19732. * The position of the device in babylon space.
  19733. */
  19734. devicePosition?: Vector3;
  19735. /**
  19736. * The rotation quaternion of the device in babylon space.
  19737. */
  19738. deviceRotationQuaternion: Quaternion;
  19739. /**
  19740. * The raw pose coming from the device.
  19741. */
  19742. rawPose: Nullable<DevicePose>;
  19743. /**
  19744. * The scale of the device to be used when translating from device space to babylon space.
  19745. */
  19746. deviceScaleFactor: number;
  19747. /**
  19748. * Updates the poseControlled values based on the input device pose.
  19749. * @param poseData the pose data to update the object with
  19750. */
  19751. updateFromDevice(poseData: DevicePose): void;
  19752. }
  19753. /**
  19754. * Set of options to customize the webVRCamera
  19755. */
  19756. export interface WebVROptions {
  19757. /**
  19758. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19759. */
  19760. trackPosition?: boolean;
  19761. /**
  19762. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19763. */
  19764. positionScale?: number;
  19765. /**
  19766. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19767. */
  19768. displayName?: string;
  19769. /**
  19770. * Should the native controller meshes be initialized. (default: true)
  19771. */
  19772. controllerMeshes?: boolean;
  19773. /**
  19774. * Creating a default HemiLight only on controllers. (default: true)
  19775. */
  19776. defaultLightingOnControllers?: boolean;
  19777. /**
  19778. * If you don't want to use the default VR button of the helper. (default: false)
  19779. */
  19780. useCustomVRButton?: boolean;
  19781. /**
  19782. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19783. */
  19784. customVRButton?: HTMLButtonElement;
  19785. /**
  19786. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19787. */
  19788. rayLength?: number;
  19789. /**
  19790. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19791. */
  19792. defaultHeight?: number;
  19793. /**
  19794. * If multiview should be used if availible (default: false)
  19795. */
  19796. useMultiview?: boolean;
  19797. }
  19798. /**
  19799. * This represents a WebVR camera.
  19800. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19801. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19802. */
  19803. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19804. private webVROptions;
  19805. /**
  19806. * @hidden
  19807. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19808. */
  19809. _vrDevice: any;
  19810. /**
  19811. * The rawPose of the vrDevice.
  19812. */
  19813. rawPose: Nullable<DevicePose>;
  19814. private _onVREnabled;
  19815. private _specsVersion;
  19816. private _attached;
  19817. private _frameData;
  19818. protected _descendants: Array<Node>;
  19819. private _deviceRoomPosition;
  19820. /** @hidden */
  19821. _deviceRoomRotationQuaternion: Quaternion;
  19822. private _standingMatrix;
  19823. /**
  19824. * Represents device position in babylon space.
  19825. */
  19826. devicePosition: Vector3;
  19827. /**
  19828. * Represents device rotation in babylon space.
  19829. */
  19830. deviceRotationQuaternion: Quaternion;
  19831. /**
  19832. * The scale of the device to be used when translating from device space to babylon space.
  19833. */
  19834. deviceScaleFactor: number;
  19835. private _deviceToWorld;
  19836. private _worldToDevice;
  19837. /**
  19838. * References to the webVR controllers for the vrDevice.
  19839. */
  19840. controllers: Array<WebVRController>;
  19841. /**
  19842. * Emits an event when a controller is attached.
  19843. */
  19844. onControllersAttachedObservable: Observable<WebVRController[]>;
  19845. /**
  19846. * Emits an event when a controller's mesh has been loaded;
  19847. */
  19848. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19849. /**
  19850. * Emits an event when the HMD's pose has been updated.
  19851. */
  19852. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19853. private _poseSet;
  19854. /**
  19855. * If the rig cameras be used as parent instead of this camera.
  19856. */
  19857. rigParenting: boolean;
  19858. private _lightOnControllers;
  19859. private _defaultHeight?;
  19860. /**
  19861. * Instantiates a WebVRFreeCamera.
  19862. * @param name The name of the WebVRFreeCamera
  19863. * @param position The starting anchor position for the camera
  19864. * @param scene The scene the camera belongs to
  19865. * @param webVROptions a set of customizable options for the webVRCamera
  19866. */
  19867. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19868. /**
  19869. * Gets the device distance from the ground in meters.
  19870. * @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.
  19871. */
  19872. deviceDistanceToRoomGround(): number;
  19873. /**
  19874. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19875. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19876. */
  19877. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19878. /**
  19879. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19880. * @returns A promise with a boolean set to if the standing matrix is supported.
  19881. */
  19882. useStandingMatrixAsync(): Promise<boolean>;
  19883. /**
  19884. * Disposes the camera
  19885. */
  19886. dispose(): void;
  19887. /**
  19888. * Gets a vrController by name.
  19889. * @param name The name of the controller to retreive
  19890. * @returns the controller matching the name specified or null if not found
  19891. */
  19892. getControllerByName(name: string): Nullable<WebVRController>;
  19893. private _leftController;
  19894. /**
  19895. * The controller corresponding to the users left hand.
  19896. */
  19897. get leftController(): Nullable<WebVRController>;
  19898. private _rightController;
  19899. /**
  19900. * The controller corresponding to the users right hand.
  19901. */
  19902. get rightController(): Nullable<WebVRController>;
  19903. /**
  19904. * Casts a ray forward from the vrCamera's gaze.
  19905. * @param length Length of the ray (default: 100)
  19906. * @returns the ray corresponding to the gaze
  19907. */
  19908. getForwardRay(length?: number): Ray;
  19909. /**
  19910. * @hidden
  19911. * Updates the camera based on device's frame data
  19912. */
  19913. _checkInputs(): void;
  19914. /**
  19915. * Updates the poseControlled values based on the input device pose.
  19916. * @param poseData Pose coming from the device
  19917. */
  19918. updateFromDevice(poseData: DevicePose): void;
  19919. private _htmlElementAttached;
  19920. private _detachIfAttached;
  19921. /**
  19922. * WebVR's attach control will start broadcasting frames to the device.
  19923. * Note that in certain browsers (chrome for example) this function must be called
  19924. * within a user-interaction callback. Example:
  19925. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19926. *
  19927. * @param element html element to attach the vrDevice to
  19928. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19929. */
  19930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19931. /**
  19932. * Detaches the camera from the html element and disables VR
  19933. *
  19934. * @param element html element to detach from
  19935. */
  19936. detachControl(element: HTMLElement): void;
  19937. /**
  19938. * @returns the name of this class
  19939. */
  19940. getClassName(): string;
  19941. /**
  19942. * Calls resetPose on the vrDisplay
  19943. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19944. */
  19945. resetToCurrentRotation(): void;
  19946. /**
  19947. * @hidden
  19948. * Updates the rig cameras (left and right eye)
  19949. */
  19950. _updateRigCameras(): void;
  19951. private _workingVector;
  19952. private _oneVector;
  19953. private _workingMatrix;
  19954. private updateCacheCalled;
  19955. private _correctPositionIfNotTrackPosition;
  19956. /**
  19957. * @hidden
  19958. * Updates the cached values of the camera
  19959. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19960. */
  19961. _updateCache(ignoreParentClass?: boolean): void;
  19962. /**
  19963. * @hidden
  19964. * Get current device position in babylon world
  19965. */
  19966. _computeDevicePosition(): void;
  19967. /**
  19968. * Updates the current device position and rotation in the babylon world
  19969. */
  19970. update(): void;
  19971. /**
  19972. * @hidden
  19973. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19974. * @returns an identity matrix
  19975. */
  19976. _getViewMatrix(): Matrix;
  19977. private _tmpMatrix;
  19978. /**
  19979. * This function is called by the two RIG cameras.
  19980. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19981. * @hidden
  19982. */
  19983. _getWebVRViewMatrix(): Matrix;
  19984. /** @hidden */
  19985. _getWebVRProjectionMatrix(): Matrix;
  19986. private _onGamepadConnectedObserver;
  19987. private _onGamepadDisconnectedObserver;
  19988. private _updateCacheWhenTrackingDisabledObserver;
  19989. /**
  19990. * Initializes the controllers and their meshes
  19991. */
  19992. initControllers(): void;
  19993. }
  19994. }
  19995. declare module BABYLON {
  19996. /**
  19997. * "Static Class" containing the most commonly used helper while dealing with material for
  19998. * rendering purpose.
  19999. *
  20000. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20001. *
  20002. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20003. */
  20004. export class MaterialHelper {
  20005. /**
  20006. * Bind the current view position to an effect.
  20007. * @param effect The effect to be bound
  20008. * @param scene The scene the eyes position is used from
  20009. * @param variableName name of the shader variable that will hold the eye position
  20010. */
  20011. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20012. /**
  20013. * Helps preparing the defines values about the UVs in used in the effect.
  20014. * UVs are shared as much as we can accross channels in the shaders.
  20015. * @param texture The texture we are preparing the UVs for
  20016. * @param defines The defines to update
  20017. * @param key The channel key "diffuse", "specular"... used in the shader
  20018. */
  20019. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20020. /**
  20021. * Binds a texture matrix value to its corrsponding uniform
  20022. * @param texture The texture to bind the matrix for
  20023. * @param uniformBuffer The uniform buffer receivin the data
  20024. * @param key The channel key "diffuse", "specular"... used in the shader
  20025. */
  20026. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20027. /**
  20028. * Gets the current status of the fog (should it be enabled?)
  20029. * @param mesh defines the mesh to evaluate for fog support
  20030. * @param scene defines the hosting scene
  20031. * @returns true if fog must be enabled
  20032. */
  20033. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20034. /**
  20035. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20036. * @param mesh defines the current mesh
  20037. * @param scene defines the current scene
  20038. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20039. * @param pointsCloud defines if point cloud rendering has to be turned on
  20040. * @param fogEnabled defines if fog has to be turned on
  20041. * @param alphaTest defines if alpha testing has to be turned on
  20042. * @param defines defines the current list of defines
  20043. */
  20044. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20045. /**
  20046. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20047. * @param scene defines the current scene
  20048. * @param engine defines the current engine
  20049. * @param defines specifies the list of active defines
  20050. * @param useInstances defines if instances have to be turned on
  20051. * @param useClipPlane defines if clip plane have to be turned on
  20052. * @param useInstances defines if instances have to be turned on
  20053. * @param useThinInstances defines if thin instances have to be turned on
  20054. */
  20055. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20056. /**
  20057. * Prepares the defines for bones
  20058. * @param mesh The mesh containing the geometry data we will draw
  20059. * @param defines The defines to update
  20060. */
  20061. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20062. /**
  20063. * Prepares the defines for morph targets
  20064. * @param mesh The mesh containing the geometry data we will draw
  20065. * @param defines The defines to update
  20066. */
  20067. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20068. /**
  20069. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20070. * @param mesh The mesh containing the geometry data we will draw
  20071. * @param defines The defines to update
  20072. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20073. * @param useBones Precise whether bones should be used or not (override mesh info)
  20074. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20075. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20076. * @returns false if defines are considered not dirty and have not been checked
  20077. */
  20078. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20079. /**
  20080. * Prepares the defines related to multiview
  20081. * @param scene The scene we are intending to draw
  20082. * @param defines The defines to update
  20083. */
  20084. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20085. /**
  20086. * Prepares the defines related to the light information passed in parameter
  20087. * @param scene The scene we are intending to draw
  20088. * @param mesh The mesh the effect is compiling for
  20089. * @param light The light the effect is compiling for
  20090. * @param lightIndex The index of the light
  20091. * @param defines The defines to update
  20092. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20093. * @param state Defines the current state regarding what is needed (normals, etc...)
  20094. */
  20095. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20096. needNormals: boolean;
  20097. needRebuild: boolean;
  20098. shadowEnabled: boolean;
  20099. specularEnabled: boolean;
  20100. lightmapMode: boolean;
  20101. }): void;
  20102. /**
  20103. * Prepares the defines related to the light information passed in parameter
  20104. * @param scene The scene we are intending to draw
  20105. * @param mesh The mesh the effect is compiling for
  20106. * @param defines The defines to update
  20107. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20108. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20109. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20110. * @returns true if normals will be required for the rest of the effect
  20111. */
  20112. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20113. /**
  20114. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20115. * @param lightIndex defines the light index
  20116. * @param uniformsList The uniform list
  20117. * @param samplersList The sampler list
  20118. * @param projectedLightTexture defines if projected texture must be used
  20119. * @param uniformBuffersList defines an optional list of uniform buffers
  20120. */
  20121. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20122. /**
  20123. * Prepares the uniforms and samplers list to be used in the effect
  20124. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20125. * @param samplersList The sampler list
  20126. * @param defines The defines helping in the list generation
  20127. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20128. */
  20129. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20130. /**
  20131. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20132. * @param defines The defines to update while falling back
  20133. * @param fallbacks The authorized effect fallbacks
  20134. * @param maxSimultaneousLights The maximum number of lights allowed
  20135. * @param rank the current rank of the Effect
  20136. * @returns The newly affected rank
  20137. */
  20138. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20139. private static _TmpMorphInfluencers;
  20140. /**
  20141. * Prepares the list of attributes required for morph targets according to the effect defines.
  20142. * @param attribs The current list of supported attribs
  20143. * @param mesh The mesh to prepare the morph targets attributes for
  20144. * @param influencers The number of influencers
  20145. */
  20146. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20147. /**
  20148. * Prepares the list of attributes required for morph targets according to the effect defines.
  20149. * @param attribs The current list of supported attribs
  20150. * @param mesh The mesh to prepare the morph targets attributes for
  20151. * @param defines The current Defines of the effect
  20152. */
  20153. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20154. /**
  20155. * Prepares the list of attributes required for bones according to the effect defines.
  20156. * @param attribs The current list of supported attribs
  20157. * @param mesh The mesh to prepare the bones attributes for
  20158. * @param defines The current Defines of the effect
  20159. * @param fallbacks The current efffect fallback strategy
  20160. */
  20161. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20162. /**
  20163. * Check and prepare the list of attributes required for instances according to the effect defines.
  20164. * @param attribs The current list of supported attribs
  20165. * @param defines The current MaterialDefines of the effect
  20166. */
  20167. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20168. /**
  20169. * Add the list of attributes required for instances to the attribs array.
  20170. * @param attribs The current list of supported attribs
  20171. */
  20172. static PushAttributesForInstances(attribs: string[]): void;
  20173. /**
  20174. * Binds the light information to the effect.
  20175. * @param light The light containing the generator
  20176. * @param effect The effect we are binding the data to
  20177. * @param lightIndex The light index in the effect used to render
  20178. */
  20179. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20180. /**
  20181. * Binds the lights information from the scene to the effect for the given mesh.
  20182. * @param light Light to bind
  20183. * @param lightIndex Light index
  20184. * @param scene The scene where the light belongs to
  20185. * @param effect The effect we are binding the data to
  20186. * @param useSpecular Defines if specular is supported
  20187. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20188. */
  20189. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20190. /**
  20191. * Binds the lights information from the scene to the effect for the given mesh.
  20192. * @param scene The scene the lights belongs to
  20193. * @param mesh The mesh we are binding the information to render
  20194. * @param effect The effect we are binding the data to
  20195. * @param defines The generated defines for the effect
  20196. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20197. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20198. */
  20199. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20200. private static _tempFogColor;
  20201. /**
  20202. * Binds the fog information from the scene to the effect for the given mesh.
  20203. * @param scene The scene the lights belongs to
  20204. * @param mesh The mesh we are binding the information to render
  20205. * @param effect The effect we are binding the data to
  20206. * @param linearSpace Defines if the fog effect is applied in linear space
  20207. */
  20208. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20209. /**
  20210. * Binds the bones information from the mesh to the effect.
  20211. * @param mesh The mesh we are binding the information to render
  20212. * @param effect The effect we are binding the data to
  20213. */
  20214. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20215. /**
  20216. * Binds the morph targets information from the mesh to the effect.
  20217. * @param abstractMesh The mesh we are binding the information to render
  20218. * @param effect The effect we are binding the data to
  20219. */
  20220. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20221. /**
  20222. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20223. * @param defines The generated defines used in the effect
  20224. * @param effect The effect we are binding the data to
  20225. * @param scene The scene we are willing to render with logarithmic scale for
  20226. */
  20227. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20228. /**
  20229. * Binds the clip plane information from the scene to the effect.
  20230. * @param scene The scene the clip plane information are extracted from
  20231. * @param effect The effect we are binding the data to
  20232. */
  20233. static BindClipPlane(effect: Effect, scene: Scene): void;
  20234. }
  20235. }
  20236. declare module BABYLON {
  20237. /**
  20238. * Block used to expose an input value
  20239. */
  20240. export class InputBlock extends NodeMaterialBlock {
  20241. private _mode;
  20242. private _associatedVariableName;
  20243. private _storedValue;
  20244. private _valueCallback;
  20245. private _type;
  20246. private _animationType;
  20247. /** Gets or set a value used to limit the range of float values */
  20248. min: number;
  20249. /** Gets or set a value used to limit the range of float values */
  20250. max: number;
  20251. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20252. isBoolean: boolean;
  20253. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20254. matrixMode: number;
  20255. /** @hidden */
  20256. _systemValue: Nullable<NodeMaterialSystemValues>;
  20257. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20258. visibleInInspector: boolean;
  20259. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20260. isConstant: boolean;
  20261. /** Gets or sets the group to use to display this block in the Inspector */
  20262. groupInInspector: string;
  20263. /** Gets an observable raised when the value is changed */
  20264. onValueChangedObservable: Observable<InputBlock>;
  20265. /**
  20266. * Gets or sets the connection point type (default is float)
  20267. */
  20268. get type(): NodeMaterialBlockConnectionPointTypes;
  20269. /**
  20270. * Creates a new InputBlock
  20271. * @param name defines the block name
  20272. * @param target defines the target of that block (Vertex by default)
  20273. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20274. */
  20275. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20276. /**
  20277. * Gets the output component
  20278. */
  20279. get output(): NodeMaterialConnectionPoint;
  20280. /**
  20281. * Set the source of this connection point to a vertex attribute
  20282. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20283. * @returns the current connection point
  20284. */
  20285. setAsAttribute(attributeName?: string): InputBlock;
  20286. /**
  20287. * Set the source of this connection point to a system value
  20288. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20289. * @returns the current connection point
  20290. */
  20291. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20292. /**
  20293. * Gets or sets the value of that point.
  20294. * Please note that this value will be ignored if valueCallback is defined
  20295. */
  20296. get value(): any;
  20297. set value(value: any);
  20298. /**
  20299. * Gets or sets a callback used to get the value of that point.
  20300. * Please note that setting this value will force the connection point to ignore the value property
  20301. */
  20302. get valueCallback(): () => any;
  20303. set valueCallback(value: () => any);
  20304. /**
  20305. * Gets or sets the associated variable name in the shader
  20306. */
  20307. get associatedVariableName(): string;
  20308. set associatedVariableName(value: string);
  20309. /** Gets or sets the type of animation applied to the input */
  20310. get animationType(): AnimatedInputBlockTypes;
  20311. set animationType(value: AnimatedInputBlockTypes);
  20312. /**
  20313. * Gets a boolean indicating that this connection point not defined yet
  20314. */
  20315. get isUndefined(): boolean;
  20316. /**
  20317. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20318. * In this case the connection point name must be the name of the uniform to use.
  20319. * Can only be set on inputs
  20320. */
  20321. get isUniform(): boolean;
  20322. set isUniform(value: boolean);
  20323. /**
  20324. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20325. * In this case the connection point name must be the name of the attribute to use
  20326. * Can only be set on inputs
  20327. */
  20328. get isAttribute(): boolean;
  20329. set isAttribute(value: boolean);
  20330. /**
  20331. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20332. * Can only be set on exit points
  20333. */
  20334. get isVarying(): boolean;
  20335. set isVarying(value: boolean);
  20336. /**
  20337. * Gets a boolean indicating that the current connection point is a system value
  20338. */
  20339. get isSystemValue(): boolean;
  20340. /**
  20341. * Gets or sets the current well known value or null if not defined as a system value
  20342. */
  20343. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20344. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20345. /**
  20346. * Gets the current class name
  20347. * @returns the class name
  20348. */
  20349. getClassName(): string;
  20350. /**
  20351. * Animate the input if animationType !== None
  20352. * @param scene defines the rendering scene
  20353. */
  20354. animate(scene: Scene): void;
  20355. private _emitDefine;
  20356. initialize(state: NodeMaterialBuildState): void;
  20357. /**
  20358. * Set the input block to its default value (based on its type)
  20359. */
  20360. setDefaultValue(): void;
  20361. private _emitConstant;
  20362. /** @hidden */
  20363. get _noContextSwitch(): boolean;
  20364. private _emit;
  20365. /** @hidden */
  20366. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20367. /** @hidden */
  20368. _transmit(effect: Effect, scene: Scene): void;
  20369. protected _buildBlock(state: NodeMaterialBuildState): void;
  20370. protected _dumpPropertiesCode(): string;
  20371. dispose(): void;
  20372. serialize(): any;
  20373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20374. }
  20375. }
  20376. declare module BABYLON {
  20377. /**
  20378. * Enum used to define the compatibility state between two connection points
  20379. */
  20380. export enum NodeMaterialConnectionPointCompatibilityStates {
  20381. /** Points are compatibles */
  20382. Compatible = 0,
  20383. /** Points are incompatible because of their types */
  20384. TypeIncompatible = 1,
  20385. /** Points are incompatible because of their targets (vertex vs fragment) */
  20386. TargetIncompatible = 2
  20387. }
  20388. /**
  20389. * Defines the direction of a connection point
  20390. */
  20391. export enum NodeMaterialConnectionPointDirection {
  20392. /** Input */
  20393. Input = 0,
  20394. /** Output */
  20395. Output = 1
  20396. }
  20397. /**
  20398. * Defines a connection point for a block
  20399. */
  20400. export class NodeMaterialConnectionPoint {
  20401. /** @hidden */
  20402. _ownerBlock: NodeMaterialBlock;
  20403. /** @hidden */
  20404. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20405. private _endpoints;
  20406. private _associatedVariableName;
  20407. private _direction;
  20408. /** @hidden */
  20409. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20410. /** @hidden */
  20411. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20412. private _type;
  20413. /** @hidden */
  20414. _enforceAssociatedVariableName: boolean;
  20415. /** Gets the direction of the point */
  20416. get direction(): NodeMaterialConnectionPointDirection;
  20417. /** Indicates that this connection point needs dual validation before being connected to another point */
  20418. needDualDirectionValidation: boolean;
  20419. /**
  20420. * Gets or sets the additional types supported by this connection point
  20421. */
  20422. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20423. /**
  20424. * Gets or sets the additional types excluded by this connection point
  20425. */
  20426. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20427. /**
  20428. * Observable triggered when this point is connected
  20429. */
  20430. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20431. /**
  20432. * Gets or sets the associated variable name in the shader
  20433. */
  20434. get associatedVariableName(): string;
  20435. set associatedVariableName(value: string);
  20436. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20437. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20438. /**
  20439. * Gets or sets the connection point type (default is float)
  20440. */
  20441. get type(): NodeMaterialBlockConnectionPointTypes;
  20442. set type(value: NodeMaterialBlockConnectionPointTypes);
  20443. /**
  20444. * Gets or sets the connection point name
  20445. */
  20446. name: string;
  20447. /**
  20448. * Gets or sets the connection point name
  20449. */
  20450. displayName: string;
  20451. /**
  20452. * Gets or sets a boolean indicating that this connection point can be omitted
  20453. */
  20454. isOptional: boolean;
  20455. /**
  20456. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20457. */
  20458. isExposedOnFrame: boolean;
  20459. /**
  20460. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20461. */
  20462. define: string;
  20463. /** @hidden */
  20464. _prioritizeVertex: boolean;
  20465. private _target;
  20466. /** Gets or sets the target of that connection point */
  20467. get target(): NodeMaterialBlockTargets;
  20468. set target(value: NodeMaterialBlockTargets);
  20469. /**
  20470. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20471. */
  20472. get isConnected(): boolean;
  20473. /**
  20474. * Gets a boolean indicating that the current point is connected to an input block
  20475. */
  20476. get isConnectedToInputBlock(): boolean;
  20477. /**
  20478. * Gets a the connected input block (if any)
  20479. */
  20480. get connectInputBlock(): Nullable<InputBlock>;
  20481. /** Get the other side of the connection (if any) */
  20482. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20483. /** Get the block that owns this connection point */
  20484. get ownerBlock(): NodeMaterialBlock;
  20485. /** Get the block connected on the other side of this connection (if any) */
  20486. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20487. /** Get the block connected on the endpoints of this connection (if any) */
  20488. get connectedBlocks(): Array<NodeMaterialBlock>;
  20489. /** Gets the list of connected endpoints */
  20490. get endpoints(): NodeMaterialConnectionPoint[];
  20491. /** Gets a boolean indicating if that output point is connected to at least one input */
  20492. get hasEndpoints(): boolean;
  20493. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20494. get isConnectedInVertexShader(): boolean;
  20495. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20496. get isConnectedInFragmentShader(): boolean;
  20497. /**
  20498. * Creates a block suitable to be used as an input for this input point.
  20499. * If null is returned, a block based on the point type will be created.
  20500. * @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
  20501. */
  20502. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20503. /**
  20504. * Creates a new connection point
  20505. * @param name defines the connection point name
  20506. * @param ownerBlock defines the block hosting this connection point
  20507. * @param direction defines the direction of the connection point
  20508. */
  20509. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20510. /**
  20511. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20512. * @returns the class name
  20513. */
  20514. getClassName(): string;
  20515. /**
  20516. * Gets a boolean indicating if the current point can be connected to another point
  20517. * @param connectionPoint defines the other connection point
  20518. * @returns a boolean
  20519. */
  20520. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20521. /**
  20522. * Gets a number indicating if the current point can be connected to another point
  20523. * @param connectionPoint defines the other connection point
  20524. * @returns a number defining the compatibility state
  20525. */
  20526. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20527. /**
  20528. * Connect this point to another connection point
  20529. * @param connectionPoint defines the other connection point
  20530. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20531. * @returns the current connection point
  20532. */
  20533. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20534. /**
  20535. * Disconnect this point from one of his endpoint
  20536. * @param endpoint defines the other connection point
  20537. * @returns the current connection point
  20538. */
  20539. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20540. /**
  20541. * Serializes this point in a JSON representation
  20542. * @param isInput defines if the connection point is an input (default is true)
  20543. * @returns the serialized point object
  20544. */
  20545. serialize(isInput?: boolean): any;
  20546. /**
  20547. * Release resources
  20548. */
  20549. dispose(): void;
  20550. }
  20551. }
  20552. declare module BABYLON {
  20553. /**
  20554. * Enum used to define the material modes
  20555. */
  20556. export enum NodeMaterialModes {
  20557. /** Regular material */
  20558. Material = 0,
  20559. /** For post process */
  20560. PostProcess = 1,
  20561. /** For particle system */
  20562. Particle = 2
  20563. }
  20564. }
  20565. declare module BABYLON {
  20566. /**
  20567. * Block used to read a texture from a sampler
  20568. */
  20569. export class TextureBlock extends NodeMaterialBlock {
  20570. private _defineName;
  20571. private _linearDefineName;
  20572. private _gammaDefineName;
  20573. private _tempTextureRead;
  20574. private _samplerName;
  20575. private _transformedUVName;
  20576. private _textureTransformName;
  20577. private _textureInfoName;
  20578. private _mainUVName;
  20579. private _mainUVDefineName;
  20580. private _fragmentOnly;
  20581. /**
  20582. * Gets or sets the texture associated with the node
  20583. */
  20584. texture: Nullable<Texture>;
  20585. /**
  20586. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20587. */
  20588. convertToGammaSpace: boolean;
  20589. /**
  20590. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20591. */
  20592. convertToLinearSpace: boolean;
  20593. /**
  20594. * Create a new TextureBlock
  20595. * @param name defines the block name
  20596. */
  20597. constructor(name: string, fragmentOnly?: boolean);
  20598. /**
  20599. * Gets the current class name
  20600. * @returns the class name
  20601. */
  20602. getClassName(): string;
  20603. /**
  20604. * Gets the uv input component
  20605. */
  20606. get uv(): NodeMaterialConnectionPoint;
  20607. /**
  20608. * Gets the rgba output component
  20609. */
  20610. get rgba(): NodeMaterialConnectionPoint;
  20611. /**
  20612. * Gets the rgb output component
  20613. */
  20614. get rgb(): NodeMaterialConnectionPoint;
  20615. /**
  20616. * Gets the r output component
  20617. */
  20618. get r(): NodeMaterialConnectionPoint;
  20619. /**
  20620. * Gets the g output component
  20621. */
  20622. get g(): NodeMaterialConnectionPoint;
  20623. /**
  20624. * Gets the b output component
  20625. */
  20626. get b(): NodeMaterialConnectionPoint;
  20627. /**
  20628. * Gets the a output component
  20629. */
  20630. get a(): NodeMaterialConnectionPoint;
  20631. get target(): NodeMaterialBlockTargets;
  20632. autoConfigure(material: NodeMaterial): void;
  20633. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20635. isReady(): boolean;
  20636. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20637. private get _isMixed();
  20638. private _injectVertexCode;
  20639. private _writeTextureRead;
  20640. private _writeOutput;
  20641. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20642. protected _dumpPropertiesCode(): string;
  20643. serialize(): any;
  20644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20645. }
  20646. }
  20647. declare module BABYLON {
  20648. /** @hidden */
  20649. export var reflectionFunction: {
  20650. name: string;
  20651. shader: string;
  20652. };
  20653. }
  20654. declare module BABYLON {
  20655. /**
  20656. * Base block used to read a reflection texture from a sampler
  20657. */
  20658. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20659. /** @hidden */
  20660. _define3DName: string;
  20661. /** @hidden */
  20662. _defineCubicName: string;
  20663. /** @hidden */
  20664. _defineExplicitName: string;
  20665. /** @hidden */
  20666. _defineProjectionName: string;
  20667. /** @hidden */
  20668. _defineLocalCubicName: string;
  20669. /** @hidden */
  20670. _defineSphericalName: string;
  20671. /** @hidden */
  20672. _definePlanarName: string;
  20673. /** @hidden */
  20674. _defineEquirectangularName: string;
  20675. /** @hidden */
  20676. _defineMirroredEquirectangularFixedName: string;
  20677. /** @hidden */
  20678. _defineEquirectangularFixedName: string;
  20679. /** @hidden */
  20680. _defineSkyboxName: string;
  20681. /** @hidden */
  20682. _defineOppositeZ: string;
  20683. /** @hidden */
  20684. _cubeSamplerName: string;
  20685. /** @hidden */
  20686. _2DSamplerName: string;
  20687. protected _positionUVWName: string;
  20688. protected _directionWName: string;
  20689. protected _reflectionVectorName: string;
  20690. /** @hidden */
  20691. _reflectionCoordsName: string;
  20692. /** @hidden */
  20693. _reflectionMatrixName: string;
  20694. protected _reflectionColorName: string;
  20695. /**
  20696. * Gets or sets the texture associated with the node
  20697. */
  20698. texture: Nullable<BaseTexture>;
  20699. /**
  20700. * Create a new ReflectionTextureBaseBlock
  20701. * @param name defines the block name
  20702. */
  20703. constructor(name: string);
  20704. /**
  20705. * Gets the current class name
  20706. * @returns the class name
  20707. */
  20708. getClassName(): string;
  20709. /**
  20710. * Gets the world position input component
  20711. */
  20712. abstract get position(): NodeMaterialConnectionPoint;
  20713. /**
  20714. * Gets the world position input component
  20715. */
  20716. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20717. /**
  20718. * Gets the world normal input component
  20719. */
  20720. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20721. /**
  20722. * Gets the world input component
  20723. */
  20724. abstract get world(): NodeMaterialConnectionPoint;
  20725. /**
  20726. * Gets the camera (or eye) position component
  20727. */
  20728. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20729. /**
  20730. * Gets the view input component
  20731. */
  20732. abstract get view(): NodeMaterialConnectionPoint;
  20733. protected _getTexture(): Nullable<BaseTexture>;
  20734. autoConfigure(material: NodeMaterial): void;
  20735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20736. isReady(): boolean;
  20737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20738. /**
  20739. * Gets the code to inject in the vertex shader
  20740. * @param state current state of the node material building
  20741. * @returns the shader code
  20742. */
  20743. handleVertexSide(state: NodeMaterialBuildState): string;
  20744. /**
  20745. * Handles the inits for the fragment code path
  20746. * @param state node material build state
  20747. */
  20748. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20749. /**
  20750. * Generates the reflection coords code for the fragment code path
  20751. * @param worldNormalVarName name of the world normal variable
  20752. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20753. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20754. * @returns the shader code
  20755. */
  20756. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20757. /**
  20758. * Generates the reflection color code for the fragment code path
  20759. * @param lodVarName name of the lod variable
  20760. * @param swizzleLookupTexture swizzle to use for the final color variable
  20761. * @returns the shader code
  20762. */
  20763. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20764. /**
  20765. * Generates the code corresponding to the connected output points
  20766. * @param state node material build state
  20767. * @param varName name of the variable to output
  20768. * @returns the shader code
  20769. */
  20770. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20771. protected _buildBlock(state: NodeMaterialBuildState): this;
  20772. protected _dumpPropertiesCode(): string;
  20773. serialize(): any;
  20774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20775. }
  20776. }
  20777. declare module BABYLON {
  20778. /**
  20779. * Defines a connection point to be used for points with a custom object type
  20780. */
  20781. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20782. private _blockType;
  20783. private _blockName;
  20784. private _nameForCheking?;
  20785. /**
  20786. * Creates a new connection point
  20787. * @param name defines the connection point name
  20788. * @param ownerBlock defines the block hosting this connection point
  20789. * @param direction defines the direction of the connection point
  20790. */
  20791. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20792. /**
  20793. * Gets a number indicating if the current point can be connected to another point
  20794. * @param connectionPoint defines the other connection point
  20795. * @returns a number defining the compatibility state
  20796. */
  20797. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20798. /**
  20799. * Creates a block suitable to be used as an input for this input point.
  20800. * If null is returned, a block based on the point type will be created.
  20801. * @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
  20802. */
  20803. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20804. }
  20805. }
  20806. declare module BABYLON {
  20807. /**
  20808. * Enum defining the type of properties that can be edited in the property pages in the NME
  20809. */
  20810. export enum PropertyTypeForEdition {
  20811. /** property is a boolean */
  20812. Boolean = 0,
  20813. /** property is a float */
  20814. Float = 1,
  20815. /** property is a Vector2 */
  20816. Vector2 = 2,
  20817. /** property is a list of values */
  20818. List = 3
  20819. }
  20820. /**
  20821. * Interface that defines an option in a variable of type list
  20822. */
  20823. export interface IEditablePropertyListOption {
  20824. /** label of the option */
  20825. "label": string;
  20826. /** value of the option */
  20827. "value": number;
  20828. }
  20829. /**
  20830. * Interface that defines the options available for an editable property
  20831. */
  20832. export interface IEditablePropertyOption {
  20833. /** min value */
  20834. "min"?: number;
  20835. /** max value */
  20836. "max"?: number;
  20837. /** notifiers: indicates which actions to take when the property is changed */
  20838. "notifiers"?: {
  20839. /** the material should be rebuilt */
  20840. "rebuild"?: boolean;
  20841. /** the preview should be updated */
  20842. "update"?: boolean;
  20843. };
  20844. /** list of the options for a variable of type list */
  20845. "options"?: IEditablePropertyListOption[];
  20846. }
  20847. /**
  20848. * Interface that describes an editable property
  20849. */
  20850. export interface IPropertyDescriptionForEdition {
  20851. /** name of the property */
  20852. "propertyName": string;
  20853. /** display name of the property */
  20854. "displayName": string;
  20855. /** type of the property */
  20856. "type": PropertyTypeForEdition;
  20857. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20858. "groupName": string;
  20859. /** options for the property */
  20860. "options": IEditablePropertyOption;
  20861. }
  20862. /**
  20863. * Decorator that flags a property in a node material block as being editable
  20864. */
  20865. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20866. }
  20867. declare module BABYLON {
  20868. /**
  20869. * Block used to implement the refraction part of the sub surface module of the PBR material
  20870. */
  20871. export class RefractionBlock extends NodeMaterialBlock {
  20872. /** @hidden */
  20873. _define3DName: string;
  20874. /** @hidden */
  20875. _refractionMatrixName: string;
  20876. /** @hidden */
  20877. _defineLODRefractionAlpha: string;
  20878. /** @hidden */
  20879. _defineLinearSpecularRefraction: string;
  20880. /** @hidden */
  20881. _defineOppositeZ: string;
  20882. /** @hidden */
  20883. _cubeSamplerName: string;
  20884. /** @hidden */
  20885. _2DSamplerName: string;
  20886. /** @hidden */
  20887. _vRefractionMicrosurfaceInfosName: string;
  20888. /** @hidden */
  20889. _vRefractionInfosName: string;
  20890. private _scene;
  20891. /**
  20892. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20893. * Materials half opaque for instance using refraction could benefit from this control.
  20894. */
  20895. linkRefractionWithTransparency: boolean;
  20896. /**
  20897. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20898. */
  20899. invertRefractionY: boolean;
  20900. /**
  20901. * Gets or sets the texture associated with the node
  20902. */
  20903. texture: Nullable<BaseTexture>;
  20904. /**
  20905. * Create a new RefractionBlock
  20906. * @param name defines the block name
  20907. */
  20908. constructor(name: string);
  20909. /**
  20910. * Gets the current class name
  20911. * @returns the class name
  20912. */
  20913. getClassName(): string;
  20914. /**
  20915. * Gets the intensity input component
  20916. */
  20917. get intensity(): NodeMaterialConnectionPoint;
  20918. /**
  20919. * Gets the index of refraction input component
  20920. */
  20921. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20922. /**
  20923. * Gets the tint at distance input component
  20924. */
  20925. get tintAtDistance(): NodeMaterialConnectionPoint;
  20926. /**
  20927. * Gets the view input component
  20928. */
  20929. get view(): NodeMaterialConnectionPoint;
  20930. /**
  20931. * Gets the refraction object output component
  20932. */
  20933. get refraction(): NodeMaterialConnectionPoint;
  20934. /**
  20935. * Returns true if the block has a texture
  20936. */
  20937. get hasTexture(): boolean;
  20938. protected _getTexture(): Nullable<BaseTexture>;
  20939. autoConfigure(material: NodeMaterial): void;
  20940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20941. isReady(): boolean;
  20942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20943. /**
  20944. * Gets the main code of the block (fragment side)
  20945. * @param state current state of the node material building
  20946. * @returns the shader code
  20947. */
  20948. getCode(state: NodeMaterialBuildState): string;
  20949. protected _buildBlock(state: NodeMaterialBuildState): this;
  20950. protected _dumpPropertiesCode(): string;
  20951. serialize(): any;
  20952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20953. }
  20954. }
  20955. declare module BABYLON {
  20956. /**
  20957. * Base block used as input for post process
  20958. */
  20959. export class CurrentScreenBlock extends NodeMaterialBlock {
  20960. private _samplerName;
  20961. private _linearDefineName;
  20962. private _gammaDefineName;
  20963. private _mainUVName;
  20964. private _tempTextureRead;
  20965. /**
  20966. * Gets or sets the texture associated with the node
  20967. */
  20968. texture: Nullable<BaseTexture>;
  20969. /**
  20970. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20971. */
  20972. convertToGammaSpace: boolean;
  20973. /**
  20974. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20975. */
  20976. convertToLinearSpace: boolean;
  20977. /**
  20978. * Create a new CurrentScreenBlock
  20979. * @param name defines the block name
  20980. */
  20981. constructor(name: string);
  20982. /**
  20983. * Gets the current class name
  20984. * @returns the class name
  20985. */
  20986. getClassName(): string;
  20987. /**
  20988. * Gets the uv input component
  20989. */
  20990. get uv(): NodeMaterialConnectionPoint;
  20991. /**
  20992. * Gets the rgba output component
  20993. */
  20994. get rgba(): NodeMaterialConnectionPoint;
  20995. /**
  20996. * Gets the rgb output component
  20997. */
  20998. get rgb(): NodeMaterialConnectionPoint;
  20999. /**
  21000. * Gets the r output component
  21001. */
  21002. get r(): NodeMaterialConnectionPoint;
  21003. /**
  21004. * Gets the g output component
  21005. */
  21006. get g(): NodeMaterialConnectionPoint;
  21007. /**
  21008. * Gets the b output component
  21009. */
  21010. get b(): NodeMaterialConnectionPoint;
  21011. /**
  21012. * Gets the a output component
  21013. */
  21014. get a(): NodeMaterialConnectionPoint;
  21015. /**
  21016. * Initialize the block and prepare the context for build
  21017. * @param state defines the state that will be used for the build
  21018. */
  21019. initialize(state: NodeMaterialBuildState): void;
  21020. get target(): NodeMaterialBlockTargets;
  21021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21022. isReady(): boolean;
  21023. private _injectVertexCode;
  21024. private _writeTextureRead;
  21025. private _writeOutput;
  21026. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21027. serialize(): any;
  21028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21029. }
  21030. }
  21031. declare module BABYLON {
  21032. /**
  21033. * Base block used for the particle texture
  21034. */
  21035. export class ParticleTextureBlock extends NodeMaterialBlock {
  21036. private _samplerName;
  21037. private _linearDefineName;
  21038. private _gammaDefineName;
  21039. private _tempTextureRead;
  21040. /**
  21041. * Gets or sets the texture associated with the node
  21042. */
  21043. texture: Nullable<BaseTexture>;
  21044. /**
  21045. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21046. */
  21047. convertToGammaSpace: boolean;
  21048. /**
  21049. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21050. */
  21051. convertToLinearSpace: boolean;
  21052. /**
  21053. * Create a new ParticleTextureBlock
  21054. * @param name defines the block name
  21055. */
  21056. constructor(name: string);
  21057. /**
  21058. * Gets the current class name
  21059. * @returns the class name
  21060. */
  21061. getClassName(): string;
  21062. /**
  21063. * Gets the uv input component
  21064. */
  21065. get uv(): NodeMaterialConnectionPoint;
  21066. /**
  21067. * Gets the rgba output component
  21068. */
  21069. get rgba(): NodeMaterialConnectionPoint;
  21070. /**
  21071. * Gets the rgb output component
  21072. */
  21073. get rgb(): NodeMaterialConnectionPoint;
  21074. /**
  21075. * Gets the r output component
  21076. */
  21077. get r(): NodeMaterialConnectionPoint;
  21078. /**
  21079. * Gets the g output component
  21080. */
  21081. get g(): NodeMaterialConnectionPoint;
  21082. /**
  21083. * Gets the b output component
  21084. */
  21085. get b(): NodeMaterialConnectionPoint;
  21086. /**
  21087. * Gets the a output component
  21088. */
  21089. get a(): NodeMaterialConnectionPoint;
  21090. /**
  21091. * Initialize the block and prepare the context for build
  21092. * @param state defines the state that will be used for the build
  21093. */
  21094. initialize(state: NodeMaterialBuildState): void;
  21095. autoConfigure(material: NodeMaterial): void;
  21096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21097. isReady(): boolean;
  21098. private _writeOutput;
  21099. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21100. serialize(): any;
  21101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21102. }
  21103. }
  21104. declare module BABYLON {
  21105. /**
  21106. * Class used to store shared data between 2 NodeMaterialBuildState
  21107. */
  21108. export class NodeMaterialBuildStateSharedData {
  21109. /**
  21110. * Gets the list of emitted varyings
  21111. */
  21112. temps: string[];
  21113. /**
  21114. * Gets the list of emitted varyings
  21115. */
  21116. varyings: string[];
  21117. /**
  21118. * Gets the varying declaration string
  21119. */
  21120. varyingDeclaration: string;
  21121. /**
  21122. * Input blocks
  21123. */
  21124. inputBlocks: InputBlock[];
  21125. /**
  21126. * Input blocks
  21127. */
  21128. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21129. /**
  21130. * Bindable blocks (Blocks that need to set data to the effect)
  21131. */
  21132. bindableBlocks: NodeMaterialBlock[];
  21133. /**
  21134. * List of blocks that can provide a compilation fallback
  21135. */
  21136. blocksWithFallbacks: NodeMaterialBlock[];
  21137. /**
  21138. * List of blocks that can provide a define update
  21139. */
  21140. blocksWithDefines: NodeMaterialBlock[];
  21141. /**
  21142. * List of blocks that can provide a repeatable content
  21143. */
  21144. repeatableContentBlocks: NodeMaterialBlock[];
  21145. /**
  21146. * List of blocks that can provide a dynamic list of uniforms
  21147. */
  21148. dynamicUniformBlocks: NodeMaterialBlock[];
  21149. /**
  21150. * List of blocks that can block the isReady function for the material
  21151. */
  21152. blockingBlocks: NodeMaterialBlock[];
  21153. /**
  21154. * Gets the list of animated inputs
  21155. */
  21156. animatedInputs: InputBlock[];
  21157. /**
  21158. * Build Id used to avoid multiple recompilations
  21159. */
  21160. buildId: number;
  21161. /** List of emitted variables */
  21162. variableNames: {
  21163. [key: string]: number;
  21164. };
  21165. /** List of emitted defines */
  21166. defineNames: {
  21167. [key: string]: number;
  21168. };
  21169. /** Should emit comments? */
  21170. emitComments: boolean;
  21171. /** Emit build activity */
  21172. verbose: boolean;
  21173. /** Gets or sets the hosting scene */
  21174. scene: Scene;
  21175. /**
  21176. * Gets the compilation hints emitted at compilation time
  21177. */
  21178. hints: {
  21179. needWorldViewMatrix: boolean;
  21180. needWorldViewProjectionMatrix: boolean;
  21181. needAlphaBlending: boolean;
  21182. needAlphaTesting: boolean;
  21183. };
  21184. /**
  21185. * List of compilation checks
  21186. */
  21187. checks: {
  21188. emitVertex: boolean;
  21189. emitFragment: boolean;
  21190. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21191. };
  21192. /**
  21193. * Is vertex program allowed to be empty?
  21194. */
  21195. allowEmptyVertexProgram: boolean;
  21196. /** Creates a new shared data */
  21197. constructor();
  21198. /**
  21199. * Emits console errors and exceptions if there is a failing check
  21200. */
  21201. emitErrors(): void;
  21202. }
  21203. }
  21204. declare module BABYLON {
  21205. /**
  21206. * Class used to store node based material build state
  21207. */
  21208. export class NodeMaterialBuildState {
  21209. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21210. supportUniformBuffers: boolean;
  21211. /**
  21212. * Gets the list of emitted attributes
  21213. */
  21214. attributes: string[];
  21215. /**
  21216. * Gets the list of emitted uniforms
  21217. */
  21218. uniforms: string[];
  21219. /**
  21220. * Gets the list of emitted constants
  21221. */
  21222. constants: string[];
  21223. /**
  21224. * Gets the list of emitted samplers
  21225. */
  21226. samplers: string[];
  21227. /**
  21228. * Gets the list of emitted functions
  21229. */
  21230. functions: {
  21231. [key: string]: string;
  21232. };
  21233. /**
  21234. * Gets the list of emitted extensions
  21235. */
  21236. extensions: {
  21237. [key: string]: string;
  21238. };
  21239. /**
  21240. * Gets the target of the compilation state
  21241. */
  21242. target: NodeMaterialBlockTargets;
  21243. /**
  21244. * Gets the list of emitted counters
  21245. */
  21246. counters: {
  21247. [key: string]: number;
  21248. };
  21249. /**
  21250. * Shared data between multiple NodeMaterialBuildState instances
  21251. */
  21252. sharedData: NodeMaterialBuildStateSharedData;
  21253. /** @hidden */
  21254. _vertexState: NodeMaterialBuildState;
  21255. /** @hidden */
  21256. _attributeDeclaration: string;
  21257. /** @hidden */
  21258. _uniformDeclaration: string;
  21259. /** @hidden */
  21260. _constantDeclaration: string;
  21261. /** @hidden */
  21262. _samplerDeclaration: string;
  21263. /** @hidden */
  21264. _varyingTransfer: string;
  21265. /** @hidden */
  21266. _injectAtEnd: string;
  21267. private _repeatableContentAnchorIndex;
  21268. /** @hidden */
  21269. _builtCompilationString: string;
  21270. /**
  21271. * Gets the emitted compilation strings
  21272. */
  21273. compilationString: string;
  21274. /**
  21275. * Finalize the compilation strings
  21276. * @param state defines the current compilation state
  21277. */
  21278. finalize(state: NodeMaterialBuildState): void;
  21279. /** @hidden */
  21280. get _repeatableContentAnchor(): string;
  21281. /** @hidden */
  21282. _getFreeVariableName(prefix: string): string;
  21283. /** @hidden */
  21284. _getFreeDefineName(prefix: string): string;
  21285. /** @hidden */
  21286. _excludeVariableName(name: string): void;
  21287. /** @hidden */
  21288. _emit2DSampler(name: string): void;
  21289. /** @hidden */
  21290. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21291. /** @hidden */
  21292. _emitExtension(name: string, extension: string, define?: string): void;
  21293. /** @hidden */
  21294. _emitFunction(name: string, code: string, comments: string): void;
  21295. /** @hidden */
  21296. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21297. replaceStrings?: {
  21298. search: RegExp;
  21299. replace: string;
  21300. }[];
  21301. repeatKey?: string;
  21302. }): string;
  21303. /** @hidden */
  21304. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21305. repeatKey?: string;
  21306. removeAttributes?: boolean;
  21307. removeUniforms?: boolean;
  21308. removeVaryings?: boolean;
  21309. removeIfDef?: boolean;
  21310. replaceStrings?: {
  21311. search: RegExp;
  21312. replace: string;
  21313. }[];
  21314. }, storeKey?: string): void;
  21315. /** @hidden */
  21316. _registerTempVariable(name: string): boolean;
  21317. /** @hidden */
  21318. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21319. /** @hidden */
  21320. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21321. /** @hidden */
  21322. _emitFloat(value: number): string;
  21323. }
  21324. }
  21325. declare module BABYLON {
  21326. /**
  21327. * Helper class used to generate session unique ID
  21328. */
  21329. export class UniqueIdGenerator {
  21330. private static _UniqueIdCounter;
  21331. /**
  21332. * Gets an unique (relatively to the current scene) Id
  21333. */
  21334. static get UniqueId(): number;
  21335. }
  21336. }
  21337. declare module BABYLON {
  21338. /**
  21339. * Defines a block that can be used inside a node based material
  21340. */
  21341. export class NodeMaterialBlock {
  21342. private _buildId;
  21343. private _buildTarget;
  21344. private _target;
  21345. private _isFinalMerger;
  21346. private _isInput;
  21347. protected _isUnique: boolean;
  21348. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21349. inputsAreExclusive: boolean;
  21350. /** @hidden */
  21351. _codeVariableName: string;
  21352. /** @hidden */
  21353. _inputs: NodeMaterialConnectionPoint[];
  21354. /** @hidden */
  21355. _outputs: NodeMaterialConnectionPoint[];
  21356. /** @hidden */
  21357. _preparationId: number;
  21358. /**
  21359. * Gets or sets the name of the block
  21360. */
  21361. name: string;
  21362. /**
  21363. * Gets or sets the unique id of the node
  21364. */
  21365. uniqueId: number;
  21366. /**
  21367. * Gets or sets the comments associated with this block
  21368. */
  21369. comments: string;
  21370. /**
  21371. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21372. */
  21373. get isUnique(): boolean;
  21374. /**
  21375. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21376. */
  21377. get isFinalMerger(): boolean;
  21378. /**
  21379. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21380. */
  21381. get isInput(): boolean;
  21382. /**
  21383. * Gets or sets the build Id
  21384. */
  21385. get buildId(): number;
  21386. set buildId(value: number);
  21387. /**
  21388. * Gets or sets the target of the block
  21389. */
  21390. get target(): NodeMaterialBlockTargets;
  21391. set target(value: NodeMaterialBlockTargets);
  21392. /**
  21393. * Gets the list of input points
  21394. */
  21395. get inputs(): NodeMaterialConnectionPoint[];
  21396. /** Gets the list of output points */
  21397. get outputs(): NodeMaterialConnectionPoint[];
  21398. /**
  21399. * Find an input by its name
  21400. * @param name defines the name of the input to look for
  21401. * @returns the input or null if not found
  21402. */
  21403. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21404. /**
  21405. * Find an output by its name
  21406. * @param name defines the name of the outputto look for
  21407. * @returns the output or null if not found
  21408. */
  21409. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21410. /**
  21411. * Creates a new NodeMaterialBlock
  21412. * @param name defines the block name
  21413. * @param target defines the target of that block (Vertex by default)
  21414. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21415. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21416. */
  21417. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21418. /**
  21419. * Initialize the block and prepare the context for build
  21420. * @param state defines the state that will be used for the build
  21421. */
  21422. initialize(state: NodeMaterialBuildState): void;
  21423. /**
  21424. * Bind data to effect. Will only be called for blocks with isBindable === true
  21425. * @param effect defines the effect to bind data to
  21426. * @param nodeMaterial defines the hosting NodeMaterial
  21427. * @param mesh defines the mesh that will be rendered
  21428. * @param subMesh defines the submesh that will be rendered
  21429. */
  21430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21431. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21432. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21433. protected _writeFloat(value: number): string;
  21434. /**
  21435. * Gets the current class name e.g. "NodeMaterialBlock"
  21436. * @returns the class name
  21437. */
  21438. getClassName(): string;
  21439. /**
  21440. * Register a new input. Must be called inside a block constructor
  21441. * @param name defines the connection point name
  21442. * @param type defines the connection point type
  21443. * @param isOptional defines a boolean indicating that this input can be omitted
  21444. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21445. * @param point an already created connection point. If not provided, create a new one
  21446. * @returns the current block
  21447. */
  21448. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21449. /**
  21450. * Register a new output. Must be called inside a block constructor
  21451. * @param name defines the connection point name
  21452. * @param type defines the connection point type
  21453. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21454. * @param point an already created connection point. If not provided, create a new one
  21455. * @returns the current block
  21456. */
  21457. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21458. /**
  21459. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21460. * @param forOutput defines an optional connection point to check compatibility with
  21461. * @returns the first available input or null
  21462. */
  21463. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21464. /**
  21465. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21466. * @param forBlock defines an optional block to check compatibility with
  21467. * @returns the first available input or null
  21468. */
  21469. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21470. /**
  21471. * Gets the sibling of the given output
  21472. * @param current defines the current output
  21473. * @returns the next output in the list or null
  21474. */
  21475. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21476. /**
  21477. * Connect current block with another block
  21478. * @param other defines the block to connect with
  21479. * @param options define the various options to help pick the right connections
  21480. * @returns the current block
  21481. */
  21482. connectTo(other: NodeMaterialBlock, options?: {
  21483. input?: string;
  21484. output?: string;
  21485. outputSwizzle?: string;
  21486. }): this | undefined;
  21487. protected _buildBlock(state: NodeMaterialBuildState): void;
  21488. /**
  21489. * Add uniforms, samplers and uniform buffers at compilation time
  21490. * @param state defines the state to update
  21491. * @param nodeMaterial defines the node material requesting the update
  21492. * @param defines defines the material defines to update
  21493. * @param uniformBuffers defines the list of uniform buffer names
  21494. */
  21495. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21496. /**
  21497. * Add potential fallbacks if shader compilation fails
  21498. * @param mesh defines the mesh to be rendered
  21499. * @param fallbacks defines the current prioritized list of fallbacks
  21500. */
  21501. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21502. /**
  21503. * Initialize defines for shader compilation
  21504. * @param mesh defines the mesh to be rendered
  21505. * @param nodeMaterial defines the node material requesting the update
  21506. * @param defines defines the material defines to update
  21507. * @param useInstances specifies that instances should be used
  21508. */
  21509. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21510. /**
  21511. * Update defines for shader compilation
  21512. * @param mesh defines the mesh to be rendered
  21513. * @param nodeMaterial defines the node material requesting the update
  21514. * @param defines defines the material defines to update
  21515. * @param useInstances specifies that instances should be used
  21516. * @param subMesh defines which submesh to render
  21517. */
  21518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21519. /**
  21520. * Lets the block try to connect some inputs automatically
  21521. * @param material defines the hosting NodeMaterial
  21522. */
  21523. autoConfigure(material: NodeMaterial): void;
  21524. /**
  21525. * Function called when a block is declared as repeatable content generator
  21526. * @param vertexShaderState defines the current compilation state for the vertex shader
  21527. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21528. * @param mesh defines the mesh to be rendered
  21529. * @param defines defines the material defines to update
  21530. */
  21531. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21532. /**
  21533. * Checks if the block is ready
  21534. * @param mesh defines the mesh to be rendered
  21535. * @param nodeMaterial defines the node material requesting the update
  21536. * @param defines defines the material defines to update
  21537. * @param useInstances specifies that instances should be used
  21538. * @returns true if the block is ready
  21539. */
  21540. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21541. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21542. private _processBuild;
  21543. /**
  21544. * Compile the current node and generate the shader code
  21545. * @param state defines the current compilation state (uniforms, samplers, current string)
  21546. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21547. * @returns true if already built
  21548. */
  21549. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21550. protected _inputRename(name: string): string;
  21551. protected _outputRename(name: string): string;
  21552. protected _dumpPropertiesCode(): string;
  21553. /** @hidden */
  21554. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21555. /** @hidden */
  21556. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21557. /**
  21558. * Clone the current block to a new identical block
  21559. * @param scene defines the hosting scene
  21560. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21561. * @returns a copy of the current block
  21562. */
  21563. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21564. /**
  21565. * Serializes this block in a JSON representation
  21566. * @returns the serialized block object
  21567. */
  21568. serialize(): any;
  21569. /** @hidden */
  21570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21571. private _deserializePortDisplayNamesAndExposedOnFrame;
  21572. /**
  21573. * Release resources
  21574. */
  21575. dispose(): void;
  21576. }
  21577. }
  21578. declare module BABYLON {
  21579. /**
  21580. * Base class of materials working in push mode in babylon JS
  21581. * @hidden
  21582. */
  21583. export class PushMaterial extends Material {
  21584. protected _activeEffect: Effect;
  21585. protected _normalMatrix: Matrix;
  21586. constructor(name: string, scene: Scene);
  21587. getEffect(): Effect;
  21588. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21589. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21590. /**
  21591. * Binds the given world matrix to the active effect
  21592. *
  21593. * @param world the matrix to bind
  21594. */
  21595. bindOnlyWorldMatrix(world: Matrix): void;
  21596. /**
  21597. * Binds the given normal matrix to the active effect
  21598. *
  21599. * @param normalMatrix the matrix to bind
  21600. */
  21601. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21602. bind(world: Matrix, mesh?: Mesh): void;
  21603. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21604. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21605. }
  21606. }
  21607. declare module BABYLON {
  21608. /**
  21609. * Root class for all node material optimizers
  21610. */
  21611. export class NodeMaterialOptimizer {
  21612. /**
  21613. * Function used to optimize a NodeMaterial graph
  21614. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21615. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21616. */
  21617. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21618. }
  21619. }
  21620. declare module BABYLON {
  21621. /**
  21622. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21623. */
  21624. export class TransformBlock extends NodeMaterialBlock {
  21625. /**
  21626. * Defines the value to use to complement W value to transform it to a Vector4
  21627. */
  21628. complementW: number;
  21629. /**
  21630. * Defines the value to use to complement z value to transform it to a Vector4
  21631. */
  21632. complementZ: number;
  21633. /**
  21634. * Creates a new TransformBlock
  21635. * @param name defines the block name
  21636. */
  21637. constructor(name: string);
  21638. /**
  21639. * Gets the current class name
  21640. * @returns the class name
  21641. */
  21642. getClassName(): string;
  21643. /**
  21644. * Gets the vector input
  21645. */
  21646. get vector(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Gets the output component
  21649. */
  21650. get output(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the xyz output component
  21653. */
  21654. get xyz(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the matrix transform input
  21657. */
  21658. get transform(): NodeMaterialConnectionPoint;
  21659. protected _buildBlock(state: NodeMaterialBuildState): this;
  21660. /**
  21661. * Update defines for shader compilation
  21662. * @param mesh defines the mesh to be rendered
  21663. * @param nodeMaterial defines the node material requesting the update
  21664. * @param defines defines the material defines to update
  21665. * @param useInstances specifies that instances should be used
  21666. * @param subMesh defines which submesh to render
  21667. */
  21668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21669. serialize(): any;
  21670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21671. protected _dumpPropertiesCode(): string;
  21672. }
  21673. }
  21674. declare module BABYLON {
  21675. /**
  21676. * Block used to output the vertex position
  21677. */
  21678. export class VertexOutputBlock extends NodeMaterialBlock {
  21679. /**
  21680. * Creates a new VertexOutputBlock
  21681. * @param name defines the block name
  21682. */
  21683. constructor(name: string);
  21684. /**
  21685. * Gets the current class name
  21686. * @returns the class name
  21687. */
  21688. getClassName(): string;
  21689. /**
  21690. * Gets the vector input component
  21691. */
  21692. get vector(): NodeMaterialConnectionPoint;
  21693. protected _buildBlock(state: NodeMaterialBuildState): this;
  21694. }
  21695. }
  21696. declare module BABYLON {
  21697. /**
  21698. * Block used to output the final color
  21699. */
  21700. export class FragmentOutputBlock extends NodeMaterialBlock {
  21701. /**
  21702. * Create a new FragmentOutputBlock
  21703. * @param name defines the block name
  21704. */
  21705. constructor(name: string);
  21706. /**
  21707. * Gets the current class name
  21708. * @returns the class name
  21709. */
  21710. getClassName(): string;
  21711. /**
  21712. * Gets the rgba input component
  21713. */
  21714. get rgba(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the rgb input component
  21717. */
  21718. get rgb(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the a input component
  21721. */
  21722. get a(): NodeMaterialConnectionPoint;
  21723. protected _buildBlock(state: NodeMaterialBuildState): this;
  21724. }
  21725. }
  21726. declare module BABYLON {
  21727. /**
  21728. * Block used for the particle ramp gradient section
  21729. */
  21730. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21731. /**
  21732. * Create a new ParticleRampGradientBlock
  21733. * @param name defines the block name
  21734. */
  21735. constructor(name: string);
  21736. /**
  21737. * Gets the current class name
  21738. * @returns the class name
  21739. */
  21740. getClassName(): string;
  21741. /**
  21742. * Gets the color input component
  21743. */
  21744. get color(): NodeMaterialConnectionPoint;
  21745. /**
  21746. * Gets the rampColor output component
  21747. */
  21748. get rampColor(): NodeMaterialConnectionPoint;
  21749. /**
  21750. * Initialize the block and prepare the context for build
  21751. * @param state defines the state that will be used for the build
  21752. */
  21753. initialize(state: NodeMaterialBuildState): void;
  21754. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21755. }
  21756. }
  21757. declare module BABYLON {
  21758. /**
  21759. * Block used for the particle blend multiply section
  21760. */
  21761. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21762. /**
  21763. * Create a new ParticleBlendMultiplyBlock
  21764. * @param name defines the block name
  21765. */
  21766. constructor(name: string);
  21767. /**
  21768. * Gets the current class name
  21769. * @returns the class name
  21770. */
  21771. getClassName(): string;
  21772. /**
  21773. * Gets the color input component
  21774. */
  21775. get color(): NodeMaterialConnectionPoint;
  21776. /**
  21777. * Gets the alphaTexture input component
  21778. */
  21779. get alphaTexture(): NodeMaterialConnectionPoint;
  21780. /**
  21781. * Gets the alphaColor input component
  21782. */
  21783. get alphaColor(): NodeMaterialConnectionPoint;
  21784. /**
  21785. * Gets the blendColor output component
  21786. */
  21787. get blendColor(): NodeMaterialConnectionPoint;
  21788. /**
  21789. * Initialize the block and prepare the context for build
  21790. * @param state defines the state that will be used for the build
  21791. */
  21792. initialize(state: NodeMaterialBuildState): void;
  21793. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21794. }
  21795. }
  21796. declare module BABYLON {
  21797. /**
  21798. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21799. */
  21800. export class VectorMergerBlock extends NodeMaterialBlock {
  21801. /**
  21802. * Create a new VectorMergerBlock
  21803. * @param name defines the block name
  21804. */
  21805. constructor(name: string);
  21806. /**
  21807. * Gets the current class name
  21808. * @returns the class name
  21809. */
  21810. getClassName(): string;
  21811. /**
  21812. * Gets the xyz component (input)
  21813. */
  21814. get xyzIn(): NodeMaterialConnectionPoint;
  21815. /**
  21816. * Gets the xy component (input)
  21817. */
  21818. get xyIn(): NodeMaterialConnectionPoint;
  21819. /**
  21820. * Gets the x component (input)
  21821. */
  21822. get x(): NodeMaterialConnectionPoint;
  21823. /**
  21824. * Gets the y component (input)
  21825. */
  21826. get y(): NodeMaterialConnectionPoint;
  21827. /**
  21828. * Gets the z component (input)
  21829. */
  21830. get z(): NodeMaterialConnectionPoint;
  21831. /**
  21832. * Gets the w component (input)
  21833. */
  21834. get w(): NodeMaterialConnectionPoint;
  21835. /**
  21836. * Gets the xyzw component (output)
  21837. */
  21838. get xyzw(): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Gets the xyz component (output)
  21841. */
  21842. get xyzOut(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the xy component (output)
  21845. */
  21846. get xyOut(): NodeMaterialConnectionPoint;
  21847. /**
  21848. * Gets the xy component (output)
  21849. * @deprecated Please use xyOut instead.
  21850. */
  21851. get xy(): NodeMaterialConnectionPoint;
  21852. /**
  21853. * Gets the xyz component (output)
  21854. * @deprecated Please use xyzOut instead.
  21855. */
  21856. get xyz(): NodeMaterialConnectionPoint;
  21857. protected _buildBlock(state: NodeMaterialBuildState): this;
  21858. }
  21859. }
  21860. declare module BABYLON {
  21861. /**
  21862. * Block used to remap a float from a range to a new one
  21863. */
  21864. export class RemapBlock extends NodeMaterialBlock {
  21865. /**
  21866. * Gets or sets the source range
  21867. */
  21868. sourceRange: Vector2;
  21869. /**
  21870. * Gets or sets the target range
  21871. */
  21872. targetRange: Vector2;
  21873. /**
  21874. * Creates a new RemapBlock
  21875. * @param name defines the block name
  21876. */
  21877. constructor(name: string);
  21878. /**
  21879. * Gets the current class name
  21880. * @returns the class name
  21881. */
  21882. getClassName(): string;
  21883. /**
  21884. * Gets the input component
  21885. */
  21886. get input(): NodeMaterialConnectionPoint;
  21887. /**
  21888. * Gets the source min input component
  21889. */
  21890. get sourceMin(): NodeMaterialConnectionPoint;
  21891. /**
  21892. * Gets the source max input component
  21893. */
  21894. get sourceMax(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the target min input component
  21897. */
  21898. get targetMin(): NodeMaterialConnectionPoint;
  21899. /**
  21900. * Gets the target max input component
  21901. */
  21902. get targetMax(): NodeMaterialConnectionPoint;
  21903. /**
  21904. * Gets the output component
  21905. */
  21906. get output(): NodeMaterialConnectionPoint;
  21907. protected _buildBlock(state: NodeMaterialBuildState): this;
  21908. protected _dumpPropertiesCode(): string;
  21909. serialize(): any;
  21910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21911. }
  21912. }
  21913. declare module BABYLON {
  21914. /**
  21915. * Block used to multiply 2 values
  21916. */
  21917. export class MultiplyBlock extends NodeMaterialBlock {
  21918. /**
  21919. * Creates a new MultiplyBlock
  21920. * @param name defines the block name
  21921. */
  21922. constructor(name: string);
  21923. /**
  21924. * Gets the current class name
  21925. * @returns the class name
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Gets the left operand input component
  21930. */
  21931. get left(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the right operand input component
  21934. */
  21935. get right(): NodeMaterialConnectionPoint;
  21936. /**
  21937. * Gets the output component
  21938. */
  21939. get output(): NodeMaterialConnectionPoint;
  21940. protected _buildBlock(state: NodeMaterialBuildState): this;
  21941. }
  21942. }
  21943. declare module BABYLON {
  21944. /**
  21945. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21946. */
  21947. export class ColorSplitterBlock extends NodeMaterialBlock {
  21948. /**
  21949. * Create a new ColorSplitterBlock
  21950. * @param name defines the block name
  21951. */
  21952. constructor(name: string);
  21953. /**
  21954. * Gets the current class name
  21955. * @returns the class name
  21956. */
  21957. getClassName(): string;
  21958. /**
  21959. * Gets the rgba component (input)
  21960. */
  21961. get rgba(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the rgb component (input)
  21964. */
  21965. get rgbIn(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the rgb component (output)
  21968. */
  21969. get rgbOut(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the r component (output)
  21972. */
  21973. get r(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the g component (output)
  21976. */
  21977. get g(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the b component (output)
  21980. */
  21981. get b(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the a component (output)
  21984. */
  21985. get a(): NodeMaterialConnectionPoint;
  21986. protected _inputRename(name: string): string;
  21987. protected _outputRename(name: string): string;
  21988. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21989. }
  21990. }
  21991. declare module BABYLON {
  21992. /**
  21993. * Interface used to configure the node material editor
  21994. */
  21995. export interface INodeMaterialEditorOptions {
  21996. /** Define the URl to load node editor script */
  21997. editorURL?: string;
  21998. }
  21999. /** @hidden */
  22000. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22001. NORMAL: boolean;
  22002. TANGENT: boolean;
  22003. UV1: boolean;
  22004. /** BONES */
  22005. NUM_BONE_INFLUENCERS: number;
  22006. BonesPerMesh: number;
  22007. BONETEXTURE: boolean;
  22008. /** MORPH TARGETS */
  22009. MORPHTARGETS: boolean;
  22010. MORPHTARGETS_NORMAL: boolean;
  22011. MORPHTARGETS_TANGENT: boolean;
  22012. MORPHTARGETS_UV: boolean;
  22013. NUM_MORPH_INFLUENCERS: number;
  22014. /** IMAGE PROCESSING */
  22015. IMAGEPROCESSING: boolean;
  22016. VIGNETTE: boolean;
  22017. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22018. VIGNETTEBLENDMODEOPAQUE: boolean;
  22019. TONEMAPPING: boolean;
  22020. TONEMAPPING_ACES: boolean;
  22021. CONTRAST: boolean;
  22022. EXPOSURE: boolean;
  22023. COLORCURVES: boolean;
  22024. COLORGRADING: boolean;
  22025. COLORGRADING3D: boolean;
  22026. SAMPLER3DGREENDEPTH: boolean;
  22027. SAMPLER3DBGRMAP: boolean;
  22028. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22029. /** MISC. */
  22030. BUMPDIRECTUV: number;
  22031. constructor();
  22032. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22033. }
  22034. /**
  22035. * Class used to configure NodeMaterial
  22036. */
  22037. export interface INodeMaterialOptions {
  22038. /**
  22039. * Defines if blocks should emit comments
  22040. */
  22041. emitComments: boolean;
  22042. }
  22043. /**
  22044. * Class used to create a node based material built by assembling shader blocks
  22045. */
  22046. export class NodeMaterial extends PushMaterial {
  22047. private static _BuildIdGenerator;
  22048. private _options;
  22049. private _vertexCompilationState;
  22050. private _fragmentCompilationState;
  22051. private _sharedData;
  22052. private _buildId;
  22053. private _buildWasSuccessful;
  22054. private _cachedWorldViewMatrix;
  22055. private _cachedWorldViewProjectionMatrix;
  22056. private _optimizers;
  22057. private _animationFrame;
  22058. /** Define the Url to load node editor script */
  22059. static EditorURL: string;
  22060. /** Define the Url to load snippets */
  22061. static SnippetUrl: string;
  22062. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22063. static IgnoreTexturesAtLoadTime: boolean;
  22064. private BJSNODEMATERIALEDITOR;
  22065. /** Get the inspector from bundle or global */
  22066. private _getGlobalNodeMaterialEditor;
  22067. /**
  22068. * Snippet ID if the material was created from the snippet server
  22069. */
  22070. snippetId: string;
  22071. /**
  22072. * Gets or sets data used by visual editor
  22073. * @see https://nme.babylonjs.com
  22074. */
  22075. editorData: any;
  22076. /**
  22077. * 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)
  22078. */
  22079. ignoreAlpha: boolean;
  22080. /**
  22081. * Defines the maximum number of lights that can be used in the material
  22082. */
  22083. maxSimultaneousLights: number;
  22084. /**
  22085. * Observable raised when the material is built
  22086. */
  22087. onBuildObservable: Observable<NodeMaterial>;
  22088. /**
  22089. * Gets or sets the root nodes of the material vertex shader
  22090. */
  22091. _vertexOutputNodes: NodeMaterialBlock[];
  22092. /**
  22093. * Gets or sets the root nodes of the material fragment (pixel) shader
  22094. */
  22095. _fragmentOutputNodes: NodeMaterialBlock[];
  22096. /** Gets or sets options to control the node material overall behavior */
  22097. get options(): INodeMaterialOptions;
  22098. set options(options: INodeMaterialOptions);
  22099. /**
  22100. * Default configuration related to image processing available in the standard Material.
  22101. */
  22102. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22103. /**
  22104. * Gets the image processing configuration used either in this material.
  22105. */
  22106. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22107. /**
  22108. * Sets the Default image processing configuration used either in the this material.
  22109. *
  22110. * If sets to null, the scene one is in use.
  22111. */
  22112. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22113. /**
  22114. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22115. */
  22116. attachedBlocks: NodeMaterialBlock[];
  22117. /**
  22118. * Specifies the mode of the node material
  22119. * @hidden
  22120. */
  22121. _mode: NodeMaterialModes;
  22122. /**
  22123. * Gets the mode property
  22124. */
  22125. get mode(): NodeMaterialModes;
  22126. /**
  22127. * Create a new node based material
  22128. * @param name defines the material name
  22129. * @param scene defines the hosting scene
  22130. * @param options defines creation option
  22131. */
  22132. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22133. /**
  22134. * Gets the current class name of the material e.g. "NodeMaterial"
  22135. * @returns the class name
  22136. */
  22137. getClassName(): string;
  22138. /**
  22139. * Keep track of the image processing observer to allow dispose and replace.
  22140. */
  22141. private _imageProcessingObserver;
  22142. /**
  22143. * Attaches a new image processing configuration to the Standard Material.
  22144. * @param configuration
  22145. */
  22146. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22147. /**
  22148. * Get a block by its name
  22149. * @param name defines the name of the block to retrieve
  22150. * @returns the required block or null if not found
  22151. */
  22152. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22153. /**
  22154. * Get a block by its name
  22155. * @param predicate defines the predicate used to find the good candidate
  22156. * @returns the required block or null if not found
  22157. */
  22158. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22159. /**
  22160. * Get an input block by its name
  22161. * @param predicate defines the predicate used to find the good candidate
  22162. * @returns the required input block or null if not found
  22163. */
  22164. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22165. /**
  22166. * Gets the list of input blocks attached to this material
  22167. * @returns an array of InputBlocks
  22168. */
  22169. getInputBlocks(): InputBlock[];
  22170. /**
  22171. * Adds a new optimizer to the list of optimizers
  22172. * @param optimizer defines the optimizers to add
  22173. * @returns the current material
  22174. */
  22175. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22176. /**
  22177. * Remove an optimizer from the list of optimizers
  22178. * @param optimizer defines the optimizers to remove
  22179. * @returns the current material
  22180. */
  22181. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22182. /**
  22183. * Add a new block to the list of output nodes
  22184. * @param node defines the node to add
  22185. * @returns the current material
  22186. */
  22187. addOutputNode(node: NodeMaterialBlock): this;
  22188. /**
  22189. * Remove a block from the list of root nodes
  22190. * @param node defines the node to remove
  22191. * @returns the current material
  22192. */
  22193. removeOutputNode(node: NodeMaterialBlock): this;
  22194. private _addVertexOutputNode;
  22195. private _removeVertexOutputNode;
  22196. private _addFragmentOutputNode;
  22197. private _removeFragmentOutputNode;
  22198. /**
  22199. * Specifies if the material will require alpha blending
  22200. * @returns a boolean specifying if alpha blending is needed
  22201. */
  22202. needAlphaBlending(): boolean;
  22203. /**
  22204. * Specifies if this material should be rendered in alpha test mode
  22205. * @returns a boolean specifying if an alpha test is needed.
  22206. */
  22207. needAlphaTesting(): boolean;
  22208. private _initializeBlock;
  22209. private _resetDualBlocks;
  22210. /**
  22211. * Remove a block from the current node material
  22212. * @param block defines the block to remove
  22213. */
  22214. removeBlock(block: NodeMaterialBlock): void;
  22215. /**
  22216. * Build the material and generates the inner effect
  22217. * @param verbose defines if the build should log activity
  22218. */
  22219. build(verbose?: boolean): void;
  22220. /**
  22221. * Runs an otpimization phase to try to improve the shader code
  22222. */
  22223. optimize(): void;
  22224. private _prepareDefinesForAttributes;
  22225. /**
  22226. * Create a post process from the material
  22227. * @param camera The camera to apply the render pass to.
  22228. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22230. * @param engine The engine which the post process will be applied. (default: current engine)
  22231. * @param reusable If the post process can be reused on the same frame. (default: false)
  22232. * @param textureType Type of textures used when performing the post process. (default: 0)
  22233. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22234. * @returns the post process created
  22235. */
  22236. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22237. /**
  22238. * Create the post process effect from the material
  22239. * @param postProcess The post process to create the effect for
  22240. */
  22241. createEffectForPostProcess(postProcess: PostProcess): void;
  22242. private _createEffectOrPostProcess;
  22243. private _createEffectForParticles;
  22244. /**
  22245. * Create the effect to be used as the custom effect for a particle system
  22246. * @param particleSystem Particle system to create the effect for
  22247. * @param onCompiled defines a function to call when the effect creation is successful
  22248. * @param onError defines a function to call when the effect creation has failed
  22249. */
  22250. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22251. private _processDefines;
  22252. /**
  22253. * Get if the submesh is ready to be used and all its information available.
  22254. * Child classes can use it to update shaders
  22255. * @param mesh defines the mesh to check
  22256. * @param subMesh defines which submesh to check
  22257. * @param useInstances specifies that instances should be used
  22258. * @returns a boolean indicating that the submesh is ready or not
  22259. */
  22260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22261. /**
  22262. * Get a string representing the shaders built by the current node graph
  22263. */
  22264. get compiledShaders(): string;
  22265. /**
  22266. * Binds the world matrix to the material
  22267. * @param world defines the world transformation matrix
  22268. */
  22269. bindOnlyWorldMatrix(world: Matrix): void;
  22270. /**
  22271. * Binds the submesh to this material by preparing the effect and shader to draw
  22272. * @param world defines the world transformation matrix
  22273. * @param mesh defines the mesh containing the submesh
  22274. * @param subMesh defines the submesh to bind the material to
  22275. */
  22276. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22277. /**
  22278. * Gets the active textures from the material
  22279. * @returns an array of textures
  22280. */
  22281. getActiveTextures(): BaseTexture[];
  22282. /**
  22283. * Gets the list of texture blocks
  22284. * @returns an array of texture blocks
  22285. */
  22286. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22287. /**
  22288. * Specifies if the material uses a texture
  22289. * @param texture defines the texture to check against the material
  22290. * @returns a boolean specifying if the material uses the texture
  22291. */
  22292. hasTexture(texture: BaseTexture): boolean;
  22293. /**
  22294. * Disposes the material
  22295. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22296. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22297. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22298. */
  22299. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22300. /** Creates the node editor window. */
  22301. private _createNodeEditor;
  22302. /**
  22303. * Launch the node material editor
  22304. * @param config Define the configuration of the editor
  22305. * @return a promise fulfilled when the node editor is visible
  22306. */
  22307. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22308. /**
  22309. * Clear the current material
  22310. */
  22311. clear(): void;
  22312. /**
  22313. * Clear the current material and set it to a default state
  22314. */
  22315. setToDefault(): void;
  22316. /**
  22317. * Clear the current material and set it to a default state for post process
  22318. */
  22319. setToDefaultPostProcess(): void;
  22320. /**
  22321. * Clear the current material and set it to a default state for particle
  22322. */
  22323. setToDefaultParticle(): void;
  22324. /**
  22325. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22326. * @param url defines the url to load from
  22327. * @returns a promise that will fullfil when the material is fully loaded
  22328. */
  22329. loadAsync(url: string): Promise<void>;
  22330. private _gatherBlocks;
  22331. /**
  22332. * Generate a string containing the code declaration required to create an equivalent of this material
  22333. * @returns a string
  22334. */
  22335. generateCode(): string;
  22336. /**
  22337. * Serializes this material in a JSON representation
  22338. * @returns the serialized material object
  22339. */
  22340. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22341. private _restoreConnections;
  22342. /**
  22343. * Clear the current graph and load a new one from a serialization object
  22344. * @param source defines the JSON representation of the material
  22345. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22346. */
  22347. loadFromSerialization(source: any, rootUrl?: string): void;
  22348. /**
  22349. * Makes a duplicate of the current material.
  22350. * @param name - name to use for the new material.
  22351. */
  22352. clone(name: string): NodeMaterial;
  22353. /**
  22354. * Creates a node material from parsed material data
  22355. * @param source defines the JSON representation of the material
  22356. * @param scene defines the hosting scene
  22357. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22358. * @returns a new node material
  22359. */
  22360. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22361. /**
  22362. * Creates a node material from a snippet saved in a remote file
  22363. * @param name defines the name of the material to create
  22364. * @param url defines the url to load from
  22365. * @param scene defines the hosting scene
  22366. * @returns a promise that will resolve to the new node material
  22367. */
  22368. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22369. /**
  22370. * Creates a node material from a snippet saved by the node material editor
  22371. * @param snippetId defines the snippet to load
  22372. * @param scene defines the hosting scene
  22373. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22374. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22375. * @returns a promise that will resolve to the new node material
  22376. */
  22377. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22378. /**
  22379. * Creates a new node material set to default basic configuration
  22380. * @param name defines the name of the material
  22381. * @param scene defines the hosting scene
  22382. * @returns a new NodeMaterial
  22383. */
  22384. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22385. }
  22386. }
  22387. declare module BABYLON {
  22388. /**
  22389. * Size options for a post process
  22390. */
  22391. export type PostProcessOptions = {
  22392. width: number;
  22393. height: number;
  22394. };
  22395. /**
  22396. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22397. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22398. */
  22399. export class PostProcess {
  22400. /** Name of the PostProcess. */
  22401. name: string;
  22402. /**
  22403. * Gets or sets the unique id of the post process
  22404. */
  22405. uniqueId: number;
  22406. /**
  22407. * Width of the texture to apply the post process on
  22408. */
  22409. width: number;
  22410. /**
  22411. * Height of the texture to apply the post process on
  22412. */
  22413. height: number;
  22414. /**
  22415. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22416. */
  22417. nodeMaterialSource: Nullable<NodeMaterial>;
  22418. /**
  22419. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22420. * @hidden
  22421. */
  22422. _outputTexture: Nullable<InternalTexture>;
  22423. /**
  22424. * Sampling mode used by the shader
  22425. * See https://doc.babylonjs.com/classes/3.1/texture
  22426. */
  22427. renderTargetSamplingMode: number;
  22428. /**
  22429. * Clear color to use when screen clearing
  22430. */
  22431. clearColor: Color4;
  22432. /**
  22433. * If the buffer needs to be cleared before applying the post process. (default: true)
  22434. * Should be set to false if shader will overwrite all previous pixels.
  22435. */
  22436. autoClear: boolean;
  22437. /**
  22438. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22439. */
  22440. alphaMode: number;
  22441. /**
  22442. * Sets the setAlphaBlendConstants of the babylon engine
  22443. */
  22444. alphaConstants: Color4;
  22445. /**
  22446. * Animations to be used for the post processing
  22447. */
  22448. animations: Animation[];
  22449. /**
  22450. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22451. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22452. */
  22453. enablePixelPerfectMode: boolean;
  22454. /**
  22455. * Force the postprocess to be applied without taking in account viewport
  22456. */
  22457. forceFullscreenViewport: boolean;
  22458. /**
  22459. * List of inspectable custom properties (used by the Inspector)
  22460. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22461. */
  22462. inspectableCustomProperties: IInspectable[];
  22463. /**
  22464. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22465. *
  22466. * | Value | Type | Description |
  22467. * | ----- | ----------------------------------- | ----------- |
  22468. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22469. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22470. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22471. *
  22472. */
  22473. scaleMode: number;
  22474. /**
  22475. * Force textures to be a power of two (default: false)
  22476. */
  22477. alwaysForcePOT: boolean;
  22478. private _samples;
  22479. /**
  22480. * Number of sample textures (default: 1)
  22481. */
  22482. get samples(): number;
  22483. set samples(n: number);
  22484. /**
  22485. * Modify the scale of the post process to be the same as the viewport (default: false)
  22486. */
  22487. adaptScaleToCurrentViewport: boolean;
  22488. private _camera;
  22489. private _scene;
  22490. private _engine;
  22491. private _options;
  22492. private _reusable;
  22493. private _textureType;
  22494. private _textureFormat;
  22495. /**
  22496. * Smart array of input and output textures for the post process.
  22497. * @hidden
  22498. */
  22499. _textures: SmartArray<InternalTexture>;
  22500. /**
  22501. * The index in _textures that corresponds to the output texture.
  22502. * @hidden
  22503. */
  22504. _currentRenderTextureInd: number;
  22505. private _effect;
  22506. private _samplers;
  22507. private _fragmentUrl;
  22508. private _vertexUrl;
  22509. private _parameters;
  22510. private _scaleRatio;
  22511. protected _indexParameters: any;
  22512. private _shareOutputWithPostProcess;
  22513. private _texelSize;
  22514. private _forcedOutputTexture;
  22515. /**
  22516. * Returns the fragment url or shader name used in the post process.
  22517. * @returns the fragment url or name in the shader store.
  22518. */
  22519. getEffectName(): string;
  22520. /**
  22521. * An event triggered when the postprocess is activated.
  22522. */
  22523. onActivateObservable: Observable<Camera>;
  22524. private _onActivateObserver;
  22525. /**
  22526. * A function that is added to the onActivateObservable
  22527. */
  22528. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22529. /**
  22530. * An event triggered when the postprocess changes its size.
  22531. */
  22532. onSizeChangedObservable: Observable<PostProcess>;
  22533. private _onSizeChangedObserver;
  22534. /**
  22535. * A function that is added to the onSizeChangedObservable
  22536. */
  22537. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22538. /**
  22539. * An event triggered when the postprocess applies its effect.
  22540. */
  22541. onApplyObservable: Observable<Effect>;
  22542. private _onApplyObserver;
  22543. /**
  22544. * A function that is added to the onApplyObservable
  22545. */
  22546. set onApply(callback: (effect: Effect) => void);
  22547. /**
  22548. * An event triggered before rendering the postprocess
  22549. */
  22550. onBeforeRenderObservable: Observable<Effect>;
  22551. private _onBeforeRenderObserver;
  22552. /**
  22553. * A function that is added to the onBeforeRenderObservable
  22554. */
  22555. set onBeforeRender(callback: (effect: Effect) => void);
  22556. /**
  22557. * An event triggered after rendering the postprocess
  22558. */
  22559. onAfterRenderObservable: Observable<Effect>;
  22560. private _onAfterRenderObserver;
  22561. /**
  22562. * A function that is added to the onAfterRenderObservable
  22563. */
  22564. set onAfterRender(callback: (efect: Effect) => void);
  22565. /**
  22566. * 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
  22567. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22568. */
  22569. get inputTexture(): InternalTexture;
  22570. set inputTexture(value: InternalTexture);
  22571. /**
  22572. * Gets the camera which post process is applied to.
  22573. * @returns The camera the post process is applied to.
  22574. */
  22575. getCamera(): Camera;
  22576. /**
  22577. * Gets the texel size of the postprocess.
  22578. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22579. */
  22580. get texelSize(): Vector2;
  22581. /**
  22582. * Creates a new instance PostProcess
  22583. * @param name The name of the PostProcess.
  22584. * @param fragmentUrl The url of the fragment shader to be used.
  22585. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22586. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22587. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22588. * @param camera The camera to apply the render pass to.
  22589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22590. * @param engine The engine which the post process will be applied. (default: current engine)
  22591. * @param reusable If the post process can be reused on the same frame. (default: false)
  22592. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22593. * @param textureType Type of textures used when performing the post process. (default: 0)
  22594. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22595. * @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
  22596. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22597. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22598. */
  22599. constructor(
  22600. /** Name of the PostProcess. */
  22601. 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);
  22602. /**
  22603. * Gets a string idenfifying the name of the class
  22604. * @returns "PostProcess" string
  22605. */
  22606. getClassName(): string;
  22607. /**
  22608. * Gets the engine which this post process belongs to.
  22609. * @returns The engine the post process was enabled with.
  22610. */
  22611. getEngine(): Engine;
  22612. /**
  22613. * The effect that is created when initializing the post process.
  22614. * @returns The created effect corresponding the the postprocess.
  22615. */
  22616. getEffect(): Effect;
  22617. /**
  22618. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22619. * @param postProcess The post process to share the output with.
  22620. * @returns This post process.
  22621. */
  22622. shareOutputWith(postProcess: PostProcess): PostProcess;
  22623. /**
  22624. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22625. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22626. */
  22627. useOwnOutput(): void;
  22628. /**
  22629. * Updates the effect with the current post process compile time values and recompiles the shader.
  22630. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22631. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22632. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22633. * @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
  22634. * @param onCompiled Called when the shader has been compiled.
  22635. * @param onError Called if there is an error when compiling a shader.
  22636. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22637. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22638. */
  22639. 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;
  22640. /**
  22641. * The post process is reusable if it can be used multiple times within one frame.
  22642. * @returns If the post process is reusable
  22643. */
  22644. isReusable(): boolean;
  22645. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22646. markTextureDirty(): void;
  22647. /**
  22648. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22649. * 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.
  22650. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22651. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22652. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22653. * @returns The target texture that was bound to be written to.
  22654. */
  22655. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22656. /**
  22657. * If the post process is supported.
  22658. */
  22659. get isSupported(): boolean;
  22660. /**
  22661. * The aspect ratio of the output texture.
  22662. */
  22663. get aspectRatio(): number;
  22664. /**
  22665. * Get a value indicating if the post-process is ready to be used
  22666. * @returns true if the post-process is ready (shader is compiled)
  22667. */
  22668. isReady(): boolean;
  22669. /**
  22670. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22671. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22672. */
  22673. apply(): Nullable<Effect>;
  22674. private _disposeTextures;
  22675. /**
  22676. * Disposes the post process.
  22677. * @param camera The camera to dispose the post process on.
  22678. */
  22679. dispose(camera?: Camera): void;
  22680. }
  22681. }
  22682. declare module BABYLON {
  22683. /** @hidden */
  22684. export var kernelBlurVaryingDeclaration: {
  22685. name: string;
  22686. shader: string;
  22687. };
  22688. }
  22689. declare module BABYLON {
  22690. /** @hidden */
  22691. export var kernelBlurFragment: {
  22692. name: string;
  22693. shader: string;
  22694. };
  22695. }
  22696. declare module BABYLON {
  22697. /** @hidden */
  22698. export var kernelBlurFragment2: {
  22699. name: string;
  22700. shader: string;
  22701. };
  22702. }
  22703. declare module BABYLON {
  22704. /** @hidden */
  22705. export var kernelBlurPixelShader: {
  22706. name: string;
  22707. shader: string;
  22708. };
  22709. }
  22710. declare module BABYLON {
  22711. /** @hidden */
  22712. export var kernelBlurVertex: {
  22713. name: string;
  22714. shader: string;
  22715. };
  22716. }
  22717. declare module BABYLON {
  22718. /** @hidden */
  22719. export var kernelBlurVertexShader: {
  22720. name: string;
  22721. shader: string;
  22722. };
  22723. }
  22724. declare module BABYLON {
  22725. /**
  22726. * The Blur Post Process which blurs an image based on a kernel and direction.
  22727. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22728. */
  22729. export class BlurPostProcess extends PostProcess {
  22730. /** The direction in which to blur the image. */
  22731. direction: Vector2;
  22732. private blockCompilation;
  22733. protected _kernel: number;
  22734. protected _idealKernel: number;
  22735. protected _packedFloat: boolean;
  22736. private _staticDefines;
  22737. /**
  22738. * Sets the length in pixels of the blur sample region
  22739. */
  22740. set kernel(v: number);
  22741. /**
  22742. * Gets the length in pixels of the blur sample region
  22743. */
  22744. get kernel(): number;
  22745. /**
  22746. * Sets wether or not the blur needs to unpack/repack floats
  22747. */
  22748. set packedFloat(v: boolean);
  22749. /**
  22750. * Gets wether or not the blur is unpacking/repacking floats
  22751. */
  22752. get packedFloat(): boolean;
  22753. /**
  22754. * Creates a new instance BlurPostProcess
  22755. * @param name The name of the effect.
  22756. * @param direction The direction in which to blur the image.
  22757. * @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.
  22758. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22759. * @param camera The camera to apply the render pass to.
  22760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22761. * @param engine The engine which the post process will be applied. (default: current engine)
  22762. * @param reusable If the post process can be reused on the same frame. (default: false)
  22763. * @param textureType Type of textures used when performing the post process. (default: 0)
  22764. * @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)
  22765. */
  22766. constructor(name: string,
  22767. /** The direction in which to blur the image. */
  22768. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22769. /**
  22770. * Updates the effect with the current post process compile time values and recompiles the shader.
  22771. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22772. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22773. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22774. * @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
  22775. * @param onCompiled Called when the shader has been compiled.
  22776. * @param onError Called if there is an error when compiling a shader.
  22777. */
  22778. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22779. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22780. /**
  22781. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22782. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22783. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22784. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22785. * The gaps between physical kernels are compensated for in the weighting of the samples
  22786. * @param idealKernel Ideal blur kernel.
  22787. * @return Nearest best kernel.
  22788. */
  22789. protected _nearestBestKernel(idealKernel: number): number;
  22790. /**
  22791. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22792. * @param x The point on the Gaussian distribution to sample.
  22793. * @return the value of the Gaussian function at x.
  22794. */
  22795. protected _gaussianWeight(x: number): number;
  22796. /**
  22797. * Generates a string that can be used as a floating point number in GLSL.
  22798. * @param x Value to print.
  22799. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22800. * @return GLSL float string.
  22801. */
  22802. protected _glslFloat(x: number, decimalFigures?: number): string;
  22803. }
  22804. }
  22805. declare module BABYLON {
  22806. /**
  22807. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22808. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22809. * You can then easily use it as a reflectionTexture on a flat surface.
  22810. * In case the surface is not a plane, please consider relying on reflection probes.
  22811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22812. */
  22813. export class MirrorTexture extends RenderTargetTexture {
  22814. private scene;
  22815. /**
  22816. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22817. * 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.
  22818. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22819. */
  22820. mirrorPlane: Plane;
  22821. /**
  22822. * Define the blur ratio used to blur the reflection if needed.
  22823. */
  22824. set blurRatio(value: number);
  22825. get blurRatio(): number;
  22826. /**
  22827. * Define the adaptive blur kernel used to blur the reflection if needed.
  22828. * This will autocompute the closest best match for the `blurKernel`
  22829. */
  22830. set adaptiveBlurKernel(value: number);
  22831. /**
  22832. * Define the blur kernel used to blur the reflection if needed.
  22833. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22834. */
  22835. set blurKernel(value: number);
  22836. /**
  22837. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22838. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22839. */
  22840. set blurKernelX(value: number);
  22841. get blurKernelX(): number;
  22842. /**
  22843. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22844. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22845. */
  22846. set blurKernelY(value: number);
  22847. get blurKernelY(): number;
  22848. private _autoComputeBlurKernel;
  22849. protected _onRatioRescale(): void;
  22850. private _updateGammaSpace;
  22851. private _imageProcessingConfigChangeObserver;
  22852. private _transformMatrix;
  22853. private _mirrorMatrix;
  22854. private _savedViewMatrix;
  22855. private _blurX;
  22856. private _blurY;
  22857. private _adaptiveBlurKernel;
  22858. private _blurKernelX;
  22859. private _blurKernelY;
  22860. private _blurRatio;
  22861. /**
  22862. * Instantiates a Mirror Texture.
  22863. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22864. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22865. * You can then easily use it as a reflectionTexture on a flat surface.
  22866. * In case the surface is not a plane, please consider relying on reflection probes.
  22867. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22868. * @param name
  22869. * @param size
  22870. * @param scene
  22871. * @param generateMipMaps
  22872. * @param type
  22873. * @param samplingMode
  22874. * @param generateDepthBuffer
  22875. */
  22876. constructor(name: string, size: number | {
  22877. width: number;
  22878. height: number;
  22879. } | {
  22880. ratio: number;
  22881. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22882. private _preparePostProcesses;
  22883. /**
  22884. * Clone the mirror texture.
  22885. * @returns the cloned texture
  22886. */
  22887. clone(): MirrorTexture;
  22888. /**
  22889. * Serialize the texture to a JSON representation you could use in Parse later on
  22890. * @returns the serialized JSON representation
  22891. */
  22892. serialize(): any;
  22893. /**
  22894. * Dispose the texture and release its associated resources.
  22895. */
  22896. dispose(): void;
  22897. }
  22898. }
  22899. declare module BABYLON {
  22900. /**
  22901. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22902. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22903. */
  22904. export class Texture extends BaseTexture {
  22905. /**
  22906. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22907. */
  22908. static SerializeBuffers: boolean;
  22909. /** @hidden */
  22910. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22911. /** @hidden */
  22912. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22913. /** @hidden */
  22914. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22915. /** nearest is mag = nearest and min = nearest and mip = linear */
  22916. static readonly NEAREST_SAMPLINGMODE: number;
  22917. /** nearest is mag = nearest and min = nearest and mip = linear */
  22918. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22920. static readonly BILINEAR_SAMPLINGMODE: number;
  22921. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22922. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22923. /** Trilinear is mag = linear and min = linear and mip = linear */
  22924. static readonly TRILINEAR_SAMPLINGMODE: number;
  22925. /** Trilinear is mag = linear and min = linear and mip = linear */
  22926. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22927. /** mag = nearest and min = nearest and mip = nearest */
  22928. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22929. /** mag = nearest and min = linear and mip = nearest */
  22930. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22931. /** mag = nearest and min = linear and mip = linear */
  22932. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22933. /** mag = nearest and min = linear and mip = none */
  22934. static readonly NEAREST_LINEAR: number;
  22935. /** mag = nearest and min = nearest and mip = none */
  22936. static readonly NEAREST_NEAREST: number;
  22937. /** mag = linear and min = nearest and mip = nearest */
  22938. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22939. /** mag = linear and min = nearest and mip = linear */
  22940. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22941. /** mag = linear and min = linear and mip = none */
  22942. static readonly LINEAR_LINEAR: number;
  22943. /** mag = linear and min = nearest and mip = none */
  22944. static readonly LINEAR_NEAREST: number;
  22945. /** Explicit coordinates mode */
  22946. static readonly EXPLICIT_MODE: number;
  22947. /** Spherical coordinates mode */
  22948. static readonly SPHERICAL_MODE: number;
  22949. /** Planar coordinates mode */
  22950. static readonly PLANAR_MODE: number;
  22951. /** Cubic coordinates mode */
  22952. static readonly CUBIC_MODE: number;
  22953. /** Projection coordinates mode */
  22954. static readonly PROJECTION_MODE: number;
  22955. /** Inverse Cubic coordinates mode */
  22956. static readonly SKYBOX_MODE: number;
  22957. /** Inverse Cubic coordinates mode */
  22958. static readonly INVCUBIC_MODE: number;
  22959. /** Equirectangular coordinates mode */
  22960. static readonly EQUIRECTANGULAR_MODE: number;
  22961. /** Equirectangular Fixed coordinates mode */
  22962. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22963. /** Equirectangular Fixed Mirrored coordinates mode */
  22964. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22965. /** Texture is not repeating outside of 0..1 UVs */
  22966. static readonly CLAMP_ADDRESSMODE: number;
  22967. /** Texture is repeating outside of 0..1 UVs */
  22968. static readonly WRAP_ADDRESSMODE: number;
  22969. /** Texture is repeating and mirrored */
  22970. static readonly MIRROR_ADDRESSMODE: number;
  22971. /**
  22972. * 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
  22973. */
  22974. static UseSerializedUrlIfAny: boolean;
  22975. /**
  22976. * Define the url of the texture.
  22977. */
  22978. url: Nullable<string>;
  22979. /**
  22980. * Define an offset on the texture to offset the u coordinates of the UVs
  22981. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22982. */
  22983. uOffset: number;
  22984. /**
  22985. * Define an offset on the texture to offset the v coordinates of the UVs
  22986. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22987. */
  22988. vOffset: number;
  22989. /**
  22990. * Define an offset on the texture to scale the u coordinates of the UVs
  22991. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22992. */
  22993. uScale: number;
  22994. /**
  22995. * Define an offset on the texture to scale the v coordinates of the UVs
  22996. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22997. */
  22998. vScale: number;
  22999. /**
  23000. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23001. * @see http://doc.babylonjs.com/how_to/more_materials
  23002. */
  23003. uAng: number;
  23004. /**
  23005. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23006. * @see http://doc.babylonjs.com/how_to/more_materials
  23007. */
  23008. vAng: number;
  23009. /**
  23010. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23011. * @see http://doc.babylonjs.com/how_to/more_materials
  23012. */
  23013. wAng: number;
  23014. /**
  23015. * Defines the center of rotation (U)
  23016. */
  23017. uRotationCenter: number;
  23018. /**
  23019. * Defines the center of rotation (V)
  23020. */
  23021. vRotationCenter: number;
  23022. /**
  23023. * Defines the center of rotation (W)
  23024. */
  23025. wRotationCenter: number;
  23026. /**
  23027. * Are mip maps generated for this texture or not.
  23028. */
  23029. get noMipmap(): boolean;
  23030. /**
  23031. * List of inspectable custom properties (used by the Inspector)
  23032. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23033. */
  23034. inspectableCustomProperties: Nullable<IInspectable[]>;
  23035. private _noMipmap;
  23036. /** @hidden */
  23037. _invertY: boolean;
  23038. private _rowGenerationMatrix;
  23039. private _cachedTextureMatrix;
  23040. private _projectionModeMatrix;
  23041. private _t0;
  23042. private _t1;
  23043. private _t2;
  23044. private _cachedUOffset;
  23045. private _cachedVOffset;
  23046. private _cachedUScale;
  23047. private _cachedVScale;
  23048. private _cachedUAng;
  23049. private _cachedVAng;
  23050. private _cachedWAng;
  23051. private _cachedProjectionMatrixId;
  23052. private _cachedCoordinatesMode;
  23053. /** @hidden */
  23054. protected _initialSamplingMode: number;
  23055. /** @hidden */
  23056. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23057. private _deleteBuffer;
  23058. protected _format: Nullable<number>;
  23059. private _delayedOnLoad;
  23060. private _delayedOnError;
  23061. private _mimeType?;
  23062. /**
  23063. * Observable triggered once the texture has been loaded.
  23064. */
  23065. onLoadObservable: Observable<Texture>;
  23066. protected _isBlocking: boolean;
  23067. /**
  23068. * Is the texture preventing material to render while loading.
  23069. * If false, a default texture will be used instead of the loading one during the preparation step.
  23070. */
  23071. set isBlocking(value: boolean);
  23072. get isBlocking(): boolean;
  23073. /**
  23074. * Get the current sampling mode associated with the texture.
  23075. */
  23076. get samplingMode(): number;
  23077. /**
  23078. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23079. */
  23080. get invertY(): boolean;
  23081. /**
  23082. * Instantiates a new texture.
  23083. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23084. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23085. * @param url defines the url of the picture to load as a texture
  23086. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23087. * @param noMipmap defines if the texture will require mip maps or not
  23088. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23089. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23090. * @param onLoad defines a callback triggered when the texture has been loaded
  23091. * @param onError defines a callback triggered when an error occurred during the loading session
  23092. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23093. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23094. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23095. * @param mimeType defines an optional mime type information
  23096. */
  23097. 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);
  23098. /**
  23099. * Update the url (and optional buffer) of this texture if url was null during construction.
  23100. * @param url the url of the texture
  23101. * @param buffer the buffer of the texture (defaults to null)
  23102. * @param onLoad callback called when the texture is loaded (defaults to null)
  23103. */
  23104. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23105. /**
  23106. * Finish the loading sequence of a texture flagged as delayed load.
  23107. * @hidden
  23108. */
  23109. delayLoad(): void;
  23110. private _prepareRowForTextureGeneration;
  23111. /**
  23112. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23113. * @returns the transform matrix of the texture.
  23114. */
  23115. getTextureMatrix(uBase?: number): Matrix;
  23116. /**
  23117. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23118. * @returns The reflection texture transform
  23119. */
  23120. getReflectionTextureMatrix(): Matrix;
  23121. /**
  23122. * Clones the texture.
  23123. * @returns the cloned texture
  23124. */
  23125. clone(): Texture;
  23126. /**
  23127. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23128. * @returns The JSON representation of the texture
  23129. */
  23130. serialize(): any;
  23131. /**
  23132. * Get the current class name of the texture useful for serialization or dynamic coding.
  23133. * @returns "Texture"
  23134. */
  23135. getClassName(): string;
  23136. /**
  23137. * Dispose the texture and release its associated resources.
  23138. */
  23139. dispose(): void;
  23140. /**
  23141. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23142. * @param parsedTexture Define the JSON representation of the texture
  23143. * @param scene Define the scene the parsed texture should be instantiated in
  23144. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23145. * @returns The parsed texture if successful
  23146. */
  23147. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23148. /**
  23149. * Creates a texture from its base 64 representation.
  23150. * @param data Define the base64 payload without the data: prefix
  23151. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23152. * @param scene Define the scene the texture should belong to
  23153. * @param noMipmap Forces the texture to not create mip map information if true
  23154. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23155. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23156. * @param onLoad define a callback triggered when the texture has been loaded
  23157. * @param onError define a callback triggered when an error occurred during the loading session
  23158. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23159. * @returns the created texture
  23160. */
  23161. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23162. /**
  23163. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23164. * @param data Define the base64 payload without the data: prefix
  23165. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23166. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23167. * @param scene Define the scene the texture should belong to
  23168. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23169. * @param noMipmap Forces the texture to not create mip map information if true
  23170. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23171. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23172. * @param onLoad define a callback triggered when the texture has been loaded
  23173. * @param onError define a callback triggered when an error occurred during the loading session
  23174. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23175. * @returns the created texture
  23176. */
  23177. 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;
  23178. }
  23179. }
  23180. declare module BABYLON {
  23181. /**
  23182. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23183. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23184. */
  23185. export class PostProcessManager {
  23186. private _scene;
  23187. private _indexBuffer;
  23188. private _vertexBuffers;
  23189. /**
  23190. * Creates a new instance PostProcess
  23191. * @param scene The scene that the post process is associated with.
  23192. */
  23193. constructor(scene: Scene);
  23194. private _prepareBuffers;
  23195. private _buildIndexBuffer;
  23196. /**
  23197. * Rebuilds the vertex buffers of the manager.
  23198. * @hidden
  23199. */
  23200. _rebuild(): void;
  23201. /**
  23202. * Prepares a frame to be run through a post process.
  23203. * @param sourceTexture The input texture to the post procesess. (default: null)
  23204. * @param postProcesses An array of post processes to be run. (default: null)
  23205. * @returns True if the post processes were able to be run.
  23206. * @hidden
  23207. */
  23208. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23209. /**
  23210. * Manually render a set of post processes to a texture.
  23211. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23212. * @param postProcesses An array of post processes to be run.
  23213. * @param targetTexture The target texture to render to.
  23214. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23215. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23216. * @param lodLevel defines which lod of the texture to render to
  23217. */
  23218. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23219. /**
  23220. * Finalize the result of the output of the postprocesses.
  23221. * @param doNotPresent If true the result will not be displayed to the screen.
  23222. * @param targetTexture The target texture to render to.
  23223. * @param faceIndex The index of the face to bind the target texture to.
  23224. * @param postProcesses The array of post processes to render.
  23225. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23226. * @hidden
  23227. */
  23228. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23229. /**
  23230. * Disposes of the post process manager.
  23231. */
  23232. dispose(): void;
  23233. }
  23234. }
  23235. declare module BABYLON {
  23236. /**
  23237. * This Helps creating a texture that will be created from a camera in your scene.
  23238. * It is basically a dynamic texture that could be used to create special effects for instance.
  23239. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23240. */
  23241. export class RenderTargetTexture extends Texture {
  23242. isCube: boolean;
  23243. /**
  23244. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23245. */
  23246. static readonly REFRESHRATE_RENDER_ONCE: number;
  23247. /**
  23248. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23249. */
  23250. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23251. /**
  23252. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23253. * the central point of your effect and can save a lot of performances.
  23254. */
  23255. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23256. /**
  23257. * Use this predicate to dynamically define the list of mesh you want to render.
  23258. * If set, the renderList property will be overwritten.
  23259. */
  23260. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23261. private _renderList;
  23262. /**
  23263. * Use this list to define the list of mesh you want to render.
  23264. */
  23265. get renderList(): Nullable<Array<AbstractMesh>>;
  23266. set renderList(value: Nullable<Array<AbstractMesh>>);
  23267. /**
  23268. * Use this function to overload the renderList array at rendering time.
  23269. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23270. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23271. * the cube (if the RTT is a cube, else layerOrFace=0).
  23272. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23273. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23274. * hold dummy elements!
  23275. */
  23276. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23277. private _hookArray;
  23278. /**
  23279. * Define if particles should be rendered in your texture.
  23280. */
  23281. renderParticles: boolean;
  23282. /**
  23283. * Define if sprites should be rendered in your texture.
  23284. */
  23285. renderSprites: boolean;
  23286. /**
  23287. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23288. */
  23289. coordinatesMode: number;
  23290. /**
  23291. * Define the camera used to render the texture.
  23292. */
  23293. activeCamera: Nullable<Camera>;
  23294. /**
  23295. * Override the mesh isReady function with your own one.
  23296. */
  23297. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23298. /**
  23299. * Override the render function of the texture with your own one.
  23300. */
  23301. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23302. /**
  23303. * Define if camera post processes should be use while rendering the texture.
  23304. */
  23305. useCameraPostProcesses: boolean;
  23306. /**
  23307. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23308. */
  23309. ignoreCameraViewport: boolean;
  23310. private _postProcessManager;
  23311. private _postProcesses;
  23312. private _resizeObserver;
  23313. /**
  23314. * An event triggered when the texture is unbind.
  23315. */
  23316. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23317. /**
  23318. * An event triggered when the texture is unbind.
  23319. */
  23320. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23321. private _onAfterUnbindObserver;
  23322. /**
  23323. * Set a after unbind callback in the texture.
  23324. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23325. */
  23326. set onAfterUnbind(callback: () => void);
  23327. /**
  23328. * An event triggered before rendering the texture
  23329. */
  23330. onBeforeRenderObservable: Observable<number>;
  23331. private _onBeforeRenderObserver;
  23332. /**
  23333. * Set a before render callback in the texture.
  23334. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23335. */
  23336. set onBeforeRender(callback: (faceIndex: number) => void);
  23337. /**
  23338. * An event triggered after rendering the texture
  23339. */
  23340. onAfterRenderObservable: Observable<number>;
  23341. private _onAfterRenderObserver;
  23342. /**
  23343. * Set a after render callback in the texture.
  23344. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23345. */
  23346. set onAfterRender(callback: (faceIndex: number) => void);
  23347. /**
  23348. * An event triggered after the texture clear
  23349. */
  23350. onClearObservable: Observable<Engine>;
  23351. private _onClearObserver;
  23352. /**
  23353. * Set a clear callback in the texture.
  23354. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23355. */
  23356. set onClear(callback: (Engine: Engine) => void);
  23357. /**
  23358. * An event triggered when the texture is resized.
  23359. */
  23360. onResizeObservable: Observable<RenderTargetTexture>;
  23361. /**
  23362. * Define the clear color of the Render Target if it should be different from the scene.
  23363. */
  23364. clearColor: Color4;
  23365. protected _size: number | {
  23366. width: number;
  23367. height: number;
  23368. layers?: number;
  23369. };
  23370. protected _initialSizeParameter: number | {
  23371. width: number;
  23372. height: number;
  23373. } | {
  23374. ratio: number;
  23375. };
  23376. protected _sizeRatio: Nullable<number>;
  23377. /** @hidden */
  23378. _generateMipMaps: boolean;
  23379. protected _renderingManager: RenderingManager;
  23380. /** @hidden */
  23381. _waitingRenderList: string[];
  23382. protected _doNotChangeAspectRatio: boolean;
  23383. protected _currentRefreshId: number;
  23384. protected _refreshRate: number;
  23385. protected _textureMatrix: Matrix;
  23386. protected _samples: number;
  23387. protected _renderTargetOptions: RenderTargetCreationOptions;
  23388. /**
  23389. * Gets render target creation options that were used.
  23390. */
  23391. get renderTargetOptions(): RenderTargetCreationOptions;
  23392. protected _onRatioRescale(): void;
  23393. /**
  23394. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23395. * It must define where the camera used to render the texture is set
  23396. */
  23397. boundingBoxPosition: Vector3;
  23398. private _boundingBoxSize;
  23399. /**
  23400. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23401. * When defined, the cubemap will switch to local mode
  23402. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23403. * @example https://www.babylonjs-playground.com/#RNASML
  23404. */
  23405. set boundingBoxSize(value: Vector3);
  23406. get boundingBoxSize(): Vector3;
  23407. /**
  23408. * In case the RTT has been created with a depth texture, get the associated
  23409. * depth texture.
  23410. * Otherwise, return null.
  23411. */
  23412. get depthStencilTexture(): Nullable<InternalTexture>;
  23413. /**
  23414. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23415. * or used a shadow, depth texture...
  23416. * @param name The friendly name of the texture
  23417. * @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)
  23418. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23419. * @param generateMipMaps True if mip maps need to be generated after render.
  23420. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23421. * @param type The type of the buffer in the RTT (int, half float, float...)
  23422. * @param isCube True if a cube texture needs to be created
  23423. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23424. * @param generateDepthBuffer True to generate a depth buffer
  23425. * @param generateStencilBuffer True to generate a stencil buffer
  23426. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23427. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23428. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23429. */
  23430. constructor(name: string, size: number | {
  23431. width: number;
  23432. height: number;
  23433. layers?: number;
  23434. } | {
  23435. ratio: number;
  23436. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23437. /**
  23438. * Creates a depth stencil texture.
  23439. * This is only available in WebGL 2 or with the depth texture extension available.
  23440. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23441. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23442. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23443. */
  23444. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23445. private _processSizeParameter;
  23446. /**
  23447. * Define the number of samples to use in case of MSAA.
  23448. * It defaults to one meaning no MSAA has been enabled.
  23449. */
  23450. get samples(): number;
  23451. set samples(value: number);
  23452. /**
  23453. * Resets the refresh counter of the texture and start bak from scratch.
  23454. * Could be useful to regenerate the texture if it is setup to render only once.
  23455. */
  23456. resetRefreshCounter(): void;
  23457. /**
  23458. * Define the refresh rate of the texture or the rendering frequency.
  23459. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23460. */
  23461. get refreshRate(): number;
  23462. set refreshRate(value: number);
  23463. /**
  23464. * Adds a post process to the render target rendering passes.
  23465. * @param postProcess define the post process to add
  23466. */
  23467. addPostProcess(postProcess: PostProcess): void;
  23468. /**
  23469. * Clear all the post processes attached to the render target
  23470. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23471. */
  23472. clearPostProcesses(dispose?: boolean): void;
  23473. /**
  23474. * Remove one of the post process from the list of attached post processes to the texture
  23475. * @param postProcess define the post process to remove from the list
  23476. */
  23477. removePostProcess(postProcess: PostProcess): void;
  23478. /** @hidden */
  23479. _shouldRender(): boolean;
  23480. /**
  23481. * Gets the actual render size of the texture.
  23482. * @returns the width of the render size
  23483. */
  23484. getRenderSize(): number;
  23485. /**
  23486. * Gets the actual render width of the texture.
  23487. * @returns the width of the render size
  23488. */
  23489. getRenderWidth(): number;
  23490. /**
  23491. * Gets the actual render height of the texture.
  23492. * @returns the height of the render size
  23493. */
  23494. getRenderHeight(): number;
  23495. /**
  23496. * Gets the actual number of layers of the texture.
  23497. * @returns the number of layers
  23498. */
  23499. getRenderLayers(): number;
  23500. /**
  23501. * Get if the texture can be rescaled or not.
  23502. */
  23503. get canRescale(): boolean;
  23504. /**
  23505. * Resize the texture using a ratio.
  23506. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23507. */
  23508. scale(ratio: number): void;
  23509. /**
  23510. * Get the texture reflection matrix used to rotate/transform the reflection.
  23511. * @returns the reflection matrix
  23512. */
  23513. getReflectionTextureMatrix(): Matrix;
  23514. /**
  23515. * Resize the texture to a new desired size.
  23516. * Be carrefull as it will recreate all the data in the new texture.
  23517. * @param size Define the new size. It can be:
  23518. * - a number for squared texture,
  23519. * - an object containing { width: number, height: number }
  23520. * - or an object containing a ratio { ratio: number }
  23521. */
  23522. resize(size: number | {
  23523. width: number;
  23524. height: number;
  23525. } | {
  23526. ratio: number;
  23527. }): void;
  23528. private _defaultRenderListPrepared;
  23529. /**
  23530. * Renders all the objects from the render list into the texture.
  23531. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23532. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23533. */
  23534. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23535. private _bestReflectionRenderTargetDimension;
  23536. private _prepareRenderingManager;
  23537. /**
  23538. * @hidden
  23539. * @param faceIndex face index to bind to if this is a cubetexture
  23540. * @param layer defines the index of the texture to bind in the array
  23541. */
  23542. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23543. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23544. private renderToTarget;
  23545. /**
  23546. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23547. * This allowed control for front to back rendering or reversly depending of the special needs.
  23548. *
  23549. * @param renderingGroupId The rendering group id corresponding to its index
  23550. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23551. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23552. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23553. */
  23554. 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;
  23555. /**
  23556. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23557. *
  23558. * @param renderingGroupId The rendering group id corresponding to its index
  23559. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23560. */
  23561. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23562. /**
  23563. * Clones the texture.
  23564. * @returns the cloned texture
  23565. */
  23566. clone(): RenderTargetTexture;
  23567. /**
  23568. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23569. * @returns The JSON representation of the texture
  23570. */
  23571. serialize(): any;
  23572. /**
  23573. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23574. */
  23575. disposeFramebufferObjects(): void;
  23576. /**
  23577. * Dispose the texture and release its associated resources.
  23578. */
  23579. dispose(): void;
  23580. /** @hidden */
  23581. _rebuild(): void;
  23582. /**
  23583. * Clear the info related to rendering groups preventing retention point in material dispose.
  23584. */
  23585. freeRenderingGroups(): void;
  23586. /**
  23587. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23588. * @returns the view count
  23589. */
  23590. getViewCount(): number;
  23591. }
  23592. }
  23593. declare module BABYLON {
  23594. /**
  23595. * Class used to manipulate GUIDs
  23596. */
  23597. export class GUID {
  23598. /**
  23599. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23600. * Be aware Math.random() could cause collisions, but:
  23601. * "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"
  23602. * @returns a pseudo random id
  23603. */
  23604. static RandomId(): string;
  23605. }
  23606. }
  23607. declare module BABYLON {
  23608. /**
  23609. * Options to be used when creating a shadow depth material
  23610. */
  23611. export interface IIOptionShadowDepthMaterial {
  23612. /** Variables in the vertex shader code that need to have their names remapped.
  23613. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23614. * "var_name" should be either: worldPos or vNormalW
  23615. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23616. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23617. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23618. */
  23619. remappedVariables?: string[];
  23620. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23621. standalone?: boolean;
  23622. }
  23623. /**
  23624. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23625. */
  23626. export class ShadowDepthWrapper {
  23627. private _scene;
  23628. private _options?;
  23629. private _baseMaterial;
  23630. private _onEffectCreatedObserver;
  23631. private _subMeshToEffect;
  23632. private _subMeshToDepthEffect;
  23633. private _meshes;
  23634. /** @hidden */
  23635. _matriceNames: any;
  23636. /** Gets the standalone status of the wrapper */
  23637. get standalone(): boolean;
  23638. /** Gets the base material the wrapper is built upon */
  23639. get baseMaterial(): Material;
  23640. /**
  23641. * Instantiate a new shadow depth wrapper.
  23642. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23643. * generate the shadow depth map. For more information, please refer to the documentation:
  23644. * https://doc.babylonjs.com/babylon101/shadows
  23645. * @param baseMaterial Material to wrap
  23646. * @param scene Define the scene the material belongs to
  23647. * @param options Options used to create the wrapper
  23648. */
  23649. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23650. /**
  23651. * Gets the effect to use to generate the depth map
  23652. * @param subMesh subMesh to get the effect for
  23653. * @param shadowGenerator shadow generator to get the effect for
  23654. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23655. */
  23656. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23657. /**
  23658. * Specifies that the submesh is ready to be used for depth rendering
  23659. * @param subMesh submesh to check
  23660. * @param defines the list of defines to take into account when checking the effect
  23661. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23662. * @param useInstances specifies that instances should be used
  23663. * @returns a boolean indicating that the submesh is ready or not
  23664. */
  23665. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23666. /**
  23667. * Disposes the resources
  23668. */
  23669. dispose(): void;
  23670. private _makeEffect;
  23671. }
  23672. }
  23673. declare module BABYLON {
  23674. /**
  23675. * Options for compiling materials.
  23676. */
  23677. export interface IMaterialCompilationOptions {
  23678. /**
  23679. * Defines whether clip planes are enabled.
  23680. */
  23681. clipPlane: boolean;
  23682. /**
  23683. * Defines whether instances are enabled.
  23684. */
  23685. useInstances: boolean;
  23686. }
  23687. /**
  23688. * Options passed when calling customShaderNameResolve
  23689. */
  23690. export interface ICustomShaderNameResolveOptions {
  23691. /**
  23692. * 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
  23693. */
  23694. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23695. }
  23696. /**
  23697. * Base class for the main features of a material in Babylon.js
  23698. */
  23699. export class Material implements IAnimatable {
  23700. /**
  23701. * Returns the triangle fill mode
  23702. */
  23703. static readonly TriangleFillMode: number;
  23704. /**
  23705. * Returns the wireframe mode
  23706. */
  23707. static readonly WireFrameFillMode: number;
  23708. /**
  23709. * Returns the point fill mode
  23710. */
  23711. static readonly PointFillMode: number;
  23712. /**
  23713. * Returns the point list draw mode
  23714. */
  23715. static readonly PointListDrawMode: number;
  23716. /**
  23717. * Returns the line list draw mode
  23718. */
  23719. static readonly LineListDrawMode: number;
  23720. /**
  23721. * Returns the line loop draw mode
  23722. */
  23723. static readonly LineLoopDrawMode: number;
  23724. /**
  23725. * Returns the line strip draw mode
  23726. */
  23727. static readonly LineStripDrawMode: number;
  23728. /**
  23729. * Returns the triangle strip draw mode
  23730. */
  23731. static readonly TriangleStripDrawMode: number;
  23732. /**
  23733. * Returns the triangle fan draw mode
  23734. */
  23735. static readonly TriangleFanDrawMode: number;
  23736. /**
  23737. * Stores the clock-wise side orientation
  23738. */
  23739. static readonly ClockWiseSideOrientation: number;
  23740. /**
  23741. * Stores the counter clock-wise side orientation
  23742. */
  23743. static readonly CounterClockWiseSideOrientation: number;
  23744. /**
  23745. * The dirty texture flag value
  23746. */
  23747. static readonly TextureDirtyFlag: number;
  23748. /**
  23749. * The dirty light flag value
  23750. */
  23751. static readonly LightDirtyFlag: number;
  23752. /**
  23753. * The dirty fresnel flag value
  23754. */
  23755. static readonly FresnelDirtyFlag: number;
  23756. /**
  23757. * The dirty attribute flag value
  23758. */
  23759. static readonly AttributesDirtyFlag: number;
  23760. /**
  23761. * The dirty misc flag value
  23762. */
  23763. static readonly MiscDirtyFlag: number;
  23764. /**
  23765. * The all dirty flag value
  23766. */
  23767. static readonly AllDirtyFlag: number;
  23768. /**
  23769. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23770. */
  23771. static readonly MATERIAL_OPAQUE: number;
  23772. /**
  23773. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23774. */
  23775. static readonly MATERIAL_ALPHATEST: number;
  23776. /**
  23777. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23778. */
  23779. static readonly MATERIAL_ALPHABLEND: number;
  23780. /**
  23781. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23782. * They are also discarded below the alpha cutoff threshold to improve performances.
  23783. */
  23784. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23785. /**
  23786. * Custom callback helping to override the default shader used in the material.
  23787. */
  23788. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23789. /**
  23790. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23791. */
  23792. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23793. /**
  23794. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23795. * This means that the material can keep using a previous shader while a new one is being compiled.
  23796. * This is mostly used when shader parallel compilation is supported (true by default)
  23797. */
  23798. allowShaderHotSwapping: boolean;
  23799. /**
  23800. * The ID of the material
  23801. */
  23802. id: string;
  23803. /**
  23804. * Gets or sets the unique id of the material
  23805. */
  23806. uniqueId: number;
  23807. /**
  23808. * The name of the material
  23809. */
  23810. name: string;
  23811. /**
  23812. * Gets or sets user defined metadata
  23813. */
  23814. metadata: any;
  23815. /**
  23816. * For internal use only. Please do not use.
  23817. */
  23818. reservedDataStore: any;
  23819. /**
  23820. * Specifies if the ready state should be checked on each call
  23821. */
  23822. checkReadyOnEveryCall: boolean;
  23823. /**
  23824. * Specifies if the ready state should be checked once
  23825. */
  23826. checkReadyOnlyOnce: boolean;
  23827. /**
  23828. * The state of the material
  23829. */
  23830. state: string;
  23831. /**
  23832. * The alpha value of the material
  23833. */
  23834. protected _alpha: number;
  23835. /**
  23836. * List of inspectable custom properties (used by the Inspector)
  23837. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23838. */
  23839. inspectableCustomProperties: IInspectable[];
  23840. /**
  23841. * Sets the alpha value of the material
  23842. */
  23843. set alpha(value: number);
  23844. /**
  23845. * Gets the alpha value of the material
  23846. */
  23847. get alpha(): number;
  23848. /**
  23849. * Specifies if back face culling is enabled
  23850. */
  23851. protected _backFaceCulling: boolean;
  23852. /**
  23853. * Sets the back-face culling state
  23854. */
  23855. set backFaceCulling(value: boolean);
  23856. /**
  23857. * Gets the back-face culling state
  23858. */
  23859. get backFaceCulling(): boolean;
  23860. /**
  23861. * Stores the value for side orientation
  23862. */
  23863. sideOrientation: number;
  23864. /**
  23865. * Callback triggered when the material is compiled
  23866. */
  23867. onCompiled: Nullable<(effect: Effect) => void>;
  23868. /**
  23869. * Callback triggered when an error occurs
  23870. */
  23871. onError: Nullable<(effect: Effect, errors: string) => void>;
  23872. /**
  23873. * Callback triggered to get the render target textures
  23874. */
  23875. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23876. /**
  23877. * Gets a boolean indicating that current material needs to register RTT
  23878. */
  23879. get hasRenderTargetTextures(): boolean;
  23880. /**
  23881. * Specifies if the material should be serialized
  23882. */
  23883. doNotSerialize: boolean;
  23884. /**
  23885. * @hidden
  23886. */
  23887. _storeEffectOnSubMeshes: boolean;
  23888. /**
  23889. * Stores the animations for the material
  23890. */
  23891. animations: Nullable<Array<Animation>>;
  23892. /**
  23893. * An event triggered when the material is disposed
  23894. */
  23895. onDisposeObservable: Observable<Material>;
  23896. /**
  23897. * An observer which watches for dispose events
  23898. */
  23899. private _onDisposeObserver;
  23900. private _onUnBindObservable;
  23901. /**
  23902. * Called during a dispose event
  23903. */
  23904. set onDispose(callback: () => void);
  23905. private _onBindObservable;
  23906. /**
  23907. * An event triggered when the material is bound
  23908. */
  23909. get onBindObservable(): Observable<AbstractMesh>;
  23910. /**
  23911. * An observer which watches for bind events
  23912. */
  23913. private _onBindObserver;
  23914. /**
  23915. * Called during a bind event
  23916. */
  23917. set onBind(callback: (Mesh: AbstractMesh) => void);
  23918. /**
  23919. * An event triggered when the material is unbound
  23920. */
  23921. get onUnBindObservable(): Observable<Material>;
  23922. protected _onEffectCreatedObservable: Nullable<Observable<{
  23923. effect: Effect;
  23924. subMesh: Nullable<SubMesh>;
  23925. }>>;
  23926. /**
  23927. * An event triggered when the effect is (re)created
  23928. */
  23929. get onEffectCreatedObservable(): Observable<{
  23930. effect: Effect;
  23931. subMesh: Nullable<SubMesh>;
  23932. }>;
  23933. /**
  23934. * Stores the value of the alpha mode
  23935. */
  23936. private _alphaMode;
  23937. /**
  23938. * Sets the value of the alpha mode.
  23939. *
  23940. * | Value | Type | Description |
  23941. * | --- | --- | --- |
  23942. * | 0 | ALPHA_DISABLE | |
  23943. * | 1 | ALPHA_ADD | |
  23944. * | 2 | ALPHA_COMBINE | |
  23945. * | 3 | ALPHA_SUBTRACT | |
  23946. * | 4 | ALPHA_MULTIPLY | |
  23947. * | 5 | ALPHA_MAXIMIZED | |
  23948. * | 6 | ALPHA_ONEONE | |
  23949. * | 7 | ALPHA_PREMULTIPLIED | |
  23950. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23951. * | 9 | ALPHA_INTERPOLATE | |
  23952. * | 10 | ALPHA_SCREENMODE | |
  23953. *
  23954. */
  23955. set alphaMode(value: number);
  23956. /**
  23957. * Gets the value of the alpha mode
  23958. */
  23959. get alphaMode(): number;
  23960. /**
  23961. * Stores the state of the need depth pre-pass value
  23962. */
  23963. private _needDepthPrePass;
  23964. /**
  23965. * Sets the need depth pre-pass value
  23966. */
  23967. set needDepthPrePass(value: boolean);
  23968. /**
  23969. * Gets the depth pre-pass value
  23970. */
  23971. get needDepthPrePass(): boolean;
  23972. /**
  23973. * Specifies if depth writing should be disabled
  23974. */
  23975. disableDepthWrite: boolean;
  23976. /**
  23977. * Specifies if color writing should be disabled
  23978. */
  23979. disableColorWrite: boolean;
  23980. /**
  23981. * Specifies if depth writing should be forced
  23982. */
  23983. forceDepthWrite: boolean;
  23984. /**
  23985. * Specifies the depth function that should be used. 0 means the default engine function
  23986. */
  23987. depthFunction: number;
  23988. /**
  23989. * Specifies if there should be a separate pass for culling
  23990. */
  23991. separateCullingPass: boolean;
  23992. /**
  23993. * Stores the state specifing if fog should be enabled
  23994. */
  23995. private _fogEnabled;
  23996. /**
  23997. * Sets the state for enabling fog
  23998. */
  23999. set fogEnabled(value: boolean);
  24000. /**
  24001. * Gets the value of the fog enabled state
  24002. */
  24003. get fogEnabled(): boolean;
  24004. /**
  24005. * Stores the size of points
  24006. */
  24007. pointSize: number;
  24008. /**
  24009. * Stores the z offset value
  24010. */
  24011. zOffset: number;
  24012. get wireframe(): boolean;
  24013. /**
  24014. * Sets the state of wireframe mode
  24015. */
  24016. set wireframe(value: boolean);
  24017. /**
  24018. * Gets the value specifying if point clouds are enabled
  24019. */
  24020. get pointsCloud(): boolean;
  24021. /**
  24022. * Sets the state of point cloud mode
  24023. */
  24024. set pointsCloud(value: boolean);
  24025. /**
  24026. * Gets the material fill mode
  24027. */
  24028. get fillMode(): number;
  24029. /**
  24030. * Sets the material fill mode
  24031. */
  24032. set fillMode(value: number);
  24033. /**
  24034. * @hidden
  24035. * Stores the effects for the material
  24036. */
  24037. _effect: Nullable<Effect>;
  24038. /**
  24039. * Specifies if uniform buffers should be used
  24040. */
  24041. private _useUBO;
  24042. /**
  24043. * Stores a reference to the scene
  24044. */
  24045. private _scene;
  24046. /**
  24047. * Stores the fill mode state
  24048. */
  24049. private _fillMode;
  24050. /**
  24051. * Specifies if the depth write state should be cached
  24052. */
  24053. private _cachedDepthWriteState;
  24054. /**
  24055. * Specifies if the color write state should be cached
  24056. */
  24057. private _cachedColorWriteState;
  24058. /**
  24059. * Specifies if the depth function state should be cached
  24060. */
  24061. private _cachedDepthFunctionState;
  24062. /**
  24063. * Stores the uniform buffer
  24064. */
  24065. protected _uniformBuffer: UniformBuffer;
  24066. /** @hidden */
  24067. _indexInSceneMaterialArray: number;
  24068. /** @hidden */
  24069. meshMap: Nullable<{
  24070. [id: string]: AbstractMesh | undefined;
  24071. }>;
  24072. /**
  24073. * Creates a material instance
  24074. * @param name defines the name of the material
  24075. * @param scene defines the scene to reference
  24076. * @param doNotAdd specifies if the material should be added to the scene
  24077. */
  24078. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24079. /**
  24080. * Returns a string representation of the current material
  24081. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24082. * @returns a string with material information
  24083. */
  24084. toString(fullDetails?: boolean): string;
  24085. /**
  24086. * Gets the class name of the material
  24087. * @returns a string with the class name of the material
  24088. */
  24089. getClassName(): string;
  24090. /**
  24091. * Specifies if updates for the material been locked
  24092. */
  24093. get isFrozen(): boolean;
  24094. /**
  24095. * Locks updates for the material
  24096. */
  24097. freeze(): void;
  24098. /**
  24099. * Unlocks updates for the material
  24100. */
  24101. unfreeze(): void;
  24102. /**
  24103. * Specifies if the material is ready to be used
  24104. * @param mesh defines the mesh to check
  24105. * @param useInstances specifies if instances should be used
  24106. * @returns a boolean indicating if the material is ready to be used
  24107. */
  24108. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24109. /**
  24110. * Specifies that the submesh is ready to be used
  24111. * @param mesh defines the mesh to check
  24112. * @param subMesh defines which submesh to check
  24113. * @param useInstances specifies that instances should be used
  24114. * @returns a boolean indicating that the submesh is ready or not
  24115. */
  24116. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24117. /**
  24118. * Returns the material effect
  24119. * @returns the effect associated with the material
  24120. */
  24121. getEffect(): Nullable<Effect>;
  24122. /**
  24123. * Returns the current scene
  24124. * @returns a Scene
  24125. */
  24126. getScene(): Scene;
  24127. /**
  24128. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24129. */
  24130. protected _forceAlphaTest: boolean;
  24131. /**
  24132. * The transparency mode of the material.
  24133. */
  24134. protected _transparencyMode: Nullable<number>;
  24135. /**
  24136. * Gets the current transparency mode.
  24137. */
  24138. get transparencyMode(): Nullable<number>;
  24139. /**
  24140. * Sets the transparency mode of the material.
  24141. *
  24142. * | Value | Type | Description |
  24143. * | ----- | ----------------------------------- | ----------- |
  24144. * | 0 | OPAQUE | |
  24145. * | 1 | ALPHATEST | |
  24146. * | 2 | ALPHABLEND | |
  24147. * | 3 | ALPHATESTANDBLEND | |
  24148. *
  24149. */
  24150. set transparencyMode(value: Nullable<number>);
  24151. /**
  24152. * Returns true if alpha blending should be disabled.
  24153. */
  24154. protected get _disableAlphaBlending(): boolean;
  24155. /**
  24156. * Specifies whether or not this material should be rendered in alpha blend mode.
  24157. * @returns a boolean specifying if alpha blending is needed
  24158. */
  24159. needAlphaBlending(): boolean;
  24160. /**
  24161. * Specifies if the mesh will require alpha blending
  24162. * @param mesh defines the mesh to check
  24163. * @returns a boolean specifying if alpha blending is needed for the mesh
  24164. */
  24165. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24166. /**
  24167. * Specifies whether or not this material should be rendered in alpha test mode.
  24168. * @returns a boolean specifying if an alpha test is needed.
  24169. */
  24170. needAlphaTesting(): boolean;
  24171. /**
  24172. * Specifies if material alpha testing should be turned on for the mesh
  24173. * @param mesh defines the mesh to check
  24174. */
  24175. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24176. /**
  24177. * Gets the texture used for the alpha test
  24178. * @returns the texture to use for alpha testing
  24179. */
  24180. getAlphaTestTexture(): Nullable<BaseTexture>;
  24181. /**
  24182. * Marks the material to indicate that it needs to be re-calculated
  24183. */
  24184. markDirty(): void;
  24185. /** @hidden */
  24186. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24187. /**
  24188. * Binds the material to the mesh
  24189. * @param world defines the world transformation matrix
  24190. * @param mesh defines the mesh to bind the material to
  24191. */
  24192. bind(world: Matrix, mesh?: Mesh): void;
  24193. /**
  24194. * Binds the submesh to the material
  24195. * @param world defines the world transformation matrix
  24196. * @param mesh defines the mesh containing the submesh
  24197. * @param subMesh defines the submesh to bind the material to
  24198. */
  24199. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24200. /**
  24201. * Binds the world matrix to the material
  24202. * @param world defines the world transformation matrix
  24203. */
  24204. bindOnlyWorldMatrix(world: Matrix): void;
  24205. /**
  24206. * Binds the scene's uniform buffer to the effect.
  24207. * @param effect defines the effect to bind to the scene uniform buffer
  24208. * @param sceneUbo defines the uniform buffer storing scene data
  24209. */
  24210. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24211. /**
  24212. * Binds the view matrix to the effect
  24213. * @param effect defines the effect to bind the view matrix to
  24214. */
  24215. bindView(effect: Effect): void;
  24216. /**
  24217. * Binds the view projection matrix to the effect
  24218. * @param effect defines the effect to bind the view projection matrix to
  24219. */
  24220. bindViewProjection(effect: Effect): void;
  24221. /**
  24222. * Processes to execute after binding the material to a mesh
  24223. * @param mesh defines the rendered mesh
  24224. */
  24225. protected _afterBind(mesh?: Mesh): void;
  24226. /**
  24227. * Unbinds the material from the mesh
  24228. */
  24229. unbind(): void;
  24230. /**
  24231. * Gets the active textures from the material
  24232. * @returns an array of textures
  24233. */
  24234. getActiveTextures(): BaseTexture[];
  24235. /**
  24236. * Specifies if the material uses a texture
  24237. * @param texture defines the texture to check against the material
  24238. * @returns a boolean specifying if the material uses the texture
  24239. */
  24240. hasTexture(texture: BaseTexture): boolean;
  24241. /**
  24242. * Makes a duplicate of the material, and gives it a new name
  24243. * @param name defines the new name for the duplicated material
  24244. * @returns the cloned material
  24245. */
  24246. clone(name: string): Nullable<Material>;
  24247. /**
  24248. * Gets the meshes bound to the material
  24249. * @returns an array of meshes bound to the material
  24250. */
  24251. getBindedMeshes(): AbstractMesh[];
  24252. /**
  24253. * Force shader compilation
  24254. * @param mesh defines the mesh associated with this material
  24255. * @param onCompiled defines a function to execute once the material is compiled
  24256. * @param options defines the options to configure the compilation
  24257. * @param onError defines a function to execute if the material fails compiling
  24258. */
  24259. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24260. /**
  24261. * Force shader compilation
  24262. * @param mesh defines the mesh that will use this material
  24263. * @param options defines additional options for compiling the shaders
  24264. * @returns a promise that resolves when the compilation completes
  24265. */
  24266. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24267. private static readonly _AllDirtyCallBack;
  24268. private static readonly _ImageProcessingDirtyCallBack;
  24269. private static readonly _TextureDirtyCallBack;
  24270. private static readonly _FresnelDirtyCallBack;
  24271. private static readonly _MiscDirtyCallBack;
  24272. private static readonly _LightsDirtyCallBack;
  24273. private static readonly _AttributeDirtyCallBack;
  24274. private static _FresnelAndMiscDirtyCallBack;
  24275. private static _TextureAndMiscDirtyCallBack;
  24276. private static readonly _DirtyCallbackArray;
  24277. private static readonly _RunDirtyCallBacks;
  24278. /**
  24279. * Marks a define in the material to indicate that it needs to be re-computed
  24280. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24281. */
  24282. markAsDirty(flag: number): void;
  24283. /**
  24284. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24285. * @param func defines a function which checks material defines against the submeshes
  24286. */
  24287. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24288. /**
  24289. * Indicates that we need to re-calculated for all submeshes
  24290. */
  24291. protected _markAllSubMeshesAsAllDirty(): void;
  24292. /**
  24293. * Indicates that image processing needs to be re-calculated for all submeshes
  24294. */
  24295. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24296. /**
  24297. * Indicates that textures need to be re-calculated for all submeshes
  24298. */
  24299. protected _markAllSubMeshesAsTexturesDirty(): void;
  24300. /**
  24301. * Indicates that fresnel needs to be re-calculated for all submeshes
  24302. */
  24303. protected _markAllSubMeshesAsFresnelDirty(): void;
  24304. /**
  24305. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24306. */
  24307. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24308. /**
  24309. * Indicates that lights need to be re-calculated for all submeshes
  24310. */
  24311. protected _markAllSubMeshesAsLightsDirty(): void;
  24312. /**
  24313. * Indicates that attributes need to be re-calculated for all submeshes
  24314. */
  24315. protected _markAllSubMeshesAsAttributesDirty(): void;
  24316. /**
  24317. * Indicates that misc needs to be re-calculated for all submeshes
  24318. */
  24319. protected _markAllSubMeshesAsMiscDirty(): void;
  24320. /**
  24321. * Indicates that textures and misc need to be re-calculated for all submeshes
  24322. */
  24323. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24324. /**
  24325. * Disposes the material
  24326. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24327. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24328. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24329. */
  24330. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24331. /** @hidden */
  24332. private releaseVertexArrayObject;
  24333. /**
  24334. * Serializes this material
  24335. * @returns the serialized material object
  24336. */
  24337. serialize(): any;
  24338. /**
  24339. * Creates a material from parsed material data
  24340. * @param parsedMaterial defines parsed material data
  24341. * @param scene defines the hosting scene
  24342. * @param rootUrl defines the root URL to use to load textures
  24343. * @returns a new material
  24344. */
  24345. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24346. }
  24347. }
  24348. declare module BABYLON {
  24349. /**
  24350. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24351. * separate meshes. This can be use to improve performances.
  24352. * @see http://doc.babylonjs.com/how_to/multi_materials
  24353. */
  24354. export class MultiMaterial extends Material {
  24355. private _subMaterials;
  24356. /**
  24357. * Gets or Sets the list of Materials used within the multi material.
  24358. * They need to be ordered according to the submeshes order in the associated mesh
  24359. */
  24360. get subMaterials(): Nullable<Material>[];
  24361. set subMaterials(value: Nullable<Material>[]);
  24362. /**
  24363. * Function used to align with Node.getChildren()
  24364. * @returns the list of Materials used within the multi material
  24365. */
  24366. getChildren(): Nullable<Material>[];
  24367. /**
  24368. * Instantiates a new Multi Material
  24369. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24370. * separate meshes. This can be use to improve performances.
  24371. * @see http://doc.babylonjs.com/how_to/multi_materials
  24372. * @param name Define the name in the scene
  24373. * @param scene Define the scene the material belongs to
  24374. */
  24375. constructor(name: string, scene: Scene);
  24376. private _hookArray;
  24377. /**
  24378. * Get one of the submaterial by its index in the submaterials array
  24379. * @param index The index to look the sub material at
  24380. * @returns The Material if the index has been defined
  24381. */
  24382. getSubMaterial(index: number): Nullable<Material>;
  24383. /**
  24384. * Get the list of active textures for the whole sub materials list.
  24385. * @returns All the textures that will be used during the rendering
  24386. */
  24387. getActiveTextures(): BaseTexture[];
  24388. /**
  24389. * Gets the current class name of the material e.g. "MultiMaterial"
  24390. * Mainly use in serialization.
  24391. * @returns the class name
  24392. */
  24393. getClassName(): string;
  24394. /**
  24395. * Checks if the material is ready to render the requested sub mesh
  24396. * @param mesh Define the mesh the submesh belongs to
  24397. * @param subMesh Define the sub mesh to look readyness for
  24398. * @param useInstances Define whether or not the material is used with instances
  24399. * @returns true if ready, otherwise false
  24400. */
  24401. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24402. /**
  24403. * Clones the current material and its related sub materials
  24404. * @param name Define the name of the newly cloned material
  24405. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24406. * @returns the cloned material
  24407. */
  24408. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24409. /**
  24410. * Serializes the materials into a JSON representation.
  24411. * @returns the JSON representation
  24412. */
  24413. serialize(): any;
  24414. /**
  24415. * Dispose the material and release its associated resources
  24416. * @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)
  24417. * @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)
  24418. * @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)
  24419. */
  24420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24421. /**
  24422. * Creates a MultiMaterial from parsed MultiMaterial data.
  24423. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24424. * @param scene defines the hosting scene
  24425. * @returns a new MultiMaterial
  24426. */
  24427. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24428. }
  24429. }
  24430. declare module BABYLON {
  24431. /**
  24432. * Defines a subdivision inside a mesh
  24433. */
  24434. export class SubMesh implements ICullable {
  24435. /** the material index to use */
  24436. materialIndex: number;
  24437. /** vertex index start */
  24438. verticesStart: number;
  24439. /** vertices count */
  24440. verticesCount: number;
  24441. /** index start */
  24442. indexStart: number;
  24443. /** indices count */
  24444. indexCount: number;
  24445. /** @hidden */
  24446. _materialDefines: Nullable<MaterialDefines>;
  24447. /** @hidden */
  24448. _materialEffect: Nullable<Effect>;
  24449. /** @hidden */
  24450. _effectOverride: Nullable<Effect>;
  24451. /**
  24452. * Gets material defines used by the effect associated to the sub mesh
  24453. */
  24454. get materialDefines(): Nullable<MaterialDefines>;
  24455. /**
  24456. * Sets material defines used by the effect associated to the sub mesh
  24457. */
  24458. set materialDefines(defines: Nullable<MaterialDefines>);
  24459. /**
  24460. * Gets associated effect
  24461. */
  24462. get effect(): Nullable<Effect>;
  24463. /**
  24464. * Sets associated effect (effect used to render this submesh)
  24465. * @param effect defines the effect to associate with
  24466. * @param defines defines the set of defines used to compile this effect
  24467. */
  24468. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24469. /** @hidden */
  24470. _linesIndexCount: number;
  24471. private _mesh;
  24472. private _renderingMesh;
  24473. private _boundingInfo;
  24474. private _linesIndexBuffer;
  24475. /** @hidden */
  24476. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24477. /** @hidden */
  24478. _trianglePlanes: Plane[];
  24479. /** @hidden */
  24480. _lastColliderTransformMatrix: Nullable<Matrix>;
  24481. /** @hidden */
  24482. _renderId: number;
  24483. /** @hidden */
  24484. _alphaIndex: number;
  24485. /** @hidden */
  24486. _distanceToCamera: number;
  24487. /** @hidden */
  24488. _id: number;
  24489. private _currentMaterial;
  24490. /**
  24491. * Add a new submesh to a mesh
  24492. * @param materialIndex defines the material index to use
  24493. * @param verticesStart defines vertex index start
  24494. * @param verticesCount defines vertices count
  24495. * @param indexStart defines index start
  24496. * @param indexCount defines indices count
  24497. * @param mesh defines the parent mesh
  24498. * @param renderingMesh defines an optional rendering mesh
  24499. * @param createBoundingBox defines if bounding box should be created for this submesh
  24500. * @returns the new submesh
  24501. */
  24502. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24503. /**
  24504. * Creates a new submesh
  24505. * @param materialIndex defines the material index to use
  24506. * @param verticesStart defines vertex index start
  24507. * @param verticesCount defines vertices count
  24508. * @param indexStart defines index start
  24509. * @param indexCount defines indices count
  24510. * @param mesh defines the parent mesh
  24511. * @param renderingMesh defines an optional rendering mesh
  24512. * @param createBoundingBox defines if bounding box should be created for this submesh
  24513. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24514. */
  24515. constructor(
  24516. /** the material index to use */
  24517. materialIndex: number,
  24518. /** vertex index start */
  24519. verticesStart: number,
  24520. /** vertices count */
  24521. verticesCount: number,
  24522. /** index start */
  24523. indexStart: number,
  24524. /** indices count */
  24525. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24526. /**
  24527. * Returns true if this submesh covers the entire parent mesh
  24528. * @ignorenaming
  24529. */
  24530. get IsGlobal(): boolean;
  24531. /**
  24532. * Returns the submesh BoudingInfo object
  24533. * @returns current bounding info (or mesh's one if the submesh is global)
  24534. */
  24535. getBoundingInfo(): BoundingInfo;
  24536. /**
  24537. * Sets the submesh BoundingInfo
  24538. * @param boundingInfo defines the new bounding info to use
  24539. * @returns the SubMesh
  24540. */
  24541. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24542. /**
  24543. * Returns the mesh of the current submesh
  24544. * @return the parent mesh
  24545. */
  24546. getMesh(): AbstractMesh;
  24547. /**
  24548. * Returns the rendering mesh of the submesh
  24549. * @returns the rendering mesh (could be different from parent mesh)
  24550. */
  24551. getRenderingMesh(): Mesh;
  24552. /**
  24553. * Returns the replacement mesh of the submesh
  24554. * @returns the replacement mesh (could be different from parent mesh)
  24555. */
  24556. getReplacementMesh(): Nullable<AbstractMesh>;
  24557. /**
  24558. * Returns the effective mesh of the submesh
  24559. * @returns the effective mesh (could be different from parent mesh)
  24560. */
  24561. getEffectiveMesh(): AbstractMesh;
  24562. /**
  24563. * Returns the submesh material
  24564. * @returns null or the current material
  24565. */
  24566. getMaterial(): Nullable<Material>;
  24567. /**
  24568. * Sets a new updated BoundingInfo object to the submesh
  24569. * @param data defines an optional position array to use to determine the bounding info
  24570. * @returns the SubMesh
  24571. */
  24572. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24573. /** @hidden */
  24574. _checkCollision(collider: Collider): boolean;
  24575. /**
  24576. * Updates the submesh BoundingInfo
  24577. * @param world defines the world matrix to use to update the bounding info
  24578. * @returns the submesh
  24579. */
  24580. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24581. /**
  24582. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24583. * @param frustumPlanes defines the frustum planes
  24584. * @returns true if the submesh is intersecting with the frustum
  24585. */
  24586. isInFrustum(frustumPlanes: Plane[]): boolean;
  24587. /**
  24588. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24589. * @param frustumPlanes defines the frustum planes
  24590. * @returns true if the submesh is inside the frustum
  24591. */
  24592. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24593. /**
  24594. * Renders the submesh
  24595. * @param enableAlphaMode defines if alpha needs to be used
  24596. * @returns the submesh
  24597. */
  24598. render(enableAlphaMode: boolean): SubMesh;
  24599. /**
  24600. * @hidden
  24601. */
  24602. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24603. /**
  24604. * Checks if the submesh intersects with a ray
  24605. * @param ray defines the ray to test
  24606. * @returns true is the passed ray intersects the submesh bounding box
  24607. */
  24608. canIntersects(ray: Ray): boolean;
  24609. /**
  24610. * Intersects current submesh with a ray
  24611. * @param ray defines the ray to test
  24612. * @param positions defines mesh's positions array
  24613. * @param indices defines mesh's indices array
  24614. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24615. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24616. * @returns intersection info or null if no intersection
  24617. */
  24618. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24619. /** @hidden */
  24620. private _intersectLines;
  24621. /** @hidden */
  24622. private _intersectUnIndexedLines;
  24623. /** @hidden */
  24624. private _intersectTriangles;
  24625. /** @hidden */
  24626. private _intersectUnIndexedTriangles;
  24627. /** @hidden */
  24628. _rebuild(): void;
  24629. /**
  24630. * Creates a new submesh from the passed mesh
  24631. * @param newMesh defines the new hosting mesh
  24632. * @param newRenderingMesh defines an optional rendering mesh
  24633. * @returns the new submesh
  24634. */
  24635. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24636. /**
  24637. * Release associated resources
  24638. */
  24639. dispose(): void;
  24640. /**
  24641. * Gets the class name
  24642. * @returns the string "SubMesh".
  24643. */
  24644. getClassName(): string;
  24645. /**
  24646. * Creates a new submesh from indices data
  24647. * @param materialIndex the index of the main mesh material
  24648. * @param startIndex the index where to start the copy in the mesh indices array
  24649. * @param indexCount the number of indices to copy then from the startIndex
  24650. * @param mesh the main mesh to create the submesh from
  24651. * @param renderingMesh the optional rendering mesh
  24652. * @returns a new submesh
  24653. */
  24654. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24655. }
  24656. }
  24657. declare module BABYLON {
  24658. /**
  24659. * Class used to represent data loading progression
  24660. */
  24661. export class SceneLoaderFlags {
  24662. private static _ForceFullSceneLoadingForIncremental;
  24663. private static _ShowLoadingScreen;
  24664. private static _CleanBoneMatrixWeights;
  24665. private static _loggingLevel;
  24666. /**
  24667. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24668. */
  24669. static get ForceFullSceneLoadingForIncremental(): boolean;
  24670. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24671. /**
  24672. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24673. */
  24674. static get ShowLoadingScreen(): boolean;
  24675. static set ShowLoadingScreen(value: boolean);
  24676. /**
  24677. * Defines the current logging level (while loading the scene)
  24678. * @ignorenaming
  24679. */
  24680. static get loggingLevel(): number;
  24681. static set loggingLevel(value: number);
  24682. /**
  24683. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24684. */
  24685. static get CleanBoneMatrixWeights(): boolean;
  24686. static set CleanBoneMatrixWeights(value: boolean);
  24687. }
  24688. }
  24689. declare module BABYLON {
  24690. /**
  24691. * Class used to store geometry data (vertex buffers + index buffer)
  24692. */
  24693. export class Geometry implements IGetSetVerticesData {
  24694. /**
  24695. * Gets or sets the ID of the geometry
  24696. */
  24697. id: string;
  24698. /**
  24699. * Gets or sets the unique ID of the geometry
  24700. */
  24701. uniqueId: number;
  24702. /**
  24703. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24704. */
  24705. delayLoadState: number;
  24706. /**
  24707. * Gets the file containing the data to load when running in delay load state
  24708. */
  24709. delayLoadingFile: Nullable<string>;
  24710. /**
  24711. * Callback called when the geometry is updated
  24712. */
  24713. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24714. private _scene;
  24715. private _engine;
  24716. private _meshes;
  24717. private _totalVertices;
  24718. /** @hidden */
  24719. _indices: IndicesArray;
  24720. /** @hidden */
  24721. _vertexBuffers: {
  24722. [key: string]: VertexBuffer;
  24723. };
  24724. private _isDisposed;
  24725. private _extend;
  24726. private _boundingBias;
  24727. /** @hidden */
  24728. _delayInfo: Array<string>;
  24729. private _indexBuffer;
  24730. private _indexBufferIsUpdatable;
  24731. /** @hidden */
  24732. _boundingInfo: Nullable<BoundingInfo>;
  24733. /** @hidden */
  24734. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24735. /** @hidden */
  24736. _softwareSkinningFrameId: number;
  24737. private _vertexArrayObjects;
  24738. private _updatable;
  24739. /** @hidden */
  24740. _positions: Nullable<Vector3[]>;
  24741. /**
  24742. * 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
  24743. */
  24744. get boundingBias(): Vector2;
  24745. /**
  24746. * 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
  24747. */
  24748. set boundingBias(value: Vector2);
  24749. /**
  24750. * Static function used to attach a new empty geometry to a mesh
  24751. * @param mesh defines the mesh to attach the geometry to
  24752. * @returns the new Geometry
  24753. */
  24754. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24755. /** Get the list of meshes using this geometry */
  24756. get meshes(): Mesh[];
  24757. /**
  24758. * Creates a new geometry
  24759. * @param id defines the unique ID
  24760. * @param scene defines the hosting scene
  24761. * @param vertexData defines the VertexData used to get geometry data
  24762. * @param updatable defines if geometry must be updatable (false by default)
  24763. * @param mesh defines the mesh that will be associated with the geometry
  24764. */
  24765. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24766. /**
  24767. * Gets the current extend of the geometry
  24768. */
  24769. get extend(): {
  24770. minimum: Vector3;
  24771. maximum: Vector3;
  24772. };
  24773. /**
  24774. * Gets the hosting scene
  24775. * @returns the hosting Scene
  24776. */
  24777. getScene(): Scene;
  24778. /**
  24779. * Gets the hosting engine
  24780. * @returns the hosting Engine
  24781. */
  24782. getEngine(): Engine;
  24783. /**
  24784. * Defines if the geometry is ready to use
  24785. * @returns true if the geometry is ready to be used
  24786. */
  24787. isReady(): boolean;
  24788. /**
  24789. * Gets a value indicating that the geometry should not be serialized
  24790. */
  24791. get doNotSerialize(): boolean;
  24792. /** @hidden */
  24793. _rebuild(): void;
  24794. /**
  24795. * Affects all geometry data in one call
  24796. * @param vertexData defines the geometry data
  24797. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24798. */
  24799. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24800. /**
  24801. * Set specific vertex data
  24802. * @param kind defines the data kind (Position, normal, etc...)
  24803. * @param data defines the vertex data to use
  24804. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24805. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24806. */
  24807. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24808. /**
  24809. * Removes a specific vertex data
  24810. * @param kind defines the data kind (Position, normal, etc...)
  24811. */
  24812. removeVerticesData(kind: string): void;
  24813. /**
  24814. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24815. * @param buffer defines the vertex buffer to use
  24816. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24817. */
  24818. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24819. /**
  24820. * Update a specific vertex buffer
  24821. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24822. * It will do nothing if the buffer is not updatable
  24823. * @param kind defines the data kind (Position, normal, etc...)
  24824. * @param data defines the data to use
  24825. * @param offset defines the offset in the target buffer where to store the data
  24826. * @param useBytes set to true if the offset is in bytes
  24827. */
  24828. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24829. /**
  24830. * Update a specific vertex buffer
  24831. * This function will create a new buffer if the current one is not updatable
  24832. * @param kind defines the data kind (Position, normal, etc...)
  24833. * @param data defines the data to use
  24834. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24835. */
  24836. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24837. private _updateBoundingInfo;
  24838. /** @hidden */
  24839. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24840. /**
  24841. * Gets total number of vertices
  24842. * @returns the total number of vertices
  24843. */
  24844. getTotalVertices(): number;
  24845. /**
  24846. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24847. * @param kind defines the data kind (Position, normal, etc...)
  24848. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24849. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24850. * @returns a float array containing vertex data
  24851. */
  24852. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24853. /**
  24854. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24855. * @param kind defines the data kind (Position, normal, etc...)
  24856. * @returns true if the vertex buffer with the specified kind is updatable
  24857. */
  24858. isVertexBufferUpdatable(kind: string): boolean;
  24859. /**
  24860. * Gets a specific vertex buffer
  24861. * @param kind defines the data kind (Position, normal, etc...)
  24862. * @returns a VertexBuffer
  24863. */
  24864. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24865. /**
  24866. * Returns all vertex buffers
  24867. * @return an object holding all vertex buffers indexed by kind
  24868. */
  24869. getVertexBuffers(): Nullable<{
  24870. [key: string]: VertexBuffer;
  24871. }>;
  24872. /**
  24873. * Gets a boolean indicating if specific vertex buffer is present
  24874. * @param kind defines the data kind (Position, normal, etc...)
  24875. * @returns true if data is present
  24876. */
  24877. isVerticesDataPresent(kind: string): boolean;
  24878. /**
  24879. * Gets a list of all attached data kinds (Position, normal, etc...)
  24880. * @returns a list of string containing all kinds
  24881. */
  24882. getVerticesDataKinds(): string[];
  24883. /**
  24884. * Update index buffer
  24885. * @param indices defines the indices to store in the index buffer
  24886. * @param offset defines the offset in the target buffer where to store the data
  24887. * @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)
  24888. */
  24889. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24890. /**
  24891. * Creates a new index buffer
  24892. * @param indices defines the indices to store in the index buffer
  24893. * @param totalVertices defines the total number of vertices (could be null)
  24894. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24895. */
  24896. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24897. /**
  24898. * Return the total number of indices
  24899. * @returns the total number of indices
  24900. */
  24901. getTotalIndices(): number;
  24902. /**
  24903. * Gets the index buffer array
  24904. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24905. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24906. * @returns the index buffer array
  24907. */
  24908. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24909. /**
  24910. * Gets the index buffer
  24911. * @return the index buffer
  24912. */
  24913. getIndexBuffer(): Nullable<DataBuffer>;
  24914. /** @hidden */
  24915. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24916. /**
  24917. * Release the associated resources for a specific mesh
  24918. * @param mesh defines the source mesh
  24919. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24920. */
  24921. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24922. /**
  24923. * Apply current geometry to a given mesh
  24924. * @param mesh defines the mesh to apply geometry to
  24925. */
  24926. applyToMesh(mesh: Mesh): void;
  24927. private _updateExtend;
  24928. private _applyToMesh;
  24929. private notifyUpdate;
  24930. /**
  24931. * Load the geometry if it was flagged as delay loaded
  24932. * @param scene defines the hosting scene
  24933. * @param onLoaded defines a callback called when the geometry is loaded
  24934. */
  24935. load(scene: Scene, onLoaded?: () => void): void;
  24936. private _queueLoad;
  24937. /**
  24938. * Invert the geometry to move from a right handed system to a left handed one.
  24939. */
  24940. toLeftHanded(): void;
  24941. /** @hidden */
  24942. _resetPointsArrayCache(): void;
  24943. /** @hidden */
  24944. _generatePointsArray(): boolean;
  24945. /**
  24946. * Gets a value indicating if the geometry is disposed
  24947. * @returns true if the geometry was disposed
  24948. */
  24949. isDisposed(): boolean;
  24950. private _disposeVertexArrayObjects;
  24951. /**
  24952. * Free all associated resources
  24953. */
  24954. dispose(): void;
  24955. /**
  24956. * Clone the current geometry into a new geometry
  24957. * @param id defines the unique ID of the new geometry
  24958. * @returns a new geometry object
  24959. */
  24960. copy(id: string): Geometry;
  24961. /**
  24962. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24963. * @return a JSON representation of the current geometry data (without the vertices data)
  24964. */
  24965. serialize(): any;
  24966. private toNumberArray;
  24967. /**
  24968. * Serialize all vertices data into a JSON oject
  24969. * @returns a JSON representation of the current geometry data
  24970. */
  24971. serializeVerticeData(): any;
  24972. /**
  24973. * Extracts a clone of a mesh geometry
  24974. * @param mesh defines the source mesh
  24975. * @param id defines the unique ID of the new geometry object
  24976. * @returns the new geometry object
  24977. */
  24978. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24979. /**
  24980. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24981. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24982. * Be aware Math.random() could cause collisions, but:
  24983. * "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"
  24984. * @returns a string containing a new GUID
  24985. */
  24986. static RandomId(): string;
  24987. /** @hidden */
  24988. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24989. private static _CleanMatricesWeights;
  24990. /**
  24991. * Create a new geometry from persisted data (Using .babylon file format)
  24992. * @param parsedVertexData defines the persisted data
  24993. * @param scene defines the hosting scene
  24994. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24995. * @returns the new geometry object
  24996. */
  24997. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24998. }
  24999. }
  25000. declare module BABYLON {
  25001. /**
  25002. * Define an interface for all classes that will get and set the data on vertices
  25003. */
  25004. export interface IGetSetVerticesData {
  25005. /**
  25006. * Gets a boolean indicating if specific vertex data is present
  25007. * @param kind defines the vertex data kind to use
  25008. * @returns true is data kind is present
  25009. */
  25010. isVerticesDataPresent(kind: string): boolean;
  25011. /**
  25012. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25013. * @param kind defines the data kind (Position, normal, etc...)
  25014. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25016. * @returns a float array containing vertex data
  25017. */
  25018. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25019. /**
  25020. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25021. * @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.
  25022. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25023. * @returns the indices array or an empty array if the mesh has no geometry
  25024. */
  25025. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25026. /**
  25027. * Set specific vertex data
  25028. * @param kind defines the data kind (Position, normal, etc...)
  25029. * @param data defines the vertex data to use
  25030. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25031. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25032. */
  25033. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25034. /**
  25035. * Update a specific associated vertex buffer
  25036. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25037. * - VertexBuffer.PositionKind
  25038. * - VertexBuffer.UVKind
  25039. * - VertexBuffer.UV2Kind
  25040. * - VertexBuffer.UV3Kind
  25041. * - VertexBuffer.UV4Kind
  25042. * - VertexBuffer.UV5Kind
  25043. * - VertexBuffer.UV6Kind
  25044. * - VertexBuffer.ColorKind
  25045. * - VertexBuffer.MatricesIndicesKind
  25046. * - VertexBuffer.MatricesIndicesExtraKind
  25047. * - VertexBuffer.MatricesWeightsKind
  25048. * - VertexBuffer.MatricesWeightsExtraKind
  25049. * @param data defines the data source
  25050. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25051. * @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)
  25052. */
  25053. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25054. /**
  25055. * Creates a new index buffer
  25056. * @param indices defines the indices to store in the index buffer
  25057. * @param totalVertices defines the total number of vertices (could be null)
  25058. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25059. */
  25060. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25061. }
  25062. /**
  25063. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25064. */
  25065. export class VertexData {
  25066. /**
  25067. * Mesh side orientation : usually the external or front surface
  25068. */
  25069. static readonly FRONTSIDE: number;
  25070. /**
  25071. * Mesh side orientation : usually the internal or back surface
  25072. */
  25073. static readonly BACKSIDE: number;
  25074. /**
  25075. * Mesh side orientation : both internal and external or front and back surfaces
  25076. */
  25077. static readonly DOUBLESIDE: number;
  25078. /**
  25079. * Mesh side orientation : by default, `FRONTSIDE`
  25080. */
  25081. static readonly DEFAULTSIDE: number;
  25082. /**
  25083. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25084. */
  25085. positions: Nullable<FloatArray>;
  25086. /**
  25087. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25088. */
  25089. normals: Nullable<FloatArray>;
  25090. /**
  25091. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25092. */
  25093. tangents: Nullable<FloatArray>;
  25094. /**
  25095. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25096. */
  25097. uvs: Nullable<FloatArray>;
  25098. /**
  25099. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25100. */
  25101. uvs2: Nullable<FloatArray>;
  25102. /**
  25103. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25104. */
  25105. uvs3: Nullable<FloatArray>;
  25106. /**
  25107. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25108. */
  25109. uvs4: Nullable<FloatArray>;
  25110. /**
  25111. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25112. */
  25113. uvs5: Nullable<FloatArray>;
  25114. /**
  25115. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25116. */
  25117. uvs6: Nullable<FloatArray>;
  25118. /**
  25119. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25120. */
  25121. colors: Nullable<FloatArray>;
  25122. /**
  25123. * 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).
  25124. */
  25125. matricesIndices: Nullable<FloatArray>;
  25126. /**
  25127. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25128. */
  25129. matricesWeights: Nullable<FloatArray>;
  25130. /**
  25131. * An array extending the number of possible indices
  25132. */
  25133. matricesIndicesExtra: Nullable<FloatArray>;
  25134. /**
  25135. * An array extending the number of possible weights when the number of indices is extended
  25136. */
  25137. matricesWeightsExtra: Nullable<FloatArray>;
  25138. /**
  25139. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25140. */
  25141. indices: Nullable<IndicesArray>;
  25142. /**
  25143. * Uses the passed data array to set the set the values for the specified kind of data
  25144. * @param data a linear array of floating numbers
  25145. * @param kind the type of data that is being set, eg positions, colors etc
  25146. */
  25147. set(data: FloatArray, kind: string): void;
  25148. /**
  25149. * Associates the vertexData to the passed Mesh.
  25150. * Sets it as updatable or not (default `false`)
  25151. * @param mesh the mesh the vertexData is applied to
  25152. * @param updatable when used and having the value true allows new data to update the vertexData
  25153. * @returns the VertexData
  25154. */
  25155. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25156. /**
  25157. * Associates the vertexData to the passed Geometry.
  25158. * Sets it as updatable or not (default `false`)
  25159. * @param geometry the geometry the vertexData is applied to
  25160. * @param updatable when used and having the value true allows new data to update the vertexData
  25161. * @returns VertexData
  25162. */
  25163. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25164. /**
  25165. * Updates the associated mesh
  25166. * @param mesh the mesh to be updated
  25167. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25168. * @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
  25169. * @returns VertexData
  25170. */
  25171. updateMesh(mesh: Mesh): VertexData;
  25172. /**
  25173. * Updates the associated geometry
  25174. * @param geometry the geometry to be updated
  25175. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25176. * @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
  25177. * @returns VertexData.
  25178. */
  25179. updateGeometry(geometry: Geometry): VertexData;
  25180. private _applyTo;
  25181. private _update;
  25182. /**
  25183. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25184. * @param matrix the transforming matrix
  25185. * @returns the VertexData
  25186. */
  25187. transform(matrix: Matrix): VertexData;
  25188. /**
  25189. * Merges the passed VertexData into the current one
  25190. * @param other the VertexData to be merged into the current one
  25191. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25192. * @returns the modified VertexData
  25193. */
  25194. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25195. private _mergeElement;
  25196. private _validate;
  25197. /**
  25198. * Serializes the VertexData
  25199. * @returns a serialized object
  25200. */
  25201. serialize(): any;
  25202. /**
  25203. * Extracts the vertexData from a mesh
  25204. * @param mesh the mesh from which to extract the VertexData
  25205. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25206. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25207. * @returns the object VertexData associated to the passed mesh
  25208. */
  25209. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25210. /**
  25211. * Extracts the vertexData from the geometry
  25212. * @param geometry the geometry from which to extract the VertexData
  25213. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25214. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25215. * @returns the object VertexData associated to the passed mesh
  25216. */
  25217. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25218. private static _ExtractFrom;
  25219. /**
  25220. * Creates the VertexData for a Ribbon
  25221. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25222. * * pathArray array of paths, each of which an array of successive Vector3
  25223. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25224. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25225. * * 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
  25226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25227. * * 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)
  25228. * * 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)
  25229. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25230. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25231. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25232. * @returns the VertexData of the ribbon
  25233. */
  25234. static CreateRibbon(options: {
  25235. pathArray: Vector3[][];
  25236. closeArray?: boolean;
  25237. closePath?: boolean;
  25238. offset?: number;
  25239. sideOrientation?: number;
  25240. frontUVs?: Vector4;
  25241. backUVs?: Vector4;
  25242. invertUV?: boolean;
  25243. uvs?: Vector2[];
  25244. colors?: Color4[];
  25245. }): VertexData;
  25246. /**
  25247. * Creates the VertexData for a box
  25248. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25249. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25250. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25251. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25252. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25253. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25254. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25255. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25256. * * 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)
  25257. * * 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)
  25258. * @returns the VertexData of the box
  25259. */
  25260. static CreateBox(options: {
  25261. size?: number;
  25262. width?: number;
  25263. height?: number;
  25264. depth?: number;
  25265. faceUV?: Vector4[];
  25266. faceColors?: Color4[];
  25267. sideOrientation?: number;
  25268. frontUVs?: Vector4;
  25269. backUVs?: Vector4;
  25270. }): VertexData;
  25271. /**
  25272. * Creates the VertexData for a tiled box
  25273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25274. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25275. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25276. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25278. * @returns the VertexData of the box
  25279. */
  25280. static CreateTiledBox(options: {
  25281. pattern?: number;
  25282. width?: number;
  25283. height?: number;
  25284. depth?: number;
  25285. tileSize?: number;
  25286. tileWidth?: number;
  25287. tileHeight?: number;
  25288. alignHorizontal?: number;
  25289. alignVertical?: number;
  25290. faceUV?: Vector4[];
  25291. faceColors?: Color4[];
  25292. sideOrientation?: number;
  25293. }): VertexData;
  25294. /**
  25295. * Creates the VertexData for a tiled plane
  25296. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25297. * * pattern a limited pattern arrangement depending on the number
  25298. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25299. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25300. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25302. * * 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)
  25303. * * 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)
  25304. * @returns the VertexData of the tiled plane
  25305. */
  25306. static CreateTiledPlane(options: {
  25307. pattern?: number;
  25308. tileSize?: number;
  25309. tileWidth?: number;
  25310. tileHeight?: number;
  25311. size?: number;
  25312. width?: number;
  25313. height?: number;
  25314. alignHorizontal?: number;
  25315. alignVertical?: number;
  25316. sideOrientation?: number;
  25317. frontUVs?: Vector4;
  25318. backUVs?: Vector4;
  25319. }): VertexData;
  25320. /**
  25321. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25322. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25323. * * segments sets the number of horizontal strips optional, default 32
  25324. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25325. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25326. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25327. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25328. * * 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
  25329. * * 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
  25330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25331. * * 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)
  25332. * * 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)
  25333. * @returns the VertexData of the ellipsoid
  25334. */
  25335. static CreateSphere(options: {
  25336. segments?: number;
  25337. diameter?: number;
  25338. diameterX?: number;
  25339. diameterY?: number;
  25340. diameterZ?: number;
  25341. arc?: number;
  25342. slice?: number;
  25343. sideOrientation?: number;
  25344. frontUVs?: Vector4;
  25345. backUVs?: Vector4;
  25346. }): VertexData;
  25347. /**
  25348. * Creates the VertexData for a cylinder, cone or prism
  25349. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25350. * * height sets the height (y direction) of the cylinder, optional, default 2
  25351. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25352. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25353. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25354. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25355. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25356. * * 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
  25357. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25358. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25359. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25360. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25362. * * 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)
  25363. * * 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)
  25364. * @returns the VertexData of the cylinder, cone or prism
  25365. */
  25366. static CreateCylinder(options: {
  25367. height?: number;
  25368. diameterTop?: number;
  25369. diameterBottom?: number;
  25370. diameter?: number;
  25371. tessellation?: number;
  25372. subdivisions?: number;
  25373. arc?: number;
  25374. faceColors?: Color4[];
  25375. faceUV?: Vector4[];
  25376. hasRings?: boolean;
  25377. enclose?: boolean;
  25378. sideOrientation?: number;
  25379. frontUVs?: Vector4;
  25380. backUVs?: Vector4;
  25381. }): VertexData;
  25382. /**
  25383. * Creates the VertexData for a torus
  25384. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25385. * * diameter the diameter of the torus, optional default 1
  25386. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25387. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25389. * * 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)
  25390. * * 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)
  25391. * @returns the VertexData of the torus
  25392. */
  25393. static CreateTorus(options: {
  25394. diameter?: number;
  25395. thickness?: number;
  25396. tessellation?: number;
  25397. sideOrientation?: number;
  25398. frontUVs?: Vector4;
  25399. backUVs?: Vector4;
  25400. }): VertexData;
  25401. /**
  25402. * Creates the VertexData of the LineSystem
  25403. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25404. * - lines an array of lines, each line being an array of successive Vector3
  25405. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25406. * @returns the VertexData of the LineSystem
  25407. */
  25408. static CreateLineSystem(options: {
  25409. lines: Vector3[][];
  25410. colors?: Nullable<Color4[][]>;
  25411. }): VertexData;
  25412. /**
  25413. * Create the VertexData for a DashedLines
  25414. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25415. * - points an array successive Vector3
  25416. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25417. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25418. * - dashNb the intended total number of dashes, optional, default 200
  25419. * @returns the VertexData for the DashedLines
  25420. */
  25421. static CreateDashedLines(options: {
  25422. points: Vector3[];
  25423. dashSize?: number;
  25424. gapSize?: number;
  25425. dashNb?: number;
  25426. }): VertexData;
  25427. /**
  25428. * Creates the VertexData for a Ground
  25429. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25430. * - width the width (x direction) of the ground, optional, default 1
  25431. * - height the height (z direction) of the ground, optional, default 1
  25432. * - subdivisions the number of subdivisions per side, optional, default 1
  25433. * @returns the VertexData of the Ground
  25434. */
  25435. static CreateGround(options: {
  25436. width?: number;
  25437. height?: number;
  25438. subdivisions?: number;
  25439. subdivisionsX?: number;
  25440. subdivisionsY?: number;
  25441. }): VertexData;
  25442. /**
  25443. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25444. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25445. * * xmin the ground minimum X coordinate, optional, default -1
  25446. * * zmin the ground minimum Z coordinate, optional, default -1
  25447. * * xmax the ground maximum X coordinate, optional, default 1
  25448. * * zmax the ground maximum Z coordinate, optional, default 1
  25449. * * 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}
  25450. * * 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}
  25451. * @returns the VertexData of the TiledGround
  25452. */
  25453. static CreateTiledGround(options: {
  25454. xmin: number;
  25455. zmin: number;
  25456. xmax: number;
  25457. zmax: number;
  25458. subdivisions?: {
  25459. w: number;
  25460. h: number;
  25461. };
  25462. precision?: {
  25463. w: number;
  25464. h: number;
  25465. };
  25466. }): VertexData;
  25467. /**
  25468. * Creates the VertexData of the Ground designed from a heightmap
  25469. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25470. * * width the width (x direction) of the ground
  25471. * * height the height (z direction) of the ground
  25472. * * subdivisions the number of subdivisions per side
  25473. * * minHeight the minimum altitude on the ground, optional, default 0
  25474. * * maxHeight the maximum altitude on the ground, optional default 1
  25475. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25476. * * buffer the array holding the image color data
  25477. * * bufferWidth the width of image
  25478. * * bufferHeight the height of image
  25479. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25480. * @returns the VertexData of the Ground designed from a heightmap
  25481. */
  25482. static CreateGroundFromHeightMap(options: {
  25483. width: number;
  25484. height: number;
  25485. subdivisions: number;
  25486. minHeight: number;
  25487. maxHeight: number;
  25488. colorFilter: Color3;
  25489. buffer: Uint8Array;
  25490. bufferWidth: number;
  25491. bufferHeight: number;
  25492. alphaFilter: number;
  25493. }): VertexData;
  25494. /**
  25495. * Creates the VertexData for a Plane
  25496. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25497. * * size sets the width and height of the plane to the value of size, optional default 1
  25498. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25499. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25501. * * 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)
  25502. * * 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)
  25503. * @returns the VertexData of the box
  25504. */
  25505. static CreatePlane(options: {
  25506. size?: number;
  25507. width?: number;
  25508. height?: number;
  25509. sideOrientation?: number;
  25510. frontUVs?: Vector4;
  25511. backUVs?: Vector4;
  25512. }): VertexData;
  25513. /**
  25514. * Creates the VertexData of the Disc or regular Polygon
  25515. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25516. * * radius the radius of the disc, optional default 0.5
  25517. * * tessellation the number of polygon sides, optional, default 64
  25518. * * 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
  25519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25520. * * 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)
  25521. * * 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)
  25522. * @returns the VertexData of the box
  25523. */
  25524. static CreateDisc(options: {
  25525. radius?: number;
  25526. tessellation?: number;
  25527. arc?: number;
  25528. sideOrientation?: number;
  25529. frontUVs?: Vector4;
  25530. backUVs?: Vector4;
  25531. }): VertexData;
  25532. /**
  25533. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25534. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25535. * @param polygon a mesh built from polygonTriangulation.build()
  25536. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25537. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25538. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25539. * @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)
  25540. * @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)
  25541. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25542. * @returns the VertexData of the Polygon
  25543. */
  25544. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25545. /**
  25546. * Creates the VertexData of the IcoSphere
  25547. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25548. * * radius the radius of the IcoSphere, optional default 1
  25549. * * radiusX allows stretching in the x direction, optional, default radius
  25550. * * radiusY allows stretching in the y direction, optional, default radius
  25551. * * radiusZ allows stretching in the z direction, optional, default radius
  25552. * * flat when true creates a flat shaded mesh, optional, default true
  25553. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25555. * * 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)
  25556. * * 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)
  25557. * @returns the VertexData of the IcoSphere
  25558. */
  25559. static CreateIcoSphere(options: {
  25560. radius?: number;
  25561. radiusX?: number;
  25562. radiusY?: number;
  25563. radiusZ?: number;
  25564. flat?: boolean;
  25565. subdivisions?: number;
  25566. sideOrientation?: number;
  25567. frontUVs?: Vector4;
  25568. backUVs?: Vector4;
  25569. }): VertexData;
  25570. /**
  25571. * Creates the VertexData for a Polyhedron
  25572. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25573. * * type provided types are:
  25574. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25575. * * 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)
  25576. * * size the size of the IcoSphere, optional default 1
  25577. * * sizeX allows stretching in the x direction, optional, default size
  25578. * * sizeY allows stretching in the y direction, optional, default size
  25579. * * sizeZ allows stretching in the z direction, optional, default size
  25580. * * 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
  25581. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25582. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25583. * * flat when true creates a flat shaded mesh, optional, default true
  25584. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25586. * * 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)
  25587. * * 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)
  25588. * @returns the VertexData of the Polyhedron
  25589. */
  25590. static CreatePolyhedron(options: {
  25591. type?: number;
  25592. size?: number;
  25593. sizeX?: number;
  25594. sizeY?: number;
  25595. sizeZ?: number;
  25596. custom?: any;
  25597. faceUV?: Vector4[];
  25598. faceColors?: Color4[];
  25599. flat?: boolean;
  25600. sideOrientation?: number;
  25601. frontUVs?: Vector4;
  25602. backUVs?: Vector4;
  25603. }): VertexData;
  25604. /**
  25605. * Creates the VertexData for a TorusKnot
  25606. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25607. * * radius the radius of the torus knot, optional, default 2
  25608. * * tube the thickness of the tube, optional, default 0.5
  25609. * * radialSegments the number of sides on each tube segments, optional, default 32
  25610. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25611. * * p the number of windings around the z axis, optional, default 2
  25612. * * q the number of windings around the x axis, optional, default 3
  25613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25614. * * 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)
  25615. * * 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)
  25616. * @returns the VertexData of the Torus Knot
  25617. */
  25618. static CreateTorusKnot(options: {
  25619. radius?: number;
  25620. tube?: number;
  25621. radialSegments?: number;
  25622. tubularSegments?: number;
  25623. p?: number;
  25624. q?: number;
  25625. sideOrientation?: number;
  25626. frontUVs?: Vector4;
  25627. backUVs?: Vector4;
  25628. }): VertexData;
  25629. /**
  25630. * Compute normals for given positions and indices
  25631. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25632. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25633. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25634. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25635. * * facetNormals : optional array of facet normals (vector3)
  25636. * * facetPositions : optional array of facet positions (vector3)
  25637. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25638. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25639. * * bInfo : optional bounding info, required for facetPartitioning computation
  25640. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25641. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25642. * * useRightHandedSystem: optional boolean to for right handed system computation
  25643. * * depthSort : optional boolean to enable the facet depth sort computation
  25644. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25645. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25646. */
  25647. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25648. facetNormals?: any;
  25649. facetPositions?: any;
  25650. facetPartitioning?: any;
  25651. ratio?: number;
  25652. bInfo?: any;
  25653. bbSize?: Vector3;
  25654. subDiv?: any;
  25655. useRightHandedSystem?: boolean;
  25656. depthSort?: boolean;
  25657. distanceTo?: Vector3;
  25658. depthSortedFacets?: any;
  25659. }): void;
  25660. /** @hidden */
  25661. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25662. /**
  25663. * Applies VertexData created from the imported parameters to the geometry
  25664. * @param parsedVertexData the parsed data from an imported file
  25665. * @param geometry the geometry to apply the VertexData to
  25666. */
  25667. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25668. }
  25669. }
  25670. declare module BABYLON {
  25671. /**
  25672. * Defines a target to use with MorphTargetManager
  25673. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25674. */
  25675. export class MorphTarget implements IAnimatable {
  25676. /** defines the name of the target */
  25677. name: string;
  25678. /**
  25679. * Gets or sets the list of animations
  25680. */
  25681. animations: Animation[];
  25682. private _scene;
  25683. private _positions;
  25684. private _normals;
  25685. private _tangents;
  25686. private _uvs;
  25687. private _influence;
  25688. private _uniqueId;
  25689. /**
  25690. * Observable raised when the influence changes
  25691. */
  25692. onInfluenceChanged: Observable<boolean>;
  25693. /** @hidden */
  25694. _onDataLayoutChanged: Observable<void>;
  25695. /**
  25696. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25697. */
  25698. get influence(): number;
  25699. set influence(influence: number);
  25700. /**
  25701. * Gets or sets the id of the morph Target
  25702. */
  25703. id: string;
  25704. private _animationPropertiesOverride;
  25705. /**
  25706. * Gets or sets the animation properties override
  25707. */
  25708. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25709. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25710. /**
  25711. * Creates a new MorphTarget
  25712. * @param name defines the name of the target
  25713. * @param influence defines the influence to use
  25714. * @param scene defines the scene the morphtarget belongs to
  25715. */
  25716. constructor(
  25717. /** defines the name of the target */
  25718. name: string, influence?: number, scene?: Nullable<Scene>);
  25719. /**
  25720. * Gets the unique ID of this manager
  25721. */
  25722. get uniqueId(): number;
  25723. /**
  25724. * Gets a boolean defining if the target contains position data
  25725. */
  25726. get hasPositions(): boolean;
  25727. /**
  25728. * Gets a boolean defining if the target contains normal data
  25729. */
  25730. get hasNormals(): boolean;
  25731. /**
  25732. * Gets a boolean defining if the target contains tangent data
  25733. */
  25734. get hasTangents(): boolean;
  25735. /**
  25736. * Gets a boolean defining if the target contains texture coordinates data
  25737. */
  25738. get hasUVs(): boolean;
  25739. /**
  25740. * Affects position data to this target
  25741. * @param data defines the position data to use
  25742. */
  25743. setPositions(data: Nullable<FloatArray>): void;
  25744. /**
  25745. * Gets the position data stored in this target
  25746. * @returns a FloatArray containing the position data (or null if not present)
  25747. */
  25748. getPositions(): Nullable<FloatArray>;
  25749. /**
  25750. * Affects normal data to this target
  25751. * @param data defines the normal data to use
  25752. */
  25753. setNormals(data: Nullable<FloatArray>): void;
  25754. /**
  25755. * Gets the normal data stored in this target
  25756. * @returns a FloatArray containing the normal data (or null if not present)
  25757. */
  25758. getNormals(): Nullable<FloatArray>;
  25759. /**
  25760. * Affects tangent data to this target
  25761. * @param data defines the tangent data to use
  25762. */
  25763. setTangents(data: Nullable<FloatArray>): void;
  25764. /**
  25765. * Gets the tangent data stored in this target
  25766. * @returns a FloatArray containing the tangent data (or null if not present)
  25767. */
  25768. getTangents(): Nullable<FloatArray>;
  25769. /**
  25770. * Affects texture coordinates data to this target
  25771. * @param data defines the texture coordinates data to use
  25772. */
  25773. setUVs(data: Nullable<FloatArray>): void;
  25774. /**
  25775. * Gets the texture coordinates data stored in this target
  25776. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25777. */
  25778. getUVs(): Nullable<FloatArray>;
  25779. /**
  25780. * Clone the current target
  25781. * @returns a new MorphTarget
  25782. */
  25783. clone(): MorphTarget;
  25784. /**
  25785. * Serializes the current target into a Serialization object
  25786. * @returns the serialized object
  25787. */
  25788. serialize(): any;
  25789. /**
  25790. * Returns the string "MorphTarget"
  25791. * @returns "MorphTarget"
  25792. */
  25793. getClassName(): string;
  25794. /**
  25795. * Creates a new target from serialized data
  25796. * @param serializationObject defines the serialized data to use
  25797. * @returns a new MorphTarget
  25798. */
  25799. static Parse(serializationObject: any): MorphTarget;
  25800. /**
  25801. * Creates a MorphTarget from mesh data
  25802. * @param mesh defines the source mesh
  25803. * @param name defines the name to use for the new target
  25804. * @param influence defines the influence to attach to the target
  25805. * @returns a new MorphTarget
  25806. */
  25807. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25808. }
  25809. }
  25810. declare module BABYLON {
  25811. /**
  25812. * This class is used to deform meshes using morphing between different targets
  25813. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25814. */
  25815. export class MorphTargetManager {
  25816. private _targets;
  25817. private _targetInfluenceChangedObservers;
  25818. private _targetDataLayoutChangedObservers;
  25819. private _activeTargets;
  25820. private _scene;
  25821. private _influences;
  25822. private _supportsNormals;
  25823. private _supportsTangents;
  25824. private _supportsUVs;
  25825. private _vertexCount;
  25826. private _uniqueId;
  25827. private _tempInfluences;
  25828. /**
  25829. * Gets or sets a boolean indicating if normals must be morphed
  25830. */
  25831. enableNormalMorphing: boolean;
  25832. /**
  25833. * Gets or sets a boolean indicating if tangents must be morphed
  25834. */
  25835. enableTangentMorphing: boolean;
  25836. /**
  25837. * Gets or sets a boolean indicating if UV must be morphed
  25838. */
  25839. enableUVMorphing: boolean;
  25840. /**
  25841. * Creates a new MorphTargetManager
  25842. * @param scene defines the current scene
  25843. */
  25844. constructor(scene?: Nullable<Scene>);
  25845. /**
  25846. * Gets the unique ID of this manager
  25847. */
  25848. get uniqueId(): number;
  25849. /**
  25850. * Gets the number of vertices handled by this manager
  25851. */
  25852. get vertexCount(): number;
  25853. /**
  25854. * Gets a boolean indicating if this manager supports morphing of normals
  25855. */
  25856. get supportsNormals(): boolean;
  25857. /**
  25858. * Gets a boolean indicating if this manager supports morphing of tangents
  25859. */
  25860. get supportsTangents(): boolean;
  25861. /**
  25862. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25863. */
  25864. get supportsUVs(): boolean;
  25865. /**
  25866. * Gets the number of targets stored in this manager
  25867. */
  25868. get numTargets(): number;
  25869. /**
  25870. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25871. */
  25872. get numInfluencers(): number;
  25873. /**
  25874. * Gets the list of influences (one per target)
  25875. */
  25876. get influences(): Float32Array;
  25877. /**
  25878. * Gets the active target at specified index. An active target is a target with an influence > 0
  25879. * @param index defines the index to check
  25880. * @returns the requested target
  25881. */
  25882. getActiveTarget(index: number): MorphTarget;
  25883. /**
  25884. * Gets the target at specified index
  25885. * @param index defines the index to check
  25886. * @returns the requested target
  25887. */
  25888. getTarget(index: number): MorphTarget;
  25889. /**
  25890. * Add a new target to this manager
  25891. * @param target defines the target to add
  25892. */
  25893. addTarget(target: MorphTarget): void;
  25894. /**
  25895. * Removes a target from the manager
  25896. * @param target defines the target to remove
  25897. */
  25898. removeTarget(target: MorphTarget): void;
  25899. /**
  25900. * Clone the current manager
  25901. * @returns a new MorphTargetManager
  25902. */
  25903. clone(): MorphTargetManager;
  25904. /**
  25905. * Serializes the current manager into a Serialization object
  25906. * @returns the serialized object
  25907. */
  25908. serialize(): any;
  25909. private _syncActiveTargets;
  25910. /**
  25911. * Syncrhonize the targets with all the meshes using this morph target manager
  25912. */
  25913. synchronize(): void;
  25914. /**
  25915. * Creates a new MorphTargetManager from serialized data
  25916. * @param serializationObject defines the serialized data
  25917. * @param scene defines the hosting scene
  25918. * @returns the new MorphTargetManager
  25919. */
  25920. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25921. }
  25922. }
  25923. declare module BABYLON {
  25924. /**
  25925. * Class used to represent a specific level of detail of a mesh
  25926. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25927. */
  25928. export class MeshLODLevel {
  25929. /** Defines the distance where this level should start being displayed */
  25930. distance: number;
  25931. /** Defines the mesh to use to render this level */
  25932. mesh: Nullable<Mesh>;
  25933. /**
  25934. * Creates a new LOD level
  25935. * @param distance defines the distance where this level should star being displayed
  25936. * @param mesh defines the mesh to use to render this level
  25937. */
  25938. constructor(
  25939. /** Defines the distance where this level should start being displayed */
  25940. distance: number,
  25941. /** Defines the mesh to use to render this level */
  25942. mesh: Nullable<Mesh>);
  25943. }
  25944. }
  25945. declare module BABYLON {
  25946. /**
  25947. * Mesh representing the gorund
  25948. */
  25949. export class GroundMesh extends Mesh {
  25950. /** If octree should be generated */
  25951. generateOctree: boolean;
  25952. private _heightQuads;
  25953. /** @hidden */
  25954. _subdivisionsX: number;
  25955. /** @hidden */
  25956. _subdivisionsY: number;
  25957. /** @hidden */
  25958. _width: number;
  25959. /** @hidden */
  25960. _height: number;
  25961. /** @hidden */
  25962. _minX: number;
  25963. /** @hidden */
  25964. _maxX: number;
  25965. /** @hidden */
  25966. _minZ: number;
  25967. /** @hidden */
  25968. _maxZ: number;
  25969. constructor(name: string, scene: Scene);
  25970. /**
  25971. * "GroundMesh"
  25972. * @returns "GroundMesh"
  25973. */
  25974. getClassName(): string;
  25975. /**
  25976. * The minimum of x and y subdivisions
  25977. */
  25978. get subdivisions(): number;
  25979. /**
  25980. * X subdivisions
  25981. */
  25982. get subdivisionsX(): number;
  25983. /**
  25984. * Y subdivisions
  25985. */
  25986. get subdivisionsY(): number;
  25987. /**
  25988. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25989. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25990. * @param chunksCount the number of subdivisions for x and y
  25991. * @param octreeBlocksSize (Default: 32)
  25992. */
  25993. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25994. /**
  25995. * Returns a height (y) value in the Worl system :
  25996. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25997. * @param x x coordinate
  25998. * @param z z coordinate
  25999. * @returns the ground y position if (x, z) are outside the ground surface.
  26000. */
  26001. getHeightAtCoordinates(x: number, z: number): number;
  26002. /**
  26003. * Returns a normalized vector (Vector3) orthogonal to the ground
  26004. * at the ground coordinates (x, z) expressed in the World system.
  26005. * @param x x coordinate
  26006. * @param z z coordinate
  26007. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26008. */
  26009. getNormalAtCoordinates(x: number, z: number): Vector3;
  26010. /**
  26011. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26012. * at the ground coordinates (x, z) expressed in the World system.
  26013. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26014. * @param x x coordinate
  26015. * @param z z coordinate
  26016. * @param ref vector to store the result
  26017. * @returns the GroundMesh.
  26018. */
  26019. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26020. /**
  26021. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26022. * if the ground has been updated.
  26023. * This can be used in the render loop.
  26024. * @returns the GroundMesh.
  26025. */
  26026. updateCoordinateHeights(): GroundMesh;
  26027. private _getFacetAt;
  26028. private _initHeightQuads;
  26029. private _computeHeightQuads;
  26030. /**
  26031. * Serializes this ground mesh
  26032. * @param serializationObject object to write serialization to
  26033. */
  26034. serialize(serializationObject: any): void;
  26035. /**
  26036. * Parses a serialized ground mesh
  26037. * @param parsedMesh the serialized mesh
  26038. * @param scene the scene to create the ground mesh in
  26039. * @returns the created ground mesh
  26040. */
  26041. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26042. }
  26043. }
  26044. declare module BABYLON {
  26045. /**
  26046. * Interface for Physics-Joint data
  26047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26048. */
  26049. export interface PhysicsJointData {
  26050. /**
  26051. * The main pivot of the joint
  26052. */
  26053. mainPivot?: Vector3;
  26054. /**
  26055. * The connected pivot of the joint
  26056. */
  26057. connectedPivot?: Vector3;
  26058. /**
  26059. * The main axis of the joint
  26060. */
  26061. mainAxis?: Vector3;
  26062. /**
  26063. * The connected axis of the joint
  26064. */
  26065. connectedAxis?: Vector3;
  26066. /**
  26067. * The collision of the joint
  26068. */
  26069. collision?: boolean;
  26070. /**
  26071. * Native Oimo/Cannon/Energy data
  26072. */
  26073. nativeParams?: any;
  26074. }
  26075. /**
  26076. * This is a holder class for the physics joint created by the physics plugin
  26077. * It holds a set of functions to control the underlying joint
  26078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26079. */
  26080. export class PhysicsJoint {
  26081. /**
  26082. * The type of the physics joint
  26083. */
  26084. type: number;
  26085. /**
  26086. * The data for the physics joint
  26087. */
  26088. jointData: PhysicsJointData;
  26089. private _physicsJoint;
  26090. protected _physicsPlugin: IPhysicsEnginePlugin;
  26091. /**
  26092. * Initializes the physics joint
  26093. * @param type The type of the physics joint
  26094. * @param jointData The data for the physics joint
  26095. */
  26096. constructor(
  26097. /**
  26098. * The type of the physics joint
  26099. */
  26100. type: number,
  26101. /**
  26102. * The data for the physics joint
  26103. */
  26104. jointData: PhysicsJointData);
  26105. /**
  26106. * Gets the physics joint
  26107. */
  26108. get physicsJoint(): any;
  26109. /**
  26110. * Sets the physics joint
  26111. */
  26112. set physicsJoint(newJoint: any);
  26113. /**
  26114. * Sets the physics plugin
  26115. */
  26116. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26117. /**
  26118. * Execute a function that is physics-plugin specific.
  26119. * @param {Function} func the function that will be executed.
  26120. * It accepts two parameters: the physics world and the physics joint
  26121. */
  26122. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26123. /**
  26124. * Distance-Joint type
  26125. */
  26126. static DistanceJoint: number;
  26127. /**
  26128. * Hinge-Joint type
  26129. */
  26130. static HingeJoint: number;
  26131. /**
  26132. * Ball-and-Socket joint type
  26133. */
  26134. static BallAndSocketJoint: number;
  26135. /**
  26136. * Wheel-Joint type
  26137. */
  26138. static WheelJoint: number;
  26139. /**
  26140. * Slider-Joint type
  26141. */
  26142. static SliderJoint: number;
  26143. /**
  26144. * Prismatic-Joint type
  26145. */
  26146. static PrismaticJoint: number;
  26147. /**
  26148. * Universal-Joint type
  26149. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26150. */
  26151. static UniversalJoint: number;
  26152. /**
  26153. * Hinge-Joint 2 type
  26154. */
  26155. static Hinge2Joint: number;
  26156. /**
  26157. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26158. */
  26159. static PointToPointJoint: number;
  26160. /**
  26161. * Spring-Joint type
  26162. */
  26163. static SpringJoint: number;
  26164. /**
  26165. * Lock-Joint type
  26166. */
  26167. static LockJoint: number;
  26168. }
  26169. /**
  26170. * A class representing a physics distance joint
  26171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26172. */
  26173. export class DistanceJoint extends PhysicsJoint {
  26174. /**
  26175. *
  26176. * @param jointData The data for the Distance-Joint
  26177. */
  26178. constructor(jointData: DistanceJointData);
  26179. /**
  26180. * Update the predefined distance.
  26181. * @param maxDistance The maximum preferred distance
  26182. * @param minDistance The minimum preferred distance
  26183. */
  26184. updateDistance(maxDistance: number, minDistance?: number): void;
  26185. }
  26186. /**
  26187. * Represents a Motor-Enabled Joint
  26188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26189. */
  26190. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26191. /**
  26192. * Initializes the Motor-Enabled Joint
  26193. * @param type The type of the joint
  26194. * @param jointData The physica joint data for the joint
  26195. */
  26196. constructor(type: number, jointData: PhysicsJointData);
  26197. /**
  26198. * Set the motor values.
  26199. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26200. * @param force the force to apply
  26201. * @param maxForce max force for this motor.
  26202. */
  26203. setMotor(force?: number, maxForce?: number): void;
  26204. /**
  26205. * Set the motor's limits.
  26206. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26207. * @param upperLimit The upper limit of the motor
  26208. * @param lowerLimit The lower limit of the motor
  26209. */
  26210. setLimit(upperLimit: number, lowerLimit?: number): void;
  26211. }
  26212. /**
  26213. * This class represents a single physics Hinge-Joint
  26214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26215. */
  26216. export class HingeJoint extends MotorEnabledJoint {
  26217. /**
  26218. * Initializes the Hinge-Joint
  26219. * @param jointData The joint data for the Hinge-Joint
  26220. */
  26221. constructor(jointData: PhysicsJointData);
  26222. /**
  26223. * Set the motor values.
  26224. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26225. * @param {number} force the force to apply
  26226. * @param {number} maxForce max force for this motor.
  26227. */
  26228. setMotor(force?: number, maxForce?: number): void;
  26229. /**
  26230. * Set the motor's limits.
  26231. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26232. * @param upperLimit The upper limit of the motor
  26233. * @param lowerLimit The lower limit of the motor
  26234. */
  26235. setLimit(upperLimit: number, lowerLimit?: number): void;
  26236. }
  26237. /**
  26238. * This class represents a dual hinge physics joint (same as wheel joint)
  26239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26240. */
  26241. export class Hinge2Joint extends MotorEnabledJoint {
  26242. /**
  26243. * Initializes the Hinge2-Joint
  26244. * @param jointData The joint data for the Hinge2-Joint
  26245. */
  26246. constructor(jointData: PhysicsJointData);
  26247. /**
  26248. * Set the motor values.
  26249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26250. * @param {number} targetSpeed the speed the motor is to reach
  26251. * @param {number} maxForce max force for this motor.
  26252. * @param {motorIndex} the motor's index, 0 or 1.
  26253. */
  26254. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26255. /**
  26256. * Set the motor limits.
  26257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26258. * @param {number} upperLimit the upper limit
  26259. * @param {number} lowerLimit lower limit
  26260. * @param {motorIndex} the motor's index, 0 or 1.
  26261. */
  26262. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26263. }
  26264. /**
  26265. * Interface for a motor enabled joint
  26266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26267. */
  26268. export interface IMotorEnabledJoint {
  26269. /**
  26270. * Physics joint
  26271. */
  26272. physicsJoint: any;
  26273. /**
  26274. * Sets the motor of the motor-enabled joint
  26275. * @param force The force of the motor
  26276. * @param maxForce The maximum force of the motor
  26277. * @param motorIndex The index of the motor
  26278. */
  26279. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26280. /**
  26281. * Sets the limit of the motor
  26282. * @param upperLimit The upper limit of the motor
  26283. * @param lowerLimit The lower limit of the motor
  26284. * @param motorIndex The index of the motor
  26285. */
  26286. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26287. }
  26288. /**
  26289. * Joint data for a Distance-Joint
  26290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26291. */
  26292. export interface DistanceJointData extends PhysicsJointData {
  26293. /**
  26294. * Max distance the 2 joint objects can be apart
  26295. */
  26296. maxDistance: number;
  26297. }
  26298. /**
  26299. * Joint data from a spring joint
  26300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26301. */
  26302. export interface SpringJointData extends PhysicsJointData {
  26303. /**
  26304. * Length of the spring
  26305. */
  26306. length: number;
  26307. /**
  26308. * Stiffness of the spring
  26309. */
  26310. stiffness: number;
  26311. /**
  26312. * Damping of the spring
  26313. */
  26314. damping: number;
  26315. /** this callback will be called when applying the force to the impostors. */
  26316. forceApplicationCallback: () => void;
  26317. }
  26318. }
  26319. declare module BABYLON {
  26320. /**
  26321. * Holds the data for the raycast result
  26322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26323. */
  26324. export class PhysicsRaycastResult {
  26325. private _hasHit;
  26326. private _hitDistance;
  26327. private _hitNormalWorld;
  26328. private _hitPointWorld;
  26329. private _rayFromWorld;
  26330. private _rayToWorld;
  26331. /**
  26332. * Gets if there was a hit
  26333. */
  26334. get hasHit(): boolean;
  26335. /**
  26336. * Gets the distance from the hit
  26337. */
  26338. get hitDistance(): number;
  26339. /**
  26340. * Gets the hit normal/direction in the world
  26341. */
  26342. get hitNormalWorld(): Vector3;
  26343. /**
  26344. * Gets the hit point in the world
  26345. */
  26346. get hitPointWorld(): Vector3;
  26347. /**
  26348. * Gets the ray "start point" of the ray in the world
  26349. */
  26350. get rayFromWorld(): Vector3;
  26351. /**
  26352. * Gets the ray "end point" of the ray in the world
  26353. */
  26354. get rayToWorld(): Vector3;
  26355. /**
  26356. * Sets the hit data (normal & point in world space)
  26357. * @param hitNormalWorld defines the normal in world space
  26358. * @param hitPointWorld defines the point in world space
  26359. */
  26360. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26361. /**
  26362. * Sets the distance from the start point to the hit point
  26363. * @param distance
  26364. */
  26365. setHitDistance(distance: number): void;
  26366. /**
  26367. * Calculates the distance manually
  26368. */
  26369. calculateHitDistance(): void;
  26370. /**
  26371. * Resets all the values to default
  26372. * @param from The from point on world space
  26373. * @param to The to point on world space
  26374. */
  26375. reset(from?: Vector3, to?: Vector3): void;
  26376. }
  26377. /**
  26378. * Interface for the size containing width and height
  26379. */
  26380. interface IXYZ {
  26381. /**
  26382. * X
  26383. */
  26384. x: number;
  26385. /**
  26386. * Y
  26387. */
  26388. y: number;
  26389. /**
  26390. * Z
  26391. */
  26392. z: number;
  26393. }
  26394. }
  26395. declare module BABYLON {
  26396. /**
  26397. * Interface used to describe a physics joint
  26398. */
  26399. export interface PhysicsImpostorJoint {
  26400. /** Defines the main impostor to which the joint is linked */
  26401. mainImpostor: PhysicsImpostor;
  26402. /** Defines the impostor that is connected to the main impostor using this joint */
  26403. connectedImpostor: PhysicsImpostor;
  26404. /** Defines the joint itself */
  26405. joint: PhysicsJoint;
  26406. }
  26407. /** @hidden */
  26408. export interface IPhysicsEnginePlugin {
  26409. world: any;
  26410. name: string;
  26411. setGravity(gravity: Vector3): void;
  26412. setTimeStep(timeStep: number): void;
  26413. getTimeStep(): number;
  26414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26415. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26416. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26417. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26418. removePhysicsBody(impostor: PhysicsImpostor): void;
  26419. generateJoint(joint: PhysicsImpostorJoint): void;
  26420. removeJoint(joint: PhysicsImpostorJoint): void;
  26421. isSupported(): boolean;
  26422. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26423. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26424. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26425. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26426. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26427. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26428. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26429. getBodyMass(impostor: PhysicsImpostor): number;
  26430. getBodyFriction(impostor: PhysicsImpostor): number;
  26431. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26432. getBodyRestitution(impostor: PhysicsImpostor): number;
  26433. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26434. getBodyPressure?(impostor: PhysicsImpostor): number;
  26435. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26436. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26437. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26438. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26439. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26440. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26441. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26442. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26443. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26444. sleepBody(impostor: PhysicsImpostor): void;
  26445. wakeUpBody(impostor: PhysicsImpostor): void;
  26446. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26447. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26448. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26449. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26450. getRadius(impostor: PhysicsImpostor): number;
  26451. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26452. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26453. dispose(): void;
  26454. }
  26455. /**
  26456. * Interface used to define a physics engine
  26457. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26458. */
  26459. export interface IPhysicsEngine {
  26460. /**
  26461. * Gets the gravity vector used by the simulation
  26462. */
  26463. gravity: Vector3;
  26464. /**
  26465. * Sets the gravity vector used by the simulation
  26466. * @param gravity defines the gravity vector to use
  26467. */
  26468. setGravity(gravity: Vector3): void;
  26469. /**
  26470. * Set the time step of the physics engine.
  26471. * Default is 1/60.
  26472. * To slow it down, enter 1/600 for example.
  26473. * To speed it up, 1/30
  26474. * @param newTimeStep the new timestep to apply to this world.
  26475. */
  26476. setTimeStep(newTimeStep: number): void;
  26477. /**
  26478. * Get the time step of the physics engine.
  26479. * @returns the current time step
  26480. */
  26481. getTimeStep(): number;
  26482. /**
  26483. * Set the sub time step of the physics engine.
  26484. * Default is 0 meaning there is no sub steps
  26485. * To increase physics resolution precision, set a small value (like 1 ms)
  26486. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26487. */
  26488. setSubTimeStep(subTimeStep: number): void;
  26489. /**
  26490. * Get the sub time step of the physics engine.
  26491. * @returns the current sub time step
  26492. */
  26493. getSubTimeStep(): number;
  26494. /**
  26495. * Release all resources
  26496. */
  26497. dispose(): void;
  26498. /**
  26499. * Gets the name of the current physics plugin
  26500. * @returns the name of the plugin
  26501. */
  26502. getPhysicsPluginName(): string;
  26503. /**
  26504. * Adding a new impostor for the impostor tracking.
  26505. * This will be done by the impostor itself.
  26506. * @param impostor the impostor to add
  26507. */
  26508. addImpostor(impostor: PhysicsImpostor): void;
  26509. /**
  26510. * Remove an impostor from the engine.
  26511. * This impostor and its mesh will not longer be updated by the physics engine.
  26512. * @param impostor the impostor to remove
  26513. */
  26514. removeImpostor(impostor: PhysicsImpostor): void;
  26515. /**
  26516. * Add a joint to the physics engine
  26517. * @param mainImpostor defines the main impostor to which the joint is added.
  26518. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26519. * @param joint defines the joint that will connect both impostors.
  26520. */
  26521. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26522. /**
  26523. * Removes a joint from the simulation
  26524. * @param mainImpostor defines the impostor used with the joint
  26525. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26526. * @param joint defines the joint to remove
  26527. */
  26528. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26529. /**
  26530. * Gets the current plugin used to run the simulation
  26531. * @returns current plugin
  26532. */
  26533. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26534. /**
  26535. * Gets the list of physic impostors
  26536. * @returns an array of PhysicsImpostor
  26537. */
  26538. getImpostors(): Array<PhysicsImpostor>;
  26539. /**
  26540. * Gets the impostor for a physics enabled object
  26541. * @param object defines the object impersonated by the impostor
  26542. * @returns the PhysicsImpostor or null if not found
  26543. */
  26544. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26545. /**
  26546. * Gets the impostor for a physics body object
  26547. * @param body defines physics body used by the impostor
  26548. * @returns the PhysicsImpostor or null if not found
  26549. */
  26550. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26551. /**
  26552. * Does a raycast in the physics world
  26553. * @param from when should the ray start?
  26554. * @param to when should the ray end?
  26555. * @returns PhysicsRaycastResult
  26556. */
  26557. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26558. /**
  26559. * Called by the scene. No need to call it.
  26560. * @param delta defines the timespam between frames
  26561. */
  26562. _step(delta: number): void;
  26563. }
  26564. }
  26565. declare module BABYLON {
  26566. /**
  26567. * The interface for the physics imposter parameters
  26568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26569. */
  26570. export interface PhysicsImpostorParameters {
  26571. /**
  26572. * The mass of the physics imposter
  26573. */
  26574. mass: number;
  26575. /**
  26576. * The friction of the physics imposter
  26577. */
  26578. friction?: number;
  26579. /**
  26580. * The coefficient of restitution of the physics imposter
  26581. */
  26582. restitution?: number;
  26583. /**
  26584. * The native options of the physics imposter
  26585. */
  26586. nativeOptions?: any;
  26587. /**
  26588. * Specifies if the parent should be ignored
  26589. */
  26590. ignoreParent?: boolean;
  26591. /**
  26592. * Specifies if bi-directional transformations should be disabled
  26593. */
  26594. disableBidirectionalTransformation?: boolean;
  26595. /**
  26596. * The pressure inside the physics imposter, soft object only
  26597. */
  26598. pressure?: number;
  26599. /**
  26600. * The stiffness the physics imposter, soft object only
  26601. */
  26602. stiffness?: number;
  26603. /**
  26604. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26605. */
  26606. velocityIterations?: number;
  26607. /**
  26608. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26609. */
  26610. positionIterations?: number;
  26611. /**
  26612. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26613. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26614. * Add to fix multiple points
  26615. */
  26616. fixedPoints?: number;
  26617. /**
  26618. * The collision margin around a soft object
  26619. */
  26620. margin?: number;
  26621. /**
  26622. * The collision margin around a soft object
  26623. */
  26624. damping?: number;
  26625. /**
  26626. * The path for a rope based on an extrusion
  26627. */
  26628. path?: any;
  26629. /**
  26630. * The shape of an extrusion used for a rope based on an extrusion
  26631. */
  26632. shape?: any;
  26633. }
  26634. /**
  26635. * Interface for a physics-enabled object
  26636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26637. */
  26638. export interface IPhysicsEnabledObject {
  26639. /**
  26640. * The position of the physics-enabled object
  26641. */
  26642. position: Vector3;
  26643. /**
  26644. * The rotation of the physics-enabled object
  26645. */
  26646. rotationQuaternion: Nullable<Quaternion>;
  26647. /**
  26648. * The scale of the physics-enabled object
  26649. */
  26650. scaling: Vector3;
  26651. /**
  26652. * The rotation of the physics-enabled object
  26653. */
  26654. rotation?: Vector3;
  26655. /**
  26656. * The parent of the physics-enabled object
  26657. */
  26658. parent?: any;
  26659. /**
  26660. * The bounding info of the physics-enabled object
  26661. * @returns The bounding info of the physics-enabled object
  26662. */
  26663. getBoundingInfo(): BoundingInfo;
  26664. /**
  26665. * Computes the world matrix
  26666. * @param force Specifies if the world matrix should be computed by force
  26667. * @returns A world matrix
  26668. */
  26669. computeWorldMatrix(force: boolean): Matrix;
  26670. /**
  26671. * Gets the world matrix
  26672. * @returns A world matrix
  26673. */
  26674. getWorldMatrix?(): Matrix;
  26675. /**
  26676. * Gets the child meshes
  26677. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26678. * @returns An array of abstract meshes
  26679. */
  26680. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26681. /**
  26682. * Gets the vertex data
  26683. * @param kind The type of vertex data
  26684. * @returns A nullable array of numbers, or a float32 array
  26685. */
  26686. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26687. /**
  26688. * Gets the indices from the mesh
  26689. * @returns A nullable array of index arrays
  26690. */
  26691. getIndices?(): Nullable<IndicesArray>;
  26692. /**
  26693. * Gets the scene from the mesh
  26694. * @returns the indices array or null
  26695. */
  26696. getScene?(): Scene;
  26697. /**
  26698. * Gets the absolute position from the mesh
  26699. * @returns the absolute position
  26700. */
  26701. getAbsolutePosition(): Vector3;
  26702. /**
  26703. * Gets the absolute pivot point from the mesh
  26704. * @returns the absolute pivot point
  26705. */
  26706. getAbsolutePivotPoint(): Vector3;
  26707. /**
  26708. * Rotates the mesh
  26709. * @param axis The axis of rotation
  26710. * @param amount The amount of rotation
  26711. * @param space The space of the rotation
  26712. * @returns The rotation transform node
  26713. */
  26714. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26715. /**
  26716. * Translates the mesh
  26717. * @param axis The axis of translation
  26718. * @param distance The distance of translation
  26719. * @param space The space of the translation
  26720. * @returns The transform node
  26721. */
  26722. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26723. /**
  26724. * Sets the absolute position of the mesh
  26725. * @param absolutePosition The absolute position of the mesh
  26726. * @returns The transform node
  26727. */
  26728. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26729. /**
  26730. * Gets the class name of the mesh
  26731. * @returns The class name
  26732. */
  26733. getClassName(): string;
  26734. }
  26735. /**
  26736. * Represents a physics imposter
  26737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26738. */
  26739. export class PhysicsImpostor {
  26740. /**
  26741. * The physics-enabled object used as the physics imposter
  26742. */
  26743. object: IPhysicsEnabledObject;
  26744. /**
  26745. * The type of the physics imposter
  26746. */
  26747. type: number;
  26748. private _options;
  26749. private _scene?;
  26750. /**
  26751. * The default object size of the imposter
  26752. */
  26753. static DEFAULT_OBJECT_SIZE: Vector3;
  26754. /**
  26755. * The identity quaternion of the imposter
  26756. */
  26757. static IDENTITY_QUATERNION: Quaternion;
  26758. /** @hidden */
  26759. _pluginData: any;
  26760. private _physicsEngine;
  26761. private _physicsBody;
  26762. private _bodyUpdateRequired;
  26763. private _onBeforePhysicsStepCallbacks;
  26764. private _onAfterPhysicsStepCallbacks;
  26765. /** @hidden */
  26766. _onPhysicsCollideCallbacks: Array<{
  26767. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26768. otherImpostors: Array<PhysicsImpostor>;
  26769. }>;
  26770. private _deltaPosition;
  26771. private _deltaRotation;
  26772. private _deltaRotationConjugated;
  26773. /** @hidden */
  26774. _isFromLine: boolean;
  26775. private _parent;
  26776. private _isDisposed;
  26777. private static _tmpVecs;
  26778. private static _tmpQuat;
  26779. /**
  26780. * Specifies if the physics imposter is disposed
  26781. */
  26782. get isDisposed(): boolean;
  26783. /**
  26784. * Gets the mass of the physics imposter
  26785. */
  26786. get mass(): number;
  26787. set mass(value: number);
  26788. /**
  26789. * Gets the coefficient of friction
  26790. */
  26791. get friction(): number;
  26792. /**
  26793. * Sets the coefficient of friction
  26794. */
  26795. set friction(value: number);
  26796. /**
  26797. * Gets the coefficient of restitution
  26798. */
  26799. get restitution(): number;
  26800. /**
  26801. * Sets the coefficient of restitution
  26802. */
  26803. set restitution(value: number);
  26804. /**
  26805. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26806. */
  26807. get pressure(): number;
  26808. /**
  26809. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26810. */
  26811. set pressure(value: number);
  26812. /**
  26813. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26814. */
  26815. get stiffness(): number;
  26816. /**
  26817. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26818. */
  26819. set stiffness(value: number);
  26820. /**
  26821. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26822. */
  26823. get velocityIterations(): number;
  26824. /**
  26825. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26826. */
  26827. set velocityIterations(value: number);
  26828. /**
  26829. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26830. */
  26831. get positionIterations(): number;
  26832. /**
  26833. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26834. */
  26835. set positionIterations(value: number);
  26836. /**
  26837. * The unique id of the physics imposter
  26838. * set by the physics engine when adding this impostor to the array
  26839. */
  26840. uniqueId: number;
  26841. /**
  26842. * @hidden
  26843. */
  26844. soft: boolean;
  26845. /**
  26846. * @hidden
  26847. */
  26848. segments: number;
  26849. private _joints;
  26850. /**
  26851. * Initializes the physics imposter
  26852. * @param object The physics-enabled object used as the physics imposter
  26853. * @param type The type of the physics imposter
  26854. * @param _options The options for the physics imposter
  26855. * @param _scene The Babylon scene
  26856. */
  26857. constructor(
  26858. /**
  26859. * The physics-enabled object used as the physics imposter
  26860. */
  26861. object: IPhysicsEnabledObject,
  26862. /**
  26863. * The type of the physics imposter
  26864. */
  26865. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26866. /**
  26867. * This function will completly initialize this impostor.
  26868. * It will create a new body - but only if this mesh has no parent.
  26869. * If it has, this impostor will not be used other than to define the impostor
  26870. * of the child mesh.
  26871. * @hidden
  26872. */
  26873. _init(): void;
  26874. private _getPhysicsParent;
  26875. /**
  26876. * Should a new body be generated.
  26877. * @returns boolean specifying if body initialization is required
  26878. */
  26879. isBodyInitRequired(): boolean;
  26880. /**
  26881. * Sets the updated scaling
  26882. * @param updated Specifies if the scaling is updated
  26883. */
  26884. setScalingUpdated(): void;
  26885. /**
  26886. * Force a regeneration of this or the parent's impostor's body.
  26887. * Use under cautious - This will remove all joints already implemented.
  26888. */
  26889. forceUpdate(): void;
  26890. /**
  26891. * Gets the body that holds this impostor. Either its own, or its parent.
  26892. */
  26893. get physicsBody(): any;
  26894. /**
  26895. * Get the parent of the physics imposter
  26896. * @returns Physics imposter or null
  26897. */
  26898. get parent(): Nullable<PhysicsImpostor>;
  26899. /**
  26900. * Sets the parent of the physics imposter
  26901. */
  26902. set parent(value: Nullable<PhysicsImpostor>);
  26903. /**
  26904. * Set the physics body. Used mainly by the physics engine/plugin
  26905. */
  26906. set physicsBody(physicsBody: any);
  26907. /**
  26908. * Resets the update flags
  26909. */
  26910. resetUpdateFlags(): void;
  26911. /**
  26912. * Gets the object extend size
  26913. * @returns the object extend size
  26914. */
  26915. getObjectExtendSize(): Vector3;
  26916. /**
  26917. * Gets the object center
  26918. * @returns The object center
  26919. */
  26920. getObjectCenter(): Vector3;
  26921. /**
  26922. * Get a specific parameter from the options parameters
  26923. * @param paramName The object parameter name
  26924. * @returns The object parameter
  26925. */
  26926. getParam(paramName: string): any;
  26927. /**
  26928. * Sets a specific parameter in the options given to the physics plugin
  26929. * @param paramName The parameter name
  26930. * @param value The value of the parameter
  26931. */
  26932. setParam(paramName: string, value: number): void;
  26933. /**
  26934. * Specifically change the body's mass option. Won't recreate the physics body object
  26935. * @param mass The mass of the physics imposter
  26936. */
  26937. setMass(mass: number): void;
  26938. /**
  26939. * Gets the linear velocity
  26940. * @returns linear velocity or null
  26941. */
  26942. getLinearVelocity(): Nullable<Vector3>;
  26943. /**
  26944. * Sets the linear velocity
  26945. * @param velocity linear velocity or null
  26946. */
  26947. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26948. /**
  26949. * Gets the angular velocity
  26950. * @returns angular velocity or null
  26951. */
  26952. getAngularVelocity(): Nullable<Vector3>;
  26953. /**
  26954. * Sets the angular velocity
  26955. * @param velocity The velocity or null
  26956. */
  26957. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26958. /**
  26959. * Execute a function with the physics plugin native code
  26960. * Provide a function the will have two variables - the world object and the physics body object
  26961. * @param func The function to execute with the physics plugin native code
  26962. */
  26963. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26964. /**
  26965. * Register a function that will be executed before the physics world is stepping forward
  26966. * @param func The function to execute before the physics world is stepped forward
  26967. */
  26968. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26969. /**
  26970. * Unregister a function that will be executed before the physics world is stepping forward
  26971. * @param func The function to execute before the physics world is stepped forward
  26972. */
  26973. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26974. /**
  26975. * Register a function that will be executed after the physics step
  26976. * @param func The function to execute after physics step
  26977. */
  26978. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26979. /**
  26980. * Unregisters a function that will be executed after the physics step
  26981. * @param func The function to execute after physics step
  26982. */
  26983. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26984. /**
  26985. * register a function that will be executed when this impostor collides against a different body
  26986. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26987. * @param func Callback that is executed on collision
  26988. */
  26989. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26990. /**
  26991. * Unregisters the physics imposter on contact
  26992. * @param collideAgainst The physics object to collide against
  26993. * @param func Callback to execute on collision
  26994. */
  26995. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26996. private _tmpQuat;
  26997. private _tmpQuat2;
  26998. /**
  26999. * Get the parent rotation
  27000. * @returns The parent rotation
  27001. */
  27002. getParentsRotation(): Quaternion;
  27003. /**
  27004. * this function is executed by the physics engine.
  27005. */
  27006. beforeStep: () => void;
  27007. /**
  27008. * this function is executed by the physics engine
  27009. */
  27010. afterStep: () => void;
  27011. /**
  27012. * Legacy collision detection event support
  27013. */
  27014. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27015. /**
  27016. * event and body object due to cannon's event-based architecture.
  27017. */
  27018. onCollide: (e: {
  27019. body: any;
  27020. }) => void;
  27021. /**
  27022. * Apply a force
  27023. * @param force The force to apply
  27024. * @param contactPoint The contact point for the force
  27025. * @returns The physics imposter
  27026. */
  27027. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27028. /**
  27029. * Apply an impulse
  27030. * @param force The impulse force
  27031. * @param contactPoint The contact point for the impulse force
  27032. * @returns The physics imposter
  27033. */
  27034. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27035. /**
  27036. * A help function to create a joint
  27037. * @param otherImpostor A physics imposter used to create a joint
  27038. * @param jointType The type of joint
  27039. * @param jointData The data for the joint
  27040. * @returns The physics imposter
  27041. */
  27042. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27043. /**
  27044. * Add a joint to this impostor with a different impostor
  27045. * @param otherImpostor A physics imposter used to add a joint
  27046. * @param joint The joint to add
  27047. * @returns The physics imposter
  27048. */
  27049. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27050. /**
  27051. * Add an anchor to a cloth impostor
  27052. * @param otherImpostor rigid impostor to anchor to
  27053. * @param width ratio across width from 0 to 1
  27054. * @param height ratio up height from 0 to 1
  27055. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27056. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27057. * @returns impostor the soft imposter
  27058. */
  27059. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27060. /**
  27061. * Add a hook to a rope impostor
  27062. * @param otherImpostor rigid impostor to anchor to
  27063. * @param length ratio across rope from 0 to 1
  27064. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27065. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27066. * @returns impostor the rope imposter
  27067. */
  27068. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27069. /**
  27070. * Will keep this body still, in a sleep mode.
  27071. * @returns the physics imposter
  27072. */
  27073. sleep(): PhysicsImpostor;
  27074. /**
  27075. * Wake the body up.
  27076. * @returns The physics imposter
  27077. */
  27078. wakeUp(): PhysicsImpostor;
  27079. /**
  27080. * Clones the physics imposter
  27081. * @param newObject The physics imposter clones to this physics-enabled object
  27082. * @returns A nullable physics imposter
  27083. */
  27084. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27085. /**
  27086. * Disposes the physics imposter
  27087. */
  27088. dispose(): void;
  27089. /**
  27090. * Sets the delta position
  27091. * @param position The delta position amount
  27092. */
  27093. setDeltaPosition(position: Vector3): void;
  27094. /**
  27095. * Sets the delta rotation
  27096. * @param rotation The delta rotation amount
  27097. */
  27098. setDeltaRotation(rotation: Quaternion): void;
  27099. /**
  27100. * Gets the box size of the physics imposter and stores the result in the input parameter
  27101. * @param result Stores the box size
  27102. * @returns The physics imposter
  27103. */
  27104. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27105. /**
  27106. * Gets the radius of the physics imposter
  27107. * @returns Radius of the physics imposter
  27108. */
  27109. getRadius(): number;
  27110. /**
  27111. * Sync a bone with this impostor
  27112. * @param bone The bone to sync to the impostor.
  27113. * @param boneMesh The mesh that the bone is influencing.
  27114. * @param jointPivot The pivot of the joint / bone in local space.
  27115. * @param distToJoint Optional distance from the impostor to the joint.
  27116. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27117. */
  27118. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27119. /**
  27120. * Sync impostor to a bone
  27121. * @param bone The bone that the impostor will be synced to.
  27122. * @param boneMesh The mesh that the bone is influencing.
  27123. * @param jointPivot The pivot of the joint / bone in local space.
  27124. * @param distToJoint Optional distance from the impostor to the joint.
  27125. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27126. * @param boneAxis Optional vector3 axis the bone is aligned with
  27127. */
  27128. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27129. /**
  27130. * No-Imposter type
  27131. */
  27132. static NoImpostor: number;
  27133. /**
  27134. * Sphere-Imposter type
  27135. */
  27136. static SphereImpostor: number;
  27137. /**
  27138. * Box-Imposter type
  27139. */
  27140. static BoxImpostor: number;
  27141. /**
  27142. * Plane-Imposter type
  27143. */
  27144. static PlaneImpostor: number;
  27145. /**
  27146. * Mesh-imposter type
  27147. */
  27148. static MeshImpostor: number;
  27149. /**
  27150. * Capsule-Impostor type (Ammo.js plugin only)
  27151. */
  27152. static CapsuleImpostor: number;
  27153. /**
  27154. * Cylinder-Imposter type
  27155. */
  27156. static CylinderImpostor: number;
  27157. /**
  27158. * Particle-Imposter type
  27159. */
  27160. static ParticleImpostor: number;
  27161. /**
  27162. * Heightmap-Imposter type
  27163. */
  27164. static HeightmapImpostor: number;
  27165. /**
  27166. * ConvexHull-Impostor type (Ammo.js plugin only)
  27167. */
  27168. static ConvexHullImpostor: number;
  27169. /**
  27170. * Custom-Imposter type (Ammo.js plugin only)
  27171. */
  27172. static CustomImpostor: number;
  27173. /**
  27174. * Rope-Imposter type
  27175. */
  27176. static RopeImpostor: number;
  27177. /**
  27178. * Cloth-Imposter type
  27179. */
  27180. static ClothImpostor: number;
  27181. /**
  27182. * Softbody-Imposter type
  27183. */
  27184. static SoftbodyImpostor: number;
  27185. }
  27186. }
  27187. declare module BABYLON {
  27188. /**
  27189. * @hidden
  27190. **/
  27191. export class _CreationDataStorage {
  27192. closePath?: boolean;
  27193. closeArray?: boolean;
  27194. idx: number[];
  27195. dashSize: number;
  27196. gapSize: number;
  27197. path3D: Path3D;
  27198. pathArray: Vector3[][];
  27199. arc: number;
  27200. radius: number;
  27201. cap: number;
  27202. tessellation: number;
  27203. }
  27204. /**
  27205. * @hidden
  27206. **/
  27207. class _InstanceDataStorage {
  27208. visibleInstances: any;
  27209. batchCache: _InstancesBatch;
  27210. instancesBufferSize: number;
  27211. instancesBuffer: Nullable<Buffer>;
  27212. instancesData: Float32Array;
  27213. overridenInstanceCount: number;
  27214. isFrozen: boolean;
  27215. previousBatch: Nullable<_InstancesBatch>;
  27216. hardwareInstancedRendering: boolean;
  27217. sideOrientation: number;
  27218. manualUpdate: boolean;
  27219. }
  27220. /**
  27221. * @hidden
  27222. **/
  27223. export class _InstancesBatch {
  27224. mustReturn: boolean;
  27225. visibleInstances: Nullable<InstancedMesh[]>[];
  27226. renderSelf: boolean[];
  27227. hardwareInstancedRendering: boolean[];
  27228. }
  27229. /**
  27230. * @hidden
  27231. **/
  27232. class _ThinInstanceDataStorage {
  27233. instancesCount: number;
  27234. matrixBuffer: Nullable<Buffer>;
  27235. matrixBufferSize: number;
  27236. matrixData: Nullable<Float32Array>;
  27237. boundingVectors: Array<Vector3>;
  27238. }
  27239. /**
  27240. * Class used to represent renderable models
  27241. */
  27242. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27243. /**
  27244. * Mesh side orientation : usually the external or front surface
  27245. */
  27246. static readonly FRONTSIDE: number;
  27247. /**
  27248. * Mesh side orientation : usually the internal or back surface
  27249. */
  27250. static readonly BACKSIDE: number;
  27251. /**
  27252. * Mesh side orientation : both internal and external or front and back surfaces
  27253. */
  27254. static readonly DOUBLESIDE: number;
  27255. /**
  27256. * Mesh side orientation : by default, `FRONTSIDE`
  27257. */
  27258. static readonly DEFAULTSIDE: number;
  27259. /**
  27260. * Mesh cap setting : no cap
  27261. */
  27262. static readonly NO_CAP: number;
  27263. /**
  27264. * Mesh cap setting : one cap at the beginning of the mesh
  27265. */
  27266. static readonly CAP_START: number;
  27267. /**
  27268. * Mesh cap setting : one cap at the end of the mesh
  27269. */
  27270. static readonly CAP_END: number;
  27271. /**
  27272. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27273. */
  27274. static readonly CAP_ALL: number;
  27275. /**
  27276. * Mesh pattern setting : no flip or rotate
  27277. */
  27278. static readonly NO_FLIP: number;
  27279. /**
  27280. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27281. */
  27282. static readonly FLIP_TILE: number;
  27283. /**
  27284. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27285. */
  27286. static readonly ROTATE_TILE: number;
  27287. /**
  27288. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27289. */
  27290. static readonly FLIP_ROW: number;
  27291. /**
  27292. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27293. */
  27294. static readonly ROTATE_ROW: number;
  27295. /**
  27296. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27297. */
  27298. static readonly FLIP_N_ROTATE_TILE: number;
  27299. /**
  27300. * Mesh pattern setting : rotate pattern and rotate
  27301. */
  27302. static readonly FLIP_N_ROTATE_ROW: number;
  27303. /**
  27304. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27305. */
  27306. static readonly CENTER: number;
  27307. /**
  27308. * Mesh tile positioning : part tiles on left
  27309. */
  27310. static readonly LEFT: number;
  27311. /**
  27312. * Mesh tile positioning : part tiles on right
  27313. */
  27314. static readonly RIGHT: number;
  27315. /**
  27316. * Mesh tile positioning : part tiles on top
  27317. */
  27318. static readonly TOP: number;
  27319. /**
  27320. * Mesh tile positioning : part tiles on bottom
  27321. */
  27322. static readonly BOTTOM: number;
  27323. /**
  27324. * Gets the default side orientation.
  27325. * @param orientation the orientation to value to attempt to get
  27326. * @returns the default orientation
  27327. * @hidden
  27328. */
  27329. static _GetDefaultSideOrientation(orientation?: number): number;
  27330. private _internalMeshDataInfo;
  27331. /**
  27332. * An event triggered before rendering the mesh
  27333. */
  27334. get onBeforeRenderObservable(): Observable<Mesh>;
  27335. /**
  27336. * An event triggered before binding the mesh
  27337. */
  27338. get onBeforeBindObservable(): Observable<Mesh>;
  27339. /**
  27340. * An event triggered after rendering the mesh
  27341. */
  27342. get onAfterRenderObservable(): Observable<Mesh>;
  27343. /**
  27344. * An event triggered before drawing the mesh
  27345. */
  27346. get onBeforeDrawObservable(): Observable<Mesh>;
  27347. private _onBeforeDrawObserver;
  27348. /**
  27349. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27350. */
  27351. set onBeforeDraw(callback: () => void);
  27352. get hasInstances(): boolean;
  27353. get hasThinInstances(): boolean;
  27354. /**
  27355. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27356. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27357. */
  27358. delayLoadState: number;
  27359. /**
  27360. * Gets the list of instances created from this mesh
  27361. * it is not supposed to be modified manually.
  27362. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27363. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27364. */
  27365. instances: InstancedMesh[];
  27366. /**
  27367. * Gets the file containing delay loading data for this mesh
  27368. */
  27369. delayLoadingFile: string;
  27370. /** @hidden */
  27371. _binaryInfo: any;
  27372. /**
  27373. * User defined function used to change how LOD level selection is done
  27374. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27375. */
  27376. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27377. /**
  27378. * Gets or sets the morph target manager
  27379. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27380. */
  27381. get morphTargetManager(): Nullable<MorphTargetManager>;
  27382. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27383. /** @hidden */
  27384. _creationDataStorage: Nullable<_CreationDataStorage>;
  27385. /** @hidden */
  27386. _geometry: Nullable<Geometry>;
  27387. /** @hidden */
  27388. _delayInfo: Array<string>;
  27389. /** @hidden */
  27390. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27391. /** @hidden */
  27392. _instanceDataStorage: _InstanceDataStorage;
  27393. /** @hidden */
  27394. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27395. private _effectiveMaterial;
  27396. /** @hidden */
  27397. _shouldGenerateFlatShading: boolean;
  27398. /** @hidden */
  27399. _originalBuilderSideOrientation: number;
  27400. /**
  27401. * Use this property to change the original side orientation defined at construction time
  27402. */
  27403. overrideMaterialSideOrientation: Nullable<number>;
  27404. /**
  27405. * Gets the source mesh (the one used to clone this one from)
  27406. */
  27407. get source(): Nullable<Mesh>;
  27408. /**
  27409. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27410. */
  27411. get isUnIndexed(): boolean;
  27412. set isUnIndexed(value: boolean);
  27413. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27414. get worldMatrixInstancedBuffer(): Float32Array;
  27415. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27416. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27417. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27418. /**
  27419. * @constructor
  27420. * @param name The value used by scene.getMeshByName() to do a lookup.
  27421. * @param scene The scene to add this mesh to.
  27422. * @param parent The parent of this mesh, if it has one
  27423. * @param source An optional Mesh from which geometry is shared, cloned.
  27424. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27425. * When false, achieved by calling a clone(), also passing False.
  27426. * This will make creation of children, recursive.
  27427. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27428. */
  27429. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27430. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27431. doNotInstantiate: boolean;
  27432. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27433. /**
  27434. * Gets the class name
  27435. * @returns the string "Mesh".
  27436. */
  27437. getClassName(): string;
  27438. /** @hidden */
  27439. get _isMesh(): boolean;
  27440. /**
  27441. * Returns a description of this mesh
  27442. * @param fullDetails define if full details about this mesh must be used
  27443. * @returns a descriptive string representing this mesh
  27444. */
  27445. toString(fullDetails?: boolean): string;
  27446. /** @hidden */
  27447. _unBindEffect(): void;
  27448. /**
  27449. * Gets a boolean indicating if this mesh has LOD
  27450. */
  27451. get hasLODLevels(): boolean;
  27452. /**
  27453. * Gets the list of MeshLODLevel associated with the current mesh
  27454. * @returns an array of MeshLODLevel
  27455. */
  27456. getLODLevels(): MeshLODLevel[];
  27457. private _sortLODLevels;
  27458. /**
  27459. * Add a mesh as LOD level triggered at the given distance.
  27460. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27461. * @param distance The distance from the center of the object to show this level
  27462. * @param mesh The mesh to be added as LOD level (can be null)
  27463. * @return This mesh (for chaining)
  27464. */
  27465. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27466. /**
  27467. * Returns the LOD level mesh at the passed distance or null if not found.
  27468. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27469. * @param distance The distance from the center of the object to show this level
  27470. * @returns a Mesh or `null`
  27471. */
  27472. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27473. /**
  27474. * Remove a mesh from the LOD array
  27475. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27476. * @param mesh defines the mesh to be removed
  27477. * @return This mesh (for chaining)
  27478. */
  27479. removeLODLevel(mesh: Mesh): Mesh;
  27480. /**
  27481. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27482. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27483. * @param camera defines the camera to use to compute distance
  27484. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27485. * @return This mesh (for chaining)
  27486. */
  27487. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27488. /**
  27489. * Gets the mesh internal Geometry object
  27490. */
  27491. get geometry(): Nullable<Geometry>;
  27492. /**
  27493. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27494. * @returns the total number of vertices
  27495. */
  27496. getTotalVertices(): number;
  27497. /**
  27498. * Returns the content of an associated vertex buffer
  27499. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27500. * - VertexBuffer.PositionKind
  27501. * - VertexBuffer.UVKind
  27502. * - VertexBuffer.UV2Kind
  27503. * - VertexBuffer.UV3Kind
  27504. * - VertexBuffer.UV4Kind
  27505. * - VertexBuffer.UV5Kind
  27506. * - VertexBuffer.UV6Kind
  27507. * - VertexBuffer.ColorKind
  27508. * - VertexBuffer.MatricesIndicesKind
  27509. * - VertexBuffer.MatricesIndicesExtraKind
  27510. * - VertexBuffer.MatricesWeightsKind
  27511. * - VertexBuffer.MatricesWeightsExtraKind
  27512. * @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
  27513. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27514. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27515. */
  27516. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27517. /**
  27518. * Returns the mesh VertexBuffer object from the requested `kind`
  27519. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27520. * - VertexBuffer.PositionKind
  27521. * - VertexBuffer.NormalKind
  27522. * - VertexBuffer.UVKind
  27523. * - VertexBuffer.UV2Kind
  27524. * - VertexBuffer.UV3Kind
  27525. * - VertexBuffer.UV4Kind
  27526. * - VertexBuffer.UV5Kind
  27527. * - VertexBuffer.UV6Kind
  27528. * - VertexBuffer.ColorKind
  27529. * - VertexBuffer.MatricesIndicesKind
  27530. * - VertexBuffer.MatricesIndicesExtraKind
  27531. * - VertexBuffer.MatricesWeightsKind
  27532. * - VertexBuffer.MatricesWeightsExtraKind
  27533. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27534. */
  27535. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27536. /**
  27537. * Tests if a specific vertex buffer is associated with this mesh
  27538. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27539. * - VertexBuffer.PositionKind
  27540. * - VertexBuffer.NormalKind
  27541. * - VertexBuffer.UVKind
  27542. * - VertexBuffer.UV2Kind
  27543. * - VertexBuffer.UV3Kind
  27544. * - VertexBuffer.UV4Kind
  27545. * - VertexBuffer.UV5Kind
  27546. * - VertexBuffer.UV6Kind
  27547. * - VertexBuffer.ColorKind
  27548. * - VertexBuffer.MatricesIndicesKind
  27549. * - VertexBuffer.MatricesIndicesExtraKind
  27550. * - VertexBuffer.MatricesWeightsKind
  27551. * - VertexBuffer.MatricesWeightsExtraKind
  27552. * @returns a boolean
  27553. */
  27554. isVerticesDataPresent(kind: string): boolean;
  27555. /**
  27556. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27557. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27558. * - VertexBuffer.PositionKind
  27559. * - VertexBuffer.UVKind
  27560. * - VertexBuffer.UV2Kind
  27561. * - VertexBuffer.UV3Kind
  27562. * - VertexBuffer.UV4Kind
  27563. * - VertexBuffer.UV5Kind
  27564. * - VertexBuffer.UV6Kind
  27565. * - VertexBuffer.ColorKind
  27566. * - VertexBuffer.MatricesIndicesKind
  27567. * - VertexBuffer.MatricesIndicesExtraKind
  27568. * - VertexBuffer.MatricesWeightsKind
  27569. * - VertexBuffer.MatricesWeightsExtraKind
  27570. * @returns a boolean
  27571. */
  27572. isVertexBufferUpdatable(kind: string): boolean;
  27573. /**
  27574. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27575. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27576. * - VertexBuffer.PositionKind
  27577. * - VertexBuffer.NormalKind
  27578. * - VertexBuffer.UVKind
  27579. * - VertexBuffer.UV2Kind
  27580. * - VertexBuffer.UV3Kind
  27581. * - VertexBuffer.UV4Kind
  27582. * - VertexBuffer.UV5Kind
  27583. * - VertexBuffer.UV6Kind
  27584. * - VertexBuffer.ColorKind
  27585. * - VertexBuffer.MatricesIndicesKind
  27586. * - VertexBuffer.MatricesIndicesExtraKind
  27587. * - VertexBuffer.MatricesWeightsKind
  27588. * - VertexBuffer.MatricesWeightsExtraKind
  27589. * @returns an array of strings
  27590. */
  27591. getVerticesDataKinds(): string[];
  27592. /**
  27593. * Returns a positive integer : the total number of indices in this mesh geometry.
  27594. * @returns the numner of indices or zero if the mesh has no geometry.
  27595. */
  27596. getTotalIndices(): number;
  27597. /**
  27598. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27599. * @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.
  27600. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27601. * @returns the indices array or an empty array if the mesh has no geometry
  27602. */
  27603. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27604. get isBlocked(): boolean;
  27605. /**
  27606. * Determine if the current mesh is ready to be rendered
  27607. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27608. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27609. * @returns true if all associated assets are ready (material, textures, shaders)
  27610. */
  27611. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27612. /**
  27613. * 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.
  27614. */
  27615. get areNormalsFrozen(): boolean;
  27616. /**
  27617. * 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.
  27618. * @returns the current mesh
  27619. */
  27620. freezeNormals(): Mesh;
  27621. /**
  27622. * 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
  27623. * @returns the current mesh
  27624. */
  27625. unfreezeNormals(): Mesh;
  27626. /**
  27627. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27628. */
  27629. set overridenInstanceCount(count: number);
  27630. /** @hidden */
  27631. _preActivate(): Mesh;
  27632. /** @hidden */
  27633. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27634. /** @hidden */
  27635. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27636. protected _afterComputeWorldMatrix(): void;
  27637. /** @hidden */
  27638. _postActivate(): void;
  27639. /**
  27640. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27641. * This means the mesh underlying bounding box and sphere are recomputed.
  27642. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27643. * @returns the current mesh
  27644. */
  27645. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27646. /** @hidden */
  27647. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27648. /**
  27649. * This function will subdivide the mesh into multiple submeshes
  27650. * @param count defines the expected number of submeshes
  27651. */
  27652. subdivide(count: number): void;
  27653. /**
  27654. * Copy a FloatArray into a specific associated vertex buffer
  27655. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27656. * - VertexBuffer.PositionKind
  27657. * - VertexBuffer.UVKind
  27658. * - VertexBuffer.UV2Kind
  27659. * - VertexBuffer.UV3Kind
  27660. * - VertexBuffer.UV4Kind
  27661. * - VertexBuffer.UV5Kind
  27662. * - VertexBuffer.UV6Kind
  27663. * - VertexBuffer.ColorKind
  27664. * - VertexBuffer.MatricesIndicesKind
  27665. * - VertexBuffer.MatricesIndicesExtraKind
  27666. * - VertexBuffer.MatricesWeightsKind
  27667. * - VertexBuffer.MatricesWeightsExtraKind
  27668. * @param data defines the data source
  27669. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27670. * @param stride defines the data stride size (can be null)
  27671. * @returns the current mesh
  27672. */
  27673. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27674. /**
  27675. * Delete a vertex buffer associated with this mesh
  27676. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27677. * - VertexBuffer.PositionKind
  27678. * - VertexBuffer.UVKind
  27679. * - VertexBuffer.UV2Kind
  27680. * - VertexBuffer.UV3Kind
  27681. * - VertexBuffer.UV4Kind
  27682. * - VertexBuffer.UV5Kind
  27683. * - VertexBuffer.UV6Kind
  27684. * - VertexBuffer.ColorKind
  27685. * - VertexBuffer.MatricesIndicesKind
  27686. * - VertexBuffer.MatricesIndicesExtraKind
  27687. * - VertexBuffer.MatricesWeightsKind
  27688. * - VertexBuffer.MatricesWeightsExtraKind
  27689. */
  27690. removeVerticesData(kind: string): void;
  27691. /**
  27692. * Flags an associated vertex buffer as updatable
  27693. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27694. * - VertexBuffer.PositionKind
  27695. * - VertexBuffer.UVKind
  27696. * - VertexBuffer.UV2Kind
  27697. * - VertexBuffer.UV3Kind
  27698. * - VertexBuffer.UV4Kind
  27699. * - VertexBuffer.UV5Kind
  27700. * - VertexBuffer.UV6Kind
  27701. * - VertexBuffer.ColorKind
  27702. * - VertexBuffer.MatricesIndicesKind
  27703. * - VertexBuffer.MatricesIndicesExtraKind
  27704. * - VertexBuffer.MatricesWeightsKind
  27705. * - VertexBuffer.MatricesWeightsExtraKind
  27706. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27707. */
  27708. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27709. /**
  27710. * Sets the mesh global Vertex Buffer
  27711. * @param buffer defines the buffer to use
  27712. * @returns the current mesh
  27713. */
  27714. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27715. /**
  27716. * Update a specific associated vertex buffer
  27717. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27718. * - VertexBuffer.PositionKind
  27719. * - VertexBuffer.UVKind
  27720. * - VertexBuffer.UV2Kind
  27721. * - VertexBuffer.UV3Kind
  27722. * - VertexBuffer.UV4Kind
  27723. * - VertexBuffer.UV5Kind
  27724. * - VertexBuffer.UV6Kind
  27725. * - VertexBuffer.ColorKind
  27726. * - VertexBuffer.MatricesIndicesKind
  27727. * - VertexBuffer.MatricesIndicesExtraKind
  27728. * - VertexBuffer.MatricesWeightsKind
  27729. * - VertexBuffer.MatricesWeightsExtraKind
  27730. * @param data defines the data source
  27731. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27732. * @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)
  27733. * @returns the current mesh
  27734. */
  27735. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27736. /**
  27737. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27738. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27739. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27740. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27741. * @returns the current mesh
  27742. */
  27743. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27744. /**
  27745. * Creates a un-shared specific occurence of the geometry for the mesh.
  27746. * @returns the current mesh
  27747. */
  27748. makeGeometryUnique(): Mesh;
  27749. /**
  27750. * Set the index buffer of this mesh
  27751. * @param indices defines the source data
  27752. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27753. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27754. * @returns the current mesh
  27755. */
  27756. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27757. /**
  27758. * Update the current index buffer
  27759. * @param indices defines the source data
  27760. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27761. * @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)
  27762. * @returns the current mesh
  27763. */
  27764. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27765. /**
  27766. * Invert the geometry to move from a right handed system to a left handed one.
  27767. * @returns the current mesh
  27768. */
  27769. toLeftHanded(): Mesh;
  27770. /** @hidden */
  27771. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27772. /** @hidden */
  27773. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27774. /**
  27775. * Registers for this mesh a javascript function called just before the rendering process
  27776. * @param func defines the function to call before rendering this mesh
  27777. * @returns the current mesh
  27778. */
  27779. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27780. /**
  27781. * Disposes a previously registered javascript function called before the rendering
  27782. * @param func defines the function to remove
  27783. * @returns the current mesh
  27784. */
  27785. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27786. /**
  27787. * Registers for this mesh a javascript function called just after the rendering is complete
  27788. * @param func defines the function to call after rendering this mesh
  27789. * @returns the current mesh
  27790. */
  27791. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27792. /**
  27793. * Disposes a previously registered javascript function called after the rendering.
  27794. * @param func defines the function to remove
  27795. * @returns the current mesh
  27796. */
  27797. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27798. /** @hidden */
  27799. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27800. /** @hidden */
  27801. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27802. /** @hidden */
  27803. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27804. /** @hidden */
  27805. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27806. /** @hidden */
  27807. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27808. /** @hidden */
  27809. _rebuild(): void;
  27810. /** @hidden */
  27811. _freeze(): void;
  27812. /** @hidden */
  27813. _unFreeze(): void;
  27814. /**
  27815. * 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
  27816. * @param subMesh defines the subMesh to render
  27817. * @param enableAlphaMode defines if alpha mode can be changed
  27818. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27819. * @returns the current mesh
  27820. */
  27821. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27822. private _onBeforeDraw;
  27823. /**
  27824. * Renormalize the mesh and patch it up if there are no weights
  27825. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27826. * However in the case of zero weights then we set just a single influence to 1.
  27827. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27828. */
  27829. cleanMatrixWeights(): void;
  27830. private normalizeSkinFourWeights;
  27831. private normalizeSkinWeightsAndExtra;
  27832. /**
  27833. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27834. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27835. * the user know there was an issue with importing the mesh
  27836. * @returns a validation object with skinned, valid and report string
  27837. */
  27838. validateSkinning(): {
  27839. skinned: boolean;
  27840. valid: boolean;
  27841. report: string;
  27842. };
  27843. /** @hidden */
  27844. _checkDelayState(): Mesh;
  27845. private _queueLoad;
  27846. /**
  27847. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27848. * A mesh is in the frustum if its bounding box intersects the frustum
  27849. * @param frustumPlanes defines the frustum to test
  27850. * @returns true if the mesh is in the frustum planes
  27851. */
  27852. isInFrustum(frustumPlanes: Plane[]): boolean;
  27853. /**
  27854. * Sets the mesh material by the material or multiMaterial `id` property
  27855. * @param id is a string identifying the material or the multiMaterial
  27856. * @returns the current mesh
  27857. */
  27858. setMaterialByID(id: string): Mesh;
  27859. /**
  27860. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27861. * @returns an array of IAnimatable
  27862. */
  27863. getAnimatables(): IAnimatable[];
  27864. /**
  27865. * Modifies the mesh geometry according to the passed transformation matrix.
  27866. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27867. * The mesh normals are modified using the same transformation.
  27868. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27869. * @param transform defines the transform matrix to use
  27870. * @see http://doc.babylonjs.com/resources/baking_transformations
  27871. * @returns the current mesh
  27872. */
  27873. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27874. /**
  27875. * Modifies the mesh geometry according to its own current World Matrix.
  27876. * The mesh World Matrix is then reset.
  27877. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27878. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27879. * @see http://doc.babylonjs.com/resources/baking_transformations
  27880. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27881. * @returns the current mesh
  27882. */
  27883. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27884. /** @hidden */
  27885. get _positions(): Nullable<Vector3[]>;
  27886. /** @hidden */
  27887. _resetPointsArrayCache(): Mesh;
  27888. /** @hidden */
  27889. _generatePointsArray(): boolean;
  27890. /**
  27891. * Returns a new Mesh object generated from the current mesh properties.
  27892. * This method must not get confused with createInstance()
  27893. * @param name is a string, the name given to the new mesh
  27894. * @param newParent can be any Node object (default `null`)
  27895. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27896. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27897. * @returns a new mesh
  27898. */
  27899. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27900. /**
  27901. * Releases resources associated with this mesh.
  27902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27904. */
  27905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27906. /** @hidden */
  27907. _disposeInstanceSpecificData(): void;
  27908. /** @hidden */
  27909. _disposeThinInstanceSpecificData(): void;
  27910. /**
  27911. * Modifies the mesh geometry according to a displacement map.
  27912. * 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.
  27913. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27914. * @param url is a string, the URL from the image file is to be downloaded.
  27915. * @param minHeight is the lower limit of the displacement.
  27916. * @param maxHeight is the upper limit of the displacement.
  27917. * @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.
  27918. * @param uvOffset is an optional vector2 used to offset UV.
  27919. * @param uvScale is an optional vector2 used to scale UV.
  27920. * @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.
  27921. * @returns the Mesh.
  27922. */
  27923. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27924. /**
  27925. * Modifies the mesh geometry according to a displacementMap buffer.
  27926. * 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.
  27927. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27928. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27929. * @param heightMapWidth is the width of the buffer image.
  27930. * @param heightMapHeight is the height of the buffer image.
  27931. * @param minHeight is the lower limit of the displacement.
  27932. * @param maxHeight is the upper limit of the displacement.
  27933. * @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.
  27934. * @param uvOffset is an optional vector2 used to offset UV.
  27935. * @param uvScale is an optional vector2 used to scale UV.
  27936. * @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.
  27937. * @returns the Mesh.
  27938. */
  27939. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27940. /**
  27941. * Modify the mesh to get a flat shading rendering.
  27942. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27943. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27944. * @returns current mesh
  27945. */
  27946. convertToFlatShadedMesh(): Mesh;
  27947. /**
  27948. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27949. * In other words, more vertices, no more indices and a single bigger VBO.
  27950. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27951. * @returns current mesh
  27952. */
  27953. convertToUnIndexedMesh(): Mesh;
  27954. /**
  27955. * Inverses facet orientations.
  27956. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27957. * @param flipNormals will also inverts the normals
  27958. * @returns current mesh
  27959. */
  27960. flipFaces(flipNormals?: boolean): Mesh;
  27961. /**
  27962. * Increase the number of facets and hence vertices in a mesh
  27963. * Vertex normals are interpolated from existing vertex normals
  27964. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27965. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27966. */
  27967. increaseVertices(numberPerEdge: number): void;
  27968. /**
  27969. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27970. * This will undo any application of covertToFlatShadedMesh
  27971. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27972. */
  27973. forceSharedVertices(): void;
  27974. /** @hidden */
  27975. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27976. /** @hidden */
  27977. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27978. /**
  27979. * Creates a new InstancedMesh object from the mesh model.
  27980. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27981. * @param name defines the name of the new instance
  27982. * @returns a new InstancedMesh
  27983. */
  27984. createInstance(name: string): InstancedMesh;
  27985. /**
  27986. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27987. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27988. * @returns the current mesh
  27989. */
  27990. synchronizeInstances(): Mesh;
  27991. /**
  27992. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27993. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27994. * This should be used together with the simplification to avoid disappearing triangles.
  27995. * @param successCallback an optional success callback to be called after the optimization finished.
  27996. * @returns the current mesh
  27997. */
  27998. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27999. /**
  28000. * Serialize current mesh
  28001. * @param serializationObject defines the object which will receive the serialization data
  28002. */
  28003. serialize(serializationObject: any): void;
  28004. /** @hidden */
  28005. _syncGeometryWithMorphTargetManager(): void;
  28006. /** @hidden */
  28007. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28008. /**
  28009. * Returns a new Mesh object parsed from the source provided.
  28010. * @param parsedMesh is the source
  28011. * @param scene defines the hosting scene
  28012. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28013. * @returns a new Mesh
  28014. */
  28015. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28016. /**
  28017. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28018. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28019. * @param name defines the name of the mesh to create
  28020. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28021. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28022. * @param closePath creates a seam between the first and the last points of each path of the path array
  28023. * @param offset is taken in account only if the `pathArray` is containing a single path
  28024. * @param scene defines the hosting scene
  28025. * @param updatable defines if the mesh must be flagged as updatable
  28026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28027. * @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)
  28028. * @returns a new Mesh
  28029. */
  28030. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28031. /**
  28032. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28033. * @param name defines the name of the mesh to create
  28034. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28035. * @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
  28036. * @param scene defines the hosting scene
  28037. * @param updatable defines if the mesh must be flagged as updatable
  28038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28039. * @returns a new Mesh
  28040. */
  28041. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28042. /**
  28043. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28044. * @param name defines the name of the mesh to create
  28045. * @param size sets the size (float) of each box side (default 1)
  28046. * @param scene defines the hosting scene
  28047. * @param updatable defines if the mesh must be flagged as updatable
  28048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28049. * @returns a new Mesh
  28050. */
  28051. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28052. /**
  28053. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28054. * @param name defines the name of the mesh to create
  28055. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28056. * @param diameter sets the diameter size (float) of the sphere (default 1)
  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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28063. /**
  28064. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28067. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28068. * @param scene defines the hosting scene
  28069. * @returns a new Mesh
  28070. */
  28071. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28072. /**
  28073. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28074. * @param name defines the name of the mesh to create
  28075. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28076. * @param diameterTop set the top cap diameter (floats, default 1)
  28077. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28078. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28079. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28080. * @param scene defines the hosting scene
  28081. * @param updatable defines if the mesh must be flagged as updatable
  28082. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28083. * @returns a new Mesh
  28084. */
  28085. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28086. /**
  28087. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28088. * @param name defines the name of the mesh to create
  28089. * @param diameter sets the diameter size (float) of the torus (default 1)
  28090. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28091. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28092. * @param scene defines the hosting scene
  28093. * @param updatable defines if the mesh must be flagged as updatable
  28094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28095. * @returns a new Mesh
  28096. */
  28097. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28098. /**
  28099. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28100. * @param name defines the name of the mesh to create
  28101. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28102. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28103. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28104. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28105. * @param p the number of windings on X axis (positive integers, default 2)
  28106. * @param q the number of windings on Y axis (positive integers, default 3)
  28107. * @param scene defines the hosting scene
  28108. * @param updatable defines if the mesh must be flagged as updatable
  28109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28110. * @returns a new Mesh
  28111. */
  28112. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28113. /**
  28114. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28115. * @param name defines the name of the mesh to create
  28116. * @param points is an array successive Vector3
  28117. * @param scene defines the hosting scene
  28118. * @param updatable defines if the mesh must be flagged as updatable
  28119. * @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).
  28120. * @returns a new Mesh
  28121. */
  28122. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28123. /**
  28124. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28125. * @param name defines the name of the mesh to create
  28126. * @param points is an array successive Vector3
  28127. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28128. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28129. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28130. * @param scene defines the hosting scene
  28131. * @param updatable defines if the mesh must be flagged as updatable
  28132. * @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)
  28133. * @returns a new Mesh
  28134. */
  28135. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28136. /**
  28137. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28138. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28139. * 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.
  28140. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28141. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28142. * Remember you can only change the shape positions, not their number when updating a polygon.
  28143. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28144. * @param name defines the name of the mesh to create
  28145. * @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
  28146. * @param scene defines the hosting scene
  28147. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28148. * @param updatable defines if the mesh must be flagged as updatable
  28149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28150. * @param earcutInjection can be used to inject your own earcut reference
  28151. * @returns a new Mesh
  28152. */
  28153. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28154. /**
  28155. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28156. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28157. * @param name defines the name of the mesh to create
  28158. * @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
  28159. * @param depth defines the height of extrusion
  28160. * @param scene defines the hosting scene
  28161. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28162. * @param updatable defines if the mesh must be flagged as updatable
  28163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28164. * @param earcutInjection can be used to inject your own earcut reference
  28165. * @returns a new Mesh
  28166. */
  28167. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28168. /**
  28169. * Creates an extruded shape mesh.
  28170. * 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
  28171. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28172. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28173. * @param name defines the name of the mesh to create
  28174. * @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
  28175. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28176. * @param scale is the value to scale the shape
  28177. * @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
  28178. * @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
  28179. * @param scene defines the hosting scene
  28180. * @param updatable defines if the mesh must be flagged as updatable
  28181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28182. * @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)
  28183. * @returns a new Mesh
  28184. */
  28185. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28186. /**
  28187. * Creates an custom extruded shape mesh.
  28188. * The custom extrusion is a parametric shape.
  28189. * It has no predefined shape. Its final shape will depend on the input parameters.
  28190. * Please consider using the same method from the MeshBuilder class instead
  28191. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28192. * @param name defines the name of the mesh to create
  28193. * @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
  28194. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28195. * @param scaleFunction is a custom Javascript function called on each path point
  28196. * @param rotationFunction is a custom Javascript function called on each path point
  28197. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28198. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28199. * @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
  28200. * @param scene defines the hosting scene
  28201. * @param updatable defines if the mesh must be flagged as updatable
  28202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28203. * @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)
  28204. * @returns a new Mesh
  28205. */
  28206. 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;
  28207. /**
  28208. * Creates lathe mesh.
  28209. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28210. * Please consider using the same method from the MeshBuilder class instead
  28211. * @param name defines the name of the mesh to create
  28212. * @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
  28213. * @param radius is the radius value of the lathe
  28214. * @param tessellation is the side number of the lathe.
  28215. * @param scene defines the hosting scene
  28216. * @param updatable defines if the mesh must be flagged as updatable
  28217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28218. * @returns a new Mesh
  28219. */
  28220. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28221. /**
  28222. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28223. * @param name defines the name of the mesh to create
  28224. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28225. * @param scene defines the hosting scene
  28226. * @param updatable defines if the mesh must be flagged as updatable
  28227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28228. * @returns a new Mesh
  28229. */
  28230. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28231. /**
  28232. * Creates a ground mesh.
  28233. * Please consider using the same method from the MeshBuilder class instead
  28234. * @param name defines the name of the mesh to create
  28235. * @param width set the width of the ground
  28236. * @param height set the height of the ground
  28237. * @param subdivisions sets the number of subdivisions per side
  28238. * @param scene defines the hosting scene
  28239. * @param updatable defines if the mesh must be flagged as updatable
  28240. * @returns a new Mesh
  28241. */
  28242. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28243. /**
  28244. * Creates a tiled ground mesh.
  28245. * Please consider using the same method from the MeshBuilder class instead
  28246. * @param name defines the name of the mesh to create
  28247. * @param xmin set the ground minimum X coordinate
  28248. * @param zmin set the ground minimum Y coordinate
  28249. * @param xmax set the ground maximum X coordinate
  28250. * @param zmax set the ground maximum Z coordinate
  28251. * @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
  28252. * @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
  28253. * @param scene defines the hosting scene
  28254. * @param updatable defines if the mesh must be flagged as updatable
  28255. * @returns a new Mesh
  28256. */
  28257. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28258. w: number;
  28259. h: number;
  28260. }, precision: {
  28261. w: number;
  28262. h: number;
  28263. }, scene: Scene, updatable?: boolean): Mesh;
  28264. /**
  28265. * Creates a ground mesh from a height map.
  28266. * Please consider using the same method from the MeshBuilder class instead
  28267. * @see http://doc.babylonjs.com/babylon101/height_map
  28268. * @param name defines the name of the mesh to create
  28269. * @param url sets the URL of the height map image resource
  28270. * @param width set the ground width size
  28271. * @param height set the ground height size
  28272. * @param subdivisions sets the number of subdivision per side
  28273. * @param minHeight is the minimum altitude on the ground
  28274. * @param maxHeight is the maximum altitude on the ground
  28275. * @param scene defines the hosting scene
  28276. * @param updatable defines if the mesh must be flagged as updatable
  28277. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28278. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28279. * @returns a new Mesh
  28280. */
  28281. 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;
  28282. /**
  28283. * Creates a tube mesh.
  28284. * The tube is a parametric shape.
  28285. * It has no predefined shape. Its final shape will depend on the input parameters.
  28286. * Please consider using the same method from the MeshBuilder class instead
  28287. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28288. * @param name defines the name of the mesh to create
  28289. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28290. * @param radius sets the tube radius size
  28291. * @param tessellation is the number of sides on the tubular surface
  28292. * @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
  28293. * @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
  28294. * @param scene defines the hosting scene
  28295. * @param updatable defines if the mesh must be flagged as updatable
  28296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28297. * @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)
  28298. * @returns a new Mesh
  28299. */
  28300. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28301. (i: number, distance: number): number;
  28302. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28303. /**
  28304. * Creates a polyhedron mesh.
  28305. * Please consider using the same method from the MeshBuilder class instead.
  28306. * * 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
  28307. * * The parameter `size` (positive float, default 1) sets the polygon size
  28308. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28309. * * 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`
  28310. * * 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
  28311. * * 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)`)
  28312. * * 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
  28313. * * 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
  28314. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28315. * * 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
  28316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28317. * @param name defines the name of the mesh to create
  28318. * @param options defines the options used to create the mesh
  28319. * @param scene defines the hosting scene
  28320. * @returns a new Mesh
  28321. */
  28322. static CreatePolyhedron(name: string, options: {
  28323. type?: number;
  28324. size?: number;
  28325. sizeX?: number;
  28326. sizeY?: number;
  28327. sizeZ?: number;
  28328. custom?: any;
  28329. faceUV?: Vector4[];
  28330. faceColors?: Color4[];
  28331. updatable?: boolean;
  28332. sideOrientation?: number;
  28333. }, scene: Scene): Mesh;
  28334. /**
  28335. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28336. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28337. * * 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`)
  28338. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28339. * * 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
  28340. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28341. * * 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
  28342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28343. * @param name defines the name of the mesh
  28344. * @param options defines the options used to create the mesh
  28345. * @param scene defines the hosting scene
  28346. * @returns a new Mesh
  28347. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28348. */
  28349. static CreateIcoSphere(name: string, options: {
  28350. radius?: number;
  28351. flat?: boolean;
  28352. subdivisions?: number;
  28353. sideOrientation?: number;
  28354. updatable?: boolean;
  28355. }, scene: Scene): Mesh;
  28356. /**
  28357. * Creates a decal mesh.
  28358. * Please consider using the same method from the MeshBuilder class instead.
  28359. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28360. * @param name defines the name of the mesh
  28361. * @param sourceMesh defines the mesh receiving the decal
  28362. * @param position sets the position of the decal in world coordinates
  28363. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28364. * @param size sets the decal scaling
  28365. * @param angle sets the angle to rotate the decal
  28366. * @returns a new Mesh
  28367. */
  28368. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28369. /**
  28370. * Prepare internal position array for software CPU skinning
  28371. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28372. */
  28373. setPositionsForCPUSkinning(): Float32Array;
  28374. /**
  28375. * Prepare internal normal array for software CPU skinning
  28376. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28377. */
  28378. setNormalsForCPUSkinning(): Float32Array;
  28379. /**
  28380. * Updates the vertex buffer by applying transformation from the bones
  28381. * @param skeleton defines the skeleton to apply to current mesh
  28382. * @returns the current mesh
  28383. */
  28384. applySkeleton(skeleton: Skeleton): Mesh;
  28385. /**
  28386. * 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
  28387. * @param meshes defines the list of meshes to scan
  28388. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28389. */
  28390. static MinMax(meshes: AbstractMesh[]): {
  28391. min: Vector3;
  28392. max: Vector3;
  28393. };
  28394. /**
  28395. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28396. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28397. * @returns a vector3
  28398. */
  28399. static Center(meshesOrMinMaxVector: {
  28400. min: Vector3;
  28401. max: Vector3;
  28402. } | AbstractMesh[]): Vector3;
  28403. /**
  28404. * Merge the array of meshes into a single mesh for performance reasons.
  28405. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28406. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28407. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28408. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28409. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28410. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28411. * @returns a new mesh
  28412. */
  28413. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28414. /** @hidden */
  28415. addInstance(instance: InstancedMesh): void;
  28416. /** @hidden */
  28417. removeInstance(instance: InstancedMesh): void;
  28418. }
  28419. }
  28420. declare module BABYLON {
  28421. /**
  28422. * This is the base class of all the camera used in the application.
  28423. * @see http://doc.babylonjs.com/features/cameras
  28424. */
  28425. export class Camera extends Node {
  28426. /** @hidden */
  28427. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28428. /**
  28429. * This is the default projection mode used by the cameras.
  28430. * It helps recreating a feeling of perspective and better appreciate depth.
  28431. * This is the best way to simulate real life cameras.
  28432. */
  28433. static readonly PERSPECTIVE_CAMERA: number;
  28434. /**
  28435. * This helps creating camera with an orthographic mode.
  28436. * 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.
  28437. */
  28438. static readonly ORTHOGRAPHIC_CAMERA: number;
  28439. /**
  28440. * This is the default FOV mode for perspective cameras.
  28441. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28442. */
  28443. static readonly FOVMODE_VERTICAL_FIXED: number;
  28444. /**
  28445. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28446. */
  28447. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28448. /**
  28449. * This specifies ther is no need for a camera rig.
  28450. * Basically only one eye is rendered corresponding to the camera.
  28451. */
  28452. static readonly RIG_MODE_NONE: number;
  28453. /**
  28454. * Simulates a camera Rig with one blue eye and one red eye.
  28455. * This can be use with 3d blue and red glasses.
  28456. */
  28457. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28458. /**
  28459. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28460. */
  28461. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28462. /**
  28463. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28464. */
  28465. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28466. /**
  28467. * Defines that both eyes of the camera will be rendered over under each other.
  28468. */
  28469. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28470. /**
  28471. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28472. */
  28473. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28474. /**
  28475. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28476. */
  28477. static readonly RIG_MODE_VR: number;
  28478. /**
  28479. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28480. */
  28481. static readonly RIG_MODE_WEBVR: number;
  28482. /**
  28483. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28484. */
  28485. static readonly RIG_MODE_CUSTOM: number;
  28486. /**
  28487. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28488. */
  28489. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28490. /**
  28491. * Define the input manager associated with the camera.
  28492. */
  28493. inputs: CameraInputsManager<Camera>;
  28494. /** @hidden */
  28495. _position: Vector3;
  28496. /**
  28497. * Define the current local position of the camera in the scene
  28498. */
  28499. get position(): Vector3;
  28500. set position(newPosition: Vector3);
  28501. /**
  28502. * The vector the camera should consider as up.
  28503. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28504. */
  28505. upVector: Vector3;
  28506. /**
  28507. * Define the current limit on the left side for an orthographic camera
  28508. * In scene unit
  28509. */
  28510. orthoLeft: Nullable<number>;
  28511. /**
  28512. * Define the current limit on the right side for an orthographic camera
  28513. * In scene unit
  28514. */
  28515. orthoRight: Nullable<number>;
  28516. /**
  28517. * Define the current limit on the bottom side for an orthographic camera
  28518. * In scene unit
  28519. */
  28520. orthoBottom: Nullable<number>;
  28521. /**
  28522. * Define the current limit on the top side for an orthographic camera
  28523. * In scene unit
  28524. */
  28525. orthoTop: Nullable<number>;
  28526. /**
  28527. * Field Of View is set in Radians. (default is 0.8)
  28528. */
  28529. fov: number;
  28530. /**
  28531. * Define the minimum distance the camera can see from.
  28532. * This is important to note that the depth buffer are not infinite and the closer it starts
  28533. * the more your scene might encounter depth fighting issue.
  28534. */
  28535. minZ: number;
  28536. /**
  28537. * Define the maximum distance the camera can see to.
  28538. * This is important to note that the depth buffer are not infinite and the further it end
  28539. * the more your scene might encounter depth fighting issue.
  28540. */
  28541. maxZ: number;
  28542. /**
  28543. * Define the default inertia of the camera.
  28544. * This helps giving a smooth feeling to the camera movement.
  28545. */
  28546. inertia: number;
  28547. /**
  28548. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28549. */
  28550. mode: number;
  28551. /**
  28552. * Define whether the camera is intermediate.
  28553. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28554. */
  28555. isIntermediate: boolean;
  28556. /**
  28557. * Define the viewport of the camera.
  28558. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28559. */
  28560. viewport: Viewport;
  28561. /**
  28562. * Restricts the camera to viewing objects with the same layerMask.
  28563. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28564. */
  28565. layerMask: number;
  28566. /**
  28567. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28568. */
  28569. fovMode: number;
  28570. /**
  28571. * Rig mode of the camera.
  28572. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28573. * This is normally controlled byt the camera themselves as internal use.
  28574. */
  28575. cameraRigMode: number;
  28576. /**
  28577. * Defines the distance between both "eyes" in case of a RIG
  28578. */
  28579. interaxialDistance: number;
  28580. /**
  28581. * Defines if stereoscopic rendering is done side by side or over under.
  28582. */
  28583. isStereoscopicSideBySide: boolean;
  28584. /**
  28585. * 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
  28586. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28587. * else in the scene. (Eg. security camera)
  28588. *
  28589. * 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)
  28590. */
  28591. customRenderTargets: RenderTargetTexture[];
  28592. /**
  28593. * When set, the camera will render to this render target instead of the default canvas
  28594. *
  28595. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28596. */
  28597. outputRenderTarget: Nullable<RenderTargetTexture>;
  28598. /**
  28599. * Observable triggered when the camera view matrix has changed.
  28600. */
  28601. onViewMatrixChangedObservable: Observable<Camera>;
  28602. /**
  28603. * Observable triggered when the camera Projection matrix has changed.
  28604. */
  28605. onProjectionMatrixChangedObservable: Observable<Camera>;
  28606. /**
  28607. * Observable triggered when the inputs have been processed.
  28608. */
  28609. onAfterCheckInputsObservable: Observable<Camera>;
  28610. /**
  28611. * Observable triggered when reset has been called and applied to the camera.
  28612. */
  28613. onRestoreStateObservable: Observable<Camera>;
  28614. /**
  28615. * Is this camera a part of a rig system?
  28616. */
  28617. isRigCamera: boolean;
  28618. /**
  28619. * If isRigCamera set to true this will be set with the parent camera.
  28620. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28621. */
  28622. rigParent?: Camera;
  28623. /** @hidden */
  28624. _cameraRigParams: any;
  28625. /** @hidden */
  28626. _rigCameras: Camera[];
  28627. /** @hidden */
  28628. _rigPostProcess: Nullable<PostProcess>;
  28629. protected _webvrViewMatrix: Matrix;
  28630. /** @hidden */
  28631. _skipRendering: boolean;
  28632. /** @hidden */
  28633. _projectionMatrix: Matrix;
  28634. /** @hidden */
  28635. _postProcesses: Nullable<PostProcess>[];
  28636. /** @hidden */
  28637. _activeMeshes: SmartArray<AbstractMesh>;
  28638. protected _globalPosition: Vector3;
  28639. /** @hidden */
  28640. _computedViewMatrix: Matrix;
  28641. private _doNotComputeProjectionMatrix;
  28642. private _transformMatrix;
  28643. private _frustumPlanes;
  28644. private _refreshFrustumPlanes;
  28645. private _storedFov;
  28646. private _stateStored;
  28647. /**
  28648. * Instantiates a new camera object.
  28649. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28650. * @see http://doc.babylonjs.com/features/cameras
  28651. * @param name Defines the name of the camera in the scene
  28652. * @param position Defines the position of the camera
  28653. * @param scene Defines the scene the camera belongs too
  28654. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28655. */
  28656. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28657. /**
  28658. * Store current camera state (fov, position, etc..)
  28659. * @returns the camera
  28660. */
  28661. storeState(): Camera;
  28662. /**
  28663. * Restores the camera state values if it has been stored. You must call storeState() first
  28664. */
  28665. protected _restoreStateValues(): boolean;
  28666. /**
  28667. * Restored camera state. You must call storeState() first.
  28668. * @returns true if restored and false otherwise
  28669. */
  28670. restoreState(): boolean;
  28671. /**
  28672. * Gets the class name of the camera.
  28673. * @returns the class name
  28674. */
  28675. getClassName(): string;
  28676. /** @hidden */
  28677. readonly _isCamera: boolean;
  28678. /**
  28679. * Gets a string representation of the camera useful for debug purpose.
  28680. * @param fullDetails Defines that a more verboe level of logging is required
  28681. * @returns the string representation
  28682. */
  28683. toString(fullDetails?: boolean): string;
  28684. /**
  28685. * Gets the current world space position of the camera.
  28686. */
  28687. get globalPosition(): Vector3;
  28688. /**
  28689. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28690. * @returns the active meshe list
  28691. */
  28692. getActiveMeshes(): SmartArray<AbstractMesh>;
  28693. /**
  28694. * Check whether a mesh is part of the current active mesh list of the camera
  28695. * @param mesh Defines the mesh to check
  28696. * @returns true if active, false otherwise
  28697. */
  28698. isActiveMesh(mesh: Mesh): boolean;
  28699. /**
  28700. * Is this camera ready to be used/rendered
  28701. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28702. * @return true if the camera is ready
  28703. */
  28704. isReady(completeCheck?: boolean): boolean;
  28705. /** @hidden */
  28706. _initCache(): void;
  28707. /** @hidden */
  28708. _updateCache(ignoreParentClass?: boolean): void;
  28709. /** @hidden */
  28710. _isSynchronized(): boolean;
  28711. /** @hidden */
  28712. _isSynchronizedViewMatrix(): boolean;
  28713. /** @hidden */
  28714. _isSynchronizedProjectionMatrix(): boolean;
  28715. /**
  28716. * Attach the input controls to a specific dom element to get the input from.
  28717. * @param element Defines the element the controls should be listened from
  28718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28719. */
  28720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28721. /**
  28722. * Detach the current controls from the specified dom element.
  28723. * @param element Defines the element to stop listening the inputs from
  28724. */
  28725. detachControl(element: HTMLElement): void;
  28726. /**
  28727. * Update the camera state according to the different inputs gathered during the frame.
  28728. */
  28729. update(): void;
  28730. /** @hidden */
  28731. _checkInputs(): void;
  28732. /** @hidden */
  28733. get rigCameras(): Camera[];
  28734. /**
  28735. * Gets the post process used by the rig cameras
  28736. */
  28737. get rigPostProcess(): Nullable<PostProcess>;
  28738. /**
  28739. * Internal, gets the first post proces.
  28740. * @returns the first post process to be run on this camera.
  28741. */
  28742. _getFirstPostProcess(): Nullable<PostProcess>;
  28743. private _cascadePostProcessesToRigCams;
  28744. /**
  28745. * Attach a post process to the camera.
  28746. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28747. * @param postProcess The post process to attach to the camera
  28748. * @param insertAt The position of the post process in case several of them are in use in the scene
  28749. * @returns the position the post process has been inserted at
  28750. */
  28751. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28752. /**
  28753. * Detach a post process to the camera.
  28754. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28755. * @param postProcess The post process to detach from the camera
  28756. */
  28757. detachPostProcess(postProcess: PostProcess): void;
  28758. /**
  28759. * Gets the current world matrix of the camera
  28760. */
  28761. getWorldMatrix(): Matrix;
  28762. /** @hidden */
  28763. _getViewMatrix(): Matrix;
  28764. /**
  28765. * Gets the current view matrix of the camera.
  28766. * @param force forces the camera to recompute the matrix without looking at the cached state
  28767. * @returns the view matrix
  28768. */
  28769. getViewMatrix(force?: boolean): Matrix;
  28770. /**
  28771. * Freeze the projection matrix.
  28772. * It will prevent the cache check of the camera projection compute and can speed up perf
  28773. * if no parameter of the camera are meant to change
  28774. * @param projection Defines manually a projection if necessary
  28775. */
  28776. freezeProjectionMatrix(projection?: Matrix): void;
  28777. /**
  28778. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28779. */
  28780. unfreezeProjectionMatrix(): void;
  28781. /**
  28782. * Gets the current projection matrix of the camera.
  28783. * @param force forces the camera to recompute the matrix without looking at the cached state
  28784. * @returns the projection matrix
  28785. */
  28786. getProjectionMatrix(force?: boolean): Matrix;
  28787. /**
  28788. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28789. * @returns a Matrix
  28790. */
  28791. getTransformationMatrix(): Matrix;
  28792. private _updateFrustumPlanes;
  28793. /**
  28794. * Checks if a cullable object (mesh...) is in the camera frustum
  28795. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28796. * @param target The object to check
  28797. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28798. * @returns true if the object is in frustum otherwise false
  28799. */
  28800. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28801. /**
  28802. * Checks if a cullable object (mesh...) is in the camera frustum
  28803. * Unlike isInFrustum this cheks the full bounding box
  28804. * @param target The object to check
  28805. * @returns true if the object is in frustum otherwise false
  28806. */
  28807. isCompletelyInFrustum(target: ICullable): boolean;
  28808. /**
  28809. * Gets a ray in the forward direction from the camera.
  28810. * @param length Defines the length of the ray to create
  28811. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28812. * @param origin Defines the start point of the ray which defaults to the camera position
  28813. * @returns the forward ray
  28814. */
  28815. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28816. /**
  28817. * Releases resources associated with this node.
  28818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28820. */
  28821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28822. /** @hidden */
  28823. _isLeftCamera: boolean;
  28824. /**
  28825. * Gets the left camera of a rig setup in case of Rigged Camera
  28826. */
  28827. get isLeftCamera(): boolean;
  28828. /** @hidden */
  28829. _isRightCamera: boolean;
  28830. /**
  28831. * Gets the right camera of a rig setup in case of Rigged Camera
  28832. */
  28833. get isRightCamera(): boolean;
  28834. /**
  28835. * Gets the left camera of a rig setup in case of Rigged Camera
  28836. */
  28837. get leftCamera(): Nullable<FreeCamera>;
  28838. /**
  28839. * Gets the right camera of a rig setup in case of Rigged Camera
  28840. */
  28841. get rightCamera(): Nullable<FreeCamera>;
  28842. /**
  28843. * Gets the left camera target of a rig setup in case of Rigged Camera
  28844. * @returns the target position
  28845. */
  28846. getLeftTarget(): Nullable<Vector3>;
  28847. /**
  28848. * Gets the right camera target of a rig setup in case of Rigged Camera
  28849. * @returns the target position
  28850. */
  28851. getRightTarget(): Nullable<Vector3>;
  28852. /**
  28853. * @hidden
  28854. */
  28855. setCameraRigMode(mode: number, rigParams: any): void;
  28856. /** @hidden */
  28857. static _setStereoscopicRigMode(camera: Camera): void;
  28858. /** @hidden */
  28859. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28860. /** @hidden */
  28861. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28862. /** @hidden */
  28863. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28864. /** @hidden */
  28865. _getVRProjectionMatrix(): Matrix;
  28866. protected _updateCameraRotationMatrix(): void;
  28867. protected _updateWebVRCameraRotationMatrix(): void;
  28868. /**
  28869. * This function MUST be overwritten by the different WebVR cameras available.
  28870. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28871. * @hidden
  28872. */
  28873. _getWebVRProjectionMatrix(): Matrix;
  28874. /**
  28875. * This function MUST be overwritten by the different WebVR cameras available.
  28876. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28877. * @hidden
  28878. */
  28879. _getWebVRViewMatrix(): Matrix;
  28880. /** @hidden */
  28881. setCameraRigParameter(name: string, value: any): void;
  28882. /**
  28883. * needs to be overridden by children so sub has required properties to be copied
  28884. * @hidden
  28885. */
  28886. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28887. /**
  28888. * May need to be overridden by children
  28889. * @hidden
  28890. */
  28891. _updateRigCameras(): void;
  28892. /** @hidden */
  28893. _setupInputs(): void;
  28894. /**
  28895. * Serialiaze the camera setup to a json represention
  28896. * @returns the JSON representation
  28897. */
  28898. serialize(): any;
  28899. /**
  28900. * Clones the current camera.
  28901. * @param name The cloned camera name
  28902. * @returns the cloned camera
  28903. */
  28904. clone(name: string): Camera;
  28905. /**
  28906. * Gets the direction of the camera relative to a given local axis.
  28907. * @param localAxis Defines the reference axis to provide a relative direction.
  28908. * @return the direction
  28909. */
  28910. getDirection(localAxis: Vector3): Vector3;
  28911. /**
  28912. * Returns the current camera absolute rotation
  28913. */
  28914. get absoluteRotation(): Quaternion;
  28915. /**
  28916. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28917. * @param localAxis Defines the reference axis to provide a relative direction.
  28918. * @param result Defines the vector to store the result in
  28919. */
  28920. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28921. /**
  28922. * Gets a camera constructor for a given camera type
  28923. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28924. * @param name The name of the camera the result will be able to instantiate
  28925. * @param scene The scene the result will construct the camera in
  28926. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28927. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28928. * @returns a factory method to construc the camera
  28929. */
  28930. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28931. /**
  28932. * Compute the world matrix of the camera.
  28933. * @returns the camera world matrix
  28934. */
  28935. computeWorldMatrix(): Matrix;
  28936. /**
  28937. * Parse a JSON and creates the camera from the parsed information
  28938. * @param parsedCamera The JSON to parse
  28939. * @param scene The scene to instantiate the camera in
  28940. * @returns the newly constructed camera
  28941. */
  28942. static Parse(parsedCamera: any, scene: Scene): Camera;
  28943. }
  28944. }
  28945. declare module BABYLON {
  28946. /**
  28947. * Class containing static functions to help procedurally build meshes
  28948. */
  28949. export class DiscBuilder {
  28950. /**
  28951. * Creates a plane polygonal mesh. By default, this is a disc
  28952. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28953. * * 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
  28954. * * 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
  28955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28956. * * 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
  28957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28958. * @param name defines the name of the mesh
  28959. * @param options defines the options used to create the mesh
  28960. * @param scene defines the hosting scene
  28961. * @returns the plane polygonal mesh
  28962. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28963. */
  28964. static CreateDisc(name: string, options: {
  28965. radius?: number;
  28966. tessellation?: number;
  28967. arc?: number;
  28968. updatable?: boolean;
  28969. sideOrientation?: number;
  28970. frontUVs?: Vector4;
  28971. backUVs?: Vector4;
  28972. }, scene?: Nullable<Scene>): Mesh;
  28973. }
  28974. }
  28975. declare module BABYLON {
  28976. /**
  28977. * Options to be used when creating a FresnelParameters.
  28978. */
  28979. export type IFresnelParametersCreationOptions = {
  28980. /**
  28981. * Define the color used on edges (grazing angle)
  28982. */
  28983. leftColor?: Color3;
  28984. /**
  28985. * Define the color used on center
  28986. */
  28987. rightColor?: Color3;
  28988. /**
  28989. * Define bias applied to computed fresnel term
  28990. */
  28991. bias?: number;
  28992. /**
  28993. * Defined the power exponent applied to fresnel term
  28994. */
  28995. power?: number;
  28996. /**
  28997. * Define if the fresnel effect is enable or not.
  28998. */
  28999. isEnabled?: boolean;
  29000. };
  29001. /**
  29002. * Serialized format for FresnelParameters.
  29003. */
  29004. export type IFresnelParametersSerialized = {
  29005. /**
  29006. * Define the color used on edges (grazing angle) [as an array]
  29007. */
  29008. leftColor: number[];
  29009. /**
  29010. * Define the color used on center [as an array]
  29011. */
  29012. rightColor: number[];
  29013. /**
  29014. * Define bias applied to computed fresnel term
  29015. */
  29016. bias: number;
  29017. /**
  29018. * Defined the power exponent applied to fresnel term
  29019. */
  29020. power?: number;
  29021. /**
  29022. * Define if the fresnel effect is enable or not.
  29023. */
  29024. isEnabled: boolean;
  29025. };
  29026. /**
  29027. * This represents all the required information to add a fresnel effect on a material:
  29028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29029. */
  29030. export class FresnelParameters {
  29031. private _isEnabled;
  29032. /**
  29033. * Define if the fresnel effect is enable or not.
  29034. */
  29035. get isEnabled(): boolean;
  29036. set isEnabled(value: boolean);
  29037. /**
  29038. * Define the color used on edges (grazing angle)
  29039. */
  29040. leftColor: Color3;
  29041. /**
  29042. * Define the color used on center
  29043. */
  29044. rightColor: Color3;
  29045. /**
  29046. * Define bias applied to computed fresnel term
  29047. */
  29048. bias: number;
  29049. /**
  29050. * Defined the power exponent applied to fresnel term
  29051. */
  29052. power: number;
  29053. /**
  29054. * Creates a new FresnelParameters object.
  29055. *
  29056. * @param options provide your own settings to optionally to override defaults
  29057. */
  29058. constructor(options?: IFresnelParametersCreationOptions);
  29059. /**
  29060. * Clones the current fresnel and its valuues
  29061. * @returns a clone fresnel configuration
  29062. */
  29063. clone(): FresnelParameters;
  29064. /**
  29065. * Determines equality between FresnelParameters objects
  29066. * @param otherFresnelParameters defines the second operand
  29067. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29068. */
  29069. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29070. /**
  29071. * Serializes the current fresnel parameters to a JSON representation.
  29072. * @return the JSON serialization
  29073. */
  29074. serialize(): IFresnelParametersSerialized;
  29075. /**
  29076. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29077. * @param parsedFresnelParameters Define the JSON representation
  29078. * @returns the parsed parameters
  29079. */
  29080. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29081. }
  29082. }
  29083. declare module BABYLON {
  29084. /**
  29085. * This groups all the flags used to control the materials channel.
  29086. */
  29087. export class MaterialFlags {
  29088. private static _DiffuseTextureEnabled;
  29089. /**
  29090. * Are diffuse textures enabled in the application.
  29091. */
  29092. static get DiffuseTextureEnabled(): boolean;
  29093. static set DiffuseTextureEnabled(value: boolean);
  29094. private static _AmbientTextureEnabled;
  29095. /**
  29096. * Are ambient textures enabled in the application.
  29097. */
  29098. static get AmbientTextureEnabled(): boolean;
  29099. static set AmbientTextureEnabled(value: boolean);
  29100. private static _OpacityTextureEnabled;
  29101. /**
  29102. * Are opacity textures enabled in the application.
  29103. */
  29104. static get OpacityTextureEnabled(): boolean;
  29105. static set OpacityTextureEnabled(value: boolean);
  29106. private static _ReflectionTextureEnabled;
  29107. /**
  29108. * Are reflection textures enabled in the application.
  29109. */
  29110. static get ReflectionTextureEnabled(): boolean;
  29111. static set ReflectionTextureEnabled(value: boolean);
  29112. private static _EmissiveTextureEnabled;
  29113. /**
  29114. * Are emissive textures enabled in the application.
  29115. */
  29116. static get EmissiveTextureEnabled(): boolean;
  29117. static set EmissiveTextureEnabled(value: boolean);
  29118. private static _SpecularTextureEnabled;
  29119. /**
  29120. * Are specular textures enabled in the application.
  29121. */
  29122. static get SpecularTextureEnabled(): boolean;
  29123. static set SpecularTextureEnabled(value: boolean);
  29124. private static _BumpTextureEnabled;
  29125. /**
  29126. * Are bump textures enabled in the application.
  29127. */
  29128. static get BumpTextureEnabled(): boolean;
  29129. static set BumpTextureEnabled(value: boolean);
  29130. private static _LightmapTextureEnabled;
  29131. /**
  29132. * Are lightmap textures enabled in the application.
  29133. */
  29134. static get LightmapTextureEnabled(): boolean;
  29135. static set LightmapTextureEnabled(value: boolean);
  29136. private static _RefractionTextureEnabled;
  29137. /**
  29138. * Are refraction textures enabled in the application.
  29139. */
  29140. static get RefractionTextureEnabled(): boolean;
  29141. static set RefractionTextureEnabled(value: boolean);
  29142. private static _ColorGradingTextureEnabled;
  29143. /**
  29144. * Are color grading textures enabled in the application.
  29145. */
  29146. static get ColorGradingTextureEnabled(): boolean;
  29147. static set ColorGradingTextureEnabled(value: boolean);
  29148. private static _FresnelEnabled;
  29149. /**
  29150. * Are fresnels enabled in the application.
  29151. */
  29152. static get FresnelEnabled(): boolean;
  29153. static set FresnelEnabled(value: boolean);
  29154. private static _ClearCoatTextureEnabled;
  29155. /**
  29156. * Are clear coat textures enabled in the application.
  29157. */
  29158. static get ClearCoatTextureEnabled(): boolean;
  29159. static set ClearCoatTextureEnabled(value: boolean);
  29160. private static _ClearCoatBumpTextureEnabled;
  29161. /**
  29162. * Are clear coat bump textures enabled in the application.
  29163. */
  29164. static get ClearCoatBumpTextureEnabled(): boolean;
  29165. static set ClearCoatBumpTextureEnabled(value: boolean);
  29166. private static _ClearCoatTintTextureEnabled;
  29167. /**
  29168. * Are clear coat tint textures enabled in the application.
  29169. */
  29170. static get ClearCoatTintTextureEnabled(): boolean;
  29171. static set ClearCoatTintTextureEnabled(value: boolean);
  29172. private static _SheenTextureEnabled;
  29173. /**
  29174. * Are sheen textures enabled in the application.
  29175. */
  29176. static get SheenTextureEnabled(): boolean;
  29177. static set SheenTextureEnabled(value: boolean);
  29178. private static _AnisotropicTextureEnabled;
  29179. /**
  29180. * Are anisotropic textures enabled in the application.
  29181. */
  29182. static get AnisotropicTextureEnabled(): boolean;
  29183. static set AnisotropicTextureEnabled(value: boolean);
  29184. private static _ThicknessTextureEnabled;
  29185. /**
  29186. * Are thickness textures enabled in the application.
  29187. */
  29188. static get ThicknessTextureEnabled(): boolean;
  29189. static set ThicknessTextureEnabled(value: boolean);
  29190. }
  29191. }
  29192. declare module BABYLON {
  29193. /** @hidden */
  29194. export var defaultFragmentDeclaration: {
  29195. name: string;
  29196. shader: string;
  29197. };
  29198. }
  29199. declare module BABYLON {
  29200. /** @hidden */
  29201. export var defaultUboDeclaration: {
  29202. name: string;
  29203. shader: string;
  29204. };
  29205. }
  29206. declare module BABYLON {
  29207. /** @hidden */
  29208. export var lightFragmentDeclaration: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module BABYLON {
  29214. /** @hidden */
  29215. export var lightUboDeclaration: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module BABYLON {
  29221. /** @hidden */
  29222. export var lightsFragmentFunctions: {
  29223. name: string;
  29224. shader: string;
  29225. };
  29226. }
  29227. declare module BABYLON {
  29228. /** @hidden */
  29229. export var shadowsFragmentFunctions: {
  29230. name: string;
  29231. shader: string;
  29232. };
  29233. }
  29234. declare module BABYLON {
  29235. /** @hidden */
  29236. export var fresnelFunction: {
  29237. name: string;
  29238. shader: string;
  29239. };
  29240. }
  29241. declare module BABYLON {
  29242. /** @hidden */
  29243. export var bumpFragmentMainFunctions: {
  29244. name: string;
  29245. shader: string;
  29246. };
  29247. }
  29248. declare module BABYLON {
  29249. /** @hidden */
  29250. export var bumpFragmentFunctions: {
  29251. name: string;
  29252. shader: string;
  29253. };
  29254. }
  29255. declare module BABYLON {
  29256. /** @hidden */
  29257. export var logDepthDeclaration: {
  29258. name: string;
  29259. shader: string;
  29260. };
  29261. }
  29262. declare module BABYLON {
  29263. /** @hidden */
  29264. export var bumpFragment: {
  29265. name: string;
  29266. shader: string;
  29267. };
  29268. }
  29269. declare module BABYLON {
  29270. /** @hidden */
  29271. export var depthPrePass: {
  29272. name: string;
  29273. shader: string;
  29274. };
  29275. }
  29276. declare module BABYLON {
  29277. /** @hidden */
  29278. export var lightFragment: {
  29279. name: string;
  29280. shader: string;
  29281. };
  29282. }
  29283. declare module BABYLON {
  29284. /** @hidden */
  29285. export var logDepthFragment: {
  29286. name: string;
  29287. shader: string;
  29288. };
  29289. }
  29290. declare module BABYLON {
  29291. /** @hidden */
  29292. export var defaultPixelShader: {
  29293. name: string;
  29294. shader: string;
  29295. };
  29296. }
  29297. declare module BABYLON {
  29298. /** @hidden */
  29299. export var defaultVertexDeclaration: {
  29300. name: string;
  29301. shader: string;
  29302. };
  29303. }
  29304. declare module BABYLON {
  29305. /** @hidden */
  29306. export var bumpVertexDeclaration: {
  29307. name: string;
  29308. shader: string;
  29309. };
  29310. }
  29311. declare module BABYLON {
  29312. /** @hidden */
  29313. export var bumpVertex: {
  29314. name: string;
  29315. shader: string;
  29316. };
  29317. }
  29318. declare module BABYLON {
  29319. /** @hidden */
  29320. export var fogVertex: {
  29321. name: string;
  29322. shader: string;
  29323. };
  29324. }
  29325. declare module BABYLON {
  29326. /** @hidden */
  29327. export var shadowsVertex: {
  29328. name: string;
  29329. shader: string;
  29330. };
  29331. }
  29332. declare module BABYLON {
  29333. /** @hidden */
  29334. export var pointCloudVertex: {
  29335. name: string;
  29336. shader: string;
  29337. };
  29338. }
  29339. declare module BABYLON {
  29340. /** @hidden */
  29341. export var logDepthVertex: {
  29342. name: string;
  29343. shader: string;
  29344. };
  29345. }
  29346. declare module BABYLON {
  29347. /** @hidden */
  29348. export var defaultVertexShader: {
  29349. name: string;
  29350. shader: string;
  29351. };
  29352. }
  29353. declare module BABYLON {
  29354. /** @hidden */
  29355. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29356. MAINUV1: boolean;
  29357. MAINUV2: boolean;
  29358. DIFFUSE: boolean;
  29359. DIFFUSEDIRECTUV: number;
  29360. AMBIENT: boolean;
  29361. AMBIENTDIRECTUV: number;
  29362. OPACITY: boolean;
  29363. OPACITYDIRECTUV: number;
  29364. OPACITYRGB: boolean;
  29365. REFLECTION: boolean;
  29366. EMISSIVE: boolean;
  29367. EMISSIVEDIRECTUV: number;
  29368. SPECULAR: boolean;
  29369. SPECULARDIRECTUV: number;
  29370. BUMP: boolean;
  29371. BUMPDIRECTUV: number;
  29372. PARALLAX: boolean;
  29373. PARALLAXOCCLUSION: boolean;
  29374. SPECULAROVERALPHA: boolean;
  29375. CLIPPLANE: boolean;
  29376. CLIPPLANE2: boolean;
  29377. CLIPPLANE3: boolean;
  29378. CLIPPLANE4: boolean;
  29379. CLIPPLANE5: boolean;
  29380. CLIPPLANE6: boolean;
  29381. ALPHATEST: boolean;
  29382. DEPTHPREPASS: boolean;
  29383. ALPHAFROMDIFFUSE: boolean;
  29384. POINTSIZE: boolean;
  29385. FOG: boolean;
  29386. SPECULARTERM: boolean;
  29387. DIFFUSEFRESNEL: boolean;
  29388. OPACITYFRESNEL: boolean;
  29389. REFLECTIONFRESNEL: boolean;
  29390. REFRACTIONFRESNEL: boolean;
  29391. EMISSIVEFRESNEL: boolean;
  29392. FRESNEL: boolean;
  29393. NORMAL: boolean;
  29394. UV1: boolean;
  29395. UV2: boolean;
  29396. VERTEXCOLOR: boolean;
  29397. VERTEXALPHA: boolean;
  29398. NUM_BONE_INFLUENCERS: number;
  29399. BonesPerMesh: number;
  29400. BONETEXTURE: boolean;
  29401. INSTANCES: boolean;
  29402. THIN_INSTANCES: boolean;
  29403. GLOSSINESS: boolean;
  29404. ROUGHNESS: boolean;
  29405. EMISSIVEASILLUMINATION: boolean;
  29406. LINKEMISSIVEWITHDIFFUSE: boolean;
  29407. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29408. LIGHTMAP: boolean;
  29409. LIGHTMAPDIRECTUV: number;
  29410. OBJECTSPACE_NORMALMAP: boolean;
  29411. USELIGHTMAPASSHADOWMAP: boolean;
  29412. REFLECTIONMAP_3D: boolean;
  29413. REFLECTIONMAP_SPHERICAL: boolean;
  29414. REFLECTIONMAP_PLANAR: boolean;
  29415. REFLECTIONMAP_CUBIC: boolean;
  29416. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29417. REFLECTIONMAP_PROJECTION: boolean;
  29418. REFLECTIONMAP_SKYBOX: boolean;
  29419. REFLECTIONMAP_EXPLICIT: boolean;
  29420. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29421. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29422. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29423. INVERTCUBICMAP: boolean;
  29424. LOGARITHMICDEPTH: boolean;
  29425. REFRACTION: boolean;
  29426. REFRACTIONMAP_3D: boolean;
  29427. REFLECTIONOVERALPHA: boolean;
  29428. TWOSIDEDLIGHTING: boolean;
  29429. SHADOWFLOAT: boolean;
  29430. MORPHTARGETS: boolean;
  29431. MORPHTARGETS_NORMAL: boolean;
  29432. MORPHTARGETS_TANGENT: boolean;
  29433. MORPHTARGETS_UV: boolean;
  29434. NUM_MORPH_INFLUENCERS: number;
  29435. NONUNIFORMSCALING: boolean;
  29436. PREMULTIPLYALPHA: boolean;
  29437. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29438. ALPHABLEND: boolean;
  29439. RGBDLIGHTMAP: boolean;
  29440. RGBDREFLECTION: boolean;
  29441. RGBDREFRACTION: boolean;
  29442. IMAGEPROCESSING: boolean;
  29443. VIGNETTE: boolean;
  29444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29445. VIGNETTEBLENDMODEOPAQUE: boolean;
  29446. TONEMAPPING: boolean;
  29447. TONEMAPPING_ACES: boolean;
  29448. CONTRAST: boolean;
  29449. COLORCURVES: boolean;
  29450. COLORGRADING: boolean;
  29451. COLORGRADING3D: boolean;
  29452. SAMPLER3DGREENDEPTH: boolean;
  29453. SAMPLER3DBGRMAP: boolean;
  29454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29455. MULTIVIEW: boolean;
  29456. /**
  29457. * If the reflection texture on this material is in linear color space
  29458. * @hidden
  29459. */
  29460. IS_REFLECTION_LINEAR: boolean;
  29461. /**
  29462. * If the refraction texture on this material is in linear color space
  29463. * @hidden
  29464. */
  29465. IS_REFRACTION_LINEAR: boolean;
  29466. EXPOSURE: boolean;
  29467. constructor();
  29468. setReflectionMode(modeToEnable: string): void;
  29469. }
  29470. /**
  29471. * This is the default material used in Babylon. It is the best trade off between quality
  29472. * and performances.
  29473. * @see http://doc.babylonjs.com/babylon101/materials
  29474. */
  29475. export class StandardMaterial extends PushMaterial {
  29476. private _diffuseTexture;
  29477. /**
  29478. * The basic texture of the material as viewed under a light.
  29479. */
  29480. diffuseTexture: Nullable<BaseTexture>;
  29481. private _ambientTexture;
  29482. /**
  29483. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29484. */
  29485. ambientTexture: Nullable<BaseTexture>;
  29486. private _opacityTexture;
  29487. /**
  29488. * Define the transparency of the material from a texture.
  29489. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29490. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29491. */
  29492. opacityTexture: Nullable<BaseTexture>;
  29493. private _reflectionTexture;
  29494. /**
  29495. * Define the texture used to display the reflection.
  29496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29497. */
  29498. reflectionTexture: Nullable<BaseTexture>;
  29499. private _emissiveTexture;
  29500. /**
  29501. * Define texture of the material as if self lit.
  29502. * This will be mixed in the final result even in the absence of light.
  29503. */
  29504. emissiveTexture: Nullable<BaseTexture>;
  29505. private _specularTexture;
  29506. /**
  29507. * Define how the color and intensity of the highlight given by the light in the material.
  29508. */
  29509. specularTexture: Nullable<BaseTexture>;
  29510. private _bumpTexture;
  29511. /**
  29512. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29513. * 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.
  29514. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29515. */
  29516. bumpTexture: Nullable<BaseTexture>;
  29517. private _lightmapTexture;
  29518. /**
  29519. * Complex lighting can be computationally expensive to compute at runtime.
  29520. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29521. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29522. */
  29523. lightmapTexture: Nullable<BaseTexture>;
  29524. private _refractionTexture;
  29525. /**
  29526. * Define the texture used to display the refraction.
  29527. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29528. */
  29529. refractionTexture: Nullable<BaseTexture>;
  29530. /**
  29531. * The color of the material lit by the environmental background lighting.
  29532. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29533. */
  29534. ambientColor: Color3;
  29535. /**
  29536. * The basic color of the material as viewed under a light.
  29537. */
  29538. diffuseColor: Color3;
  29539. /**
  29540. * Define how the color and intensity of the highlight given by the light in the material.
  29541. */
  29542. specularColor: Color3;
  29543. /**
  29544. * Define the color of the material as if self lit.
  29545. * This will be mixed in the final result even in the absence of light.
  29546. */
  29547. emissiveColor: Color3;
  29548. /**
  29549. * Defines how sharp are the highlights in the material.
  29550. * The bigger the value the sharper giving a more glossy feeling to the result.
  29551. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29552. */
  29553. specularPower: number;
  29554. private _useAlphaFromDiffuseTexture;
  29555. /**
  29556. * Does the transparency come from the diffuse texture alpha channel.
  29557. */
  29558. useAlphaFromDiffuseTexture: boolean;
  29559. private _useEmissiveAsIllumination;
  29560. /**
  29561. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29562. */
  29563. useEmissiveAsIllumination: boolean;
  29564. private _linkEmissiveWithDiffuse;
  29565. /**
  29566. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29567. * the emissive level when the final color is close to one.
  29568. */
  29569. linkEmissiveWithDiffuse: boolean;
  29570. private _useSpecularOverAlpha;
  29571. /**
  29572. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29573. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29574. */
  29575. useSpecularOverAlpha: boolean;
  29576. private _useReflectionOverAlpha;
  29577. /**
  29578. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29579. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29580. */
  29581. useReflectionOverAlpha: boolean;
  29582. private _disableLighting;
  29583. /**
  29584. * Does lights from the scene impacts this material.
  29585. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29586. */
  29587. disableLighting: boolean;
  29588. private _useObjectSpaceNormalMap;
  29589. /**
  29590. * Allows using an object space normal map (instead of tangent space).
  29591. */
  29592. useObjectSpaceNormalMap: boolean;
  29593. private _useParallax;
  29594. /**
  29595. * Is parallax enabled or not.
  29596. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29597. */
  29598. useParallax: boolean;
  29599. private _useParallaxOcclusion;
  29600. /**
  29601. * Is parallax occlusion enabled or not.
  29602. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29603. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29604. */
  29605. useParallaxOcclusion: boolean;
  29606. /**
  29607. * 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.
  29608. */
  29609. parallaxScaleBias: number;
  29610. private _roughness;
  29611. /**
  29612. * Helps to define how blurry the reflections should appears in the material.
  29613. */
  29614. roughness: number;
  29615. /**
  29616. * In case of refraction, define the value of the index of refraction.
  29617. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29618. */
  29619. indexOfRefraction: number;
  29620. /**
  29621. * Invert the refraction texture alongside the y axis.
  29622. * It can be useful with procedural textures or probe for instance.
  29623. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29624. */
  29625. invertRefractionY: boolean;
  29626. /**
  29627. * Defines the alpha limits in alpha test mode.
  29628. */
  29629. alphaCutOff: number;
  29630. private _useLightmapAsShadowmap;
  29631. /**
  29632. * In case of light mapping, define whether the map contains light or shadow informations.
  29633. */
  29634. useLightmapAsShadowmap: boolean;
  29635. private _diffuseFresnelParameters;
  29636. /**
  29637. * Define the diffuse fresnel parameters of the material.
  29638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29639. */
  29640. diffuseFresnelParameters: FresnelParameters;
  29641. private _opacityFresnelParameters;
  29642. /**
  29643. * Define the opacity fresnel parameters of the material.
  29644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29645. */
  29646. opacityFresnelParameters: FresnelParameters;
  29647. private _reflectionFresnelParameters;
  29648. /**
  29649. * Define the reflection fresnel parameters of the material.
  29650. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29651. */
  29652. reflectionFresnelParameters: FresnelParameters;
  29653. private _refractionFresnelParameters;
  29654. /**
  29655. * Define the refraction fresnel parameters of the material.
  29656. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29657. */
  29658. refractionFresnelParameters: FresnelParameters;
  29659. private _emissiveFresnelParameters;
  29660. /**
  29661. * Define the emissive fresnel parameters of the material.
  29662. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29663. */
  29664. emissiveFresnelParameters: FresnelParameters;
  29665. private _useReflectionFresnelFromSpecular;
  29666. /**
  29667. * If true automatically deducts the fresnels values from the material specularity.
  29668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29669. */
  29670. useReflectionFresnelFromSpecular: boolean;
  29671. private _useGlossinessFromSpecularMapAlpha;
  29672. /**
  29673. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29674. */
  29675. useGlossinessFromSpecularMapAlpha: boolean;
  29676. private _maxSimultaneousLights;
  29677. /**
  29678. * Defines the maximum number of lights that can be used in the material
  29679. */
  29680. maxSimultaneousLights: number;
  29681. private _invertNormalMapX;
  29682. /**
  29683. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29684. */
  29685. invertNormalMapX: boolean;
  29686. private _invertNormalMapY;
  29687. /**
  29688. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29689. */
  29690. invertNormalMapY: boolean;
  29691. private _twoSidedLighting;
  29692. /**
  29693. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29694. */
  29695. twoSidedLighting: boolean;
  29696. /**
  29697. * Default configuration related to image processing available in the standard Material.
  29698. */
  29699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29700. /**
  29701. * Gets the image processing configuration used either in this material.
  29702. */
  29703. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29704. /**
  29705. * Sets the Default image processing configuration used either in the this material.
  29706. *
  29707. * If sets to null, the scene one is in use.
  29708. */
  29709. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29710. /**
  29711. * Keep track of the image processing observer to allow dispose and replace.
  29712. */
  29713. private _imageProcessingObserver;
  29714. /**
  29715. * Attaches a new image processing configuration to the Standard Material.
  29716. * @param configuration
  29717. */
  29718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29719. /**
  29720. * Gets wether the color curves effect is enabled.
  29721. */
  29722. get cameraColorCurvesEnabled(): boolean;
  29723. /**
  29724. * Sets wether the color curves effect is enabled.
  29725. */
  29726. set cameraColorCurvesEnabled(value: boolean);
  29727. /**
  29728. * Gets wether the color grading effect is enabled.
  29729. */
  29730. get cameraColorGradingEnabled(): boolean;
  29731. /**
  29732. * Gets wether the color grading effect is enabled.
  29733. */
  29734. set cameraColorGradingEnabled(value: boolean);
  29735. /**
  29736. * Gets wether tonemapping is enabled or not.
  29737. */
  29738. get cameraToneMappingEnabled(): boolean;
  29739. /**
  29740. * Sets wether tonemapping is enabled or not
  29741. */
  29742. set cameraToneMappingEnabled(value: boolean);
  29743. /**
  29744. * The camera exposure used on this material.
  29745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29746. * This corresponds to a photographic exposure.
  29747. */
  29748. get cameraExposure(): number;
  29749. /**
  29750. * The camera exposure used on this material.
  29751. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29752. * This corresponds to a photographic exposure.
  29753. */
  29754. set cameraExposure(value: number);
  29755. /**
  29756. * Gets The camera contrast used on this material.
  29757. */
  29758. get cameraContrast(): number;
  29759. /**
  29760. * Sets The camera contrast used on this material.
  29761. */
  29762. set cameraContrast(value: number);
  29763. /**
  29764. * Gets the Color Grading 2D Lookup Texture.
  29765. */
  29766. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29767. /**
  29768. * Sets the Color Grading 2D Lookup Texture.
  29769. */
  29770. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29771. /**
  29772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29774. * 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;
  29775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29776. */
  29777. get cameraColorCurves(): Nullable<ColorCurves>;
  29778. /**
  29779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29781. * 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;
  29782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29783. */
  29784. set cameraColorCurves(value: Nullable<ColorCurves>);
  29785. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29786. protected _worldViewProjectionMatrix: Matrix;
  29787. protected _globalAmbientColor: Color3;
  29788. protected _useLogarithmicDepth: boolean;
  29789. protected _rebuildInParallel: boolean;
  29790. /**
  29791. * Instantiates a new standard material.
  29792. * This is the default material used in Babylon. It is the best trade off between quality
  29793. * and performances.
  29794. * @see http://doc.babylonjs.com/babylon101/materials
  29795. * @param name Define the name of the material in the scene
  29796. * @param scene Define the scene the material belong to
  29797. */
  29798. constructor(name: string, scene: Scene);
  29799. /**
  29800. * Gets a boolean indicating that current material needs to register RTT
  29801. */
  29802. get hasRenderTargetTextures(): boolean;
  29803. /**
  29804. * Gets the current class name of the material e.g. "StandardMaterial"
  29805. * Mainly use in serialization.
  29806. * @returns the class name
  29807. */
  29808. getClassName(): string;
  29809. /**
  29810. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29811. * You can try switching to logarithmic depth.
  29812. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29813. */
  29814. get useLogarithmicDepth(): boolean;
  29815. set useLogarithmicDepth(value: boolean);
  29816. /**
  29817. * Specifies if the material will require alpha blending
  29818. * @returns a boolean specifying if alpha blending is needed
  29819. */
  29820. needAlphaBlending(): boolean;
  29821. /**
  29822. * Specifies if this material should be rendered in alpha test mode
  29823. * @returns a boolean specifying if an alpha test is needed.
  29824. */
  29825. needAlphaTesting(): boolean;
  29826. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29827. /**
  29828. * Get the texture used for alpha test purpose.
  29829. * @returns the diffuse texture in case of the standard material.
  29830. */
  29831. getAlphaTestTexture(): Nullable<BaseTexture>;
  29832. /**
  29833. * Get if the submesh is ready to be used and all its information available.
  29834. * Child classes can use it to update shaders
  29835. * @param mesh defines the mesh to check
  29836. * @param subMesh defines which submesh to check
  29837. * @param useInstances specifies that instances should be used
  29838. * @returns a boolean indicating that the submesh is ready or not
  29839. */
  29840. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29841. /**
  29842. * Builds the material UBO layouts.
  29843. * Used internally during the effect preparation.
  29844. */
  29845. buildUniformLayout(): void;
  29846. /**
  29847. * Unbinds the material from the mesh
  29848. */
  29849. unbind(): void;
  29850. /**
  29851. * Binds the submesh to this material by preparing the effect and shader to draw
  29852. * @param world defines the world transformation matrix
  29853. * @param mesh defines the mesh containing the submesh
  29854. * @param subMesh defines the submesh to bind the material to
  29855. */
  29856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29857. /**
  29858. * Get the list of animatables in the material.
  29859. * @returns the list of animatables object used in the material
  29860. */
  29861. getAnimatables(): IAnimatable[];
  29862. /**
  29863. * Gets the active textures from the material
  29864. * @returns an array of textures
  29865. */
  29866. getActiveTextures(): BaseTexture[];
  29867. /**
  29868. * Specifies if the material uses a texture
  29869. * @param texture defines the texture to check against the material
  29870. * @returns a boolean specifying if the material uses the texture
  29871. */
  29872. hasTexture(texture: BaseTexture): boolean;
  29873. /**
  29874. * Disposes the material
  29875. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29876. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29877. */
  29878. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29879. /**
  29880. * Makes a duplicate of the material, and gives it a new name
  29881. * @param name defines the new name for the duplicated material
  29882. * @returns the cloned material
  29883. */
  29884. clone(name: string): StandardMaterial;
  29885. /**
  29886. * Serializes this material in a JSON representation
  29887. * @returns the serialized material object
  29888. */
  29889. serialize(): any;
  29890. /**
  29891. * Creates a standard material from parsed material data
  29892. * @param source defines the JSON representation of the material
  29893. * @param scene defines the hosting scene
  29894. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29895. * @returns a new standard material
  29896. */
  29897. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29898. /**
  29899. * Are diffuse textures enabled in the application.
  29900. */
  29901. static get DiffuseTextureEnabled(): boolean;
  29902. static set DiffuseTextureEnabled(value: boolean);
  29903. /**
  29904. * Are ambient textures enabled in the application.
  29905. */
  29906. static get AmbientTextureEnabled(): boolean;
  29907. static set AmbientTextureEnabled(value: boolean);
  29908. /**
  29909. * Are opacity textures enabled in the application.
  29910. */
  29911. static get OpacityTextureEnabled(): boolean;
  29912. static set OpacityTextureEnabled(value: boolean);
  29913. /**
  29914. * Are reflection textures enabled in the application.
  29915. */
  29916. static get ReflectionTextureEnabled(): boolean;
  29917. static set ReflectionTextureEnabled(value: boolean);
  29918. /**
  29919. * Are emissive textures enabled in the application.
  29920. */
  29921. static get EmissiveTextureEnabled(): boolean;
  29922. static set EmissiveTextureEnabled(value: boolean);
  29923. /**
  29924. * Are specular textures enabled in the application.
  29925. */
  29926. static get SpecularTextureEnabled(): boolean;
  29927. static set SpecularTextureEnabled(value: boolean);
  29928. /**
  29929. * Are bump textures enabled in the application.
  29930. */
  29931. static get BumpTextureEnabled(): boolean;
  29932. static set BumpTextureEnabled(value: boolean);
  29933. /**
  29934. * Are lightmap textures enabled in the application.
  29935. */
  29936. static get LightmapTextureEnabled(): boolean;
  29937. static set LightmapTextureEnabled(value: boolean);
  29938. /**
  29939. * Are refraction textures enabled in the application.
  29940. */
  29941. static get RefractionTextureEnabled(): boolean;
  29942. static set RefractionTextureEnabled(value: boolean);
  29943. /**
  29944. * Are color grading textures enabled in the application.
  29945. */
  29946. static get ColorGradingTextureEnabled(): boolean;
  29947. static set ColorGradingTextureEnabled(value: boolean);
  29948. /**
  29949. * Are fresnels enabled in the application.
  29950. */
  29951. static get FresnelEnabled(): boolean;
  29952. static set FresnelEnabled(value: boolean);
  29953. }
  29954. }
  29955. declare module BABYLON {
  29956. /**
  29957. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29958. *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.
  29959. * The SPS is also a particle system. It provides some methods to manage the particles.
  29960. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29961. *
  29962. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29963. */
  29964. export class SolidParticleSystem implements IDisposable {
  29965. /**
  29966. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29967. * Example : var p = SPS.particles[i];
  29968. */
  29969. particles: SolidParticle[];
  29970. /**
  29971. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29972. */
  29973. nbParticles: number;
  29974. /**
  29975. * If the particles must ever face the camera (default false). Useful for planar particles.
  29976. */
  29977. billboard: boolean;
  29978. /**
  29979. * Recompute normals when adding a shape
  29980. */
  29981. recomputeNormals: boolean;
  29982. /**
  29983. * This a counter ofr your own usage. It's not set by any SPS functions.
  29984. */
  29985. counter: number;
  29986. /**
  29987. * The SPS name. This name is also given to the underlying mesh.
  29988. */
  29989. name: string;
  29990. /**
  29991. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29992. */
  29993. mesh: Mesh;
  29994. /**
  29995. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29996. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29997. */
  29998. vars: any;
  29999. /**
  30000. * This array is populated when the SPS is set as 'pickable'.
  30001. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30002. * Each element of this array is an object `{idx: int, faceId: int}`.
  30003. * `idx` is the picked particle index in the `SPS.particles` array
  30004. * `faceId` is the picked face index counted within this particle.
  30005. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30006. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30007. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30008. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30009. */
  30010. pickedParticles: {
  30011. idx: number;
  30012. faceId: number;
  30013. }[];
  30014. /**
  30015. * This array is populated when the SPS is set as 'pickable'
  30016. * Each key of this array is a submesh index.
  30017. * Each element of this array is a second array defined like this :
  30018. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30019. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30020. * `idx` is the picked particle index in the `SPS.particles` array
  30021. * `faceId` is the picked face index counted within this particle.
  30022. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30023. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30024. */
  30025. pickedBySubMesh: {
  30026. idx: number;
  30027. faceId: number;
  30028. }[][];
  30029. /**
  30030. * This array is populated when `enableDepthSort` is set to true.
  30031. * Each element of this array is an instance of the class DepthSortedParticle.
  30032. */
  30033. depthSortedParticles: DepthSortedParticle[];
  30034. /**
  30035. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30036. * @hidden
  30037. */
  30038. _bSphereOnly: boolean;
  30039. /**
  30040. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30041. * @hidden
  30042. */
  30043. _bSphereRadiusFactor: number;
  30044. private _scene;
  30045. private _positions;
  30046. private _indices;
  30047. private _normals;
  30048. private _colors;
  30049. private _uvs;
  30050. private _indices32;
  30051. private _positions32;
  30052. private _normals32;
  30053. private _fixedNormal32;
  30054. private _colors32;
  30055. private _uvs32;
  30056. private _index;
  30057. private _updatable;
  30058. private _pickable;
  30059. private _isVisibilityBoxLocked;
  30060. private _alwaysVisible;
  30061. private _depthSort;
  30062. private _expandable;
  30063. private _shapeCounter;
  30064. private _copy;
  30065. private _color;
  30066. private _computeParticleColor;
  30067. private _computeParticleTexture;
  30068. private _computeParticleRotation;
  30069. private _computeParticleVertex;
  30070. private _computeBoundingBox;
  30071. private _depthSortParticles;
  30072. private _camera;
  30073. private _mustUnrotateFixedNormals;
  30074. private _particlesIntersect;
  30075. private _needs32Bits;
  30076. private _isNotBuilt;
  30077. private _lastParticleId;
  30078. private _idxOfId;
  30079. private _multimaterialEnabled;
  30080. private _useModelMaterial;
  30081. private _indicesByMaterial;
  30082. private _materialIndexes;
  30083. private _depthSortFunction;
  30084. private _materialSortFunction;
  30085. private _materials;
  30086. private _multimaterial;
  30087. private _materialIndexesById;
  30088. private _defaultMaterial;
  30089. private _autoUpdateSubMeshes;
  30090. private _tmpVertex;
  30091. /**
  30092. * Creates a SPS (Solid Particle System) object.
  30093. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30094. * @param scene (Scene) is the scene in which the SPS is added.
  30095. * @param options defines the options of the sps e.g.
  30096. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30097. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30098. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30099. * * 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.
  30100. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30101. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30102. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30103. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30104. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30105. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30106. */
  30107. constructor(name: string, scene: Scene, options?: {
  30108. updatable?: boolean;
  30109. isPickable?: boolean;
  30110. enableDepthSort?: boolean;
  30111. particleIntersection?: boolean;
  30112. boundingSphereOnly?: boolean;
  30113. bSphereRadiusFactor?: number;
  30114. expandable?: boolean;
  30115. useModelMaterial?: boolean;
  30116. enableMultiMaterial?: boolean;
  30117. });
  30118. /**
  30119. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30120. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30121. * @returns the created mesh
  30122. */
  30123. buildMesh(): Mesh;
  30124. /**
  30125. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30126. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30127. * Thus the particles generated from `digest()` have their property `position` set yet.
  30128. * @param mesh ( Mesh ) is the mesh to be digested
  30129. * @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
  30130. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30131. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30132. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30133. * @returns the current SPS
  30134. */
  30135. digest(mesh: Mesh, options?: {
  30136. facetNb?: number;
  30137. number?: number;
  30138. delta?: number;
  30139. storage?: [];
  30140. }): SolidParticleSystem;
  30141. /**
  30142. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30143. * @hidden
  30144. */
  30145. private _unrotateFixedNormals;
  30146. /**
  30147. * Resets the temporary working copy particle
  30148. * @hidden
  30149. */
  30150. private _resetCopy;
  30151. /**
  30152. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30153. * @param p the current index in the positions array to be updated
  30154. * @param ind the current index in the indices array
  30155. * @param shape a Vector3 array, the shape geometry
  30156. * @param positions the positions array to be updated
  30157. * @param meshInd the shape indices array
  30158. * @param indices the indices array to be updated
  30159. * @param meshUV the shape uv array
  30160. * @param uvs the uv array to be updated
  30161. * @param meshCol the shape color array
  30162. * @param colors the color array to be updated
  30163. * @param meshNor the shape normals array
  30164. * @param normals the normals array to be updated
  30165. * @param idx the particle index
  30166. * @param idxInShape the particle index in its shape
  30167. * @param options the addShape() method passed options
  30168. * @model the particle model
  30169. * @hidden
  30170. */
  30171. private _meshBuilder;
  30172. /**
  30173. * Returns a shape Vector3 array from positions float array
  30174. * @param positions float array
  30175. * @returns a vector3 array
  30176. * @hidden
  30177. */
  30178. private _posToShape;
  30179. /**
  30180. * Returns a shapeUV array from a float uvs (array deep copy)
  30181. * @param uvs as a float array
  30182. * @returns a shapeUV array
  30183. * @hidden
  30184. */
  30185. private _uvsToShapeUV;
  30186. /**
  30187. * Adds a new particle object in the particles array
  30188. * @param idx particle index in particles array
  30189. * @param id particle id
  30190. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30191. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30192. * @param model particle ModelShape object
  30193. * @param shapeId model shape identifier
  30194. * @param idxInShape index of the particle in the current model
  30195. * @param bInfo model bounding info object
  30196. * @param storage target storage array, if any
  30197. * @hidden
  30198. */
  30199. private _addParticle;
  30200. /**
  30201. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30202. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30203. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30204. * @param nb (positive integer) the number of particles to be created from this model
  30205. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30206. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30207. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30208. * @returns the number of shapes in the system
  30209. */
  30210. addShape(mesh: Mesh, nb: number, options?: {
  30211. positionFunction?: any;
  30212. vertexFunction?: any;
  30213. storage?: [];
  30214. }): number;
  30215. /**
  30216. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30217. * @hidden
  30218. */
  30219. private _rebuildParticle;
  30220. /**
  30221. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30222. * @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.
  30223. * @returns the SPS.
  30224. */
  30225. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30226. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30227. * Returns an array with the removed particles.
  30228. * 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.
  30229. * The SPS can't be empty so at least one particle needs to remain in place.
  30230. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30231. * @param start index of the first particle to remove
  30232. * @param end index of the last particle to remove (included)
  30233. * @returns an array populated with the removed particles
  30234. */
  30235. removeParticles(start: number, end: number): SolidParticle[];
  30236. /**
  30237. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30238. * @param solidParticleArray an array populated with Solid Particles objects
  30239. * @returns the SPS
  30240. */
  30241. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30242. /**
  30243. * Creates a new particle and modifies the SPS mesh geometry :
  30244. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30245. * - calls _addParticle() to populate the particle array
  30246. * factorized code from addShape() and insertParticlesFromArray()
  30247. * @param idx particle index in the particles array
  30248. * @param i particle index in its shape
  30249. * @param modelShape particle ModelShape object
  30250. * @param shape shape vertex array
  30251. * @param meshInd shape indices array
  30252. * @param meshUV shape uv array
  30253. * @param meshCol shape color array
  30254. * @param meshNor shape normals array
  30255. * @param bbInfo shape bounding info
  30256. * @param storage target particle storage
  30257. * @options addShape() passed options
  30258. * @hidden
  30259. */
  30260. private _insertNewParticle;
  30261. /**
  30262. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30263. * This method calls `updateParticle()` for each particle of the SPS.
  30264. * For an animated SPS, it is usually called within the render loop.
  30265. * 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.
  30266. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30267. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30268. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30269. * @returns the SPS.
  30270. */
  30271. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30272. /**
  30273. * Disposes the SPS.
  30274. */
  30275. dispose(): void;
  30276. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30277. * idx is the particle index in the SPS
  30278. * faceId is the picked face index counted within this particle.
  30279. * Returns null if the pickInfo can't identify a picked particle.
  30280. * @param pickingInfo (PickingInfo object)
  30281. * @returns {idx: number, faceId: number} or null
  30282. */
  30283. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30284. idx: number;
  30285. faceId: number;
  30286. }>;
  30287. /**
  30288. * Returns a SolidParticle object from its identifier : particle.id
  30289. * @param id (integer) the particle Id
  30290. * @returns the searched particle or null if not found in the SPS.
  30291. */
  30292. getParticleById(id: number): Nullable<SolidParticle>;
  30293. /**
  30294. * Returns a new array populated with the particles having the passed shapeId.
  30295. * @param shapeId (integer) the shape identifier
  30296. * @returns a new solid particle array
  30297. */
  30298. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30299. /**
  30300. * Populates the passed array "ref" with the particles having the passed shapeId.
  30301. * @param shapeId the shape identifier
  30302. * @returns the SPS
  30303. * @param ref
  30304. */
  30305. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30306. /**
  30307. * Computes the required SubMeshes according the materials assigned to the particles.
  30308. * @returns the solid particle system.
  30309. * Does nothing if called before the SPS mesh is built.
  30310. */
  30311. computeSubMeshes(): SolidParticleSystem;
  30312. /**
  30313. * Sorts the solid particles by material when MultiMaterial is enabled.
  30314. * Updates the indices32 array.
  30315. * Updates the indicesByMaterial array.
  30316. * Updates the mesh indices array.
  30317. * @returns the SPS
  30318. * @hidden
  30319. */
  30320. private _sortParticlesByMaterial;
  30321. /**
  30322. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30323. * @hidden
  30324. */
  30325. private _setMaterialIndexesById;
  30326. /**
  30327. * Returns an array with unique values of Materials from the passed array
  30328. * @param array the material array to be checked and filtered
  30329. * @hidden
  30330. */
  30331. private _filterUniqueMaterialId;
  30332. /**
  30333. * Sets a new Standard Material as _defaultMaterial if not already set.
  30334. * @hidden
  30335. */
  30336. private _setDefaultMaterial;
  30337. /**
  30338. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30339. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30340. * @returns the SPS.
  30341. */
  30342. refreshVisibleSize(): SolidParticleSystem;
  30343. /**
  30344. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30345. * @param size the size (float) of the visibility box
  30346. * note : this doesn't lock the SPS mesh bounding box.
  30347. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30348. */
  30349. setVisibilityBox(size: number): void;
  30350. /**
  30351. * Gets whether the SPS as always visible or not
  30352. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30353. */
  30354. get isAlwaysVisible(): boolean;
  30355. /**
  30356. * Sets the SPS as always visible or not
  30357. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30358. */
  30359. set isAlwaysVisible(val: boolean);
  30360. /**
  30361. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30363. */
  30364. set isVisibilityBoxLocked(val: boolean);
  30365. /**
  30366. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30367. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30368. */
  30369. get isVisibilityBoxLocked(): boolean;
  30370. /**
  30371. * Tells to `setParticles()` to compute the particle rotations or not.
  30372. * Default value : true. The SPS is faster when it's set to false.
  30373. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30374. */
  30375. set computeParticleRotation(val: boolean);
  30376. /**
  30377. * Tells to `setParticles()` to compute the particle colors or not.
  30378. * Default value : true. The SPS is faster when it's set to false.
  30379. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30380. */
  30381. set computeParticleColor(val: boolean);
  30382. set computeParticleTexture(val: boolean);
  30383. /**
  30384. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30385. * Default value : false. The SPS is faster when it's set to false.
  30386. * Note : the particle custom vertex positions aren't stored values.
  30387. */
  30388. set computeParticleVertex(val: boolean);
  30389. /**
  30390. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30391. */
  30392. set computeBoundingBox(val: boolean);
  30393. /**
  30394. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30395. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30396. * Default : `true`
  30397. */
  30398. set depthSortParticles(val: boolean);
  30399. /**
  30400. * Gets if `setParticles()` computes the particle rotations or not.
  30401. * Default value : true. The SPS is faster when it's set to false.
  30402. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30403. */
  30404. get computeParticleRotation(): boolean;
  30405. /**
  30406. * Gets if `setParticles()` computes the particle colors or not.
  30407. * Default value : true. The SPS is faster when it's set to false.
  30408. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30409. */
  30410. get computeParticleColor(): boolean;
  30411. /**
  30412. * Gets if `setParticles()` computes the particle textures or not.
  30413. * Default value : true. The SPS is faster when it's set to false.
  30414. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30415. */
  30416. get computeParticleTexture(): boolean;
  30417. /**
  30418. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30419. * Default value : false. The SPS is faster when it's set to false.
  30420. * Note : the particle custom vertex positions aren't stored values.
  30421. */
  30422. get computeParticleVertex(): boolean;
  30423. /**
  30424. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30425. */
  30426. get computeBoundingBox(): boolean;
  30427. /**
  30428. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30429. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30430. * Default : `true`
  30431. */
  30432. get depthSortParticles(): boolean;
  30433. /**
  30434. * Gets if the SPS is created as expandable at construction time.
  30435. * Default : `false`
  30436. */
  30437. get expandable(): boolean;
  30438. /**
  30439. * Gets if the SPS supports the Multi Materials
  30440. */
  30441. get multimaterialEnabled(): boolean;
  30442. /**
  30443. * Gets if the SPS uses the model materials for its own multimaterial.
  30444. */
  30445. get useModelMaterial(): boolean;
  30446. /**
  30447. * The SPS used material array.
  30448. */
  30449. get materials(): Material[];
  30450. /**
  30451. * Sets the SPS MultiMaterial from the passed materials.
  30452. * Note : the passed array is internally copied and not used then by reference.
  30453. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30454. */
  30455. setMultiMaterial(materials: Material[]): void;
  30456. /**
  30457. * The SPS computed multimaterial object
  30458. */
  30459. get multimaterial(): MultiMaterial;
  30460. set multimaterial(mm: MultiMaterial);
  30461. /**
  30462. * If the subMeshes must be updated on the next call to setParticles()
  30463. */
  30464. get autoUpdateSubMeshes(): boolean;
  30465. set autoUpdateSubMeshes(val: boolean);
  30466. /**
  30467. * This function does nothing. It may be overwritten to set all the particle first values.
  30468. * The SPS doesn't call this function, you may have to call it by your own.
  30469. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30470. */
  30471. initParticles(): void;
  30472. /**
  30473. * This function does nothing. It may be overwritten to recycle a particle.
  30474. * The SPS doesn't call this function, you may have to call it by your own.
  30475. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30476. * @param particle The particle to recycle
  30477. * @returns the recycled particle
  30478. */
  30479. recycleParticle(particle: SolidParticle): SolidParticle;
  30480. /**
  30481. * Updates a particle : this function should be overwritten by the user.
  30482. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30483. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30484. * @example : just set a particle position or velocity and recycle conditions
  30485. * @param particle The particle to update
  30486. * @returns the updated particle
  30487. */
  30488. updateParticle(particle: SolidParticle): SolidParticle;
  30489. /**
  30490. * Updates a vertex of a particle : it can be overwritten by the user.
  30491. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30492. * @param particle the current particle
  30493. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30494. * @param pt the index of the current vertex in the particle shape
  30495. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30496. * @example : just set a vertex particle position or color
  30497. * @returns the sps
  30498. */
  30499. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30500. /**
  30501. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30502. * This does nothing and may be overwritten by the user.
  30503. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30504. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30505. * @param update the boolean update value actually passed to setParticles()
  30506. */
  30507. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30508. /**
  30509. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30510. * This will be passed three parameters.
  30511. * This does nothing and may be overwritten by the user.
  30512. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30513. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30514. * @param update the boolean update value actually passed to setParticles()
  30515. */
  30516. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30517. }
  30518. }
  30519. declare module BABYLON {
  30520. /**
  30521. * Represents one particle of a solid particle system.
  30522. */
  30523. export class SolidParticle {
  30524. /**
  30525. * particle global index
  30526. */
  30527. idx: number;
  30528. /**
  30529. * particle identifier
  30530. */
  30531. id: number;
  30532. /**
  30533. * The color of the particle
  30534. */
  30535. color: Nullable<Color4>;
  30536. /**
  30537. * The world space position of the particle.
  30538. */
  30539. position: Vector3;
  30540. /**
  30541. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30542. */
  30543. rotation: Vector3;
  30544. /**
  30545. * The world space rotation quaternion of the particle.
  30546. */
  30547. rotationQuaternion: Nullable<Quaternion>;
  30548. /**
  30549. * The scaling of the particle.
  30550. */
  30551. scaling: Vector3;
  30552. /**
  30553. * The uvs of the particle.
  30554. */
  30555. uvs: Vector4;
  30556. /**
  30557. * The current speed of the particle.
  30558. */
  30559. velocity: Vector3;
  30560. /**
  30561. * The pivot point in the particle local space.
  30562. */
  30563. pivot: Vector3;
  30564. /**
  30565. * Must the particle be translated from its pivot point in its local space ?
  30566. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30567. * Default : false
  30568. */
  30569. translateFromPivot: boolean;
  30570. /**
  30571. * Is the particle active or not ?
  30572. */
  30573. alive: boolean;
  30574. /**
  30575. * Is the particle visible or not ?
  30576. */
  30577. isVisible: boolean;
  30578. /**
  30579. * Index of this particle in the global "positions" array (Internal use)
  30580. * @hidden
  30581. */
  30582. _pos: number;
  30583. /**
  30584. * @hidden Index of this particle in the global "indices" array (Internal use)
  30585. */
  30586. _ind: number;
  30587. /**
  30588. * @hidden ModelShape of this particle (Internal use)
  30589. */
  30590. _model: ModelShape;
  30591. /**
  30592. * ModelShape id of this particle
  30593. */
  30594. shapeId: number;
  30595. /**
  30596. * Index of the particle in its shape id
  30597. */
  30598. idxInShape: number;
  30599. /**
  30600. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30601. */
  30602. _modelBoundingInfo: BoundingInfo;
  30603. /**
  30604. * @hidden Particle BoundingInfo object (Internal use)
  30605. */
  30606. _boundingInfo: BoundingInfo;
  30607. /**
  30608. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30609. */
  30610. _sps: SolidParticleSystem;
  30611. /**
  30612. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30613. */
  30614. _stillInvisible: boolean;
  30615. /**
  30616. * @hidden Last computed particle rotation matrix
  30617. */
  30618. _rotationMatrix: number[];
  30619. /**
  30620. * Parent particle Id, if any.
  30621. * Default null.
  30622. */
  30623. parentId: Nullable<number>;
  30624. /**
  30625. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30626. */
  30627. materialIndex: Nullable<number>;
  30628. /**
  30629. * Custom object or properties.
  30630. */
  30631. props: Nullable<any>;
  30632. /**
  30633. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30634. * The possible values are :
  30635. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30636. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30637. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30638. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30639. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30640. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30641. * */
  30642. cullingStrategy: number;
  30643. /**
  30644. * @hidden Internal global position in the SPS.
  30645. */
  30646. _globalPosition: Vector3;
  30647. /**
  30648. * Creates a Solid Particle object.
  30649. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30650. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30651. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30652. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30653. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30654. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30655. * @param shapeId (integer) is the model shape identifier in the SPS.
  30656. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30657. * @param sps defines the sps it is associated to
  30658. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30659. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30660. */
  30661. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30662. /**
  30663. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30664. * @param target the particle target
  30665. * @returns the current particle
  30666. */
  30667. copyToRef(target: SolidParticle): SolidParticle;
  30668. /**
  30669. * Legacy support, changed scale to scaling
  30670. */
  30671. get scale(): Vector3;
  30672. /**
  30673. * Legacy support, changed scale to scaling
  30674. */
  30675. set scale(scale: Vector3);
  30676. /**
  30677. * Legacy support, changed quaternion to rotationQuaternion
  30678. */
  30679. get quaternion(): Nullable<Quaternion>;
  30680. /**
  30681. * Legacy support, changed quaternion to rotationQuaternion
  30682. */
  30683. set quaternion(q: Nullable<Quaternion>);
  30684. /**
  30685. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30686. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30687. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30688. * @returns true if it intersects
  30689. */
  30690. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30691. /**
  30692. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30693. * A particle is in the frustum if its bounding box intersects the frustum
  30694. * @param frustumPlanes defines the frustum to test
  30695. * @returns true if the particle is in the frustum planes
  30696. */
  30697. isInFrustum(frustumPlanes: Plane[]): boolean;
  30698. /**
  30699. * get the rotation matrix of the particle
  30700. * @hidden
  30701. */
  30702. getRotationMatrix(m: Matrix): void;
  30703. }
  30704. /**
  30705. * Represents the shape of the model used by one particle of a solid particle system.
  30706. * SPS internal tool, don't use it manually.
  30707. */
  30708. export class ModelShape {
  30709. /**
  30710. * The shape id
  30711. * @hidden
  30712. */
  30713. shapeID: number;
  30714. /**
  30715. * flat array of model positions (internal use)
  30716. * @hidden
  30717. */
  30718. _shape: Vector3[];
  30719. /**
  30720. * flat array of model UVs (internal use)
  30721. * @hidden
  30722. */
  30723. _shapeUV: number[];
  30724. /**
  30725. * color array of the model
  30726. * @hidden
  30727. */
  30728. _shapeColors: number[];
  30729. /**
  30730. * indices array of the model
  30731. * @hidden
  30732. */
  30733. _indices: number[];
  30734. /**
  30735. * normals array of the model
  30736. * @hidden
  30737. */
  30738. _normals: number[];
  30739. /**
  30740. * length of the shape in the model indices array (internal use)
  30741. * @hidden
  30742. */
  30743. _indicesLength: number;
  30744. /**
  30745. * Custom position function (internal use)
  30746. * @hidden
  30747. */
  30748. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30749. /**
  30750. * Custom vertex function (internal use)
  30751. * @hidden
  30752. */
  30753. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30754. /**
  30755. * Model material (internal use)
  30756. * @hidden
  30757. */
  30758. _material: Nullable<Material>;
  30759. /**
  30760. * 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.
  30761. * SPS internal tool, don't use it manually.
  30762. * @hidden
  30763. */
  30764. 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>);
  30765. }
  30766. /**
  30767. * Represents a Depth Sorted Particle in the solid particle system.
  30768. * @hidden
  30769. */
  30770. export class DepthSortedParticle {
  30771. /**
  30772. * Particle index
  30773. */
  30774. idx: number;
  30775. /**
  30776. * Index of the particle in the "indices" array
  30777. */
  30778. ind: number;
  30779. /**
  30780. * Length of the particle shape in the "indices" array
  30781. */
  30782. indicesLength: number;
  30783. /**
  30784. * Squared distance from the particle to the camera
  30785. */
  30786. sqDistance: number;
  30787. /**
  30788. * Material index when used with MultiMaterials
  30789. */
  30790. materialIndex: number;
  30791. /**
  30792. * Creates a new sorted particle
  30793. * @param materialIndex
  30794. */
  30795. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30796. }
  30797. /**
  30798. * Represents a solid particle vertex
  30799. */
  30800. export class SolidParticleVertex {
  30801. /**
  30802. * Vertex position
  30803. */
  30804. position: Vector3;
  30805. /**
  30806. * Vertex color
  30807. */
  30808. color: Color4;
  30809. /**
  30810. * Vertex UV
  30811. */
  30812. uv: Vector2;
  30813. /**
  30814. * Creates a new solid particle vertex
  30815. */
  30816. constructor();
  30817. /** Vertex x coordinate */
  30818. get x(): number;
  30819. set x(val: number);
  30820. /** Vertex y coordinate */
  30821. get y(): number;
  30822. set y(val: number);
  30823. /** Vertex z coordinate */
  30824. get z(): number;
  30825. set z(val: number);
  30826. }
  30827. }
  30828. declare module BABYLON {
  30829. /**
  30830. * @hidden
  30831. */
  30832. export class _MeshCollisionData {
  30833. _checkCollisions: boolean;
  30834. _collisionMask: number;
  30835. _collisionGroup: number;
  30836. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30837. _collider: Nullable<Collider>;
  30838. _oldPositionForCollisions: Vector3;
  30839. _diffPositionForCollisions: Vector3;
  30840. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30841. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30842. }
  30843. }
  30844. declare module BABYLON {
  30845. /** @hidden */
  30846. class _FacetDataStorage {
  30847. facetPositions: Vector3[];
  30848. facetNormals: Vector3[];
  30849. facetPartitioning: number[][];
  30850. facetNb: number;
  30851. partitioningSubdivisions: number;
  30852. partitioningBBoxRatio: number;
  30853. facetDataEnabled: boolean;
  30854. facetParameters: any;
  30855. bbSize: Vector3;
  30856. subDiv: {
  30857. max: number;
  30858. X: number;
  30859. Y: number;
  30860. Z: number;
  30861. };
  30862. facetDepthSort: boolean;
  30863. facetDepthSortEnabled: boolean;
  30864. depthSortedIndices: IndicesArray;
  30865. depthSortedFacets: {
  30866. ind: number;
  30867. sqDistance: number;
  30868. }[];
  30869. facetDepthSortFunction: (f1: {
  30870. ind: number;
  30871. sqDistance: number;
  30872. }, f2: {
  30873. ind: number;
  30874. sqDistance: number;
  30875. }) => number;
  30876. facetDepthSortFrom: Vector3;
  30877. facetDepthSortOrigin: Vector3;
  30878. invertedMatrix: Matrix;
  30879. }
  30880. /**
  30881. * @hidden
  30882. **/
  30883. class _InternalAbstractMeshDataInfo {
  30884. _hasVertexAlpha: boolean;
  30885. _useVertexColors: boolean;
  30886. _numBoneInfluencers: number;
  30887. _applyFog: boolean;
  30888. _receiveShadows: boolean;
  30889. _facetData: _FacetDataStorage;
  30890. _visibility: number;
  30891. _skeleton: Nullable<Skeleton>;
  30892. _layerMask: number;
  30893. _computeBonesUsingShaders: boolean;
  30894. _isActive: boolean;
  30895. _onlyForInstances: boolean;
  30896. _isActiveIntermediate: boolean;
  30897. _onlyForInstancesIntermediate: boolean;
  30898. _actAsRegularMesh: boolean;
  30899. }
  30900. /**
  30901. * Class used to store all common mesh properties
  30902. */
  30903. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30904. /** No occlusion */
  30905. static OCCLUSION_TYPE_NONE: number;
  30906. /** Occlusion set to optimisitic */
  30907. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30908. /** Occlusion set to strict */
  30909. static OCCLUSION_TYPE_STRICT: number;
  30910. /** Use an accurante occlusion algorithm */
  30911. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30912. /** Use a conservative occlusion algorithm */
  30913. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30914. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30915. * Test order :
  30916. * Is the bounding sphere outside the frustum ?
  30917. * If not, are the bounding box vertices outside the frustum ?
  30918. * It not, then the cullable object is in the frustum.
  30919. */
  30920. static readonly CULLINGSTRATEGY_STANDARD: number;
  30921. /** Culling strategy : Bounding Sphere Only.
  30922. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30923. * It's also less accurate than the standard because some not visible objects can still be selected.
  30924. * Test : is the bounding sphere outside the frustum ?
  30925. * If not, then the cullable object is in the frustum.
  30926. */
  30927. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30928. /** Culling strategy : Optimistic Inclusion.
  30929. * This in an inclusion test first, then the standard exclusion test.
  30930. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30931. * 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.
  30932. * Anyway, it's as accurate as the standard strategy.
  30933. * Test :
  30934. * Is the cullable object bounding sphere center in the frustum ?
  30935. * If not, apply the default culling strategy.
  30936. */
  30937. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30938. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30939. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30940. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30941. * 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.
  30942. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30943. * Test :
  30944. * Is the cullable object bounding sphere center in the frustum ?
  30945. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30946. */
  30947. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30948. /**
  30949. * No billboard
  30950. */
  30951. static get BILLBOARDMODE_NONE(): number;
  30952. /** Billboard on X axis */
  30953. static get BILLBOARDMODE_X(): number;
  30954. /** Billboard on Y axis */
  30955. static get BILLBOARDMODE_Y(): number;
  30956. /** Billboard on Z axis */
  30957. static get BILLBOARDMODE_Z(): number;
  30958. /** Billboard on all axes */
  30959. static get BILLBOARDMODE_ALL(): number;
  30960. /** Billboard on using position instead of orientation */
  30961. static get BILLBOARDMODE_USE_POSITION(): number;
  30962. /** @hidden */
  30963. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30964. /**
  30965. * The culling strategy to use to check whether the mesh must be rendered or not.
  30966. * This value can be changed at any time and will be used on the next render mesh selection.
  30967. * The possible values are :
  30968. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30969. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30970. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30971. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30972. * Please read each static variable documentation to get details about the culling process.
  30973. * */
  30974. cullingStrategy: number;
  30975. /**
  30976. * Gets the number of facets in the mesh
  30977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30978. */
  30979. get facetNb(): number;
  30980. /**
  30981. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30983. */
  30984. get partitioningSubdivisions(): number;
  30985. set partitioningSubdivisions(nb: number);
  30986. /**
  30987. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30988. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30990. */
  30991. get partitioningBBoxRatio(): number;
  30992. set partitioningBBoxRatio(ratio: number);
  30993. /**
  30994. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30995. * Works only for updatable meshes.
  30996. * Doesn't work with multi-materials
  30997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30998. */
  30999. get mustDepthSortFacets(): boolean;
  31000. set mustDepthSortFacets(sort: boolean);
  31001. /**
  31002. * The location (Vector3) where the facet depth sort must be computed from.
  31003. * By default, the active camera position.
  31004. * Used only when facet depth sort is enabled
  31005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31006. */
  31007. get facetDepthSortFrom(): Vector3;
  31008. set facetDepthSortFrom(location: Vector3);
  31009. /**
  31010. * gets a boolean indicating if facetData is enabled
  31011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31012. */
  31013. get isFacetDataEnabled(): boolean;
  31014. /** @hidden */
  31015. _updateNonUniformScalingState(value: boolean): boolean;
  31016. /**
  31017. * An event triggered when this mesh collides with another one
  31018. */
  31019. onCollideObservable: Observable<AbstractMesh>;
  31020. /** Set a function to call when this mesh collides with another one */
  31021. set onCollide(callback: () => void);
  31022. /**
  31023. * An event triggered when the collision's position changes
  31024. */
  31025. onCollisionPositionChangeObservable: Observable<Vector3>;
  31026. /** Set a function to call when the collision's position changes */
  31027. set onCollisionPositionChange(callback: () => void);
  31028. /**
  31029. * An event triggered when material is changed
  31030. */
  31031. onMaterialChangedObservable: Observable<AbstractMesh>;
  31032. /**
  31033. * Gets or sets the orientation for POV movement & rotation
  31034. */
  31035. definedFacingForward: boolean;
  31036. /** @hidden */
  31037. _occlusionQuery: Nullable<WebGLQuery>;
  31038. /** @hidden */
  31039. _renderingGroup: Nullable<RenderingGroup>;
  31040. /**
  31041. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31042. */
  31043. get visibility(): number;
  31044. /**
  31045. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31046. */
  31047. set visibility(value: number);
  31048. /** Gets or sets the alpha index used to sort transparent meshes
  31049. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31050. */
  31051. alphaIndex: number;
  31052. /**
  31053. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31054. */
  31055. isVisible: boolean;
  31056. /**
  31057. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31058. */
  31059. isPickable: boolean;
  31060. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31061. showSubMeshesBoundingBox: boolean;
  31062. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31063. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31064. */
  31065. isBlocker: boolean;
  31066. /**
  31067. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31068. */
  31069. enablePointerMoveEvents: boolean;
  31070. /**
  31071. * Specifies the rendering group id for this mesh (0 by default)
  31072. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31073. */
  31074. renderingGroupId: number;
  31075. private _material;
  31076. /** Gets or sets current material */
  31077. get material(): Nullable<Material>;
  31078. set material(value: Nullable<Material>);
  31079. /**
  31080. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31081. * @see http://doc.babylonjs.com/babylon101/shadows
  31082. */
  31083. get receiveShadows(): boolean;
  31084. set receiveShadows(value: boolean);
  31085. /** Defines color to use when rendering outline */
  31086. outlineColor: Color3;
  31087. /** Define width to use when rendering outline */
  31088. outlineWidth: number;
  31089. /** Defines color to use when rendering overlay */
  31090. overlayColor: Color3;
  31091. /** Defines alpha to use when rendering overlay */
  31092. overlayAlpha: number;
  31093. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31094. get hasVertexAlpha(): boolean;
  31095. set hasVertexAlpha(value: boolean);
  31096. /** 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) */
  31097. get useVertexColors(): boolean;
  31098. set useVertexColors(value: boolean);
  31099. /**
  31100. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31101. */
  31102. get computeBonesUsingShaders(): boolean;
  31103. set computeBonesUsingShaders(value: boolean);
  31104. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31105. get numBoneInfluencers(): number;
  31106. set numBoneInfluencers(value: number);
  31107. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31108. get applyFog(): boolean;
  31109. set applyFog(value: boolean);
  31110. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31111. useOctreeForRenderingSelection: boolean;
  31112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31113. useOctreeForPicking: boolean;
  31114. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31115. useOctreeForCollisions: boolean;
  31116. /**
  31117. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31118. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31119. */
  31120. get layerMask(): number;
  31121. set layerMask(value: number);
  31122. /**
  31123. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31124. */
  31125. alwaysSelectAsActiveMesh: boolean;
  31126. /**
  31127. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31128. */
  31129. doNotSyncBoundingInfo: boolean;
  31130. /**
  31131. * Gets or sets the current action manager
  31132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31133. */
  31134. actionManager: Nullable<AbstractActionManager>;
  31135. private _meshCollisionData;
  31136. /**
  31137. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31139. */
  31140. ellipsoid: Vector3;
  31141. /**
  31142. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31144. */
  31145. ellipsoidOffset: Vector3;
  31146. /**
  31147. * Gets or sets a collision mask used to mask collisions (default is -1).
  31148. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31149. */
  31150. get collisionMask(): number;
  31151. set collisionMask(mask: number);
  31152. /**
  31153. * Gets or sets the current collision group mask (-1 by default).
  31154. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31155. */
  31156. get collisionGroup(): number;
  31157. set collisionGroup(mask: number);
  31158. /**
  31159. * Gets or sets current surrounding meshes (null by default).
  31160. *
  31161. * By default collision detection is tested against every mesh in the scene.
  31162. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31163. * meshes will be tested for the collision.
  31164. *
  31165. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31166. */
  31167. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31168. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31169. /**
  31170. * Defines edge width used when edgesRenderer is enabled
  31171. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31172. */
  31173. edgesWidth: number;
  31174. /**
  31175. * Defines edge color used when edgesRenderer is enabled
  31176. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31177. */
  31178. edgesColor: Color4;
  31179. /** @hidden */
  31180. _edgesRenderer: Nullable<IEdgesRenderer>;
  31181. /** @hidden */
  31182. _masterMesh: Nullable<AbstractMesh>;
  31183. /** @hidden */
  31184. _boundingInfo: Nullable<BoundingInfo>;
  31185. /** @hidden */
  31186. _renderId: number;
  31187. /**
  31188. * Gets or sets the list of subMeshes
  31189. * @see http://doc.babylonjs.com/how_to/multi_materials
  31190. */
  31191. subMeshes: SubMesh[];
  31192. /** @hidden */
  31193. _intersectionsInProgress: AbstractMesh[];
  31194. /** @hidden */
  31195. _unIndexed: boolean;
  31196. /** @hidden */
  31197. _lightSources: Light[];
  31198. /** Gets the list of lights affecting that mesh */
  31199. get lightSources(): Light[];
  31200. /** @hidden */
  31201. get _positions(): Nullable<Vector3[]>;
  31202. /** @hidden */
  31203. _waitingData: {
  31204. lods: Nullable<any>;
  31205. actions: Nullable<any>;
  31206. freezeWorldMatrix: Nullable<boolean>;
  31207. };
  31208. /** @hidden */
  31209. _bonesTransformMatrices: Nullable<Float32Array>;
  31210. /** @hidden */
  31211. _transformMatrixTexture: Nullable<RawTexture>;
  31212. /**
  31213. * Gets or sets a skeleton to apply skining transformations
  31214. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31215. */
  31216. set skeleton(value: Nullable<Skeleton>);
  31217. get skeleton(): Nullable<Skeleton>;
  31218. /**
  31219. * An event triggered when the mesh is rebuilt.
  31220. */
  31221. onRebuildObservable: Observable<AbstractMesh>;
  31222. /**
  31223. * Creates a new AbstractMesh
  31224. * @param name defines the name of the mesh
  31225. * @param scene defines the hosting scene
  31226. */
  31227. constructor(name: string, scene?: Nullable<Scene>);
  31228. /**
  31229. * Returns the string "AbstractMesh"
  31230. * @returns "AbstractMesh"
  31231. */
  31232. getClassName(): string;
  31233. /**
  31234. * Gets a string representation of the current mesh
  31235. * @param fullDetails defines a boolean indicating if full details must be included
  31236. * @returns a string representation of the current mesh
  31237. */
  31238. toString(fullDetails?: boolean): string;
  31239. /**
  31240. * @hidden
  31241. */
  31242. protected _getEffectiveParent(): Nullable<Node>;
  31243. /** @hidden */
  31244. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31245. /** @hidden */
  31246. _rebuild(): void;
  31247. /** @hidden */
  31248. _resyncLightSources(): void;
  31249. /** @hidden */
  31250. _resyncLightSource(light: Light): void;
  31251. /** @hidden */
  31252. _unBindEffect(): void;
  31253. /** @hidden */
  31254. _removeLightSource(light: Light, dispose: boolean): void;
  31255. private _markSubMeshesAsDirty;
  31256. /** @hidden */
  31257. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31258. /** @hidden */
  31259. _markSubMeshesAsAttributesDirty(): void;
  31260. /** @hidden */
  31261. _markSubMeshesAsMiscDirty(): void;
  31262. /**
  31263. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31264. */
  31265. get scaling(): Vector3;
  31266. set scaling(newScaling: Vector3);
  31267. /**
  31268. * Returns true if the mesh is blocked. Implemented by child classes
  31269. */
  31270. get isBlocked(): boolean;
  31271. /**
  31272. * Returns the mesh itself by default. Implemented by child classes
  31273. * @param camera defines the camera to use to pick the right LOD level
  31274. * @returns the currentAbstractMesh
  31275. */
  31276. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31277. /**
  31278. * Returns 0 by default. Implemented by child classes
  31279. * @returns an integer
  31280. */
  31281. getTotalVertices(): number;
  31282. /**
  31283. * Returns a positive integer : the total number of indices in this mesh geometry.
  31284. * @returns the numner of indices or zero if the mesh has no geometry.
  31285. */
  31286. getTotalIndices(): number;
  31287. /**
  31288. * Returns null by default. Implemented by child classes
  31289. * @returns null
  31290. */
  31291. getIndices(): Nullable<IndicesArray>;
  31292. /**
  31293. * Returns the array of the requested vertex data kind. Implemented by child classes
  31294. * @param kind defines the vertex data kind to use
  31295. * @returns null
  31296. */
  31297. getVerticesData(kind: string): Nullable<FloatArray>;
  31298. /**
  31299. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31300. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31301. * Note that a new underlying VertexBuffer object is created each call.
  31302. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31303. * @param kind defines vertex data kind:
  31304. * * VertexBuffer.PositionKind
  31305. * * VertexBuffer.UVKind
  31306. * * VertexBuffer.UV2Kind
  31307. * * VertexBuffer.UV3Kind
  31308. * * VertexBuffer.UV4Kind
  31309. * * VertexBuffer.UV5Kind
  31310. * * VertexBuffer.UV6Kind
  31311. * * VertexBuffer.ColorKind
  31312. * * VertexBuffer.MatricesIndicesKind
  31313. * * VertexBuffer.MatricesIndicesExtraKind
  31314. * * VertexBuffer.MatricesWeightsKind
  31315. * * VertexBuffer.MatricesWeightsExtraKind
  31316. * @param data defines the data source
  31317. * @param updatable defines if the data must be flagged as updatable (or static)
  31318. * @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
  31319. * @returns the current mesh
  31320. */
  31321. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31322. /**
  31323. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31324. * If the mesh has no geometry, it is simply returned as it is.
  31325. * @param kind defines vertex data kind:
  31326. * * VertexBuffer.PositionKind
  31327. * * VertexBuffer.UVKind
  31328. * * VertexBuffer.UV2Kind
  31329. * * VertexBuffer.UV3Kind
  31330. * * VertexBuffer.UV4Kind
  31331. * * VertexBuffer.UV5Kind
  31332. * * VertexBuffer.UV6Kind
  31333. * * VertexBuffer.ColorKind
  31334. * * VertexBuffer.MatricesIndicesKind
  31335. * * VertexBuffer.MatricesIndicesExtraKind
  31336. * * VertexBuffer.MatricesWeightsKind
  31337. * * VertexBuffer.MatricesWeightsExtraKind
  31338. * @param data defines the data source
  31339. * @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
  31340. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31341. * @returns the current mesh
  31342. */
  31343. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31344. /**
  31345. * Sets the mesh indices,
  31346. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31347. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31348. * @param totalVertices Defines the total number of vertices
  31349. * @returns the current mesh
  31350. */
  31351. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31352. /**
  31353. * Gets a boolean indicating if specific vertex data is present
  31354. * @param kind defines the vertex data kind to use
  31355. * @returns true is data kind is present
  31356. */
  31357. isVerticesDataPresent(kind: string): boolean;
  31358. /**
  31359. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31360. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31361. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31362. * @returns a BoundingInfo
  31363. */
  31364. getBoundingInfo(): BoundingInfo;
  31365. /**
  31366. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31367. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31368. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31369. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31370. * @returns the current mesh
  31371. */
  31372. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31373. /**
  31374. * Overwrite the current bounding info
  31375. * @param boundingInfo defines the new bounding info
  31376. * @returns the current mesh
  31377. */
  31378. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31379. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31380. get useBones(): boolean;
  31381. /** @hidden */
  31382. _preActivate(): void;
  31383. /** @hidden */
  31384. _preActivateForIntermediateRendering(renderId: number): void;
  31385. /** @hidden */
  31386. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31387. /** @hidden */
  31388. _postActivate(): void;
  31389. /** @hidden */
  31390. _freeze(): void;
  31391. /** @hidden */
  31392. _unFreeze(): void;
  31393. /**
  31394. * Gets the current world matrix
  31395. * @returns a Matrix
  31396. */
  31397. getWorldMatrix(): Matrix;
  31398. /** @hidden */
  31399. _getWorldMatrixDeterminant(): number;
  31400. /**
  31401. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31402. */
  31403. get isAnInstance(): boolean;
  31404. /**
  31405. * Gets a boolean indicating if this mesh has instances
  31406. */
  31407. get hasInstances(): boolean;
  31408. /**
  31409. * Gets a boolean indicating if this mesh has thin instances
  31410. */
  31411. get hasThinInstances(): boolean;
  31412. /**
  31413. * Perform relative position change from the point of view of behind the front of the mesh.
  31414. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31415. * Supports definition of mesh facing forward or backward
  31416. * @param amountRight defines the distance on the right axis
  31417. * @param amountUp defines the distance on the up axis
  31418. * @param amountForward defines the distance on the forward axis
  31419. * @returns the current mesh
  31420. */
  31421. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31422. /**
  31423. * Calculate relative position change from the point of view of behind the front of the mesh.
  31424. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31425. * Supports definition of mesh facing forward or backward
  31426. * @param amountRight defines the distance on the right axis
  31427. * @param amountUp defines the distance on the up axis
  31428. * @param amountForward defines the distance on the forward axis
  31429. * @returns the new displacement vector
  31430. */
  31431. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31432. /**
  31433. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31434. * Supports definition of mesh facing forward or backward
  31435. * @param flipBack defines the flip
  31436. * @param twirlClockwise defines the twirl
  31437. * @param tiltRight defines the tilt
  31438. * @returns the current mesh
  31439. */
  31440. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31441. /**
  31442. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31443. * Supports definition of mesh facing forward or backward.
  31444. * @param flipBack defines the flip
  31445. * @param twirlClockwise defines the twirl
  31446. * @param tiltRight defines the tilt
  31447. * @returns the new rotation vector
  31448. */
  31449. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31450. /**
  31451. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31452. * This means the mesh underlying bounding box and sphere are recomputed.
  31453. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31454. * @returns the current mesh
  31455. */
  31456. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31457. /** @hidden */
  31458. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31459. /** @hidden */
  31460. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31461. /** @hidden */
  31462. _updateBoundingInfo(): AbstractMesh;
  31463. /** @hidden */
  31464. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31465. /** @hidden */
  31466. protected _afterComputeWorldMatrix(): void;
  31467. /** @hidden */
  31468. get _effectiveMesh(): AbstractMesh;
  31469. /**
  31470. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31471. * A mesh is in the frustum if its bounding box intersects the frustum
  31472. * @param frustumPlanes defines the frustum to test
  31473. * @returns true if the mesh is in the frustum planes
  31474. */
  31475. isInFrustum(frustumPlanes: Plane[]): boolean;
  31476. /**
  31477. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31478. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31479. * @param frustumPlanes defines the frustum to test
  31480. * @returns true if the mesh is completely in the frustum planes
  31481. */
  31482. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31483. /**
  31484. * True if the mesh intersects another mesh or a SolidParticle object
  31485. * @param mesh defines a target mesh or SolidParticle to test
  31486. * @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)
  31487. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31488. * @returns true if there is an intersection
  31489. */
  31490. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31491. /**
  31492. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31493. * @param point defines the point to test
  31494. * @returns true if there is an intersection
  31495. */
  31496. intersectsPoint(point: Vector3): boolean;
  31497. /**
  31498. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31500. */
  31501. get checkCollisions(): boolean;
  31502. set checkCollisions(collisionEnabled: boolean);
  31503. /**
  31504. * Gets Collider object used to compute collisions (not physics)
  31505. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31506. */
  31507. get collider(): Nullable<Collider>;
  31508. /**
  31509. * Move the mesh using collision engine
  31510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31511. * @param displacement defines the requested displacement vector
  31512. * @returns the current mesh
  31513. */
  31514. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31515. private _onCollisionPositionChange;
  31516. /** @hidden */
  31517. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31518. /** @hidden */
  31519. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31520. /** @hidden */
  31521. _checkCollision(collider: Collider): AbstractMesh;
  31522. /** @hidden */
  31523. _generatePointsArray(): boolean;
  31524. /**
  31525. * Checks if the passed Ray intersects with the mesh
  31526. * @param ray defines the ray to use
  31527. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31528. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31529. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31530. * @returns the picking info
  31531. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31532. */
  31533. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31534. /**
  31535. * Clones the current mesh
  31536. * @param name defines the mesh name
  31537. * @param newParent defines the new mesh parent
  31538. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31539. * @returns the new mesh
  31540. */
  31541. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31542. /**
  31543. * Disposes all the submeshes of the current meshnp
  31544. * @returns the current mesh
  31545. */
  31546. releaseSubMeshes(): AbstractMesh;
  31547. /**
  31548. * Releases resources associated with this abstract mesh.
  31549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31551. */
  31552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31553. /**
  31554. * Adds the passed mesh as a child to the current mesh
  31555. * @param mesh defines the child mesh
  31556. * @returns the current mesh
  31557. */
  31558. addChild(mesh: AbstractMesh): AbstractMesh;
  31559. /**
  31560. * Removes the passed mesh from the current mesh children list
  31561. * @param mesh defines the child mesh
  31562. * @returns the current mesh
  31563. */
  31564. removeChild(mesh: AbstractMesh): AbstractMesh;
  31565. /** @hidden */
  31566. private _initFacetData;
  31567. /**
  31568. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31569. * This method can be called within the render loop.
  31570. * 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
  31571. * @returns the current mesh
  31572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31573. */
  31574. updateFacetData(): AbstractMesh;
  31575. /**
  31576. * Returns the facetLocalNormals array.
  31577. * The normals are expressed in the mesh local spac
  31578. * @returns an array of Vector3
  31579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31580. */
  31581. getFacetLocalNormals(): Vector3[];
  31582. /**
  31583. * Returns the facetLocalPositions array.
  31584. * The facet positions are expressed in the mesh local space
  31585. * @returns an array of Vector3
  31586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31587. */
  31588. getFacetLocalPositions(): Vector3[];
  31589. /**
  31590. * Returns the facetLocalPartioning array
  31591. * @returns an array of array of numbers
  31592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31593. */
  31594. getFacetLocalPartitioning(): number[][];
  31595. /**
  31596. * Returns the i-th facet position in the world system.
  31597. * This method allocates a new Vector3 per call
  31598. * @param i defines the facet index
  31599. * @returns a new Vector3
  31600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31601. */
  31602. getFacetPosition(i: number): Vector3;
  31603. /**
  31604. * Sets the reference Vector3 with the i-th facet position in the world system
  31605. * @param i defines the facet index
  31606. * @param ref defines the target vector
  31607. * @returns the current mesh
  31608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31609. */
  31610. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31611. /**
  31612. * Returns the i-th facet normal in the world system.
  31613. * This method allocates a new Vector3 per call
  31614. * @param i defines the facet index
  31615. * @returns a new Vector3
  31616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31617. */
  31618. getFacetNormal(i: number): Vector3;
  31619. /**
  31620. * Sets the reference Vector3 with the i-th facet normal in the world system
  31621. * @param i defines the facet index
  31622. * @param ref defines the target vector
  31623. * @returns the current mesh
  31624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31625. */
  31626. getFacetNormalToRef(i: number, ref: Vector3): this;
  31627. /**
  31628. * 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)
  31629. * @param x defines x coordinate
  31630. * @param y defines y coordinate
  31631. * @param z defines z coordinate
  31632. * @returns the array of facet indexes
  31633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31634. */
  31635. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31636. /**
  31637. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31638. * @param projected sets as the (x,y,z) world projection on the facet
  31639. * @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
  31640. * @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
  31641. * @param x defines x coordinate
  31642. * @param y defines y coordinate
  31643. * @param z defines z coordinate
  31644. * @returns the face index if found (or null instead)
  31645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31646. */
  31647. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31648. /**
  31649. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31650. * @param projected sets as the (x,y,z) local projection on the facet
  31651. * @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
  31652. * @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
  31653. * @param x defines x coordinate
  31654. * @param y defines y coordinate
  31655. * @param z defines z coordinate
  31656. * @returns the face index if found (or null instead)
  31657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31658. */
  31659. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31660. /**
  31661. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31662. * @returns the parameters
  31663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31664. */
  31665. getFacetDataParameters(): any;
  31666. /**
  31667. * Disables the feature FacetData and frees the related memory
  31668. * @returns the current mesh
  31669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31670. */
  31671. disableFacetData(): AbstractMesh;
  31672. /**
  31673. * Updates the AbstractMesh indices array
  31674. * @param indices defines the data source
  31675. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31676. * @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)
  31677. * @returns the current mesh
  31678. */
  31679. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31680. /**
  31681. * Creates new normals data for the mesh
  31682. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31683. * @returns the current mesh
  31684. */
  31685. createNormals(updatable: boolean): AbstractMesh;
  31686. /**
  31687. * Align the mesh with a normal
  31688. * @param normal defines the normal to use
  31689. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31690. * @returns the current mesh
  31691. */
  31692. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31693. /** @hidden */
  31694. _checkOcclusionQuery(): boolean;
  31695. /**
  31696. * Disables the mesh edge rendering mode
  31697. * @returns the currentAbstractMesh
  31698. */
  31699. disableEdgesRendering(): AbstractMesh;
  31700. /**
  31701. * Enables the edge rendering mode on the mesh.
  31702. * This mode makes the mesh edges visible
  31703. * @param epsilon defines the maximal distance between two angles to detect a face
  31704. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31705. * @returns the currentAbstractMesh
  31706. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31707. */
  31708. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31709. }
  31710. }
  31711. declare module BABYLON {
  31712. /**
  31713. * Interface used to define ActionEvent
  31714. */
  31715. export interface IActionEvent {
  31716. /** The mesh or sprite that triggered the action */
  31717. source: any;
  31718. /** The X mouse cursor position at the time of the event */
  31719. pointerX: number;
  31720. /** The Y mouse cursor position at the time of the event */
  31721. pointerY: number;
  31722. /** The mesh that is currently pointed at (can be null) */
  31723. meshUnderPointer: Nullable<AbstractMesh>;
  31724. /** the original (browser) event that triggered the ActionEvent */
  31725. sourceEvent?: any;
  31726. /** additional data for the event */
  31727. additionalData?: any;
  31728. }
  31729. /**
  31730. * ActionEvent is the event being sent when an action is triggered.
  31731. */
  31732. export class ActionEvent implements IActionEvent {
  31733. /** The mesh or sprite that triggered the action */
  31734. source: any;
  31735. /** The X mouse cursor position at the time of the event */
  31736. pointerX: number;
  31737. /** The Y mouse cursor position at the time of the event */
  31738. pointerY: number;
  31739. /** The mesh that is currently pointed at (can be null) */
  31740. meshUnderPointer: Nullable<AbstractMesh>;
  31741. /** the original (browser) event that triggered the ActionEvent */
  31742. sourceEvent?: any;
  31743. /** additional data for the event */
  31744. additionalData?: any;
  31745. /**
  31746. * Creates a new ActionEvent
  31747. * @param source The mesh or sprite that triggered the action
  31748. * @param pointerX The X mouse cursor position at the time of the event
  31749. * @param pointerY The Y mouse cursor position at the time of the event
  31750. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31751. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31752. * @param additionalData additional data for the event
  31753. */
  31754. constructor(
  31755. /** The mesh or sprite that triggered the action */
  31756. source: any,
  31757. /** The X mouse cursor position at the time of the event */
  31758. pointerX: number,
  31759. /** The Y mouse cursor position at the time of the event */
  31760. pointerY: number,
  31761. /** The mesh that is currently pointed at (can be null) */
  31762. meshUnderPointer: Nullable<AbstractMesh>,
  31763. /** the original (browser) event that triggered the ActionEvent */
  31764. sourceEvent?: any,
  31765. /** additional data for the event */
  31766. additionalData?: any);
  31767. /**
  31768. * Helper function to auto-create an ActionEvent from a source mesh.
  31769. * @param source The source mesh that triggered the event
  31770. * @param evt The original (browser) event
  31771. * @param additionalData additional data for the event
  31772. * @returns the new ActionEvent
  31773. */
  31774. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31775. /**
  31776. * Helper function to auto-create an ActionEvent from a source sprite
  31777. * @param source The source sprite that triggered the event
  31778. * @param scene Scene associated with the sprite
  31779. * @param evt The original (browser) event
  31780. * @param additionalData additional data for the event
  31781. * @returns the new ActionEvent
  31782. */
  31783. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31784. /**
  31785. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31786. * @param scene the scene where the event occurred
  31787. * @param evt The original (browser) event
  31788. * @returns the new ActionEvent
  31789. */
  31790. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31791. /**
  31792. * Helper function to auto-create an ActionEvent from a primitive
  31793. * @param prim defines the target primitive
  31794. * @param pointerPos defines the pointer position
  31795. * @param evt The original (browser) event
  31796. * @param additionalData additional data for the event
  31797. * @returns the new ActionEvent
  31798. */
  31799. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31800. }
  31801. }
  31802. declare module BABYLON {
  31803. /**
  31804. * Abstract class used to decouple action Manager from scene and meshes.
  31805. * Do not instantiate.
  31806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31807. */
  31808. export abstract class AbstractActionManager implements IDisposable {
  31809. /** Gets the list of active triggers */
  31810. static Triggers: {
  31811. [key: string]: number;
  31812. };
  31813. /** Gets the cursor to use when hovering items */
  31814. hoverCursor: string;
  31815. /** Gets the list of actions */
  31816. actions: IAction[];
  31817. /**
  31818. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31819. */
  31820. isRecursive: boolean;
  31821. /**
  31822. * Releases all associated resources
  31823. */
  31824. abstract dispose(): void;
  31825. /**
  31826. * Does this action manager has pointer triggers
  31827. */
  31828. abstract get hasPointerTriggers(): boolean;
  31829. /**
  31830. * Does this action manager has pick triggers
  31831. */
  31832. abstract get hasPickTriggers(): boolean;
  31833. /**
  31834. * Process a specific trigger
  31835. * @param trigger defines the trigger to process
  31836. * @param evt defines the event details to be processed
  31837. */
  31838. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31839. /**
  31840. * Does this action manager handles actions of any of the given triggers
  31841. * @param triggers defines the triggers to be tested
  31842. * @return a boolean indicating whether one (or more) of the triggers is handled
  31843. */
  31844. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31845. /**
  31846. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31847. * speed.
  31848. * @param triggerA defines the trigger to be tested
  31849. * @param triggerB defines the trigger to be tested
  31850. * @return a boolean indicating whether one (or more) of the triggers is handled
  31851. */
  31852. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31853. /**
  31854. * Does this action manager handles actions of a given trigger
  31855. * @param trigger defines the trigger to be tested
  31856. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31857. * @return whether the trigger is handled
  31858. */
  31859. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31860. /**
  31861. * Serialize this manager to a JSON object
  31862. * @param name defines the property name to store this manager
  31863. * @returns a JSON representation of this manager
  31864. */
  31865. abstract serialize(name: string): any;
  31866. /**
  31867. * Registers an action to this action manager
  31868. * @param action defines the action to be registered
  31869. * @return the action amended (prepared) after registration
  31870. */
  31871. abstract registerAction(action: IAction): Nullable<IAction>;
  31872. /**
  31873. * Unregisters an action to this action manager
  31874. * @param action defines the action to be unregistered
  31875. * @return a boolean indicating whether the action has been unregistered
  31876. */
  31877. abstract unregisterAction(action: IAction): Boolean;
  31878. /**
  31879. * Does exist one action manager with at least one trigger
  31880. **/
  31881. static get HasTriggers(): boolean;
  31882. /**
  31883. * Does exist one action manager with at least one pick trigger
  31884. **/
  31885. static get HasPickTriggers(): boolean;
  31886. /**
  31887. * Does exist one action manager that handles actions of a given trigger
  31888. * @param trigger defines the trigger to be tested
  31889. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31890. **/
  31891. static HasSpecificTrigger(trigger: number): boolean;
  31892. }
  31893. }
  31894. declare module BABYLON {
  31895. /**
  31896. * Defines how a node can be built from a string name.
  31897. */
  31898. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31899. /**
  31900. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31901. */
  31902. export class Node implements IBehaviorAware<Node> {
  31903. /** @hidden */
  31904. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31905. private static _NodeConstructors;
  31906. /**
  31907. * Add a new node constructor
  31908. * @param type defines the type name of the node to construct
  31909. * @param constructorFunc defines the constructor function
  31910. */
  31911. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31912. /**
  31913. * Returns a node constructor based on type name
  31914. * @param type defines the type name
  31915. * @param name defines the new node name
  31916. * @param scene defines the hosting scene
  31917. * @param options defines optional options to transmit to constructors
  31918. * @returns the new constructor or null
  31919. */
  31920. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31921. /**
  31922. * Gets or sets the name of the node
  31923. */
  31924. name: string;
  31925. /**
  31926. * Gets or sets the id of the node
  31927. */
  31928. id: string;
  31929. /**
  31930. * Gets or sets the unique id of the node
  31931. */
  31932. uniqueId: number;
  31933. /**
  31934. * Gets or sets a string used to store user defined state for the node
  31935. */
  31936. state: string;
  31937. /**
  31938. * Gets or sets an object used to store user defined information for the node
  31939. */
  31940. metadata: any;
  31941. /**
  31942. * For internal use only. Please do not use.
  31943. */
  31944. reservedDataStore: any;
  31945. /**
  31946. * List of inspectable custom properties (used by the Inspector)
  31947. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31948. */
  31949. inspectableCustomProperties: IInspectable[];
  31950. private _doNotSerialize;
  31951. /**
  31952. * Gets or sets a boolean used to define if the node must be serialized
  31953. */
  31954. get doNotSerialize(): boolean;
  31955. set doNotSerialize(value: boolean);
  31956. /** @hidden */
  31957. _isDisposed: boolean;
  31958. /**
  31959. * Gets a list of Animations associated with the node
  31960. */
  31961. animations: Animation[];
  31962. protected _ranges: {
  31963. [name: string]: Nullable<AnimationRange>;
  31964. };
  31965. /**
  31966. * Callback raised when the node is ready to be used
  31967. */
  31968. onReady: Nullable<(node: Node) => void>;
  31969. private _isEnabled;
  31970. private _isParentEnabled;
  31971. private _isReady;
  31972. /** @hidden */
  31973. _currentRenderId: number;
  31974. private _parentUpdateId;
  31975. /** @hidden */
  31976. _childUpdateId: number;
  31977. /** @hidden */
  31978. _waitingParentId: Nullable<string>;
  31979. /** @hidden */
  31980. _scene: Scene;
  31981. /** @hidden */
  31982. _cache: any;
  31983. private _parentNode;
  31984. private _children;
  31985. /** @hidden */
  31986. _worldMatrix: Matrix;
  31987. /** @hidden */
  31988. _worldMatrixDeterminant: number;
  31989. /** @hidden */
  31990. _worldMatrixDeterminantIsDirty: boolean;
  31991. /** @hidden */
  31992. private _sceneRootNodesIndex;
  31993. /**
  31994. * Gets a boolean indicating if the node has been disposed
  31995. * @returns true if the node was disposed
  31996. */
  31997. isDisposed(): boolean;
  31998. /**
  31999. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32000. * @see https://doc.babylonjs.com/how_to/parenting
  32001. */
  32002. set parent(parent: Nullable<Node>);
  32003. get parent(): Nullable<Node>;
  32004. /** @hidden */
  32005. _addToSceneRootNodes(): void;
  32006. /** @hidden */
  32007. _removeFromSceneRootNodes(): void;
  32008. private _animationPropertiesOverride;
  32009. /**
  32010. * Gets or sets the animation properties override
  32011. */
  32012. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32013. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32014. /**
  32015. * Gets a string idenfifying the name of the class
  32016. * @returns "Node" string
  32017. */
  32018. getClassName(): string;
  32019. /** @hidden */
  32020. readonly _isNode: boolean;
  32021. /**
  32022. * An event triggered when the mesh is disposed
  32023. */
  32024. onDisposeObservable: Observable<Node>;
  32025. private _onDisposeObserver;
  32026. /**
  32027. * Sets a callback that will be raised when the node will be disposed
  32028. */
  32029. set onDispose(callback: () => void);
  32030. /**
  32031. * Creates a new Node
  32032. * @param name the name and id to be given to this node
  32033. * @param scene the scene this node will be added to
  32034. */
  32035. constructor(name: string, scene?: Nullable<Scene>);
  32036. /**
  32037. * Gets the scene of the node
  32038. * @returns a scene
  32039. */
  32040. getScene(): Scene;
  32041. /**
  32042. * Gets the engine of the node
  32043. * @returns a Engine
  32044. */
  32045. getEngine(): Engine;
  32046. private _behaviors;
  32047. /**
  32048. * Attach a behavior to the node
  32049. * @see http://doc.babylonjs.com/features/behaviour
  32050. * @param behavior defines the behavior to attach
  32051. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32052. * @returns the current Node
  32053. */
  32054. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32055. /**
  32056. * Remove an attached behavior
  32057. * @see http://doc.babylonjs.com/features/behaviour
  32058. * @param behavior defines the behavior to attach
  32059. * @returns the current Node
  32060. */
  32061. removeBehavior(behavior: Behavior<Node>): Node;
  32062. /**
  32063. * Gets the list of attached behaviors
  32064. * @see http://doc.babylonjs.com/features/behaviour
  32065. */
  32066. get behaviors(): Behavior<Node>[];
  32067. /**
  32068. * Gets an attached behavior by name
  32069. * @param name defines the name of the behavior to look for
  32070. * @see http://doc.babylonjs.com/features/behaviour
  32071. * @returns null if behavior was not found else the requested behavior
  32072. */
  32073. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32074. /**
  32075. * Returns the latest update of the World matrix
  32076. * @returns a Matrix
  32077. */
  32078. getWorldMatrix(): Matrix;
  32079. /** @hidden */
  32080. _getWorldMatrixDeterminant(): number;
  32081. /**
  32082. * Returns directly the latest state of the mesh World matrix.
  32083. * A Matrix is returned.
  32084. */
  32085. get worldMatrixFromCache(): Matrix;
  32086. /** @hidden */
  32087. _initCache(): void;
  32088. /** @hidden */
  32089. updateCache(force?: boolean): void;
  32090. /** @hidden */
  32091. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32092. /** @hidden */
  32093. _updateCache(ignoreParentClass?: boolean): void;
  32094. /** @hidden */
  32095. _isSynchronized(): boolean;
  32096. /** @hidden */
  32097. _markSyncedWithParent(): void;
  32098. /** @hidden */
  32099. isSynchronizedWithParent(): boolean;
  32100. /** @hidden */
  32101. isSynchronized(): boolean;
  32102. /**
  32103. * Is this node ready to be used/rendered
  32104. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32105. * @return true if the node is ready
  32106. */
  32107. isReady(completeCheck?: boolean): boolean;
  32108. /**
  32109. * Is this node enabled?
  32110. * 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
  32111. * @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
  32112. * @return whether this node (and its parent) is enabled
  32113. */
  32114. isEnabled(checkAncestors?: boolean): boolean;
  32115. /** @hidden */
  32116. protected _syncParentEnabledState(): void;
  32117. /**
  32118. * Set the enabled state of this node
  32119. * @param value defines the new enabled state
  32120. */
  32121. setEnabled(value: boolean): void;
  32122. /**
  32123. * Is this node a descendant of the given node?
  32124. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32125. * @param ancestor defines the parent node to inspect
  32126. * @returns a boolean indicating if this node is a descendant of the given node
  32127. */
  32128. isDescendantOf(ancestor: Node): boolean;
  32129. /** @hidden */
  32130. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32131. /**
  32132. * Will return all nodes that have this node as ascendant
  32133. * @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
  32134. * @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
  32135. * @return all children nodes of all types
  32136. */
  32137. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32138. /**
  32139. * Get all child-meshes of this node
  32140. * @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)
  32141. * @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
  32142. * @returns an array of AbstractMesh
  32143. */
  32144. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32145. /**
  32146. * Get all direct children of this node
  32147. * @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
  32148. * @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)
  32149. * @returns an array of Node
  32150. */
  32151. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32152. /** @hidden */
  32153. _setReady(state: boolean): void;
  32154. /**
  32155. * Get an animation by name
  32156. * @param name defines the name of the animation to look for
  32157. * @returns null if not found else the requested animation
  32158. */
  32159. getAnimationByName(name: string): Nullable<Animation>;
  32160. /**
  32161. * Creates an animation range for this node
  32162. * @param name defines the name of the range
  32163. * @param from defines the starting key
  32164. * @param to defines the end key
  32165. */
  32166. createAnimationRange(name: string, from: number, to: number): void;
  32167. /**
  32168. * Delete a specific animation range
  32169. * @param name defines the name of the range to delete
  32170. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32171. */
  32172. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32173. /**
  32174. * Get an animation range by name
  32175. * @param name defines the name of the animation range to look for
  32176. * @returns null if not found else the requested animation range
  32177. */
  32178. getAnimationRange(name: string): Nullable<AnimationRange>;
  32179. /**
  32180. * Gets the list of all animation ranges defined on this node
  32181. * @returns an array
  32182. */
  32183. getAnimationRanges(): Nullable<AnimationRange>[];
  32184. /**
  32185. * Will start the animation sequence
  32186. * @param name defines the range frames for animation sequence
  32187. * @param loop defines if the animation should loop (false by default)
  32188. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32189. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32190. * @returns the object created for this animation. If range does not exist, it will return null
  32191. */
  32192. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32193. /**
  32194. * Serialize animation ranges into a JSON compatible object
  32195. * @returns serialization object
  32196. */
  32197. serializeAnimationRanges(): any;
  32198. /**
  32199. * Computes the world matrix of the node
  32200. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32201. * @returns the world matrix
  32202. */
  32203. computeWorldMatrix(force?: boolean): Matrix;
  32204. /**
  32205. * Releases resources associated with this node.
  32206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32208. */
  32209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32210. /**
  32211. * Parse animation range data from a serialization object and store them into a given node
  32212. * @param node defines where to store the animation ranges
  32213. * @param parsedNode defines the serialization object to read data from
  32214. * @param scene defines the hosting scene
  32215. */
  32216. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32217. /**
  32218. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32219. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32220. * @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
  32221. * @returns the new bounding vectors
  32222. */
  32223. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32224. min: Vector3;
  32225. max: Vector3;
  32226. };
  32227. }
  32228. }
  32229. declare module BABYLON {
  32230. /**
  32231. * @hidden
  32232. */
  32233. export class _IAnimationState {
  32234. key: number;
  32235. repeatCount: number;
  32236. workValue?: any;
  32237. loopMode?: number;
  32238. offsetValue?: any;
  32239. highLimitValue?: any;
  32240. }
  32241. /**
  32242. * Class used to store any kind of animation
  32243. */
  32244. export class Animation {
  32245. /**Name of the animation */
  32246. name: string;
  32247. /**Property to animate */
  32248. targetProperty: string;
  32249. /**The frames per second of the animation */
  32250. framePerSecond: number;
  32251. /**The data type of the animation */
  32252. dataType: number;
  32253. /**The loop mode of the animation */
  32254. loopMode?: number | undefined;
  32255. /**Specifies if blending should be enabled */
  32256. enableBlending?: boolean | undefined;
  32257. /**
  32258. * Use matrix interpolation instead of using direct key value when animating matrices
  32259. */
  32260. static AllowMatricesInterpolation: boolean;
  32261. /**
  32262. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32263. */
  32264. static AllowMatrixDecomposeForInterpolation: boolean;
  32265. /** Define the Url to load snippets */
  32266. static SnippetUrl: string;
  32267. /** Snippet ID if the animation was created from the snippet server */
  32268. snippetId: string;
  32269. /**
  32270. * Stores the key frames of the animation
  32271. */
  32272. private _keys;
  32273. /**
  32274. * Stores the easing function of the animation
  32275. */
  32276. private _easingFunction;
  32277. /**
  32278. * @hidden Internal use only
  32279. */
  32280. _runtimeAnimations: RuntimeAnimation[];
  32281. /**
  32282. * The set of event that will be linked to this animation
  32283. */
  32284. private _events;
  32285. /**
  32286. * Stores an array of target property paths
  32287. */
  32288. targetPropertyPath: string[];
  32289. /**
  32290. * Stores the blending speed of the animation
  32291. */
  32292. blendingSpeed: number;
  32293. /**
  32294. * Stores the animation ranges for the animation
  32295. */
  32296. private _ranges;
  32297. /**
  32298. * @hidden Internal use
  32299. */
  32300. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32301. /**
  32302. * Sets up an animation
  32303. * @param property The property to animate
  32304. * @param animationType The animation type to apply
  32305. * @param framePerSecond The frames per second of the animation
  32306. * @param easingFunction The easing function used in the animation
  32307. * @returns The created animation
  32308. */
  32309. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32310. /**
  32311. * Create and start an animation on a node
  32312. * @param name defines the name of the global animation that will be run on all nodes
  32313. * @param node defines the root node where the animation will take place
  32314. * @param targetProperty defines property to animate
  32315. * @param framePerSecond defines the number of frame per second yo use
  32316. * @param totalFrame defines the number of frames in total
  32317. * @param from defines the initial value
  32318. * @param to defines the final value
  32319. * @param loopMode defines which loop mode you want to use (off by default)
  32320. * @param easingFunction defines the easing function to use (linear by default)
  32321. * @param onAnimationEnd defines the callback to call when animation end
  32322. * @returns the animatable created for this animation
  32323. */
  32324. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32325. /**
  32326. * Create and start an animation on a node and its descendants
  32327. * @param name defines the name of the global animation that will be run on all nodes
  32328. * @param node defines the root node where the animation will take place
  32329. * @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
  32330. * @param targetProperty defines property to animate
  32331. * @param framePerSecond defines the number of frame per second to use
  32332. * @param totalFrame defines the number of frames in total
  32333. * @param from defines the initial value
  32334. * @param to defines the final value
  32335. * @param loopMode defines which loop mode you want to use (off by default)
  32336. * @param easingFunction defines the easing function to use (linear by default)
  32337. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32338. * @returns the list of animatables created for all nodes
  32339. * @example https://www.babylonjs-playground.com/#MH0VLI
  32340. */
  32341. 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[]>;
  32342. /**
  32343. * Creates a new animation, merges it with the existing animations and starts it
  32344. * @param name Name of the animation
  32345. * @param node Node which contains the scene that begins the animations
  32346. * @param targetProperty Specifies which property to animate
  32347. * @param framePerSecond The frames per second of the animation
  32348. * @param totalFrame The total number of frames
  32349. * @param from The frame at the beginning of the animation
  32350. * @param to The frame at the end of the animation
  32351. * @param loopMode Specifies the loop mode of the animation
  32352. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32353. * @param onAnimationEnd Callback to run once the animation is complete
  32354. * @returns Nullable animation
  32355. */
  32356. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32357. /**
  32358. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32359. * @param sourceAnimation defines the Animation containing keyframes to convert
  32360. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32361. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32362. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32363. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32364. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32365. */
  32366. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32367. /**
  32368. * Transition property of an host to the target Value
  32369. * @param property The property to transition
  32370. * @param targetValue The target Value of the property
  32371. * @param host The object where the property to animate belongs
  32372. * @param scene Scene used to run the animation
  32373. * @param frameRate Framerate (in frame/s) to use
  32374. * @param transition The transition type we want to use
  32375. * @param duration The duration of the animation, in milliseconds
  32376. * @param onAnimationEnd Callback trigger at the end of the animation
  32377. * @returns Nullable animation
  32378. */
  32379. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32380. /**
  32381. * Return the array of runtime animations currently using this animation
  32382. */
  32383. get runtimeAnimations(): RuntimeAnimation[];
  32384. /**
  32385. * Specifies if any of the runtime animations are currently running
  32386. */
  32387. get hasRunningRuntimeAnimations(): boolean;
  32388. /**
  32389. * Initializes the animation
  32390. * @param name Name of the animation
  32391. * @param targetProperty Property to animate
  32392. * @param framePerSecond The frames per second of the animation
  32393. * @param dataType The data type of the animation
  32394. * @param loopMode The loop mode of the animation
  32395. * @param enableBlending Specifies if blending should be enabled
  32396. */
  32397. constructor(
  32398. /**Name of the animation */
  32399. name: string,
  32400. /**Property to animate */
  32401. targetProperty: string,
  32402. /**The frames per second of the animation */
  32403. framePerSecond: number,
  32404. /**The data type of the animation */
  32405. dataType: number,
  32406. /**The loop mode of the animation */
  32407. loopMode?: number | undefined,
  32408. /**Specifies if blending should be enabled */
  32409. enableBlending?: boolean | undefined);
  32410. /**
  32411. * Converts the animation to a string
  32412. * @param fullDetails support for multiple levels of logging within scene loading
  32413. * @returns String form of the animation
  32414. */
  32415. toString(fullDetails?: boolean): string;
  32416. /**
  32417. * Add an event to this animation
  32418. * @param event Event to add
  32419. */
  32420. addEvent(event: AnimationEvent): void;
  32421. /**
  32422. * Remove all events found at the given frame
  32423. * @param frame The frame to remove events from
  32424. */
  32425. removeEvents(frame: number): void;
  32426. /**
  32427. * Retrieves all the events from the animation
  32428. * @returns Events from the animation
  32429. */
  32430. getEvents(): AnimationEvent[];
  32431. /**
  32432. * Creates an animation range
  32433. * @param name Name of the animation range
  32434. * @param from Starting frame of the animation range
  32435. * @param to Ending frame of the animation
  32436. */
  32437. createRange(name: string, from: number, to: number): void;
  32438. /**
  32439. * Deletes an animation range by name
  32440. * @param name Name of the animation range to delete
  32441. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32442. */
  32443. deleteRange(name: string, deleteFrames?: boolean): void;
  32444. /**
  32445. * Gets the animation range by name, or null if not defined
  32446. * @param name Name of the animation range
  32447. * @returns Nullable animation range
  32448. */
  32449. getRange(name: string): Nullable<AnimationRange>;
  32450. /**
  32451. * Gets the key frames from the animation
  32452. * @returns The key frames of the animation
  32453. */
  32454. getKeys(): Array<IAnimationKey>;
  32455. /**
  32456. * Gets the highest frame rate of the animation
  32457. * @returns Highest frame rate of the animation
  32458. */
  32459. getHighestFrame(): number;
  32460. /**
  32461. * Gets the easing function of the animation
  32462. * @returns Easing function of the animation
  32463. */
  32464. getEasingFunction(): IEasingFunction;
  32465. /**
  32466. * Sets the easing function of the animation
  32467. * @param easingFunction A custom mathematical formula for animation
  32468. */
  32469. setEasingFunction(easingFunction: EasingFunction): void;
  32470. /**
  32471. * Interpolates a scalar 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 scalar value
  32476. */
  32477. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32478. /**
  32479. * Interpolates a scalar 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 scalar value
  32486. */
  32487. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32488. /**
  32489. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  32494. */
  32495. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32496. /**
  32497. * Interpolates a quaternion cubically
  32498. * @param startValue Start value of the animation curve
  32499. * @param outTangent End tangent of the animation curve
  32500. * @param endValue End value of the animation curve
  32501. * @param inTangent Start tangent of the animation curve
  32502. * @param gradient Scalar amount to interpolate
  32503. * @returns Interpolated quaternion value
  32504. */
  32505. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32506. /**
  32507. * Interpolates a Vector3 linearl
  32508. * @param startValue Start value of the animation curve
  32509. * @param endValue End value of the animation curve
  32510. * @param gradient Scalar amount to interpolate
  32511. * @returns Interpolated scalar value
  32512. */
  32513. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32514. /**
  32515. * Interpolates a Vector3 cubically
  32516. * @param startValue Start value of the animation curve
  32517. * @param outTangent End tangent of the animation
  32518. * @param endValue End value of the animation curve
  32519. * @param inTangent Start tangent of the animation curve
  32520. * @param gradient Scalar amount to interpolate
  32521. * @returns InterpolatedVector3 value
  32522. */
  32523. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32524. /**
  32525. * Interpolates a Vector2 linearly
  32526. * @param startValue Start value of the animation curve
  32527. * @param endValue End value of the animation curve
  32528. * @param gradient Scalar amount to interpolate
  32529. * @returns Interpolated Vector2 value
  32530. */
  32531. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32532. /**
  32533. * Interpolates a Vector2 cubically
  32534. * @param startValue Start value of the animation curve
  32535. * @param outTangent End tangent of the animation
  32536. * @param endValue End value of the animation curve
  32537. * @param inTangent Start tangent of the animation curve
  32538. * @param gradient Scalar amount to interpolate
  32539. * @returns Interpolated Vector2 value
  32540. */
  32541. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32542. /**
  32543. * Interpolates a size linearly
  32544. * @param startValue Start value of the animation curve
  32545. * @param endValue End value of the animation curve
  32546. * @param gradient Scalar amount to interpolate
  32547. * @returns Interpolated Size value
  32548. */
  32549. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32550. /**
  32551. * Interpolates a Color3 linearly
  32552. * @param startValue Start value of the animation curve
  32553. * @param endValue End value of the animation curve
  32554. * @param gradient Scalar amount to interpolate
  32555. * @returns Interpolated Color3 value
  32556. */
  32557. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32558. /**
  32559. * Interpolates a Color4 linearly
  32560. * @param startValue Start value of the animation curve
  32561. * @param endValue End value of the animation curve
  32562. * @param gradient Scalar amount to interpolate
  32563. * @returns Interpolated Color3 value
  32564. */
  32565. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32566. /**
  32567. * @hidden Internal use only
  32568. */
  32569. _getKeyValue(value: any): any;
  32570. /**
  32571. * @hidden Internal use only
  32572. */
  32573. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32574. /**
  32575. * Defines the function to use to interpolate matrices
  32576. * @param startValue defines the start matrix
  32577. * @param endValue defines the end matrix
  32578. * @param gradient defines the gradient between both matrices
  32579. * @param result defines an optional target matrix where to store the interpolation
  32580. * @returns the interpolated matrix
  32581. */
  32582. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32583. /**
  32584. * Makes a copy of the animation
  32585. * @returns Cloned animation
  32586. */
  32587. clone(): Animation;
  32588. /**
  32589. * Sets the key frames of the animation
  32590. * @param values The animation key frames to set
  32591. */
  32592. setKeys(values: Array<IAnimationKey>): void;
  32593. /**
  32594. * Serializes the animation to an object
  32595. * @returns Serialized object
  32596. */
  32597. serialize(): any;
  32598. /**
  32599. * Float animation type
  32600. */
  32601. static readonly ANIMATIONTYPE_FLOAT: number;
  32602. /**
  32603. * Vector3 animation type
  32604. */
  32605. static readonly ANIMATIONTYPE_VECTOR3: number;
  32606. /**
  32607. * Quaternion animation type
  32608. */
  32609. static readonly ANIMATIONTYPE_QUATERNION: number;
  32610. /**
  32611. * Matrix animation type
  32612. */
  32613. static readonly ANIMATIONTYPE_MATRIX: number;
  32614. /**
  32615. * Color3 animation type
  32616. */
  32617. static readonly ANIMATIONTYPE_COLOR3: number;
  32618. /**
  32619. * Color3 animation type
  32620. */
  32621. static readonly ANIMATIONTYPE_COLOR4: number;
  32622. /**
  32623. * Vector2 animation type
  32624. */
  32625. static readonly ANIMATIONTYPE_VECTOR2: number;
  32626. /**
  32627. * Size animation type
  32628. */
  32629. static readonly ANIMATIONTYPE_SIZE: number;
  32630. /**
  32631. * Relative Loop Mode
  32632. */
  32633. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32634. /**
  32635. * Cycle Loop Mode
  32636. */
  32637. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32638. /**
  32639. * Constant Loop Mode
  32640. */
  32641. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32642. /** @hidden */
  32643. static _UniversalLerp(left: any, right: any, amount: number): any;
  32644. /**
  32645. * Parses an animation object and creates an animation
  32646. * @param parsedAnimation Parsed animation object
  32647. * @returns Animation object
  32648. */
  32649. static Parse(parsedAnimation: any): Animation;
  32650. /**
  32651. * Appends the serialized animations from the source animations
  32652. * @param source Source containing the animations
  32653. * @param destination Target to store the animations
  32654. */
  32655. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32656. /**
  32657. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32658. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32659. * @param url defines the url to load from
  32660. * @returns a promise that will resolve to the new animation or an array of animations
  32661. */
  32662. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32663. /**
  32664. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32665. * @param snippetId defines the snippet to load
  32666. * @returns a promise that will resolve to the new animation or a new array of animations
  32667. */
  32668. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32669. }
  32670. }
  32671. declare module BABYLON {
  32672. /**
  32673. * Interface containing an array of animations
  32674. */
  32675. export interface IAnimatable {
  32676. /**
  32677. * Array of animations
  32678. */
  32679. animations: Nullable<Array<Animation>>;
  32680. }
  32681. }
  32682. declare module BABYLON {
  32683. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32684. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32685. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32686. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32687. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32688. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32689. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32690. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32691. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32692. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32693. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32694. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32695. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32696. /**
  32697. * Decorator used to define property that can be serialized as reference to a camera
  32698. * @param sourceName defines the name of the property to decorate
  32699. */
  32700. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32701. /**
  32702. * Class used to help serialization objects
  32703. */
  32704. export class SerializationHelper {
  32705. /** @hidden */
  32706. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32707. /** @hidden */
  32708. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32709. /** @hidden */
  32710. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32711. /** @hidden */
  32712. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32713. /**
  32714. * Appends the serialized animations from the source animations
  32715. * @param source Source containing the animations
  32716. * @param destination Target to store the animations
  32717. */
  32718. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32719. /**
  32720. * Static function used to serialized a specific entity
  32721. * @param entity defines the entity to serialize
  32722. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32723. * @returns a JSON compatible object representing the serialization of the entity
  32724. */
  32725. static Serialize<T>(entity: T, serializationObject?: any): any;
  32726. /**
  32727. * Creates a new entity from a serialization data object
  32728. * @param creationFunction defines a function used to instanciated the new entity
  32729. * @param source defines the source serialization data
  32730. * @param scene defines the hosting scene
  32731. * @param rootUrl defines the root url for resources
  32732. * @returns a new entity
  32733. */
  32734. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32735. /**
  32736. * Clones an object
  32737. * @param creationFunction defines the function used to instanciate the new object
  32738. * @param source defines the source object
  32739. * @returns the cloned object
  32740. */
  32741. static Clone<T>(creationFunction: () => T, source: T): T;
  32742. /**
  32743. * Instanciates a new object based on a source one (some data will be shared between both object)
  32744. * @param creationFunction defines the function used to instanciate the new object
  32745. * @param source defines the source object
  32746. * @returns the new object
  32747. */
  32748. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32749. }
  32750. }
  32751. declare module BABYLON {
  32752. /**
  32753. * Base class of all the textures in babylon.
  32754. * It groups all the common properties the materials, post process, lights... might need
  32755. * in order to make a correct use of the texture.
  32756. */
  32757. export class BaseTexture implements IAnimatable {
  32758. /**
  32759. * Default anisotropic filtering level for the application.
  32760. * It is set to 4 as a good tradeoff between perf and quality.
  32761. */
  32762. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32763. /**
  32764. * Gets or sets the unique id of the texture
  32765. */
  32766. uniqueId: number;
  32767. /**
  32768. * Define the name of the texture.
  32769. */
  32770. name: string;
  32771. /**
  32772. * Gets or sets an object used to store user defined information.
  32773. */
  32774. metadata: any;
  32775. /**
  32776. * For internal use only. Please do not use.
  32777. */
  32778. reservedDataStore: any;
  32779. private _hasAlpha;
  32780. /**
  32781. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32782. */
  32783. set hasAlpha(value: boolean);
  32784. get hasAlpha(): boolean;
  32785. /**
  32786. * Defines if the alpha value should be determined via the rgb values.
  32787. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32788. */
  32789. getAlphaFromRGB: boolean;
  32790. /**
  32791. * Intensity or strength of the texture.
  32792. * It is commonly used by materials to fine tune the intensity of the texture
  32793. */
  32794. level: number;
  32795. /**
  32796. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32797. * This is part of the texture as textures usually maps to one uv set.
  32798. */
  32799. coordinatesIndex: number;
  32800. private _coordinatesMode;
  32801. /**
  32802. * How a texture is mapped.
  32803. *
  32804. * | Value | Type | Description |
  32805. * | ----- | ----------------------------------- | ----------- |
  32806. * | 0 | EXPLICIT_MODE | |
  32807. * | 1 | SPHERICAL_MODE | |
  32808. * | 2 | PLANAR_MODE | |
  32809. * | 3 | CUBIC_MODE | |
  32810. * | 4 | PROJECTION_MODE | |
  32811. * | 5 | SKYBOX_MODE | |
  32812. * | 6 | INVCUBIC_MODE | |
  32813. * | 7 | EQUIRECTANGULAR_MODE | |
  32814. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32815. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32816. */
  32817. set coordinatesMode(value: number);
  32818. get coordinatesMode(): number;
  32819. /**
  32820. * | Value | Type | Description |
  32821. * | ----- | ------------------ | ----------- |
  32822. * | 0 | CLAMP_ADDRESSMODE | |
  32823. * | 1 | WRAP_ADDRESSMODE | |
  32824. * | 2 | MIRROR_ADDRESSMODE | |
  32825. */
  32826. wrapU: number;
  32827. /**
  32828. * | Value | Type | Description |
  32829. * | ----- | ------------------ | ----------- |
  32830. * | 0 | CLAMP_ADDRESSMODE | |
  32831. * | 1 | WRAP_ADDRESSMODE | |
  32832. * | 2 | MIRROR_ADDRESSMODE | |
  32833. */
  32834. wrapV: number;
  32835. /**
  32836. * | Value | Type | Description |
  32837. * | ----- | ------------------ | ----------- |
  32838. * | 0 | CLAMP_ADDRESSMODE | |
  32839. * | 1 | WRAP_ADDRESSMODE | |
  32840. * | 2 | MIRROR_ADDRESSMODE | |
  32841. */
  32842. wrapR: number;
  32843. /**
  32844. * With compliant hardware and browser (supporting anisotropic filtering)
  32845. * this defines the level of anisotropic filtering in the texture.
  32846. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32847. */
  32848. anisotropicFilteringLevel: number;
  32849. /**
  32850. * Define if the texture is a cube texture or if false a 2d texture.
  32851. */
  32852. get isCube(): boolean;
  32853. set isCube(value: boolean);
  32854. /**
  32855. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32856. */
  32857. get is3D(): boolean;
  32858. set is3D(value: boolean);
  32859. /**
  32860. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32861. */
  32862. get is2DArray(): boolean;
  32863. set is2DArray(value: boolean);
  32864. /**
  32865. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32866. * HDR texture are usually stored in linear space.
  32867. * This only impacts the PBR and Background materials
  32868. */
  32869. gammaSpace: boolean;
  32870. /**
  32871. * Gets or sets whether or not the texture contains RGBD data.
  32872. */
  32873. get isRGBD(): boolean;
  32874. set isRGBD(value: boolean);
  32875. /**
  32876. * Is Z inverted in the texture (useful in a cube texture).
  32877. */
  32878. invertZ: boolean;
  32879. /**
  32880. * Are mip maps generated for this texture or not.
  32881. */
  32882. get noMipmap(): boolean;
  32883. /**
  32884. * @hidden
  32885. */
  32886. lodLevelInAlpha: boolean;
  32887. /**
  32888. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32889. */
  32890. get lodGenerationOffset(): number;
  32891. set lodGenerationOffset(value: number);
  32892. /**
  32893. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32894. */
  32895. get lodGenerationScale(): number;
  32896. set lodGenerationScale(value: number);
  32897. /**
  32898. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32899. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32900. * average roughness values.
  32901. */
  32902. get linearSpecularLOD(): boolean;
  32903. set linearSpecularLOD(value: boolean);
  32904. /**
  32905. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32906. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32907. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32908. */
  32909. get irradianceTexture(): Nullable<BaseTexture>;
  32910. set irradianceTexture(value: Nullable<BaseTexture>);
  32911. /**
  32912. * Define if the texture is a render target.
  32913. */
  32914. isRenderTarget: boolean;
  32915. /**
  32916. * Define the unique id of the texture in the scene.
  32917. */
  32918. get uid(): string;
  32919. /** @hidden */
  32920. _prefiltered: boolean;
  32921. /**
  32922. * Return a string representation of the texture.
  32923. * @returns the texture as a string
  32924. */
  32925. toString(): string;
  32926. /**
  32927. * Get the class name of the texture.
  32928. * @returns "BaseTexture"
  32929. */
  32930. getClassName(): string;
  32931. /**
  32932. * Define the list of animation attached to the texture.
  32933. */
  32934. animations: Animation[];
  32935. /**
  32936. * An event triggered when the texture is disposed.
  32937. */
  32938. onDisposeObservable: Observable<BaseTexture>;
  32939. private _onDisposeObserver;
  32940. /**
  32941. * Callback triggered when the texture has been disposed.
  32942. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32943. */
  32944. set onDispose(callback: () => void);
  32945. /**
  32946. * Define the current state of the loading sequence when in delayed load mode.
  32947. */
  32948. delayLoadState: number;
  32949. private _scene;
  32950. private _engine;
  32951. /** @hidden */
  32952. _texture: Nullable<InternalTexture>;
  32953. private _uid;
  32954. /**
  32955. * Define if the texture is preventinga material to render or not.
  32956. * If not and the texture is not ready, the engine will use a default black texture instead.
  32957. */
  32958. get isBlocking(): boolean;
  32959. /**
  32960. * Instantiates a new BaseTexture.
  32961. * Base class of all the textures in babylon.
  32962. * It groups all the common properties the materials, post process, lights... might need
  32963. * in order to make a correct use of the texture.
  32964. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32965. */
  32966. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32967. /**
  32968. * Get the scene the texture belongs to.
  32969. * @returns the scene or null if undefined
  32970. */
  32971. getScene(): Nullable<Scene>;
  32972. /** @hidden */
  32973. protected _getEngine(): Nullable<ThinEngine>;
  32974. /**
  32975. * Get the texture transform matrix used to offset tile the texture for istance.
  32976. * @returns the transformation matrix
  32977. */
  32978. getTextureMatrix(): Matrix;
  32979. /**
  32980. * Get the texture reflection matrix used to rotate/transform the reflection.
  32981. * @returns the reflection matrix
  32982. */
  32983. getReflectionTextureMatrix(): Matrix;
  32984. /**
  32985. * Get the underlying lower level texture from Babylon.
  32986. * @returns the insternal texture
  32987. */
  32988. getInternalTexture(): Nullable<InternalTexture>;
  32989. /**
  32990. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32991. * @returns true if ready or not blocking
  32992. */
  32993. isReadyOrNotBlocking(): boolean;
  32994. /**
  32995. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32996. * @returns true if fully ready
  32997. */
  32998. isReady(): boolean;
  32999. private _cachedSize;
  33000. /**
  33001. * Get the size of the texture.
  33002. * @returns the texture size.
  33003. */
  33004. getSize(): ISize;
  33005. /**
  33006. * Get the base size of the texture.
  33007. * It can be different from the size if the texture has been resized for POT for instance
  33008. * @returns the base size
  33009. */
  33010. getBaseSize(): ISize;
  33011. /**
  33012. * Update the sampling mode of the texture.
  33013. * Default is Trilinear mode.
  33014. *
  33015. * | Value | Type | Description |
  33016. * | ----- | ------------------ | ----------- |
  33017. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33018. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33019. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33020. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33021. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33022. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33023. * | 7 | NEAREST_LINEAR | |
  33024. * | 8 | NEAREST_NEAREST | |
  33025. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33026. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33027. * | 11 | LINEAR_LINEAR | |
  33028. * | 12 | LINEAR_NEAREST | |
  33029. *
  33030. * > _mag_: magnification filter (close to the viewer)
  33031. * > _min_: minification filter (far from the viewer)
  33032. * > _mip_: filter used between mip map levels
  33033. *@param samplingMode Define the new sampling mode of the texture
  33034. */
  33035. updateSamplingMode(samplingMode: number): void;
  33036. /**
  33037. * Scales the texture if is `canRescale()`
  33038. * @param ratio the resize factor we want to use to rescale
  33039. */
  33040. scale(ratio: number): void;
  33041. /**
  33042. * Get if the texture can rescale.
  33043. */
  33044. get canRescale(): boolean;
  33045. /** @hidden */
  33046. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33047. /** @hidden */
  33048. _rebuild(): void;
  33049. /**
  33050. * Triggers the load sequence in delayed load mode.
  33051. */
  33052. delayLoad(): void;
  33053. /**
  33054. * Clones the texture.
  33055. * @returns the cloned texture
  33056. */
  33057. clone(): Nullable<BaseTexture>;
  33058. /**
  33059. * Get the texture underlying type (INT, FLOAT...)
  33060. */
  33061. get textureType(): number;
  33062. /**
  33063. * Get the texture underlying format (RGB, RGBA...)
  33064. */
  33065. get textureFormat(): number;
  33066. /**
  33067. * Indicates that textures need to be re-calculated for all materials
  33068. */
  33069. protected _markAllSubMeshesAsTexturesDirty(): void;
  33070. /**
  33071. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33072. * This will returns an RGBA array buffer containing either in values (0-255) or
  33073. * float values (0-1) depending of the underlying buffer type.
  33074. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33075. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33076. * @param buffer defines a user defined buffer to fill with data (can be null)
  33077. * @returns The Array buffer containing the pixels data.
  33078. */
  33079. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33080. /**
  33081. * Release and destroy the underlying lower level texture aka internalTexture.
  33082. */
  33083. releaseInternalTexture(): void;
  33084. /** @hidden */
  33085. get _lodTextureHigh(): Nullable<BaseTexture>;
  33086. /** @hidden */
  33087. get _lodTextureMid(): Nullable<BaseTexture>;
  33088. /** @hidden */
  33089. get _lodTextureLow(): Nullable<BaseTexture>;
  33090. /**
  33091. * Dispose the texture and release its associated resources.
  33092. */
  33093. dispose(): void;
  33094. /**
  33095. * Serialize the texture into a JSON representation that can be parsed later on.
  33096. * @returns the JSON representation of the texture
  33097. */
  33098. serialize(): any;
  33099. /**
  33100. * Helper function to be called back once a list of texture contains only ready textures.
  33101. * @param textures Define the list of textures to wait for
  33102. * @param callback Define the callback triggered once the entire list will be ready
  33103. */
  33104. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33105. private static _isScene;
  33106. }
  33107. }
  33108. declare module BABYLON {
  33109. /**
  33110. * Options to be used when creating an effect.
  33111. */
  33112. export interface IEffectCreationOptions {
  33113. /**
  33114. * Atrributes that will be used in the shader.
  33115. */
  33116. attributes: string[];
  33117. /**
  33118. * Uniform varible names that will be set in the shader.
  33119. */
  33120. uniformsNames: string[];
  33121. /**
  33122. * Uniform buffer variable names that will be set in the shader.
  33123. */
  33124. uniformBuffersNames: string[];
  33125. /**
  33126. * Sampler texture variable names that will be set in the shader.
  33127. */
  33128. samplers: string[];
  33129. /**
  33130. * Define statements that will be set in the shader.
  33131. */
  33132. defines: any;
  33133. /**
  33134. * Possible fallbacks for this effect to improve performance when needed.
  33135. */
  33136. fallbacks: Nullable<IEffectFallbacks>;
  33137. /**
  33138. * Callback that will be called when the shader is compiled.
  33139. */
  33140. onCompiled: Nullable<(effect: Effect) => void>;
  33141. /**
  33142. * Callback that will be called if an error occurs during shader compilation.
  33143. */
  33144. onError: Nullable<(effect: Effect, errors: string) => void>;
  33145. /**
  33146. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33147. */
  33148. indexParameters?: any;
  33149. /**
  33150. * Max number of lights that can be used in the shader.
  33151. */
  33152. maxSimultaneousLights?: number;
  33153. /**
  33154. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33155. */
  33156. transformFeedbackVaryings?: Nullable<string[]>;
  33157. /**
  33158. * 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
  33159. */
  33160. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33161. }
  33162. /**
  33163. * Effect containing vertex and fragment shader that can be executed on an object.
  33164. */
  33165. export class Effect implements IDisposable {
  33166. /**
  33167. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33168. */
  33169. static ShadersRepository: string;
  33170. /**
  33171. * Enable logging of the shader code when a compilation error occurs
  33172. */
  33173. static LogShaderCodeOnCompilationError: boolean;
  33174. /**
  33175. * Name of the effect.
  33176. */
  33177. name: any;
  33178. /**
  33179. * String container all the define statements that should be set on the shader.
  33180. */
  33181. defines: string;
  33182. /**
  33183. * Callback that will be called when the shader is compiled.
  33184. */
  33185. onCompiled: Nullable<(effect: Effect) => void>;
  33186. /**
  33187. * Callback that will be called if an error occurs during shader compilation.
  33188. */
  33189. onError: Nullable<(effect: Effect, errors: string) => void>;
  33190. /**
  33191. * Callback that will be called when effect is bound.
  33192. */
  33193. onBind: Nullable<(effect: Effect) => void>;
  33194. /**
  33195. * Unique ID of the effect.
  33196. */
  33197. uniqueId: number;
  33198. /**
  33199. * Observable that will be called when the shader is compiled.
  33200. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33201. */
  33202. onCompileObservable: Observable<Effect>;
  33203. /**
  33204. * Observable that will be called if an error occurs during shader compilation.
  33205. */
  33206. onErrorObservable: Observable<Effect>;
  33207. /** @hidden */
  33208. _onBindObservable: Nullable<Observable<Effect>>;
  33209. /**
  33210. * @hidden
  33211. * Specifies if the effect was previously ready
  33212. */
  33213. _wasPreviouslyReady: boolean;
  33214. /**
  33215. * Observable that will be called when effect is bound.
  33216. */
  33217. get onBindObservable(): Observable<Effect>;
  33218. /** @hidden */
  33219. _bonesComputationForcedToCPU: boolean;
  33220. private static _uniqueIdSeed;
  33221. private _engine;
  33222. private _uniformBuffersNames;
  33223. private _uniformBuffersNamesList;
  33224. private _uniformsNames;
  33225. private _samplerList;
  33226. private _samplers;
  33227. private _isReady;
  33228. private _compilationError;
  33229. private _allFallbacksProcessed;
  33230. private _attributesNames;
  33231. private _attributes;
  33232. private _attributeLocationByName;
  33233. private _uniforms;
  33234. /**
  33235. * Key for the effect.
  33236. * @hidden
  33237. */
  33238. _key: string;
  33239. private _indexParameters;
  33240. private _fallbacks;
  33241. private _vertexSourceCode;
  33242. private _fragmentSourceCode;
  33243. private _vertexSourceCodeOverride;
  33244. private _fragmentSourceCodeOverride;
  33245. private _transformFeedbackVaryings;
  33246. /**
  33247. * Compiled shader to webGL program.
  33248. * @hidden
  33249. */
  33250. _pipelineContext: Nullable<IPipelineContext>;
  33251. private _valueCache;
  33252. private static _baseCache;
  33253. /**
  33254. * Instantiates an effect.
  33255. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33256. * @param baseName Name of the effect.
  33257. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33258. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33259. * @param samplers List of sampler variables that will be passed to the shader.
  33260. * @param engine Engine to be used to render the effect
  33261. * @param defines Define statements to be added to the shader.
  33262. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33263. * @param onCompiled Callback that will be called when the shader is compiled.
  33264. * @param onError Callback that will be called if an error occurs during shader compilation.
  33265. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33266. */
  33267. 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);
  33268. private _useFinalCode;
  33269. /**
  33270. * Unique key for this effect
  33271. */
  33272. get key(): string;
  33273. /**
  33274. * If the effect has been compiled and prepared.
  33275. * @returns if the effect is compiled and prepared.
  33276. */
  33277. isReady(): boolean;
  33278. private _isReadyInternal;
  33279. /**
  33280. * The engine the effect was initialized with.
  33281. * @returns the engine.
  33282. */
  33283. getEngine(): Engine;
  33284. /**
  33285. * The pipeline context for this effect
  33286. * @returns the associated pipeline context
  33287. */
  33288. getPipelineContext(): Nullable<IPipelineContext>;
  33289. /**
  33290. * The set of names of attribute variables for the shader.
  33291. * @returns An array of attribute names.
  33292. */
  33293. getAttributesNames(): string[];
  33294. /**
  33295. * Returns the attribute at the given index.
  33296. * @param index The index of the attribute.
  33297. * @returns The location of the attribute.
  33298. */
  33299. getAttributeLocation(index: number): number;
  33300. /**
  33301. * Returns the attribute based on the name of the variable.
  33302. * @param name of the attribute to look up.
  33303. * @returns the attribute location.
  33304. */
  33305. getAttributeLocationByName(name: string): number;
  33306. /**
  33307. * The number of attributes.
  33308. * @returns the numnber of attributes.
  33309. */
  33310. getAttributesCount(): number;
  33311. /**
  33312. * Gets the index of a uniform variable.
  33313. * @param uniformName of the uniform to look up.
  33314. * @returns the index.
  33315. */
  33316. getUniformIndex(uniformName: string): number;
  33317. /**
  33318. * Returns the attribute based on the name of the variable.
  33319. * @param uniformName of the uniform to look up.
  33320. * @returns the location of the uniform.
  33321. */
  33322. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33323. /**
  33324. * Returns an array of sampler variable names
  33325. * @returns The array of sampler variable names.
  33326. */
  33327. getSamplers(): string[];
  33328. /**
  33329. * Returns an array of uniform variable names
  33330. * @returns The array of uniform variable names.
  33331. */
  33332. getUniformNames(): string[];
  33333. /**
  33334. * Returns an array of uniform buffer variable names
  33335. * @returns The array of uniform buffer variable names.
  33336. */
  33337. getUniformBuffersNames(): string[];
  33338. /**
  33339. * Returns the index parameters used to create the effect
  33340. * @returns The index parameters object
  33341. */
  33342. getIndexParameters(): any;
  33343. /**
  33344. * The error from the last compilation.
  33345. * @returns the error string.
  33346. */
  33347. getCompilationError(): string;
  33348. /**
  33349. * Gets a boolean indicating that all fallbacks were used during compilation
  33350. * @returns true if all fallbacks were used
  33351. */
  33352. allFallbacksProcessed(): boolean;
  33353. /**
  33354. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33355. * @param func The callback to be used.
  33356. */
  33357. executeWhenCompiled(func: (effect: Effect) => void): void;
  33358. private _checkIsReady;
  33359. private _loadShader;
  33360. /**
  33361. * Gets the vertex shader source code of this effect
  33362. */
  33363. get vertexSourceCode(): string;
  33364. /**
  33365. * Gets the fragment shader source code of this effect
  33366. */
  33367. get fragmentSourceCode(): string;
  33368. /**
  33369. * Recompiles the webGL program
  33370. * @param vertexSourceCode The source code for the vertex shader.
  33371. * @param fragmentSourceCode The source code for the fragment shader.
  33372. * @param onCompiled Callback called when completed.
  33373. * @param onError Callback called on error.
  33374. * @hidden
  33375. */
  33376. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33377. /**
  33378. * Prepares the effect
  33379. * @hidden
  33380. */
  33381. _prepareEffect(): void;
  33382. private _getShaderCodeAndErrorLine;
  33383. private _processCompilationErrors;
  33384. /**
  33385. * Checks if the effect is supported. (Must be called after compilation)
  33386. */
  33387. get isSupported(): boolean;
  33388. /**
  33389. * Binds a texture to the engine to be used as output of the shader.
  33390. * @param channel Name of the output variable.
  33391. * @param texture Texture to bind.
  33392. * @hidden
  33393. */
  33394. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33395. /**
  33396. * Sets a texture on the engine to be used in the shader.
  33397. * @param channel Name of the sampler variable.
  33398. * @param texture Texture to set.
  33399. */
  33400. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33401. /**
  33402. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33403. * @param channel Name of the sampler variable.
  33404. * @param texture Texture to set.
  33405. */
  33406. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33407. /**
  33408. * Sets an array of textures on the engine to be used in the shader.
  33409. * @param channel Name of the variable.
  33410. * @param textures Textures to set.
  33411. */
  33412. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33413. /**
  33414. * 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)
  33415. * @param channel Name of the sampler variable.
  33416. * @param postProcess Post process to get the input texture from.
  33417. */
  33418. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33419. /**
  33420. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33421. * 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)
  33422. * @param channel Name of the sampler variable.
  33423. * @param postProcess Post process to get the output texture from.
  33424. */
  33425. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33426. /** @hidden */
  33427. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33428. /** @hidden */
  33429. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33430. /** @hidden */
  33431. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33432. /** @hidden */
  33433. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33434. /**
  33435. * Binds a buffer to a uniform.
  33436. * @param buffer Buffer to bind.
  33437. * @param name Name of the uniform variable to bind to.
  33438. */
  33439. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33440. /**
  33441. * Binds block to a uniform.
  33442. * @param blockName Name of the block to bind.
  33443. * @param index Index to bind.
  33444. */
  33445. bindUniformBlock(blockName: string, index: number): void;
  33446. /**
  33447. * Sets an interger value on a uniform variable.
  33448. * @param uniformName Name of the variable.
  33449. * @param value Value to be set.
  33450. * @returns this effect.
  33451. */
  33452. setInt(uniformName: string, value: number): Effect;
  33453. /**
  33454. * Sets an int array on a uniform variable.
  33455. * @param uniformName Name of the variable.
  33456. * @param array array to be set.
  33457. * @returns this effect.
  33458. */
  33459. setIntArray(uniformName: string, array: Int32Array): Effect;
  33460. /**
  33461. * 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)
  33462. * @param uniformName Name of the variable.
  33463. * @param array array to be set.
  33464. * @returns this effect.
  33465. */
  33466. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33467. /**
  33468. * 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)
  33469. * @param uniformName Name of the variable.
  33470. * @param array array to be set.
  33471. * @returns this effect.
  33472. */
  33473. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33474. /**
  33475. * 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)
  33476. * @param uniformName Name of the variable.
  33477. * @param array array to be set.
  33478. * @returns this effect.
  33479. */
  33480. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33481. /**
  33482. * Sets an float array on a uniform variable.
  33483. * @param uniformName Name of the variable.
  33484. * @param array array to be set.
  33485. * @returns this effect.
  33486. */
  33487. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33488. /**
  33489. * 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)
  33490. * @param uniformName Name of the variable.
  33491. * @param array array to be set.
  33492. * @returns this effect.
  33493. */
  33494. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33495. /**
  33496. * 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)
  33497. * @param uniformName Name of the variable.
  33498. * @param array array to be set.
  33499. * @returns this effect.
  33500. */
  33501. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33502. /**
  33503. * 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)
  33504. * @param uniformName Name of the variable.
  33505. * @param array array to be set.
  33506. * @returns this effect.
  33507. */
  33508. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33509. /**
  33510. * Sets an array on a uniform variable.
  33511. * @param uniformName Name of the variable.
  33512. * @param array array to be set.
  33513. * @returns this effect.
  33514. */
  33515. setArray(uniformName: string, array: number[]): Effect;
  33516. /**
  33517. * 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)
  33518. * @param uniformName Name of the variable.
  33519. * @param array array to be set.
  33520. * @returns this effect.
  33521. */
  33522. setArray2(uniformName: string, array: number[]): Effect;
  33523. /**
  33524. * 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)
  33525. * @param uniformName Name of the variable.
  33526. * @param array array to be set.
  33527. * @returns this effect.
  33528. */
  33529. setArray3(uniformName: string, array: number[]): Effect;
  33530. /**
  33531. * 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)
  33532. * @param uniformName Name of the variable.
  33533. * @param array array to be set.
  33534. * @returns this effect.
  33535. */
  33536. setArray4(uniformName: string, array: number[]): Effect;
  33537. /**
  33538. * Sets matrices on a uniform variable.
  33539. * @param uniformName Name of the variable.
  33540. * @param matrices matrices to be set.
  33541. * @returns this effect.
  33542. */
  33543. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33544. /**
  33545. * Sets matrix on a uniform variable.
  33546. * @param uniformName Name of the variable.
  33547. * @param matrix matrix to be set.
  33548. * @returns this effect.
  33549. */
  33550. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33551. /**
  33552. * 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)
  33553. * @param uniformName Name of the variable.
  33554. * @param matrix matrix to be set.
  33555. * @returns this effect.
  33556. */
  33557. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33558. /**
  33559. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33560. * @param uniformName Name of the variable.
  33561. * @param matrix matrix to be set.
  33562. * @returns this effect.
  33563. */
  33564. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33565. /**
  33566. * Sets a float on a uniform variable.
  33567. * @param uniformName Name of the variable.
  33568. * @param value value to be set.
  33569. * @returns this effect.
  33570. */
  33571. setFloat(uniformName: string, value: number): Effect;
  33572. /**
  33573. * Sets a boolean on a uniform variable.
  33574. * @param uniformName Name of the variable.
  33575. * @param bool value to be set.
  33576. * @returns this effect.
  33577. */
  33578. setBool(uniformName: string, bool: boolean): Effect;
  33579. /**
  33580. * Sets a Vector2 on a uniform variable.
  33581. * @param uniformName Name of the variable.
  33582. * @param vector2 vector2 to be set.
  33583. * @returns this effect.
  33584. */
  33585. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33586. /**
  33587. * Sets a float2 on a uniform variable.
  33588. * @param uniformName Name of the variable.
  33589. * @param x First float in float2.
  33590. * @param y Second float in float2.
  33591. * @returns this effect.
  33592. */
  33593. setFloat2(uniformName: string, x: number, y: number): Effect;
  33594. /**
  33595. * Sets a Vector3 on a uniform variable.
  33596. * @param uniformName Name of the variable.
  33597. * @param vector3 Value to be set.
  33598. * @returns this effect.
  33599. */
  33600. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33601. /**
  33602. * Sets a float3 on a uniform variable.
  33603. * @param uniformName Name of the variable.
  33604. * @param x First float in float3.
  33605. * @param y Second float in float3.
  33606. * @param z Third float in float3.
  33607. * @returns this effect.
  33608. */
  33609. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33610. /**
  33611. * Sets a Vector4 on a uniform variable.
  33612. * @param uniformName Name of the variable.
  33613. * @param vector4 Value to be set.
  33614. * @returns this effect.
  33615. */
  33616. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33617. /**
  33618. * Sets a float4 on a uniform variable.
  33619. * @param uniformName Name of the variable.
  33620. * @param x First float in float4.
  33621. * @param y Second float in float4.
  33622. * @param z Third float in float4.
  33623. * @param w Fourth float in float4.
  33624. * @returns this effect.
  33625. */
  33626. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33627. /**
  33628. * Sets a Color3 on a uniform variable.
  33629. * @param uniformName Name of the variable.
  33630. * @param color3 Value to be set.
  33631. * @returns this effect.
  33632. */
  33633. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33634. /**
  33635. * Sets a Color4 on a uniform variable.
  33636. * @param uniformName Name of the variable.
  33637. * @param color3 Value to be set.
  33638. * @param alpha Alpha value to be set.
  33639. * @returns this effect.
  33640. */
  33641. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33642. /**
  33643. * Sets a Color4 on a uniform variable
  33644. * @param uniformName defines the name of the variable
  33645. * @param color4 defines the value to be set
  33646. * @returns this effect.
  33647. */
  33648. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33649. /** Release all associated resources */
  33650. dispose(): void;
  33651. /**
  33652. * This function will add a new shader to the shader store
  33653. * @param name the name of the shader
  33654. * @param pixelShader optional pixel shader content
  33655. * @param vertexShader optional vertex shader content
  33656. */
  33657. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33658. /**
  33659. * Store of each shader (The can be looked up using effect.key)
  33660. */
  33661. static ShadersStore: {
  33662. [key: string]: string;
  33663. };
  33664. /**
  33665. * Store of each included file for a shader (The can be looked up using effect.key)
  33666. */
  33667. static IncludesShadersStore: {
  33668. [key: string]: string;
  33669. };
  33670. /**
  33671. * Resets the cache of effects.
  33672. */
  33673. static ResetCache(): void;
  33674. }
  33675. }
  33676. declare module BABYLON {
  33677. /**
  33678. * Interface used to describe the capabilities of the engine relatively to the current browser
  33679. */
  33680. export interface EngineCapabilities {
  33681. /** Maximum textures units per fragment shader */
  33682. maxTexturesImageUnits: number;
  33683. /** Maximum texture units per vertex shader */
  33684. maxVertexTextureImageUnits: number;
  33685. /** Maximum textures units in the entire pipeline */
  33686. maxCombinedTexturesImageUnits: number;
  33687. /** Maximum texture size */
  33688. maxTextureSize: number;
  33689. /** Maximum texture samples */
  33690. maxSamples?: number;
  33691. /** Maximum cube texture size */
  33692. maxCubemapTextureSize: number;
  33693. /** Maximum render texture size */
  33694. maxRenderTextureSize: number;
  33695. /** Maximum number of vertex attributes */
  33696. maxVertexAttribs: number;
  33697. /** Maximum number of varyings */
  33698. maxVaryingVectors: number;
  33699. /** Maximum number of uniforms per vertex shader */
  33700. maxVertexUniformVectors: number;
  33701. /** Maximum number of uniforms per fragment shader */
  33702. maxFragmentUniformVectors: number;
  33703. /** Defines if standard derivates (dx/dy) are supported */
  33704. standardDerivatives: boolean;
  33705. /** Defines if s3tc texture compression is supported */
  33706. s3tc?: WEBGL_compressed_texture_s3tc;
  33707. /** Defines if pvrtc texture compression is supported */
  33708. pvrtc: any;
  33709. /** Defines if etc1 texture compression is supported */
  33710. etc1: any;
  33711. /** Defines if etc2 texture compression is supported */
  33712. etc2: any;
  33713. /** Defines if astc texture compression is supported */
  33714. astc: any;
  33715. /** Defines if float textures are supported */
  33716. textureFloat: boolean;
  33717. /** Defines if vertex array objects are supported */
  33718. vertexArrayObject: boolean;
  33719. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33720. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33721. /** Gets the maximum level of anisotropy supported */
  33722. maxAnisotropy: number;
  33723. /** Defines if instancing is supported */
  33724. instancedArrays: boolean;
  33725. /** Defines if 32 bits indices are supported */
  33726. uintIndices: boolean;
  33727. /** Defines if high precision shaders are supported */
  33728. highPrecisionShaderSupported: boolean;
  33729. /** Defines if depth reading in the fragment shader is supported */
  33730. fragmentDepthSupported: boolean;
  33731. /** Defines if float texture linear filtering is supported*/
  33732. textureFloatLinearFiltering: boolean;
  33733. /** Defines if rendering to float textures is supported */
  33734. textureFloatRender: boolean;
  33735. /** Defines if half float textures are supported*/
  33736. textureHalfFloat: boolean;
  33737. /** Defines if half float texture linear filtering is supported*/
  33738. textureHalfFloatLinearFiltering: boolean;
  33739. /** Defines if rendering to half float textures is supported */
  33740. textureHalfFloatRender: boolean;
  33741. /** Defines if textureLOD shader command is supported */
  33742. textureLOD: boolean;
  33743. /** Defines if draw buffers extension is supported */
  33744. drawBuffersExtension: boolean;
  33745. /** Defines if depth textures are supported */
  33746. depthTextureExtension: boolean;
  33747. /** Defines if float color buffer are supported */
  33748. colorBufferFloat: boolean;
  33749. /** Gets disjoint timer query extension (null if not supported) */
  33750. timerQuery?: EXT_disjoint_timer_query;
  33751. /** Defines if timestamp can be used with timer query */
  33752. canUseTimestampForTimerQuery: boolean;
  33753. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33754. multiview?: any;
  33755. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33756. oculusMultiview?: any;
  33757. /** Function used to let the system compiles shaders in background */
  33758. parallelShaderCompile?: {
  33759. COMPLETION_STATUS_KHR: number;
  33760. };
  33761. /** Max number of texture samples for MSAA */
  33762. maxMSAASamples: number;
  33763. /** Defines if the blend min max extension is supported */
  33764. blendMinMax: boolean;
  33765. }
  33766. }
  33767. declare module BABYLON {
  33768. /**
  33769. * @hidden
  33770. **/
  33771. export class DepthCullingState {
  33772. private _isDepthTestDirty;
  33773. private _isDepthMaskDirty;
  33774. private _isDepthFuncDirty;
  33775. private _isCullFaceDirty;
  33776. private _isCullDirty;
  33777. private _isZOffsetDirty;
  33778. private _isFrontFaceDirty;
  33779. private _depthTest;
  33780. private _depthMask;
  33781. private _depthFunc;
  33782. private _cull;
  33783. private _cullFace;
  33784. private _zOffset;
  33785. private _frontFace;
  33786. /**
  33787. * Initializes the state.
  33788. */
  33789. constructor();
  33790. get isDirty(): boolean;
  33791. get zOffset(): number;
  33792. set zOffset(value: number);
  33793. get cullFace(): Nullable<number>;
  33794. set cullFace(value: Nullable<number>);
  33795. get cull(): Nullable<boolean>;
  33796. set cull(value: Nullable<boolean>);
  33797. get depthFunc(): Nullable<number>;
  33798. set depthFunc(value: Nullable<number>);
  33799. get depthMask(): boolean;
  33800. set depthMask(value: boolean);
  33801. get depthTest(): boolean;
  33802. set depthTest(value: boolean);
  33803. get frontFace(): Nullable<number>;
  33804. set frontFace(value: Nullable<number>);
  33805. reset(): void;
  33806. apply(gl: WebGLRenderingContext): void;
  33807. }
  33808. }
  33809. declare module BABYLON {
  33810. /**
  33811. * @hidden
  33812. **/
  33813. export class StencilState {
  33814. /** 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 */
  33815. static readonly ALWAYS: number;
  33816. /** Passed to stencilOperation to specify that stencil value must be kept */
  33817. static readonly KEEP: number;
  33818. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33819. static readonly REPLACE: number;
  33820. private _isStencilTestDirty;
  33821. private _isStencilMaskDirty;
  33822. private _isStencilFuncDirty;
  33823. private _isStencilOpDirty;
  33824. private _stencilTest;
  33825. private _stencilMask;
  33826. private _stencilFunc;
  33827. private _stencilFuncRef;
  33828. private _stencilFuncMask;
  33829. private _stencilOpStencilFail;
  33830. private _stencilOpDepthFail;
  33831. private _stencilOpStencilDepthPass;
  33832. get isDirty(): boolean;
  33833. get stencilFunc(): number;
  33834. set stencilFunc(value: number);
  33835. get stencilFuncRef(): number;
  33836. set stencilFuncRef(value: number);
  33837. get stencilFuncMask(): number;
  33838. set stencilFuncMask(value: number);
  33839. get stencilOpStencilFail(): number;
  33840. set stencilOpStencilFail(value: number);
  33841. get stencilOpDepthFail(): number;
  33842. set stencilOpDepthFail(value: number);
  33843. get stencilOpStencilDepthPass(): number;
  33844. set stencilOpStencilDepthPass(value: number);
  33845. get stencilMask(): number;
  33846. set stencilMask(value: number);
  33847. get stencilTest(): boolean;
  33848. set stencilTest(value: boolean);
  33849. constructor();
  33850. reset(): void;
  33851. apply(gl: WebGLRenderingContext): void;
  33852. }
  33853. }
  33854. declare module BABYLON {
  33855. /**
  33856. * @hidden
  33857. **/
  33858. export class AlphaState {
  33859. private _isAlphaBlendDirty;
  33860. private _isBlendFunctionParametersDirty;
  33861. private _isBlendEquationParametersDirty;
  33862. private _isBlendConstantsDirty;
  33863. private _alphaBlend;
  33864. private _blendFunctionParameters;
  33865. private _blendEquationParameters;
  33866. private _blendConstants;
  33867. /**
  33868. * Initializes the state.
  33869. */
  33870. constructor();
  33871. get isDirty(): boolean;
  33872. get alphaBlend(): boolean;
  33873. set alphaBlend(value: boolean);
  33874. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33875. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33876. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33877. reset(): void;
  33878. apply(gl: WebGLRenderingContext): void;
  33879. }
  33880. }
  33881. declare module BABYLON {
  33882. /** @hidden */
  33883. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33884. attributeProcessor(attribute: string): string;
  33885. varyingProcessor(varying: string, isFragment: boolean): string;
  33886. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33887. }
  33888. }
  33889. declare module BABYLON {
  33890. /**
  33891. * Interface for attribute information associated with buffer instanciation
  33892. */
  33893. export interface InstancingAttributeInfo {
  33894. /**
  33895. * Name of the GLSL attribute
  33896. * if attribute index is not specified, this is used to retrieve the index from the effect
  33897. */
  33898. attributeName: string;
  33899. /**
  33900. * Index/offset of the attribute in the vertex shader
  33901. * if not specified, this will be computes from the name.
  33902. */
  33903. index?: number;
  33904. /**
  33905. * size of the attribute, 1, 2, 3 or 4
  33906. */
  33907. attributeSize: number;
  33908. /**
  33909. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33910. */
  33911. offset: number;
  33912. /**
  33913. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33914. * default to 1
  33915. */
  33916. divisor?: number;
  33917. /**
  33918. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33919. * default is FLOAT
  33920. */
  33921. attributeType?: number;
  33922. /**
  33923. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33924. */
  33925. normalized?: boolean;
  33926. }
  33927. }
  33928. declare module BABYLON {
  33929. interface ThinEngine {
  33930. /**
  33931. * Update a video texture
  33932. * @param texture defines the texture to update
  33933. * @param video defines the video element to use
  33934. * @param invertY defines if data must be stored with Y axis inverted
  33935. */
  33936. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33937. }
  33938. }
  33939. declare module BABYLON {
  33940. /**
  33941. * Settings for finer control over video usage
  33942. */
  33943. export interface VideoTextureSettings {
  33944. /**
  33945. * Applies `autoplay` to video, if specified
  33946. */
  33947. autoPlay?: boolean;
  33948. /**
  33949. * Applies `loop` to video, if specified
  33950. */
  33951. loop?: boolean;
  33952. /**
  33953. * Automatically updates internal texture from video at every frame in the render loop
  33954. */
  33955. autoUpdateTexture: boolean;
  33956. /**
  33957. * Image src displayed during the video loading or until the user interacts with the video.
  33958. */
  33959. poster?: string;
  33960. }
  33961. /**
  33962. * If you want to display a video in your scene, this is the special texture for that.
  33963. * This special texture works similar to other textures, with the exception of a few parameters.
  33964. * @see https://doc.babylonjs.com/how_to/video_texture
  33965. */
  33966. export class VideoTexture extends Texture {
  33967. /**
  33968. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33969. */
  33970. readonly autoUpdateTexture: boolean;
  33971. /**
  33972. * The video instance used by the texture internally
  33973. */
  33974. readonly video: HTMLVideoElement;
  33975. private _onUserActionRequestedObservable;
  33976. /**
  33977. * Event triggerd when a dom action is required by the user to play the video.
  33978. * This happens due to recent changes in browser policies preventing video to auto start.
  33979. */
  33980. get onUserActionRequestedObservable(): Observable<Texture>;
  33981. private _generateMipMaps;
  33982. private _stillImageCaptured;
  33983. private _displayingPosterTexture;
  33984. private _settings;
  33985. private _createInternalTextureOnEvent;
  33986. private _frameId;
  33987. private _currentSrc;
  33988. /**
  33989. * Creates a video texture.
  33990. * If you want to display a video in your scene, this is the special texture for that.
  33991. * This special texture works similar to other textures, with the exception of a few parameters.
  33992. * @see https://doc.babylonjs.com/how_to/video_texture
  33993. * @param name optional name, will detect from video source, if not defined
  33994. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33995. * @param scene is obviously the current scene.
  33996. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33997. * @param invertY is false by default but can be used to invert video on Y axis
  33998. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33999. * @param settings allows finer control over video usage
  34000. */
  34001. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34002. private _getName;
  34003. private _getVideo;
  34004. private _createInternalTexture;
  34005. private reset;
  34006. /**
  34007. * @hidden Internal method to initiate `update`.
  34008. */
  34009. _rebuild(): void;
  34010. /**
  34011. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34012. */
  34013. update(): void;
  34014. /**
  34015. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34016. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34017. */
  34018. updateTexture(isVisible: boolean): void;
  34019. protected _updateInternalTexture: () => void;
  34020. /**
  34021. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34022. * @param url New url.
  34023. */
  34024. updateURL(url: string): void;
  34025. /**
  34026. * Clones the texture.
  34027. * @returns the cloned texture
  34028. */
  34029. clone(): VideoTexture;
  34030. /**
  34031. * Dispose the texture and release its associated resources.
  34032. */
  34033. dispose(): void;
  34034. /**
  34035. * Creates a video texture straight from a stream.
  34036. * @param scene Define the scene the texture should be created in
  34037. * @param stream Define the stream the texture should be created from
  34038. * @returns The created video texture as a promise
  34039. */
  34040. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34041. /**
  34042. * Creates a video texture straight from your WebCam video feed.
  34043. * @param scene Define the scene the texture should be created in
  34044. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34045. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34046. * @returns The created video texture as a promise
  34047. */
  34048. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34049. minWidth: number;
  34050. maxWidth: number;
  34051. minHeight: number;
  34052. maxHeight: number;
  34053. deviceId: string;
  34054. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34055. /**
  34056. * Creates a video texture straight from your WebCam video feed.
  34057. * @param scene Define the scene the texture should be created in
  34058. * @param onReady Define a callback to triggered once the texture will be ready
  34059. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34060. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34061. */
  34062. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34063. minWidth: number;
  34064. maxWidth: number;
  34065. minHeight: number;
  34066. maxHeight: number;
  34067. deviceId: string;
  34068. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34069. }
  34070. }
  34071. declare module BABYLON {
  34072. /**
  34073. * Defines the interface used by objects working like Scene
  34074. * @hidden
  34075. */
  34076. export interface ISceneLike {
  34077. _addPendingData(data: any): void;
  34078. _removePendingData(data: any): void;
  34079. offlineProvider: IOfflineProvider;
  34080. }
  34081. /** Interface defining initialization parameters for Engine class */
  34082. export interface EngineOptions extends WebGLContextAttributes {
  34083. /**
  34084. * Defines if the engine should no exceed a specified device ratio
  34085. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34086. */
  34087. limitDeviceRatio?: number;
  34088. /**
  34089. * Defines if webvr should be enabled automatically
  34090. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34091. */
  34092. autoEnableWebVR?: boolean;
  34093. /**
  34094. * Defines if webgl2 should be turned off even if supported
  34095. * @see http://doc.babylonjs.com/features/webgl2
  34096. */
  34097. disableWebGL2Support?: boolean;
  34098. /**
  34099. * Defines if webaudio should be initialized as well
  34100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34101. */
  34102. audioEngine?: boolean;
  34103. /**
  34104. * Defines if animations should run using a deterministic lock step
  34105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34106. */
  34107. deterministicLockstep?: boolean;
  34108. /** Defines the maximum steps to use with deterministic lock step mode */
  34109. lockstepMaxSteps?: number;
  34110. /** Defines the seconds between each deterministic lock step */
  34111. timeStep?: number;
  34112. /**
  34113. * Defines that engine should ignore context lost events
  34114. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34115. */
  34116. doNotHandleContextLost?: boolean;
  34117. /**
  34118. * Defines that engine should ignore modifying touch action attribute and style
  34119. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34120. */
  34121. doNotHandleTouchAction?: boolean;
  34122. /**
  34123. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34124. */
  34125. useHighPrecisionFloats?: boolean;
  34126. /**
  34127. * Make the canvas XR Compatible for XR sessions
  34128. */
  34129. xrCompatible?: boolean;
  34130. }
  34131. /**
  34132. * The base engine class (root of all engines)
  34133. */
  34134. export class ThinEngine {
  34135. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34136. static ExceptionList: ({
  34137. key: string;
  34138. capture: string;
  34139. captureConstraint: number;
  34140. targets: string[];
  34141. } | {
  34142. key: string;
  34143. capture: null;
  34144. captureConstraint: null;
  34145. targets: string[];
  34146. })[];
  34147. /** @hidden */
  34148. static _TextureLoaders: IInternalTextureLoader[];
  34149. /**
  34150. * Returns the current npm package of the sdk
  34151. */
  34152. static get NpmPackage(): string;
  34153. /**
  34154. * Returns the current version of the framework
  34155. */
  34156. static get Version(): string;
  34157. /**
  34158. * Returns a string describing the current engine
  34159. */
  34160. get description(): string;
  34161. /**
  34162. * Gets or sets the epsilon value used by collision engine
  34163. */
  34164. static CollisionsEpsilon: number;
  34165. /**
  34166. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34167. */
  34168. static get ShadersRepository(): string;
  34169. static set ShadersRepository(value: string);
  34170. /** @hidden */
  34171. _shaderProcessor: IShaderProcessor;
  34172. /**
  34173. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34174. */
  34175. forcePOTTextures: boolean;
  34176. /**
  34177. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34178. */
  34179. isFullscreen: boolean;
  34180. /**
  34181. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34182. */
  34183. cullBackFaces: boolean;
  34184. /**
  34185. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34186. */
  34187. renderEvenInBackground: boolean;
  34188. /**
  34189. * Gets or sets a boolean indicating that cache can be kept between frames
  34190. */
  34191. preventCacheWipeBetweenFrames: boolean;
  34192. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34193. validateShaderPrograms: boolean;
  34194. /**
  34195. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34196. * This can provide greater z depth for distant objects.
  34197. */
  34198. useReverseDepthBuffer: boolean;
  34199. /**
  34200. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34201. */
  34202. disableUniformBuffers: boolean;
  34203. /** @hidden */
  34204. _uniformBuffers: UniformBuffer[];
  34205. /**
  34206. * Gets a boolean indicating that the engine supports uniform buffers
  34207. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34208. */
  34209. get supportsUniformBuffers(): boolean;
  34210. /** @hidden */
  34211. _gl: WebGLRenderingContext;
  34212. /** @hidden */
  34213. _webGLVersion: number;
  34214. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34215. protected _windowIsBackground: boolean;
  34216. protected _creationOptions: EngineOptions;
  34217. protected _highPrecisionShadersAllowed: boolean;
  34218. /** @hidden */
  34219. get _shouldUseHighPrecisionShader(): boolean;
  34220. /**
  34221. * Gets a boolean indicating that only power of 2 textures are supported
  34222. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34223. */
  34224. get needPOTTextures(): boolean;
  34225. /** @hidden */
  34226. _badOS: boolean;
  34227. /** @hidden */
  34228. _badDesktopOS: boolean;
  34229. private _hardwareScalingLevel;
  34230. /** @hidden */
  34231. _caps: EngineCapabilities;
  34232. private _isStencilEnable;
  34233. private _glVersion;
  34234. private _glRenderer;
  34235. private _glVendor;
  34236. /** @hidden */
  34237. _videoTextureSupported: boolean;
  34238. protected _renderingQueueLaunched: boolean;
  34239. protected _activeRenderLoops: (() => void)[];
  34240. /**
  34241. * Observable signaled when a context lost event is raised
  34242. */
  34243. onContextLostObservable: Observable<ThinEngine>;
  34244. /**
  34245. * Observable signaled when a context restored event is raised
  34246. */
  34247. onContextRestoredObservable: Observable<ThinEngine>;
  34248. private _onContextLost;
  34249. private _onContextRestored;
  34250. protected _contextWasLost: boolean;
  34251. /** @hidden */
  34252. _doNotHandleContextLost: boolean;
  34253. /**
  34254. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34256. */
  34257. get doNotHandleContextLost(): boolean;
  34258. set doNotHandleContextLost(value: boolean);
  34259. /**
  34260. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34261. */
  34262. disableVertexArrayObjects: boolean;
  34263. /** @hidden */
  34264. protected _colorWrite: boolean;
  34265. /** @hidden */
  34266. protected _colorWriteChanged: boolean;
  34267. /** @hidden */
  34268. protected _depthCullingState: DepthCullingState;
  34269. /** @hidden */
  34270. protected _stencilState: StencilState;
  34271. /** @hidden */
  34272. _alphaState: AlphaState;
  34273. /** @hidden */
  34274. _alphaMode: number;
  34275. /** @hidden */
  34276. _alphaEquation: number;
  34277. /** @hidden */
  34278. _internalTexturesCache: InternalTexture[];
  34279. /** @hidden */
  34280. protected _activeChannel: number;
  34281. private _currentTextureChannel;
  34282. /** @hidden */
  34283. protected _boundTexturesCache: {
  34284. [key: string]: Nullable<InternalTexture>;
  34285. };
  34286. /** @hidden */
  34287. protected _currentEffect: Nullable<Effect>;
  34288. /** @hidden */
  34289. protected _currentProgram: Nullable<WebGLProgram>;
  34290. private _compiledEffects;
  34291. private _vertexAttribArraysEnabled;
  34292. /** @hidden */
  34293. protected _cachedViewport: Nullable<IViewportLike>;
  34294. private _cachedVertexArrayObject;
  34295. /** @hidden */
  34296. protected _cachedVertexBuffers: any;
  34297. /** @hidden */
  34298. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34299. /** @hidden */
  34300. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34301. /** @hidden */
  34302. _currentRenderTarget: Nullable<InternalTexture>;
  34303. private _uintIndicesCurrentlySet;
  34304. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34305. /** @hidden */
  34306. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34307. /** @hidden */
  34308. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34309. private _currentBufferPointers;
  34310. private _currentInstanceLocations;
  34311. private _currentInstanceBuffers;
  34312. private _textureUnits;
  34313. /** @hidden */
  34314. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34315. /** @hidden */
  34316. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34317. /** @hidden */
  34318. _boundRenderFunction: any;
  34319. private _vaoRecordInProgress;
  34320. private _mustWipeVertexAttributes;
  34321. private _emptyTexture;
  34322. private _emptyCubeTexture;
  34323. private _emptyTexture3D;
  34324. private _emptyTexture2DArray;
  34325. /** @hidden */
  34326. _frameHandler: number;
  34327. private _nextFreeTextureSlots;
  34328. private _maxSimultaneousTextures;
  34329. private _activeRequests;
  34330. /** @hidden */
  34331. _transformTextureUrl: Nullable<(url: string) => string>;
  34332. protected get _supportsHardwareTextureRescaling(): boolean;
  34333. private _framebufferDimensionsObject;
  34334. /**
  34335. * sets the object from which width and height will be taken from when getting render width and height
  34336. * Will fallback to the gl object
  34337. * @param dimensions the framebuffer width and height that will be used.
  34338. */
  34339. set framebufferDimensionsObject(dimensions: Nullable<{
  34340. framebufferWidth: number;
  34341. framebufferHeight: number;
  34342. }>);
  34343. /**
  34344. * Gets the current viewport
  34345. */
  34346. get currentViewport(): Nullable<IViewportLike>;
  34347. /**
  34348. * Gets the default empty texture
  34349. */
  34350. get emptyTexture(): InternalTexture;
  34351. /**
  34352. * Gets the default empty 3D texture
  34353. */
  34354. get emptyTexture3D(): InternalTexture;
  34355. /**
  34356. * Gets the default empty 2D array texture
  34357. */
  34358. get emptyTexture2DArray(): InternalTexture;
  34359. /**
  34360. * Gets the default empty cube texture
  34361. */
  34362. get emptyCubeTexture(): InternalTexture;
  34363. /**
  34364. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34365. */
  34366. readonly premultipliedAlpha: boolean;
  34367. /**
  34368. * Observable event triggered before each texture is initialized
  34369. */
  34370. onBeforeTextureInitObservable: Observable<Texture>;
  34371. /**
  34372. * Creates a new engine
  34373. * @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
  34374. * @param antialias defines enable antialiasing (default: false)
  34375. * @param options defines further options to be sent to the getContext() function
  34376. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34377. */
  34378. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34379. private _rebuildInternalTextures;
  34380. private _rebuildEffects;
  34381. /**
  34382. * Gets a boolean indicating if all created effects are ready
  34383. * @returns true if all effects are ready
  34384. */
  34385. areAllEffectsReady(): boolean;
  34386. protected _rebuildBuffers(): void;
  34387. protected _initGLContext(): void;
  34388. /**
  34389. * Gets version of the current webGL context
  34390. */
  34391. get webGLVersion(): number;
  34392. /**
  34393. * Gets a string idenfifying the name of the class
  34394. * @returns "Engine" string
  34395. */
  34396. getClassName(): string;
  34397. /**
  34398. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34399. */
  34400. get isStencilEnable(): boolean;
  34401. /** @hidden */
  34402. _prepareWorkingCanvas(): void;
  34403. /**
  34404. * Reset the texture cache to empty state
  34405. */
  34406. resetTextureCache(): void;
  34407. /**
  34408. * Gets an object containing information about the current webGL context
  34409. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34410. */
  34411. getGlInfo(): {
  34412. vendor: string;
  34413. renderer: string;
  34414. version: string;
  34415. };
  34416. /**
  34417. * Defines the hardware scaling level.
  34418. * By default the hardware scaling level is computed from the window device ratio.
  34419. * 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.
  34420. * @param level defines the level to use
  34421. */
  34422. setHardwareScalingLevel(level: number): void;
  34423. /**
  34424. * Gets the current hardware scaling level.
  34425. * By default the hardware scaling level is computed from the window device ratio.
  34426. * 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.
  34427. * @returns a number indicating the current hardware scaling level
  34428. */
  34429. getHardwareScalingLevel(): number;
  34430. /**
  34431. * Gets the list of loaded textures
  34432. * @returns an array containing all loaded textures
  34433. */
  34434. getLoadedTexturesCache(): InternalTexture[];
  34435. /**
  34436. * Gets the object containing all engine capabilities
  34437. * @returns the EngineCapabilities object
  34438. */
  34439. getCaps(): EngineCapabilities;
  34440. /**
  34441. * stop executing a render loop function and remove it from the execution array
  34442. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34443. */
  34444. stopRenderLoop(renderFunction?: () => void): void;
  34445. /** @hidden */
  34446. _renderLoop(): void;
  34447. /**
  34448. * Gets the HTML canvas attached with the current webGL context
  34449. * @returns a HTML canvas
  34450. */
  34451. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34452. /**
  34453. * Gets host window
  34454. * @returns the host window object
  34455. */
  34456. getHostWindow(): Nullable<Window>;
  34457. /**
  34458. * Gets the current render width
  34459. * @param useScreen defines if screen size must be used (or the current render target if any)
  34460. * @returns a number defining the current render width
  34461. */
  34462. getRenderWidth(useScreen?: boolean): number;
  34463. /**
  34464. * Gets the current render height
  34465. * @param useScreen defines if screen size must be used (or the current render target if any)
  34466. * @returns a number defining the current render height
  34467. */
  34468. getRenderHeight(useScreen?: boolean): number;
  34469. /**
  34470. * Can be used to override the current requestAnimationFrame requester.
  34471. * @hidden
  34472. */
  34473. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34474. /**
  34475. * Register and execute a render loop. The engine can have more than one render function
  34476. * @param renderFunction defines the function to continuously execute
  34477. */
  34478. runRenderLoop(renderFunction: () => void): void;
  34479. /**
  34480. * Clear the current render buffer or the current render target (if any is set up)
  34481. * @param color defines the color to use
  34482. * @param backBuffer defines if the back buffer must be cleared
  34483. * @param depth defines if the depth buffer must be cleared
  34484. * @param stencil defines if the stencil buffer must be cleared
  34485. */
  34486. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34487. private _viewportCached;
  34488. /** @hidden */
  34489. _viewport(x: number, y: number, width: number, height: number): void;
  34490. /**
  34491. * Set the WebGL's viewport
  34492. * @param viewport defines the viewport element to be used
  34493. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34494. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34495. */
  34496. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34497. /**
  34498. * Begin a new frame
  34499. */
  34500. beginFrame(): void;
  34501. /**
  34502. * Enf the current frame
  34503. */
  34504. endFrame(): void;
  34505. /**
  34506. * Resize the view according to the canvas' size
  34507. */
  34508. resize(): void;
  34509. /**
  34510. * Force a specific size of the canvas
  34511. * @param width defines the new canvas' width
  34512. * @param height defines the new canvas' height
  34513. */
  34514. setSize(width: number, height: number): void;
  34515. /**
  34516. * Binds the frame buffer to the specified texture.
  34517. * @param texture The texture to render to or null for the default canvas
  34518. * @param faceIndex The face of the texture to render to in case of cube texture
  34519. * @param requiredWidth The width of the target to render to
  34520. * @param requiredHeight The height of the target to render to
  34521. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34522. * @param lodLevel defines the lod level to bind to the frame buffer
  34523. * @param layer defines the 2d array index to bind to frame buffer to
  34524. */
  34525. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34526. /** @hidden */
  34527. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34528. /**
  34529. * Unbind the current render target texture from the webGL context
  34530. * @param texture defines the render target texture to unbind
  34531. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34532. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34533. */
  34534. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34535. /**
  34536. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34537. */
  34538. flushFramebuffer(): void;
  34539. /**
  34540. * Unbind the current render target and bind the default framebuffer
  34541. */
  34542. restoreDefaultFramebuffer(): void;
  34543. /** @hidden */
  34544. protected _resetVertexBufferBinding(): void;
  34545. /**
  34546. * Creates a vertex buffer
  34547. * @param data the data for the vertex buffer
  34548. * @returns the new WebGL static buffer
  34549. */
  34550. createVertexBuffer(data: DataArray): DataBuffer;
  34551. private _createVertexBuffer;
  34552. /**
  34553. * Creates a dynamic vertex buffer
  34554. * @param data the data for the dynamic vertex buffer
  34555. * @returns the new WebGL dynamic buffer
  34556. */
  34557. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34558. protected _resetIndexBufferBinding(): void;
  34559. /**
  34560. * Creates a new index buffer
  34561. * @param indices defines the content of the index buffer
  34562. * @param updatable defines if the index buffer must be updatable
  34563. * @returns a new webGL buffer
  34564. */
  34565. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34566. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34567. /**
  34568. * Bind a webGL buffer to the webGL context
  34569. * @param buffer defines the buffer to bind
  34570. */
  34571. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34572. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34573. private bindBuffer;
  34574. /**
  34575. * update the bound buffer with the given data
  34576. * @param data defines the data to update
  34577. */
  34578. updateArrayBuffer(data: Float32Array): void;
  34579. private _vertexAttribPointer;
  34580. /** @hidden */
  34581. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34582. private _bindVertexBuffersAttributes;
  34583. /**
  34584. * Records a vertex array object
  34585. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34586. * @param vertexBuffers defines the list of vertex buffers to store
  34587. * @param indexBuffer defines the index buffer to store
  34588. * @param effect defines the effect to store
  34589. * @returns the new vertex array object
  34590. */
  34591. recordVertexArrayObject(vertexBuffers: {
  34592. [key: string]: VertexBuffer;
  34593. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34594. /**
  34595. * Bind a specific vertex array object
  34596. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34597. * @param vertexArrayObject defines the vertex array object to bind
  34598. * @param indexBuffer defines the index buffer to bind
  34599. */
  34600. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34601. /**
  34602. * Bind webGl buffers directly to the webGL context
  34603. * @param vertexBuffer defines the vertex buffer to bind
  34604. * @param indexBuffer defines the index buffer to bind
  34605. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34606. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34607. * @param effect defines the effect associated with the vertex buffer
  34608. */
  34609. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34610. private _unbindVertexArrayObject;
  34611. /**
  34612. * Bind a list of vertex buffers to the webGL context
  34613. * @param vertexBuffers defines the list of vertex buffers to bind
  34614. * @param indexBuffer defines the index buffer to bind
  34615. * @param effect defines the effect associated with the vertex buffers
  34616. */
  34617. bindBuffers(vertexBuffers: {
  34618. [key: string]: Nullable<VertexBuffer>;
  34619. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34620. /**
  34621. * Unbind all instance attributes
  34622. */
  34623. unbindInstanceAttributes(): void;
  34624. /**
  34625. * Release and free the memory of a vertex array object
  34626. * @param vao defines the vertex array object to delete
  34627. */
  34628. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34629. /** @hidden */
  34630. _releaseBuffer(buffer: DataBuffer): boolean;
  34631. protected _deleteBuffer(buffer: DataBuffer): void;
  34632. /**
  34633. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34634. * @param instancesBuffer defines the webGL buffer to update and bind
  34635. * @param data defines the data to store in the buffer
  34636. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34637. */
  34638. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34639. /**
  34640. * Bind the content of a webGL buffer used with instantiation
  34641. * @param instancesBuffer defines the webGL buffer to bind
  34642. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34643. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34644. */
  34645. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34646. /**
  34647. * Disable the instance attribute corresponding to the name in parameter
  34648. * @param name defines the name of the attribute to disable
  34649. */
  34650. disableInstanceAttributeByName(name: string): void;
  34651. /**
  34652. * Disable the instance attribute corresponding to the location in parameter
  34653. * @param attributeLocation defines the attribute location of the attribute to disable
  34654. */
  34655. disableInstanceAttribute(attributeLocation: number): void;
  34656. /**
  34657. * Disable the attribute corresponding to the location in parameter
  34658. * @param attributeLocation defines the attribute location of the attribute to disable
  34659. */
  34660. disableAttributeByIndex(attributeLocation: number): void;
  34661. /**
  34662. * Send a draw order
  34663. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34664. * @param indexStart defines the starting index
  34665. * @param indexCount defines the number of index to draw
  34666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34667. */
  34668. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34669. /**
  34670. * Draw a list of points
  34671. * @param verticesStart defines the index of first vertex to draw
  34672. * @param verticesCount defines the count of vertices to draw
  34673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34674. */
  34675. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34676. /**
  34677. * Draw a list of unindexed primitives
  34678. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34679. * @param verticesStart defines the index of first vertex to draw
  34680. * @param verticesCount defines the count of vertices to draw
  34681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34682. */
  34683. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34684. /**
  34685. * Draw a list of indexed primitives
  34686. * @param fillMode defines the primitive to use
  34687. * @param indexStart defines the starting index
  34688. * @param indexCount defines the number of index to draw
  34689. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34690. */
  34691. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34692. /**
  34693. * Draw a list of unindexed primitives
  34694. * @param fillMode defines the primitive to use
  34695. * @param verticesStart defines the index of first vertex to draw
  34696. * @param verticesCount defines the count of vertices to draw
  34697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34698. */
  34699. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34700. private _drawMode;
  34701. /** @hidden */
  34702. protected _reportDrawCall(): void;
  34703. /** @hidden */
  34704. _releaseEffect(effect: Effect): void;
  34705. /** @hidden */
  34706. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34707. /**
  34708. * Create a new effect (used to store vertex/fragment shaders)
  34709. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34710. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34711. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34712. * @param samplers defines an array of string used to represent textures
  34713. * @param defines defines the string containing the defines to use to compile the shaders
  34714. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34715. * @param onCompiled defines a function to call when the effect creation is successful
  34716. * @param onError defines a function to call when the effect creation has failed
  34717. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34718. * @returns the new Effect
  34719. */
  34720. 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;
  34721. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34722. private _compileShader;
  34723. private _compileRawShader;
  34724. /** @hidden */
  34725. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34726. /**
  34727. * Directly creates a webGL program
  34728. * @param pipelineContext defines the pipeline context to attach to
  34729. * @param vertexCode defines the vertex shader code to use
  34730. * @param fragmentCode defines the fragment shader code to use
  34731. * @param context defines the webGL context to use (if not set, the current one will be used)
  34732. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34733. * @returns the new webGL program
  34734. */
  34735. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34736. /**
  34737. * Creates a webGL program
  34738. * @param pipelineContext defines the pipeline context to attach to
  34739. * @param vertexCode defines the vertex shader code to use
  34740. * @param fragmentCode defines the fragment shader code to use
  34741. * @param defines defines the string containing the defines to use to compile the shaders
  34742. * @param context defines the webGL context to use (if not set, the current one will be used)
  34743. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34744. * @returns the new webGL program
  34745. */
  34746. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34747. /**
  34748. * Creates a new pipeline context
  34749. * @returns the new pipeline
  34750. */
  34751. createPipelineContext(): IPipelineContext;
  34752. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34753. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34754. /** @hidden */
  34755. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34756. /** @hidden */
  34757. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34758. /** @hidden */
  34759. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34760. /**
  34761. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34762. * @param pipelineContext defines the pipeline context to use
  34763. * @param uniformsNames defines the list of uniform names
  34764. * @returns an array of webGL uniform locations
  34765. */
  34766. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34767. /**
  34768. * Gets the lsit of active attributes for a given webGL program
  34769. * @param pipelineContext defines the pipeline context to use
  34770. * @param attributesNames defines the list of attribute names to get
  34771. * @returns an array of indices indicating the offset of each attribute
  34772. */
  34773. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34774. /**
  34775. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34776. * @param effect defines the effect to activate
  34777. */
  34778. enableEffect(effect: Nullable<Effect>): void;
  34779. /**
  34780. * Set the value of an uniform to a number (int)
  34781. * @param uniform defines the webGL uniform location where to store the value
  34782. * @param value defines the int number to store
  34783. */
  34784. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34785. /**
  34786. * Set the value of an uniform to an array of int32
  34787. * @param uniform defines the webGL uniform location where to store the value
  34788. * @param array defines the array of int32 to store
  34789. */
  34790. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34791. /**
  34792. * Set the value of an uniform to an array of int32 (stored as vec2)
  34793. * @param uniform defines the webGL uniform location where to store the value
  34794. * @param array defines the array of int32 to store
  34795. */
  34796. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34797. /**
  34798. * Set the value of an uniform to an array of int32 (stored as vec3)
  34799. * @param uniform defines the webGL uniform location where to store the value
  34800. * @param array defines the array of int32 to store
  34801. */
  34802. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34803. /**
  34804. * Set the value of an uniform to an array of int32 (stored as vec4)
  34805. * @param uniform defines the webGL uniform location where to store the value
  34806. * @param array defines the array of int32 to store
  34807. */
  34808. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34809. /**
  34810. * Set the value of an uniform to an array of number
  34811. * @param uniform defines the webGL uniform location where to store the value
  34812. * @param array defines the array of number to store
  34813. */
  34814. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34815. /**
  34816. * Set the value of an uniform to an array of number (stored as vec2)
  34817. * @param uniform defines the webGL uniform location where to store the value
  34818. * @param array defines the array of number to store
  34819. */
  34820. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34821. /**
  34822. * Set the value of an uniform to an array of number (stored as vec3)
  34823. * @param uniform defines the webGL uniform location where to store the value
  34824. * @param array defines the array of number to store
  34825. */
  34826. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34827. /**
  34828. * Set the value of an uniform to an array of number (stored as vec4)
  34829. * @param uniform defines the webGL uniform location where to store the value
  34830. * @param array defines the array of number to store
  34831. */
  34832. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34833. /**
  34834. * Set the value of an uniform to an array of float32 (stored as matrices)
  34835. * @param uniform defines the webGL uniform location where to store the value
  34836. * @param matrices defines the array of float32 to store
  34837. */
  34838. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34839. /**
  34840. * Set the value of an uniform to a matrix (3x3)
  34841. * @param uniform defines the webGL uniform location where to store the value
  34842. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34843. */
  34844. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34845. /**
  34846. * Set the value of an uniform to a matrix (2x2)
  34847. * @param uniform defines the webGL uniform location where to store the value
  34848. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34849. */
  34850. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34851. /**
  34852. * Set the value of an uniform to a number (float)
  34853. * @param uniform defines the webGL uniform location where to store the value
  34854. * @param value defines the float number to store
  34855. */
  34856. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34857. /**
  34858. * Set the value of an uniform to a vec2
  34859. * @param uniform defines the webGL uniform location where to store the value
  34860. * @param x defines the 1st component of the value
  34861. * @param y defines the 2nd component of the value
  34862. */
  34863. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34864. /**
  34865. * Set the value of an uniform to a vec3
  34866. * @param uniform defines the webGL uniform location where to store the value
  34867. * @param x defines the 1st component of the value
  34868. * @param y defines the 2nd component of the value
  34869. * @param z defines the 3rd component of the value
  34870. */
  34871. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34872. /**
  34873. * Set the value of an uniform to a vec4
  34874. * @param uniform defines the webGL uniform location where to store the value
  34875. * @param x defines the 1st component of the value
  34876. * @param y defines the 2nd component of the value
  34877. * @param z defines the 3rd component of the value
  34878. * @param w defines the 4th component of the value
  34879. */
  34880. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34881. /**
  34882. * Apply all cached states (depth, culling, stencil and alpha)
  34883. */
  34884. applyStates(): void;
  34885. /**
  34886. * Enable or disable color writing
  34887. * @param enable defines the state to set
  34888. */
  34889. setColorWrite(enable: boolean): void;
  34890. /**
  34891. * Gets a boolean indicating if color writing is enabled
  34892. * @returns the current color writing state
  34893. */
  34894. getColorWrite(): boolean;
  34895. /**
  34896. * Gets the depth culling state manager
  34897. */
  34898. get depthCullingState(): DepthCullingState;
  34899. /**
  34900. * Gets the alpha state manager
  34901. */
  34902. get alphaState(): AlphaState;
  34903. /**
  34904. * Gets the stencil state manager
  34905. */
  34906. get stencilState(): StencilState;
  34907. /**
  34908. * Clears the list of texture accessible through engine.
  34909. * This can help preventing texture load conflict due to name collision.
  34910. */
  34911. clearInternalTexturesCache(): void;
  34912. /**
  34913. * Force the entire cache to be cleared
  34914. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34915. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34916. */
  34917. wipeCaches(bruteForce?: boolean): void;
  34918. /** @hidden */
  34919. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34920. min: number;
  34921. mag: number;
  34922. };
  34923. /** @hidden */
  34924. _createTexture(): WebGLTexture;
  34925. /**
  34926. * Usually called from Texture.ts.
  34927. * Passed information to create a WebGLTexture
  34928. * @param url defines a value which contains one of the following:
  34929. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34930. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34931. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34933. * @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)
  34934. * @param scene needed for loading to the correct scene
  34935. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34936. * @param onLoad optional callback to be called upon successful completion
  34937. * @param onError optional callback to be called upon failure
  34938. * @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
  34939. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34940. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34941. * @param forcedExtension defines the extension to use to pick the right loader
  34942. * @param mimeType defines an optional mime type
  34943. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34944. */
  34945. 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;
  34946. /**
  34947. * Loads an image as an HTMLImageElement.
  34948. * @param input url string, ArrayBuffer, or Blob to load
  34949. * @param onLoad callback called when the image successfully loads
  34950. * @param onError callback called when the image fails to load
  34951. * @param offlineProvider offline provider for caching
  34952. * @param mimeType optional mime type
  34953. * @returns the HTMLImageElement of the loaded image
  34954. * @hidden
  34955. */
  34956. 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>;
  34957. /**
  34958. * @hidden
  34959. */
  34960. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34961. private _unpackFlipYCached;
  34962. /**
  34963. * In case you are sharing the context with other applications, it might
  34964. * be interested to not cache the unpack flip y state to ensure a consistent
  34965. * value would be set.
  34966. */
  34967. enableUnpackFlipYCached: boolean;
  34968. /** @hidden */
  34969. _unpackFlipY(value: boolean): void;
  34970. /** @hidden */
  34971. _getUnpackAlignement(): number;
  34972. private _getTextureTarget;
  34973. /**
  34974. * Update the sampling mode of a given texture
  34975. * @param samplingMode defines the required sampling mode
  34976. * @param texture defines the texture to update
  34977. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34978. */
  34979. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34980. /**
  34981. * Update the sampling mode of a given texture
  34982. * @param texture defines the texture to update
  34983. * @param wrapU defines the texture wrap mode of the u coordinates
  34984. * @param wrapV defines the texture wrap mode of the v coordinates
  34985. * @param wrapR defines the texture wrap mode of the r coordinates
  34986. */
  34987. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34988. /** @hidden */
  34989. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34990. width: number;
  34991. height: number;
  34992. layers?: number;
  34993. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34994. /** @hidden */
  34995. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34996. /** @hidden */
  34997. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34998. /**
  34999. * Update a portion of an internal texture
  35000. * @param texture defines the texture to update
  35001. * @param imageData defines the data to store into the texture
  35002. * @param xOffset defines the x coordinates of the update rectangle
  35003. * @param yOffset defines the y coordinates of the update rectangle
  35004. * @param width defines the width of the update rectangle
  35005. * @param height defines the height of the update rectangle
  35006. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35007. * @param lod defines the lod level to update (0 by default)
  35008. */
  35009. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35010. /** @hidden */
  35011. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35012. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35013. private _prepareWebGLTexture;
  35014. /** @hidden */
  35015. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35016. private _getDepthStencilBuffer;
  35017. /** @hidden */
  35018. _releaseFramebufferObjects(texture: InternalTexture): void;
  35019. /** @hidden */
  35020. _releaseTexture(texture: InternalTexture): void;
  35021. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35022. protected _setProgram(program: WebGLProgram): void;
  35023. protected _boundUniforms: {
  35024. [key: number]: WebGLUniformLocation;
  35025. };
  35026. /**
  35027. * Binds an effect to the webGL context
  35028. * @param effect defines the effect to bind
  35029. */
  35030. bindSamplers(effect: Effect): void;
  35031. private _activateCurrentTexture;
  35032. /** @hidden */
  35033. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35034. /** @hidden */
  35035. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35036. /**
  35037. * Unbind all textures from the webGL context
  35038. */
  35039. unbindAllTextures(): void;
  35040. /**
  35041. * Sets a texture to the according uniform.
  35042. * @param channel The texture channel
  35043. * @param uniform The uniform to set
  35044. * @param texture The texture to apply
  35045. */
  35046. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35047. private _bindSamplerUniformToChannel;
  35048. private _getTextureWrapMode;
  35049. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35050. /**
  35051. * Sets an array of texture to the webGL context
  35052. * @param channel defines the channel where the texture array must be set
  35053. * @param uniform defines the associated uniform location
  35054. * @param textures defines the array of textures to bind
  35055. */
  35056. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35057. /** @hidden */
  35058. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35059. private _setTextureParameterFloat;
  35060. private _setTextureParameterInteger;
  35061. /**
  35062. * Unbind all vertex attributes from the webGL context
  35063. */
  35064. unbindAllAttributes(): void;
  35065. /**
  35066. * 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
  35067. */
  35068. releaseEffects(): void;
  35069. /**
  35070. * Dispose and release all associated resources
  35071. */
  35072. dispose(): void;
  35073. /**
  35074. * Attach a new callback raised when context lost event is fired
  35075. * @param callback defines the callback to call
  35076. */
  35077. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35078. /**
  35079. * Attach a new callback raised when context restored event is fired
  35080. * @param callback defines the callback to call
  35081. */
  35082. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35083. /**
  35084. * Get the current error code of the webGL context
  35085. * @returns the error code
  35086. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35087. */
  35088. getError(): number;
  35089. private _canRenderToFloatFramebuffer;
  35090. private _canRenderToHalfFloatFramebuffer;
  35091. private _canRenderToFramebuffer;
  35092. /** @hidden */
  35093. _getWebGLTextureType(type: number): number;
  35094. /** @hidden */
  35095. _getInternalFormat(format: number): number;
  35096. /** @hidden */
  35097. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35098. /** @hidden */
  35099. _getRGBAMultiSampleBufferFormat(type: number): number;
  35100. /** @hidden */
  35101. _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;
  35102. /**
  35103. * Loads a file from a url
  35104. * @param url url to load
  35105. * @param onSuccess callback called when the file successfully loads
  35106. * @param onProgress callback called while file is loading (if the server supports this mode)
  35107. * @param offlineProvider defines the offline provider for caching
  35108. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35109. * @param onError callback called when the file fails to load
  35110. * @returns a file request object
  35111. * @hidden
  35112. */
  35113. 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;
  35114. /**
  35115. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35116. * @param x defines the x coordinate of the rectangle where pixels must be read
  35117. * @param y defines the y coordinate of the rectangle where pixels must be read
  35118. * @param width defines the width of the rectangle where pixels must be read
  35119. * @param height defines the height of the rectangle where pixels must be read
  35120. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35121. * @returns a Uint8Array containing RGBA colors
  35122. */
  35123. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35124. private static _isSupported;
  35125. /**
  35126. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35127. * @returns true if the engine can be created
  35128. * @ignorenaming
  35129. */
  35130. static isSupported(): boolean;
  35131. /**
  35132. * Find the next highest power of two.
  35133. * @param x Number to start search from.
  35134. * @return Next highest power of two.
  35135. */
  35136. static CeilingPOT(x: number): number;
  35137. /**
  35138. * Find the next lowest power of two.
  35139. * @param x Number to start search from.
  35140. * @return Next lowest power of two.
  35141. */
  35142. static FloorPOT(x: number): number;
  35143. /**
  35144. * Find the nearest power of two.
  35145. * @param x Number to start search from.
  35146. * @return Next nearest power of two.
  35147. */
  35148. static NearestPOT(x: number): number;
  35149. /**
  35150. * Get the closest exponent of two
  35151. * @param value defines the value to approximate
  35152. * @param max defines the maximum value to return
  35153. * @param mode defines how to define the closest value
  35154. * @returns closest exponent of two of the given value
  35155. */
  35156. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35157. /**
  35158. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35159. * @param func - the function to be called
  35160. * @param requester - the object that will request the next frame. Falls back to window.
  35161. * @returns frame number
  35162. */
  35163. static QueueNewFrame(func: () => void, requester?: any): number;
  35164. /**
  35165. * Gets host document
  35166. * @returns the host document object
  35167. */
  35168. getHostDocument(): Nullable<Document>;
  35169. }
  35170. }
  35171. declare module BABYLON {
  35172. /**
  35173. * Class representing spherical harmonics coefficients to the 3rd degree
  35174. */
  35175. export class SphericalHarmonics {
  35176. /**
  35177. * Defines whether or not the harmonics have been prescaled for rendering.
  35178. */
  35179. preScaled: boolean;
  35180. /**
  35181. * The l0,0 coefficients of the spherical harmonics
  35182. */
  35183. l00: Vector3;
  35184. /**
  35185. * The l1,-1 coefficients of the spherical harmonics
  35186. */
  35187. l1_1: Vector3;
  35188. /**
  35189. * The l1,0 coefficients of the spherical harmonics
  35190. */
  35191. l10: Vector3;
  35192. /**
  35193. * The l1,1 coefficients of the spherical harmonics
  35194. */
  35195. l11: Vector3;
  35196. /**
  35197. * The l2,-2 coefficients of the spherical harmonics
  35198. */
  35199. l2_2: Vector3;
  35200. /**
  35201. * The l2,-1 coefficients of the spherical harmonics
  35202. */
  35203. l2_1: Vector3;
  35204. /**
  35205. * The l2,0 coefficients of the spherical harmonics
  35206. */
  35207. l20: Vector3;
  35208. /**
  35209. * The l2,1 coefficients of the spherical harmonics
  35210. */
  35211. l21: Vector3;
  35212. /**
  35213. * The l2,2 coefficients of the spherical harmonics
  35214. */
  35215. l22: Vector3;
  35216. /**
  35217. * Adds a light to the spherical harmonics
  35218. * @param direction the direction of the light
  35219. * @param color the color of the light
  35220. * @param deltaSolidAngle the delta solid angle of the light
  35221. */
  35222. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35223. /**
  35224. * Scales the spherical harmonics by the given amount
  35225. * @param scale the amount to scale
  35226. */
  35227. scaleInPlace(scale: number): void;
  35228. /**
  35229. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35230. *
  35231. * ```
  35232. * E_lm = A_l * L_lm
  35233. * ```
  35234. *
  35235. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35236. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35237. * the scaling factors are given in equation 9.
  35238. */
  35239. convertIncidentRadianceToIrradiance(): void;
  35240. /**
  35241. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35242. *
  35243. * ```
  35244. * L = (1/pi) * E * rho
  35245. * ```
  35246. *
  35247. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35248. */
  35249. convertIrradianceToLambertianRadiance(): void;
  35250. /**
  35251. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35252. * required operations at run time.
  35253. *
  35254. * This is simply done by scaling back the SH with Ylm constants parameter.
  35255. * The trigonometric part being applied by the shader at run time.
  35256. */
  35257. preScaleForRendering(): void;
  35258. /**
  35259. * Constructs a spherical harmonics from an array.
  35260. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35261. * @returns the spherical harmonics
  35262. */
  35263. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35264. /**
  35265. * Gets the spherical harmonics from polynomial
  35266. * @param polynomial the spherical polynomial
  35267. * @returns the spherical harmonics
  35268. */
  35269. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35270. }
  35271. /**
  35272. * Class representing spherical polynomial coefficients to the 3rd degree
  35273. */
  35274. export class SphericalPolynomial {
  35275. private _harmonics;
  35276. /**
  35277. * The spherical harmonics used to create the polynomials.
  35278. */
  35279. get preScaledHarmonics(): SphericalHarmonics;
  35280. /**
  35281. * The x coefficients of the spherical polynomial
  35282. */
  35283. x: Vector3;
  35284. /**
  35285. * The y coefficients of the spherical polynomial
  35286. */
  35287. y: Vector3;
  35288. /**
  35289. * The z coefficients of the spherical polynomial
  35290. */
  35291. z: Vector3;
  35292. /**
  35293. * The xx coefficients of the spherical polynomial
  35294. */
  35295. xx: Vector3;
  35296. /**
  35297. * The yy coefficients of the spherical polynomial
  35298. */
  35299. yy: Vector3;
  35300. /**
  35301. * The zz coefficients of the spherical polynomial
  35302. */
  35303. zz: Vector3;
  35304. /**
  35305. * The xy coefficients of the spherical polynomial
  35306. */
  35307. xy: Vector3;
  35308. /**
  35309. * The yz coefficients of the spherical polynomial
  35310. */
  35311. yz: Vector3;
  35312. /**
  35313. * The zx coefficients of the spherical polynomial
  35314. */
  35315. zx: Vector3;
  35316. /**
  35317. * Adds an ambient color to the spherical polynomial
  35318. * @param color the color to add
  35319. */
  35320. addAmbient(color: Color3): void;
  35321. /**
  35322. * Scales the spherical polynomial by the given amount
  35323. * @param scale the amount to scale
  35324. */
  35325. scaleInPlace(scale: number): void;
  35326. /**
  35327. * Gets the spherical polynomial from harmonics
  35328. * @param harmonics the spherical harmonics
  35329. * @returns the spherical polynomial
  35330. */
  35331. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35332. /**
  35333. * Constructs a spherical polynomial from an array.
  35334. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35335. * @returns the spherical polynomial
  35336. */
  35337. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35338. }
  35339. }
  35340. declare module BABYLON {
  35341. /**
  35342. * Defines the source of the internal texture
  35343. */
  35344. export enum InternalTextureSource {
  35345. /**
  35346. * The source of the texture data is unknown
  35347. */
  35348. Unknown = 0,
  35349. /**
  35350. * Texture data comes from an URL
  35351. */
  35352. Url = 1,
  35353. /**
  35354. * Texture data is only used for temporary storage
  35355. */
  35356. Temp = 2,
  35357. /**
  35358. * Texture data comes from raw data (ArrayBuffer)
  35359. */
  35360. Raw = 3,
  35361. /**
  35362. * Texture content is dynamic (video or dynamic texture)
  35363. */
  35364. Dynamic = 4,
  35365. /**
  35366. * Texture content is generated by rendering to it
  35367. */
  35368. RenderTarget = 5,
  35369. /**
  35370. * Texture content is part of a multi render target process
  35371. */
  35372. MultiRenderTarget = 6,
  35373. /**
  35374. * Texture data comes from a cube data file
  35375. */
  35376. Cube = 7,
  35377. /**
  35378. * Texture data comes from a raw cube data
  35379. */
  35380. CubeRaw = 8,
  35381. /**
  35382. * Texture data come from a prefiltered cube data file
  35383. */
  35384. CubePrefiltered = 9,
  35385. /**
  35386. * Texture content is raw 3D data
  35387. */
  35388. Raw3D = 10,
  35389. /**
  35390. * Texture content is raw 2D array data
  35391. */
  35392. Raw2DArray = 11,
  35393. /**
  35394. * Texture content is a depth texture
  35395. */
  35396. Depth = 12,
  35397. /**
  35398. * Texture data comes from a raw cube data encoded with RGBD
  35399. */
  35400. CubeRawRGBD = 13
  35401. }
  35402. /**
  35403. * Class used to store data associated with WebGL texture data for the engine
  35404. * This class should not be used directly
  35405. */
  35406. export class InternalTexture {
  35407. /** @hidden */
  35408. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35409. /**
  35410. * Defines if the texture is ready
  35411. */
  35412. isReady: boolean;
  35413. /**
  35414. * Defines if the texture is a cube texture
  35415. */
  35416. isCube: boolean;
  35417. /**
  35418. * Defines if the texture contains 3D data
  35419. */
  35420. is3D: boolean;
  35421. /**
  35422. * Defines if the texture contains 2D array data
  35423. */
  35424. is2DArray: boolean;
  35425. /**
  35426. * Defines if the texture contains multiview data
  35427. */
  35428. isMultiview: boolean;
  35429. /**
  35430. * Gets the URL used to load this texture
  35431. */
  35432. url: string;
  35433. /**
  35434. * Gets the sampling mode of the texture
  35435. */
  35436. samplingMode: number;
  35437. /**
  35438. * Gets a boolean indicating if the texture needs mipmaps generation
  35439. */
  35440. generateMipMaps: boolean;
  35441. /**
  35442. * Gets the number of samples used by the texture (WebGL2+ only)
  35443. */
  35444. samples: number;
  35445. /**
  35446. * Gets the type of the texture (int, float...)
  35447. */
  35448. type: number;
  35449. /**
  35450. * Gets the format of the texture (RGB, RGBA...)
  35451. */
  35452. format: number;
  35453. /**
  35454. * Observable called when the texture is loaded
  35455. */
  35456. onLoadedObservable: Observable<InternalTexture>;
  35457. /**
  35458. * Gets the width of the texture
  35459. */
  35460. width: number;
  35461. /**
  35462. * Gets the height of the texture
  35463. */
  35464. height: number;
  35465. /**
  35466. * Gets the depth of the texture
  35467. */
  35468. depth: number;
  35469. /**
  35470. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35471. */
  35472. baseWidth: number;
  35473. /**
  35474. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35475. */
  35476. baseHeight: number;
  35477. /**
  35478. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35479. */
  35480. baseDepth: number;
  35481. /**
  35482. * Gets a boolean indicating if the texture is inverted on Y axis
  35483. */
  35484. invertY: boolean;
  35485. /** @hidden */
  35486. _invertVScale: boolean;
  35487. /** @hidden */
  35488. _associatedChannel: number;
  35489. /** @hidden */
  35490. _source: InternalTextureSource;
  35491. /** @hidden */
  35492. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35493. /** @hidden */
  35494. _bufferView: Nullable<ArrayBufferView>;
  35495. /** @hidden */
  35496. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35497. /** @hidden */
  35498. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35499. /** @hidden */
  35500. _size: number;
  35501. /** @hidden */
  35502. _extension: string;
  35503. /** @hidden */
  35504. _files: Nullable<string[]>;
  35505. /** @hidden */
  35506. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35507. /** @hidden */
  35508. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35509. /** @hidden */
  35510. _framebuffer: Nullable<WebGLFramebuffer>;
  35511. /** @hidden */
  35512. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35513. /** @hidden */
  35514. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35515. /** @hidden */
  35516. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35517. /** @hidden */
  35518. _attachments: Nullable<number[]>;
  35519. /** @hidden */
  35520. _cachedCoordinatesMode: Nullable<number>;
  35521. /** @hidden */
  35522. _cachedWrapU: Nullable<number>;
  35523. /** @hidden */
  35524. _cachedWrapV: Nullable<number>;
  35525. /** @hidden */
  35526. _cachedWrapR: Nullable<number>;
  35527. /** @hidden */
  35528. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35529. /** @hidden */
  35530. _isDisabled: boolean;
  35531. /** @hidden */
  35532. _compression: Nullable<string>;
  35533. /** @hidden */
  35534. _generateStencilBuffer: boolean;
  35535. /** @hidden */
  35536. _generateDepthBuffer: boolean;
  35537. /** @hidden */
  35538. _comparisonFunction: number;
  35539. /** @hidden */
  35540. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35541. /** @hidden */
  35542. _lodGenerationScale: number;
  35543. /** @hidden */
  35544. _lodGenerationOffset: number;
  35545. /** @hidden */
  35546. _depthStencilTexture: Nullable<InternalTexture>;
  35547. /** @hidden */
  35548. _colorTextureArray: Nullable<WebGLTexture>;
  35549. /** @hidden */
  35550. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35551. /** @hidden */
  35552. _lodTextureHigh: Nullable<BaseTexture>;
  35553. /** @hidden */
  35554. _lodTextureMid: Nullable<BaseTexture>;
  35555. /** @hidden */
  35556. _lodTextureLow: Nullable<BaseTexture>;
  35557. /** @hidden */
  35558. _isRGBD: boolean;
  35559. /** @hidden */
  35560. _linearSpecularLOD: boolean;
  35561. /** @hidden */
  35562. _irradianceTexture: Nullable<BaseTexture>;
  35563. /** @hidden */
  35564. _webGLTexture: Nullable<WebGLTexture>;
  35565. /** @hidden */
  35566. _references: number;
  35567. private _engine;
  35568. /**
  35569. * Gets the Engine the texture belongs to.
  35570. * @returns The babylon engine
  35571. */
  35572. getEngine(): ThinEngine;
  35573. /**
  35574. * Gets the data source type of the texture
  35575. */
  35576. get source(): InternalTextureSource;
  35577. /**
  35578. * Creates a new InternalTexture
  35579. * @param engine defines the engine to use
  35580. * @param source defines the type of data that will be used
  35581. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35582. */
  35583. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35584. /**
  35585. * Increments the number of references (ie. the number of Texture that point to it)
  35586. */
  35587. incrementReferences(): void;
  35588. /**
  35589. * Change the size of the texture (not the size of the content)
  35590. * @param width defines the new width
  35591. * @param height defines the new height
  35592. * @param depth defines the new depth (1 by default)
  35593. */
  35594. updateSize(width: int, height: int, depth?: int): void;
  35595. /** @hidden */
  35596. _rebuild(): void;
  35597. /** @hidden */
  35598. _swapAndDie(target: InternalTexture): void;
  35599. /**
  35600. * Dispose the current allocated resources
  35601. */
  35602. dispose(): void;
  35603. }
  35604. }
  35605. declare module BABYLON {
  35606. /**
  35607. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35609. */
  35610. export class Analyser {
  35611. /**
  35612. * Gets or sets the smoothing
  35613. * @ignorenaming
  35614. */
  35615. SMOOTHING: number;
  35616. /**
  35617. * Gets or sets the FFT table size
  35618. * @ignorenaming
  35619. */
  35620. FFT_SIZE: number;
  35621. /**
  35622. * Gets or sets the bar graph amplitude
  35623. * @ignorenaming
  35624. */
  35625. BARGRAPHAMPLITUDE: number;
  35626. /**
  35627. * Gets or sets the position of the debug canvas
  35628. * @ignorenaming
  35629. */
  35630. DEBUGCANVASPOS: {
  35631. x: number;
  35632. y: number;
  35633. };
  35634. /**
  35635. * Gets or sets the debug canvas size
  35636. * @ignorenaming
  35637. */
  35638. DEBUGCANVASSIZE: {
  35639. width: number;
  35640. height: number;
  35641. };
  35642. private _byteFreqs;
  35643. private _byteTime;
  35644. private _floatFreqs;
  35645. private _webAudioAnalyser;
  35646. private _debugCanvas;
  35647. private _debugCanvasContext;
  35648. private _scene;
  35649. private _registerFunc;
  35650. private _audioEngine;
  35651. /**
  35652. * Creates a new analyser
  35653. * @param scene defines hosting scene
  35654. */
  35655. constructor(scene: Scene);
  35656. /**
  35657. * Get the number of data values you will have to play with for the visualization
  35658. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35659. * @returns a number
  35660. */
  35661. getFrequencyBinCount(): number;
  35662. /**
  35663. * Gets the current frequency data as a byte array
  35664. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35665. * @returns a Uint8Array
  35666. */
  35667. getByteFrequencyData(): Uint8Array;
  35668. /**
  35669. * Gets the current waveform as a byte array
  35670. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35671. * @returns a Uint8Array
  35672. */
  35673. getByteTimeDomainData(): Uint8Array;
  35674. /**
  35675. * Gets the current frequency data as a float array
  35676. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35677. * @returns a Float32Array
  35678. */
  35679. getFloatFrequencyData(): Float32Array;
  35680. /**
  35681. * Renders the debug canvas
  35682. */
  35683. drawDebugCanvas(): void;
  35684. /**
  35685. * Stops rendering the debug canvas and removes it
  35686. */
  35687. stopDebugCanvas(): void;
  35688. /**
  35689. * Connects two audio nodes
  35690. * @param inputAudioNode defines first node to connect
  35691. * @param outputAudioNode defines second node to connect
  35692. */
  35693. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35694. /**
  35695. * Releases all associated resources
  35696. */
  35697. dispose(): void;
  35698. }
  35699. }
  35700. declare module BABYLON {
  35701. /**
  35702. * This represents an audio engine and it is responsible
  35703. * to play, synchronize and analyse sounds throughout the application.
  35704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35705. */
  35706. export interface IAudioEngine extends IDisposable {
  35707. /**
  35708. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35709. */
  35710. readonly canUseWebAudio: boolean;
  35711. /**
  35712. * Gets the current AudioContext if available.
  35713. */
  35714. readonly audioContext: Nullable<AudioContext>;
  35715. /**
  35716. * The master gain node defines the global audio volume of your audio engine.
  35717. */
  35718. readonly masterGain: GainNode;
  35719. /**
  35720. * Gets whether or not mp3 are supported by your browser.
  35721. */
  35722. readonly isMP3supported: boolean;
  35723. /**
  35724. * Gets whether or not ogg are supported by your browser.
  35725. */
  35726. readonly isOGGsupported: boolean;
  35727. /**
  35728. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35729. * @ignoreNaming
  35730. */
  35731. WarnedWebAudioUnsupported: boolean;
  35732. /**
  35733. * Defines if the audio engine relies on a custom unlocked button.
  35734. * In this case, the embedded button will not be displayed.
  35735. */
  35736. useCustomUnlockedButton: boolean;
  35737. /**
  35738. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35739. */
  35740. readonly unlocked: boolean;
  35741. /**
  35742. * Event raised when audio has been unlocked on the browser.
  35743. */
  35744. onAudioUnlockedObservable: Observable<AudioEngine>;
  35745. /**
  35746. * Event raised when audio has been locked on the browser.
  35747. */
  35748. onAudioLockedObservable: Observable<AudioEngine>;
  35749. /**
  35750. * Flags the audio engine in Locked state.
  35751. * This happens due to new browser policies preventing audio to autoplay.
  35752. */
  35753. lock(): void;
  35754. /**
  35755. * Unlocks the audio engine once a user action has been done on the dom.
  35756. * This is helpful to resume play once browser policies have been satisfied.
  35757. */
  35758. unlock(): void;
  35759. /**
  35760. * Gets the global volume sets on the master gain.
  35761. * @returns the global volume if set or -1 otherwise
  35762. */
  35763. getGlobalVolume(): number;
  35764. /**
  35765. * Sets the global volume of your experience (sets on the master gain).
  35766. * @param newVolume Defines the new global volume of the application
  35767. */
  35768. setGlobalVolume(newVolume: number): void;
  35769. /**
  35770. * Connect the audio engine to an audio analyser allowing some amazing
  35771. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35773. * @param analyser The analyser to connect to the engine
  35774. */
  35775. connectToAnalyser(analyser: Analyser): void;
  35776. }
  35777. /**
  35778. * This represents the default audio engine used in babylon.
  35779. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35781. */
  35782. export class AudioEngine implements IAudioEngine {
  35783. private _audioContext;
  35784. private _audioContextInitialized;
  35785. private _muteButton;
  35786. private _hostElement;
  35787. /**
  35788. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35789. */
  35790. canUseWebAudio: boolean;
  35791. /**
  35792. * The master gain node defines the global audio volume of your audio engine.
  35793. */
  35794. masterGain: GainNode;
  35795. /**
  35796. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35797. * @ignoreNaming
  35798. */
  35799. WarnedWebAudioUnsupported: boolean;
  35800. /**
  35801. * Gets whether or not mp3 are supported by your browser.
  35802. */
  35803. isMP3supported: boolean;
  35804. /**
  35805. * Gets whether or not ogg are supported by your browser.
  35806. */
  35807. isOGGsupported: boolean;
  35808. /**
  35809. * Gets whether audio has been unlocked on the device.
  35810. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35811. * a user interaction has happened.
  35812. */
  35813. unlocked: boolean;
  35814. /**
  35815. * Defines if the audio engine relies on a custom unlocked button.
  35816. * In this case, the embedded button will not be displayed.
  35817. */
  35818. useCustomUnlockedButton: boolean;
  35819. /**
  35820. * Event raised when audio has been unlocked on the browser.
  35821. */
  35822. onAudioUnlockedObservable: Observable<AudioEngine>;
  35823. /**
  35824. * Event raised when audio has been locked on the browser.
  35825. */
  35826. onAudioLockedObservable: Observable<AudioEngine>;
  35827. /**
  35828. * Gets the current AudioContext if available.
  35829. */
  35830. get audioContext(): Nullable<AudioContext>;
  35831. private _connectedAnalyser;
  35832. /**
  35833. * Instantiates a new audio engine.
  35834. *
  35835. * There should be only one per page as some browsers restrict the number
  35836. * of audio contexts you can create.
  35837. * @param hostElement defines the host element where to display the mute icon if necessary
  35838. */
  35839. constructor(hostElement?: Nullable<HTMLElement>);
  35840. /**
  35841. * Flags the audio engine in Locked state.
  35842. * This happens due to new browser policies preventing audio to autoplay.
  35843. */
  35844. lock(): void;
  35845. /**
  35846. * Unlocks the audio engine once a user action has been done on the dom.
  35847. * This is helpful to resume play once browser policies have been satisfied.
  35848. */
  35849. unlock(): void;
  35850. private _resumeAudioContext;
  35851. private _initializeAudioContext;
  35852. private _tryToRun;
  35853. private _triggerRunningState;
  35854. private _triggerSuspendedState;
  35855. private _displayMuteButton;
  35856. private _moveButtonToTopLeft;
  35857. private _onResize;
  35858. private _hideMuteButton;
  35859. /**
  35860. * Destroy and release the resources associated with the audio ccontext.
  35861. */
  35862. dispose(): void;
  35863. /**
  35864. * Gets the global volume sets on the master gain.
  35865. * @returns the global volume if set or -1 otherwise
  35866. */
  35867. getGlobalVolume(): number;
  35868. /**
  35869. * Sets the global volume of your experience (sets on the master gain).
  35870. * @param newVolume Defines the new global volume of the application
  35871. */
  35872. setGlobalVolume(newVolume: number): void;
  35873. /**
  35874. * Connect the audio engine to an audio analyser allowing some amazing
  35875. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35877. * @param analyser The analyser to connect to the engine
  35878. */
  35879. connectToAnalyser(analyser: Analyser): void;
  35880. }
  35881. }
  35882. declare module BABYLON {
  35883. /**
  35884. * Interface used to present a loading screen while loading a scene
  35885. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35886. */
  35887. export interface ILoadingScreen {
  35888. /**
  35889. * Function called to display the loading screen
  35890. */
  35891. displayLoadingUI: () => void;
  35892. /**
  35893. * Function called to hide the loading screen
  35894. */
  35895. hideLoadingUI: () => void;
  35896. /**
  35897. * Gets or sets the color to use for the background
  35898. */
  35899. loadingUIBackgroundColor: string;
  35900. /**
  35901. * Gets or sets the text to display while loading
  35902. */
  35903. loadingUIText: string;
  35904. }
  35905. /**
  35906. * Class used for the default loading screen
  35907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35908. */
  35909. export class DefaultLoadingScreen implements ILoadingScreen {
  35910. private _renderingCanvas;
  35911. private _loadingText;
  35912. private _loadingDivBackgroundColor;
  35913. private _loadingDiv;
  35914. private _loadingTextDiv;
  35915. /** Gets or sets the logo url to use for the default loading screen */
  35916. static DefaultLogoUrl: string;
  35917. /** Gets or sets the spinner url to use for the default loading screen */
  35918. static DefaultSpinnerUrl: string;
  35919. /**
  35920. * Creates a new default loading screen
  35921. * @param _renderingCanvas defines the canvas used to render the scene
  35922. * @param _loadingText defines the default text to display
  35923. * @param _loadingDivBackgroundColor defines the default background color
  35924. */
  35925. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35926. /**
  35927. * Function called to display the loading screen
  35928. */
  35929. displayLoadingUI(): void;
  35930. /**
  35931. * Function called to hide the loading screen
  35932. */
  35933. hideLoadingUI(): void;
  35934. /**
  35935. * Gets or sets the text to display while loading
  35936. */
  35937. set loadingUIText(text: string);
  35938. get loadingUIText(): string;
  35939. /**
  35940. * Gets or sets the color to use for the background
  35941. */
  35942. get loadingUIBackgroundColor(): string;
  35943. set loadingUIBackgroundColor(color: string);
  35944. private _resizeLoadingUI;
  35945. }
  35946. }
  35947. declare module BABYLON {
  35948. /**
  35949. * Interface for any object that can request an animation frame
  35950. */
  35951. export interface ICustomAnimationFrameRequester {
  35952. /**
  35953. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35954. */
  35955. renderFunction?: Function;
  35956. /**
  35957. * Called to request the next frame to render to
  35958. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35959. */
  35960. requestAnimationFrame: Function;
  35961. /**
  35962. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35963. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35964. */
  35965. requestID?: number;
  35966. }
  35967. }
  35968. declare module BABYLON {
  35969. /**
  35970. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35971. */
  35972. export class PerformanceMonitor {
  35973. private _enabled;
  35974. private _rollingFrameTime;
  35975. private _lastFrameTimeMs;
  35976. /**
  35977. * constructor
  35978. * @param frameSampleSize The number of samples required to saturate the sliding window
  35979. */
  35980. constructor(frameSampleSize?: number);
  35981. /**
  35982. * Samples current frame
  35983. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35984. */
  35985. sampleFrame(timeMs?: number): void;
  35986. /**
  35987. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35988. */
  35989. get averageFrameTime(): number;
  35990. /**
  35991. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35992. */
  35993. get averageFrameTimeVariance(): number;
  35994. /**
  35995. * Returns the frame time of the most recent frame
  35996. */
  35997. get instantaneousFrameTime(): number;
  35998. /**
  35999. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36000. */
  36001. get averageFPS(): number;
  36002. /**
  36003. * Returns the average framerate in frames per second using the most recent frame time
  36004. */
  36005. get instantaneousFPS(): number;
  36006. /**
  36007. * Returns true if enough samples have been taken to completely fill the sliding window
  36008. */
  36009. get isSaturated(): boolean;
  36010. /**
  36011. * Enables contributions to the sliding window sample set
  36012. */
  36013. enable(): void;
  36014. /**
  36015. * Disables contributions to the sliding window sample set
  36016. * Samples will not be interpolated over the disabled period
  36017. */
  36018. disable(): void;
  36019. /**
  36020. * Returns true if sampling is enabled
  36021. */
  36022. get isEnabled(): boolean;
  36023. /**
  36024. * Resets performance monitor
  36025. */
  36026. reset(): void;
  36027. }
  36028. /**
  36029. * RollingAverage
  36030. *
  36031. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36032. */
  36033. export class RollingAverage {
  36034. /**
  36035. * Current average
  36036. */
  36037. average: number;
  36038. /**
  36039. * Current variance
  36040. */
  36041. variance: number;
  36042. protected _samples: Array<number>;
  36043. protected _sampleCount: number;
  36044. protected _pos: number;
  36045. protected _m2: number;
  36046. /**
  36047. * constructor
  36048. * @param length The number of samples required to saturate the sliding window
  36049. */
  36050. constructor(length: number);
  36051. /**
  36052. * Adds a sample to the sample set
  36053. * @param v The sample value
  36054. */
  36055. add(v: number): void;
  36056. /**
  36057. * Returns previously added values or null if outside of history or outside the sliding window domain
  36058. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36059. * @return Value previously recorded with add() or null if outside of range
  36060. */
  36061. history(i: number): number;
  36062. /**
  36063. * Returns true if enough samples have been taken to completely fill the sliding window
  36064. * @return true if sample-set saturated
  36065. */
  36066. isSaturated(): boolean;
  36067. /**
  36068. * Resets the rolling average (equivalent to 0 samples taken so far)
  36069. */
  36070. reset(): void;
  36071. /**
  36072. * Wraps a value around the sample range boundaries
  36073. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36074. * @return Wrapped position in sample range
  36075. */
  36076. protected _wrapPosition(i: number): number;
  36077. }
  36078. }
  36079. declare module BABYLON {
  36080. /**
  36081. * This class is used to track a performance counter which is number based.
  36082. * The user has access to many properties which give statistics of different nature.
  36083. *
  36084. * The implementer can track two kinds of Performance Counter: time and count.
  36085. * 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.
  36086. * 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.
  36087. */
  36088. export class PerfCounter {
  36089. /**
  36090. * Gets or sets a global boolean to turn on and off all the counters
  36091. */
  36092. static Enabled: boolean;
  36093. /**
  36094. * Returns the smallest value ever
  36095. */
  36096. get min(): number;
  36097. /**
  36098. * Returns the biggest value ever
  36099. */
  36100. get max(): number;
  36101. /**
  36102. * Returns the average value since the performance counter is running
  36103. */
  36104. get average(): number;
  36105. /**
  36106. * Returns the average value of the last second the counter was monitored
  36107. */
  36108. get lastSecAverage(): number;
  36109. /**
  36110. * Returns the current value
  36111. */
  36112. get current(): number;
  36113. /**
  36114. * Gets the accumulated total
  36115. */
  36116. get total(): number;
  36117. /**
  36118. * Gets the total value count
  36119. */
  36120. get count(): number;
  36121. /**
  36122. * Creates a new counter
  36123. */
  36124. constructor();
  36125. /**
  36126. * Call this method to start monitoring a new frame.
  36127. * 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.
  36128. */
  36129. fetchNewFrame(): void;
  36130. /**
  36131. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36132. * @param newCount the count value to add to the monitored count
  36133. * @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.
  36134. */
  36135. addCount(newCount: number, fetchResult: boolean): void;
  36136. /**
  36137. * Start monitoring this performance counter
  36138. */
  36139. beginMonitoring(): void;
  36140. /**
  36141. * Compute the time lapsed since the previous beginMonitoring() call.
  36142. * @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
  36143. */
  36144. endMonitoring(newFrame?: boolean): void;
  36145. private _fetchResult;
  36146. private _startMonitoringTime;
  36147. private _min;
  36148. private _max;
  36149. private _average;
  36150. private _current;
  36151. private _totalValueCount;
  36152. private _totalAccumulated;
  36153. private _lastSecAverage;
  36154. private _lastSecAccumulated;
  36155. private _lastSecTime;
  36156. private _lastSecValueCount;
  36157. }
  36158. }
  36159. declare module BABYLON {
  36160. interface ThinEngine {
  36161. /**
  36162. * Sets alpha constants used by some alpha blending modes
  36163. * @param r defines the red component
  36164. * @param g defines the green component
  36165. * @param b defines the blue component
  36166. * @param a defines the alpha component
  36167. */
  36168. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36169. /**
  36170. * Sets the current alpha mode
  36171. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36172. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36173. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36174. */
  36175. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36176. /**
  36177. * Gets the current alpha mode
  36178. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36179. * @returns the current alpha mode
  36180. */
  36181. getAlphaMode(): number;
  36182. /**
  36183. * Sets the current alpha equation
  36184. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36185. */
  36186. setAlphaEquation(equation: number): void;
  36187. /**
  36188. * Gets the current alpha equation.
  36189. * @returns the current alpha equation
  36190. */
  36191. getAlphaEquation(): number;
  36192. }
  36193. }
  36194. declare module BABYLON {
  36195. interface ThinEngine {
  36196. /** @hidden */
  36197. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36198. }
  36199. }
  36200. declare module BABYLON {
  36201. /**
  36202. * Defines the interface used by display changed events
  36203. */
  36204. export interface IDisplayChangedEventArgs {
  36205. /** Gets the vrDisplay object (if any) */
  36206. vrDisplay: Nullable<any>;
  36207. /** Gets a boolean indicating if webVR is supported */
  36208. vrSupported: boolean;
  36209. }
  36210. /**
  36211. * Defines the interface used by objects containing a viewport (like a camera)
  36212. */
  36213. interface IViewportOwnerLike {
  36214. /**
  36215. * Gets or sets the viewport
  36216. */
  36217. viewport: IViewportLike;
  36218. }
  36219. /**
  36220. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36221. */
  36222. export class Engine extends ThinEngine {
  36223. /** Defines that alpha blending is disabled */
  36224. static readonly ALPHA_DISABLE: number;
  36225. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36226. static readonly ALPHA_ADD: number;
  36227. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36228. static readonly ALPHA_COMBINE: number;
  36229. /** Defines that alpha blending to DEST - SRC * DEST */
  36230. static readonly ALPHA_SUBTRACT: number;
  36231. /** Defines that alpha blending to SRC * DEST */
  36232. static readonly ALPHA_MULTIPLY: number;
  36233. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36234. static readonly ALPHA_MAXIMIZED: number;
  36235. /** Defines that alpha blending to SRC + DEST */
  36236. static readonly ALPHA_ONEONE: number;
  36237. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36238. static readonly ALPHA_PREMULTIPLIED: number;
  36239. /**
  36240. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36241. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36242. */
  36243. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36244. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36245. static readonly ALPHA_INTERPOLATE: number;
  36246. /**
  36247. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36248. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36249. */
  36250. static readonly ALPHA_SCREENMODE: number;
  36251. /** Defines that the ressource is not delayed*/
  36252. static readonly DELAYLOADSTATE_NONE: number;
  36253. /** Defines that the ressource was successfully delay loaded */
  36254. static readonly DELAYLOADSTATE_LOADED: number;
  36255. /** Defines that the ressource is currently delay loading */
  36256. static readonly DELAYLOADSTATE_LOADING: number;
  36257. /** Defines that the ressource is delayed and has not started loading */
  36258. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36259. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36260. static readonly NEVER: number;
  36261. /** 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 */
  36262. static readonly ALWAYS: number;
  36263. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36264. static readonly LESS: number;
  36265. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36266. static readonly EQUAL: number;
  36267. /** 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 */
  36268. static readonly LEQUAL: number;
  36269. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36270. static readonly GREATER: number;
  36271. /** 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 */
  36272. static readonly GEQUAL: number;
  36273. /** 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 */
  36274. static readonly NOTEQUAL: number;
  36275. /** Passed to stencilOperation to specify that stencil value must be kept */
  36276. static readonly KEEP: number;
  36277. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36278. static readonly REPLACE: number;
  36279. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36280. static readonly INCR: number;
  36281. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36282. static readonly DECR: number;
  36283. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36284. static readonly INVERT: number;
  36285. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36286. static readonly INCR_WRAP: number;
  36287. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36288. static readonly DECR_WRAP: number;
  36289. /** Texture is not repeating outside of 0..1 UVs */
  36290. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36291. /** Texture is repeating outside of 0..1 UVs */
  36292. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36293. /** Texture is repeating and mirrored */
  36294. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36295. /** ALPHA */
  36296. static readonly TEXTUREFORMAT_ALPHA: number;
  36297. /** LUMINANCE */
  36298. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36299. /** LUMINANCE_ALPHA */
  36300. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36301. /** RGB */
  36302. static readonly TEXTUREFORMAT_RGB: number;
  36303. /** RGBA */
  36304. static readonly TEXTUREFORMAT_RGBA: number;
  36305. /** RED */
  36306. static readonly TEXTUREFORMAT_RED: number;
  36307. /** RED (2nd reference) */
  36308. static readonly TEXTUREFORMAT_R: number;
  36309. /** RG */
  36310. static readonly TEXTUREFORMAT_RG: number;
  36311. /** RED_INTEGER */
  36312. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36313. /** RED_INTEGER (2nd reference) */
  36314. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36315. /** RG_INTEGER */
  36316. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36317. /** RGB_INTEGER */
  36318. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36319. /** RGBA_INTEGER */
  36320. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36321. /** UNSIGNED_BYTE */
  36322. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36323. /** UNSIGNED_BYTE (2nd reference) */
  36324. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36325. /** FLOAT */
  36326. static readonly TEXTURETYPE_FLOAT: number;
  36327. /** HALF_FLOAT */
  36328. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36329. /** BYTE */
  36330. static readonly TEXTURETYPE_BYTE: number;
  36331. /** SHORT */
  36332. static readonly TEXTURETYPE_SHORT: number;
  36333. /** UNSIGNED_SHORT */
  36334. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36335. /** INT */
  36336. static readonly TEXTURETYPE_INT: number;
  36337. /** UNSIGNED_INT */
  36338. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36339. /** UNSIGNED_SHORT_4_4_4_4 */
  36340. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36341. /** UNSIGNED_SHORT_5_5_5_1 */
  36342. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36343. /** UNSIGNED_SHORT_5_6_5 */
  36344. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36345. /** UNSIGNED_INT_2_10_10_10_REV */
  36346. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36347. /** UNSIGNED_INT_24_8 */
  36348. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36349. /** UNSIGNED_INT_10F_11F_11F_REV */
  36350. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36351. /** UNSIGNED_INT_5_9_9_9_REV */
  36352. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36353. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36354. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36355. /** nearest is mag = nearest and min = nearest and mip = linear */
  36356. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36357. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36358. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36359. /** Trilinear is mag = linear and min = linear and mip = linear */
  36360. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36361. /** nearest is mag = nearest and min = nearest and mip = linear */
  36362. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36363. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36364. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36365. /** Trilinear is mag = linear and min = linear and mip = linear */
  36366. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36367. /** mag = nearest and min = nearest and mip = nearest */
  36368. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36369. /** mag = nearest and min = linear and mip = nearest */
  36370. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36371. /** mag = nearest and min = linear and mip = linear */
  36372. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36373. /** mag = nearest and min = linear and mip = none */
  36374. static readonly TEXTURE_NEAREST_LINEAR: number;
  36375. /** mag = nearest and min = nearest and mip = none */
  36376. static readonly TEXTURE_NEAREST_NEAREST: number;
  36377. /** mag = linear and min = nearest and mip = nearest */
  36378. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36379. /** mag = linear and min = nearest and mip = linear */
  36380. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36381. /** mag = linear and min = linear and mip = none */
  36382. static readonly TEXTURE_LINEAR_LINEAR: number;
  36383. /** mag = linear and min = nearest and mip = none */
  36384. static readonly TEXTURE_LINEAR_NEAREST: number;
  36385. /** Explicit coordinates mode */
  36386. static readonly TEXTURE_EXPLICIT_MODE: number;
  36387. /** Spherical coordinates mode */
  36388. static readonly TEXTURE_SPHERICAL_MODE: number;
  36389. /** Planar coordinates mode */
  36390. static readonly TEXTURE_PLANAR_MODE: number;
  36391. /** Cubic coordinates mode */
  36392. static readonly TEXTURE_CUBIC_MODE: number;
  36393. /** Projection coordinates mode */
  36394. static readonly TEXTURE_PROJECTION_MODE: number;
  36395. /** Skybox coordinates mode */
  36396. static readonly TEXTURE_SKYBOX_MODE: number;
  36397. /** Inverse Cubic coordinates mode */
  36398. static readonly TEXTURE_INVCUBIC_MODE: number;
  36399. /** Equirectangular coordinates mode */
  36400. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36401. /** Equirectangular Fixed coordinates mode */
  36402. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36403. /** Equirectangular Fixed Mirrored coordinates mode */
  36404. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36405. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36406. static readonly SCALEMODE_FLOOR: number;
  36407. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36408. static readonly SCALEMODE_NEAREST: number;
  36409. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36410. static readonly SCALEMODE_CEILING: number;
  36411. /**
  36412. * Returns the current npm package of the sdk
  36413. */
  36414. static get NpmPackage(): string;
  36415. /**
  36416. * Returns the current version of the framework
  36417. */
  36418. static get Version(): string;
  36419. /** Gets the list of created engines */
  36420. static get Instances(): Engine[];
  36421. /**
  36422. * Gets the latest created engine
  36423. */
  36424. static get LastCreatedEngine(): Nullable<Engine>;
  36425. /**
  36426. * Gets the latest created scene
  36427. */
  36428. static get LastCreatedScene(): Nullable<Scene>;
  36429. /**
  36430. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36431. * @param flag defines which part of the materials must be marked as dirty
  36432. * @param predicate defines a predicate used to filter which materials should be affected
  36433. */
  36434. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36435. /**
  36436. * Method called to create the default loading screen.
  36437. * This can be overriden in your own app.
  36438. * @param canvas The rendering canvas element
  36439. * @returns The loading screen
  36440. */
  36441. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36442. /**
  36443. * Method called to create the default rescale post process on each engine.
  36444. */
  36445. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36446. /**
  36447. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36448. **/
  36449. enableOfflineSupport: boolean;
  36450. /**
  36451. * 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)
  36452. **/
  36453. disableManifestCheck: boolean;
  36454. /**
  36455. * Gets the list of created scenes
  36456. */
  36457. scenes: Scene[];
  36458. /**
  36459. * Event raised when a new scene is created
  36460. */
  36461. onNewSceneAddedObservable: Observable<Scene>;
  36462. /**
  36463. * Gets the list of created postprocesses
  36464. */
  36465. postProcesses: PostProcess[];
  36466. /**
  36467. * Gets a boolean indicating if the pointer is currently locked
  36468. */
  36469. isPointerLock: boolean;
  36470. /**
  36471. * Observable event triggered each time the rendering canvas is resized
  36472. */
  36473. onResizeObservable: Observable<Engine>;
  36474. /**
  36475. * Observable event triggered each time the canvas loses focus
  36476. */
  36477. onCanvasBlurObservable: Observable<Engine>;
  36478. /**
  36479. * Observable event triggered each time the canvas gains focus
  36480. */
  36481. onCanvasFocusObservable: Observable<Engine>;
  36482. /**
  36483. * Observable event triggered each time the canvas receives pointerout event
  36484. */
  36485. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36486. /**
  36487. * Observable raised when the engine begins a new frame
  36488. */
  36489. onBeginFrameObservable: Observable<Engine>;
  36490. /**
  36491. * If set, will be used to request the next animation frame for the render loop
  36492. */
  36493. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36494. /**
  36495. * Observable raised when the engine ends the current frame
  36496. */
  36497. onEndFrameObservable: Observable<Engine>;
  36498. /**
  36499. * Observable raised when the engine is about to compile a shader
  36500. */
  36501. onBeforeShaderCompilationObservable: Observable<Engine>;
  36502. /**
  36503. * Observable raised when the engine has jsut compiled a shader
  36504. */
  36505. onAfterShaderCompilationObservable: Observable<Engine>;
  36506. /**
  36507. * Gets the audio engine
  36508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36509. * @ignorenaming
  36510. */
  36511. static audioEngine: IAudioEngine;
  36512. /**
  36513. * Default AudioEngine factory responsible of creating the Audio Engine.
  36514. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36515. */
  36516. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36517. /**
  36518. * Default offline support factory responsible of creating a tool used to store data locally.
  36519. * By default, this will create a Database object if the workload has been embedded.
  36520. */
  36521. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36522. private _loadingScreen;
  36523. private _pointerLockRequested;
  36524. private _rescalePostProcess;
  36525. private _deterministicLockstep;
  36526. private _lockstepMaxSteps;
  36527. private _timeStep;
  36528. protected get _supportsHardwareTextureRescaling(): boolean;
  36529. private _fps;
  36530. private _deltaTime;
  36531. /** @hidden */
  36532. _drawCalls: PerfCounter;
  36533. /** 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 */
  36534. canvasTabIndex: number;
  36535. /**
  36536. * Turn this value on if you want to pause FPS computation when in background
  36537. */
  36538. disablePerformanceMonitorInBackground: boolean;
  36539. private _performanceMonitor;
  36540. /**
  36541. * Gets the performance monitor attached to this engine
  36542. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36543. */
  36544. get performanceMonitor(): PerformanceMonitor;
  36545. private _onFocus;
  36546. private _onBlur;
  36547. private _onCanvasPointerOut;
  36548. private _onCanvasBlur;
  36549. private _onCanvasFocus;
  36550. private _onFullscreenChange;
  36551. private _onPointerLockChange;
  36552. /**
  36553. * Gets the HTML element used to attach event listeners
  36554. * @returns a HTML element
  36555. */
  36556. getInputElement(): Nullable<HTMLElement>;
  36557. /**
  36558. * Creates a new engine
  36559. * @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
  36560. * @param antialias defines enable antialiasing (default: false)
  36561. * @param options defines further options to be sent to the getContext() function
  36562. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36563. */
  36564. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36565. /**
  36566. * Gets current aspect ratio
  36567. * @param viewportOwner defines the camera to use to get the aspect ratio
  36568. * @param useScreen defines if screen size must be used (or the current render target if any)
  36569. * @returns a number defining the aspect ratio
  36570. */
  36571. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36572. /**
  36573. * Gets current screen aspect ratio
  36574. * @returns a number defining the aspect ratio
  36575. */
  36576. getScreenAspectRatio(): number;
  36577. /**
  36578. * Gets the client rect of the HTML canvas attached with the current webGL context
  36579. * @returns a client rectanglee
  36580. */
  36581. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36582. /**
  36583. * Gets the client rect of the HTML element used for events
  36584. * @returns a client rectanglee
  36585. */
  36586. getInputElementClientRect(): Nullable<ClientRect>;
  36587. /**
  36588. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36589. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36590. * @returns true if engine is in deterministic lock step mode
  36591. */
  36592. isDeterministicLockStep(): boolean;
  36593. /**
  36594. * Gets the max steps when engine is running in deterministic lock step
  36595. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36596. * @returns the max steps
  36597. */
  36598. getLockstepMaxSteps(): number;
  36599. /**
  36600. * Returns the time in ms between steps when using deterministic lock step.
  36601. * @returns time step in (ms)
  36602. */
  36603. getTimeStep(): number;
  36604. /**
  36605. * Force the mipmap generation for the given render target texture
  36606. * @param texture defines the render target texture to use
  36607. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36608. */
  36609. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36610. /** States */
  36611. /**
  36612. * Set various states to the webGL context
  36613. * @param culling defines backface culling state
  36614. * @param zOffset defines the value to apply to zOffset (0 by default)
  36615. * @param force defines if states must be applied even if cache is up to date
  36616. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36617. */
  36618. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36619. /**
  36620. * Set the z offset to apply to current rendering
  36621. * @param value defines the offset to apply
  36622. */
  36623. setZOffset(value: number): void;
  36624. /**
  36625. * Gets the current value of the zOffset
  36626. * @returns the current zOffset state
  36627. */
  36628. getZOffset(): number;
  36629. /**
  36630. * Enable or disable depth buffering
  36631. * @param enable defines the state to set
  36632. */
  36633. setDepthBuffer(enable: boolean): void;
  36634. /**
  36635. * Gets a boolean indicating if depth writing is enabled
  36636. * @returns the current depth writing state
  36637. */
  36638. getDepthWrite(): boolean;
  36639. /**
  36640. * Enable or disable depth writing
  36641. * @param enable defines the state to set
  36642. */
  36643. setDepthWrite(enable: boolean): void;
  36644. /**
  36645. * Gets a boolean indicating if stencil buffer is enabled
  36646. * @returns the current stencil buffer state
  36647. */
  36648. getStencilBuffer(): boolean;
  36649. /**
  36650. * Enable or disable the stencil buffer
  36651. * @param enable defines if the stencil buffer must be enabled or disabled
  36652. */
  36653. setStencilBuffer(enable: boolean): void;
  36654. /**
  36655. * Gets the current stencil mask
  36656. * @returns a number defining the new stencil mask to use
  36657. */
  36658. getStencilMask(): number;
  36659. /**
  36660. * Sets the current stencil mask
  36661. * @param mask defines the new stencil mask to use
  36662. */
  36663. setStencilMask(mask: number): void;
  36664. /**
  36665. * Gets the current stencil function
  36666. * @returns a number defining the stencil function to use
  36667. */
  36668. getStencilFunction(): number;
  36669. /**
  36670. * Gets the current stencil reference value
  36671. * @returns a number defining the stencil reference value to use
  36672. */
  36673. getStencilFunctionReference(): number;
  36674. /**
  36675. * Gets the current stencil mask
  36676. * @returns a number defining the stencil mask to use
  36677. */
  36678. getStencilFunctionMask(): number;
  36679. /**
  36680. * Sets the current stencil function
  36681. * @param stencilFunc defines the new stencil function to use
  36682. */
  36683. setStencilFunction(stencilFunc: number): void;
  36684. /**
  36685. * Sets the current stencil reference
  36686. * @param reference defines the new stencil reference to use
  36687. */
  36688. setStencilFunctionReference(reference: number): void;
  36689. /**
  36690. * Sets the current stencil mask
  36691. * @param mask defines the new stencil mask to use
  36692. */
  36693. setStencilFunctionMask(mask: number): void;
  36694. /**
  36695. * Gets the current stencil operation when stencil fails
  36696. * @returns a number defining stencil operation to use when stencil fails
  36697. */
  36698. getStencilOperationFail(): number;
  36699. /**
  36700. * Gets the current stencil operation when depth fails
  36701. * @returns a number defining stencil operation to use when depth fails
  36702. */
  36703. getStencilOperationDepthFail(): number;
  36704. /**
  36705. * Gets the current stencil operation when stencil passes
  36706. * @returns a number defining stencil operation to use when stencil passes
  36707. */
  36708. getStencilOperationPass(): number;
  36709. /**
  36710. * Sets the stencil operation to use when stencil fails
  36711. * @param operation defines the stencil operation to use when stencil fails
  36712. */
  36713. setStencilOperationFail(operation: number): void;
  36714. /**
  36715. * Sets the stencil operation to use when depth fails
  36716. * @param operation defines the stencil operation to use when depth fails
  36717. */
  36718. setStencilOperationDepthFail(operation: number): void;
  36719. /**
  36720. * Sets the stencil operation to use when stencil passes
  36721. * @param operation defines the stencil operation to use when stencil passes
  36722. */
  36723. setStencilOperationPass(operation: number): void;
  36724. /**
  36725. * Sets a boolean indicating if the dithering state is enabled or disabled
  36726. * @param value defines the dithering state
  36727. */
  36728. setDitheringState(value: boolean): void;
  36729. /**
  36730. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36731. * @param value defines the rasterizer state
  36732. */
  36733. setRasterizerState(value: boolean): void;
  36734. /**
  36735. * Gets the current depth function
  36736. * @returns a number defining the depth function
  36737. */
  36738. getDepthFunction(): Nullable<number>;
  36739. /**
  36740. * Sets the current depth function
  36741. * @param depthFunc defines the function to use
  36742. */
  36743. setDepthFunction(depthFunc: number): void;
  36744. /**
  36745. * Sets the current depth function to GREATER
  36746. */
  36747. setDepthFunctionToGreater(): void;
  36748. /**
  36749. * Sets the current depth function to GEQUAL
  36750. */
  36751. setDepthFunctionToGreaterOrEqual(): void;
  36752. /**
  36753. * Sets the current depth function to LESS
  36754. */
  36755. setDepthFunctionToLess(): void;
  36756. /**
  36757. * Sets the current depth function to LEQUAL
  36758. */
  36759. setDepthFunctionToLessOrEqual(): void;
  36760. private _cachedStencilBuffer;
  36761. private _cachedStencilFunction;
  36762. private _cachedStencilMask;
  36763. private _cachedStencilOperationPass;
  36764. private _cachedStencilOperationFail;
  36765. private _cachedStencilOperationDepthFail;
  36766. private _cachedStencilReference;
  36767. /**
  36768. * Caches the the state of the stencil buffer
  36769. */
  36770. cacheStencilState(): void;
  36771. /**
  36772. * Restores the state of the stencil buffer
  36773. */
  36774. restoreStencilState(): void;
  36775. /**
  36776. * Directly set the WebGL Viewport
  36777. * @param x defines the x coordinate of the viewport (in screen space)
  36778. * @param y defines the y coordinate of the viewport (in screen space)
  36779. * @param width defines the width of the viewport (in screen space)
  36780. * @param height defines the height of the viewport (in screen space)
  36781. * @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
  36782. */
  36783. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36784. /**
  36785. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36786. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36787. * @param y defines the y-coordinate of the corner of the clear rectangle
  36788. * @param width defines the width of the clear rectangle
  36789. * @param height defines the height of the clear rectangle
  36790. * @param clearColor defines the clear color
  36791. */
  36792. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36793. /**
  36794. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36795. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36796. * @param y defines the y-coordinate of the corner of the clear rectangle
  36797. * @param width defines the width of the clear rectangle
  36798. * @param height defines the height of the clear rectangle
  36799. */
  36800. enableScissor(x: number, y: number, width: number, height: number): void;
  36801. /**
  36802. * Disable previously set scissor test rectangle
  36803. */
  36804. disableScissor(): void;
  36805. protected _reportDrawCall(): void;
  36806. /**
  36807. * Initializes a webVR display and starts listening to display change events
  36808. * The onVRDisplayChangedObservable will be notified upon these changes
  36809. * @returns The onVRDisplayChangedObservable
  36810. */
  36811. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36812. /** @hidden */
  36813. _prepareVRComponent(): void;
  36814. /** @hidden */
  36815. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36816. /** @hidden */
  36817. _submitVRFrame(): void;
  36818. /**
  36819. * Call this function to leave webVR mode
  36820. * Will do nothing if webVR is not supported or if there is no webVR device
  36821. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36822. */
  36823. disableVR(): void;
  36824. /**
  36825. * Gets a boolean indicating that the system is in VR mode and is presenting
  36826. * @returns true if VR mode is engaged
  36827. */
  36828. isVRPresenting(): boolean;
  36829. /** @hidden */
  36830. _requestVRFrame(): void;
  36831. /** @hidden */
  36832. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36833. /**
  36834. * Gets the source code of the vertex shader associated with a specific webGL program
  36835. * @param program defines the program to use
  36836. * @returns a string containing the source code of the vertex shader associated with the program
  36837. */
  36838. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36839. /**
  36840. * Gets the source code of the fragment shader associated with a specific webGL program
  36841. * @param program defines the program to use
  36842. * @returns a string containing the source code of the fragment shader associated with the program
  36843. */
  36844. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36845. /**
  36846. * Sets a depth stencil texture from a render target to the according uniform.
  36847. * @param channel The texture channel
  36848. * @param uniform The uniform to set
  36849. * @param texture The render target texture containing the depth stencil texture to apply
  36850. */
  36851. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36852. /**
  36853. * Sets a texture to the webGL context from a postprocess
  36854. * @param channel defines the channel to use
  36855. * @param postProcess defines the source postprocess
  36856. */
  36857. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36858. /**
  36859. * Binds the output of the passed in post process to the texture channel specified
  36860. * @param channel The channel the texture should be bound to
  36861. * @param postProcess The post process which's output should be bound
  36862. */
  36863. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36864. protected _rebuildBuffers(): void;
  36865. /** @hidden */
  36866. _renderFrame(): void;
  36867. _renderLoop(): void;
  36868. /** @hidden */
  36869. _renderViews(): boolean;
  36870. /**
  36871. * Toggle full screen mode
  36872. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36873. */
  36874. switchFullscreen(requestPointerLock: boolean): void;
  36875. /**
  36876. * Enters full screen mode
  36877. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36878. */
  36879. enterFullscreen(requestPointerLock: boolean): void;
  36880. /**
  36881. * Exits full screen mode
  36882. */
  36883. exitFullscreen(): void;
  36884. /**
  36885. * Enters Pointerlock mode
  36886. */
  36887. enterPointerlock(): void;
  36888. /**
  36889. * Exits Pointerlock mode
  36890. */
  36891. exitPointerlock(): void;
  36892. /**
  36893. * Begin a new frame
  36894. */
  36895. beginFrame(): void;
  36896. /**
  36897. * Enf the current frame
  36898. */
  36899. endFrame(): void;
  36900. resize(): void;
  36901. /**
  36902. * Force a specific size of the canvas
  36903. * @param width defines the new canvas' width
  36904. * @param height defines the new canvas' height
  36905. */
  36906. setSize(width: number, height: number): void;
  36907. /**
  36908. * Updates a dynamic vertex buffer.
  36909. * @param vertexBuffer the vertex buffer to update
  36910. * @param data the data used to update the vertex buffer
  36911. * @param byteOffset the byte offset of the data
  36912. * @param byteLength the byte length of the data
  36913. */
  36914. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36915. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36916. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36917. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36918. _releaseTexture(texture: InternalTexture): void;
  36919. /**
  36920. * @hidden
  36921. * Rescales a texture
  36922. * @param source input texutre
  36923. * @param destination destination texture
  36924. * @param scene scene to use to render the resize
  36925. * @param internalFormat format to use when resizing
  36926. * @param onComplete callback to be called when resize has completed
  36927. */
  36928. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36929. /**
  36930. * Gets the current framerate
  36931. * @returns a number representing the framerate
  36932. */
  36933. getFps(): number;
  36934. /**
  36935. * Gets the time spent between current and previous frame
  36936. * @returns a number representing the delta time in ms
  36937. */
  36938. getDeltaTime(): number;
  36939. private _measureFps;
  36940. /** @hidden */
  36941. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36942. /**
  36943. * Update a dynamic index buffer
  36944. * @param indexBuffer defines the target index buffer
  36945. * @param indices defines the data to update
  36946. * @param offset defines the offset in the target index buffer where update should start
  36947. */
  36948. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36949. /**
  36950. * Updates the sample count of a render target texture
  36951. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36952. * @param texture defines the texture to update
  36953. * @param samples defines the sample count to set
  36954. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36955. */
  36956. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36957. /**
  36958. * Updates a depth texture Comparison Mode and Function.
  36959. * If the comparison Function is equal to 0, the mode will be set to none.
  36960. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36961. * @param texture The texture to set the comparison function for
  36962. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36963. */
  36964. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36965. /**
  36966. * Creates a webGL buffer to use with instanciation
  36967. * @param capacity defines the size of the buffer
  36968. * @returns the webGL buffer
  36969. */
  36970. createInstancesBuffer(capacity: number): DataBuffer;
  36971. /**
  36972. * Delete a webGL buffer used with instanciation
  36973. * @param buffer defines the webGL buffer to delete
  36974. */
  36975. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36976. private _clientWaitAsync;
  36977. /** @hidden */
  36978. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36979. dispose(): void;
  36980. private _disableTouchAction;
  36981. /**
  36982. * Display the loading screen
  36983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36984. */
  36985. displayLoadingUI(): void;
  36986. /**
  36987. * Hide the loading screen
  36988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36989. */
  36990. hideLoadingUI(): void;
  36991. /**
  36992. * Gets the current loading screen object
  36993. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36994. */
  36995. get loadingScreen(): ILoadingScreen;
  36996. /**
  36997. * Sets the current loading screen object
  36998. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36999. */
  37000. set loadingScreen(loadingScreen: ILoadingScreen);
  37001. /**
  37002. * Sets the current loading screen text
  37003. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37004. */
  37005. set loadingUIText(text: string);
  37006. /**
  37007. * Sets the current loading screen background color
  37008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37009. */
  37010. set loadingUIBackgroundColor(color: string);
  37011. /** Pointerlock and fullscreen */
  37012. /**
  37013. * Ask the browser to promote the current element to pointerlock mode
  37014. * @param element defines the DOM element to promote
  37015. */
  37016. static _RequestPointerlock(element: HTMLElement): void;
  37017. /**
  37018. * Asks the browser to exit pointerlock mode
  37019. */
  37020. static _ExitPointerlock(): void;
  37021. /**
  37022. * Ask the browser to promote the current element to fullscreen rendering mode
  37023. * @param element defines the DOM element to promote
  37024. */
  37025. static _RequestFullscreen(element: HTMLElement): void;
  37026. /**
  37027. * Asks the browser to exit fullscreen mode
  37028. */
  37029. static _ExitFullscreen(): void;
  37030. }
  37031. }
  37032. declare module BABYLON {
  37033. /**
  37034. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37035. * during the life time of the application.
  37036. */
  37037. export class EngineStore {
  37038. /** Gets the list of created engines */
  37039. static Instances: Engine[];
  37040. /** @hidden */
  37041. static _LastCreatedScene: Nullable<Scene>;
  37042. /**
  37043. * Gets the latest created engine
  37044. */
  37045. static get LastCreatedEngine(): Nullable<Engine>;
  37046. /**
  37047. * Gets the latest created scene
  37048. */
  37049. static get LastCreatedScene(): Nullable<Scene>;
  37050. /**
  37051. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37052. * @ignorenaming
  37053. */
  37054. static UseFallbackTexture: boolean;
  37055. /**
  37056. * Texture content used if a texture cannot loaded
  37057. * @ignorenaming
  37058. */
  37059. static FallbackTexture: string;
  37060. }
  37061. }
  37062. declare module BABYLON {
  37063. /**
  37064. * Helper class that provides a small promise polyfill
  37065. */
  37066. export class PromisePolyfill {
  37067. /**
  37068. * Static function used to check if the polyfill is required
  37069. * If this is the case then the function will inject the polyfill to window.Promise
  37070. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37071. */
  37072. static Apply(force?: boolean): void;
  37073. }
  37074. }
  37075. declare module BABYLON {
  37076. /**
  37077. * Interface for screenshot methods with describe argument called `size` as object with options
  37078. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37079. */
  37080. export interface IScreenshotSize {
  37081. /**
  37082. * number in pixels for canvas height
  37083. */
  37084. height?: number;
  37085. /**
  37086. * multiplier allowing render at a higher or lower resolution
  37087. * If value is defined then height and width will be ignored and taken from camera
  37088. */
  37089. precision?: number;
  37090. /**
  37091. * number in pixels for canvas width
  37092. */
  37093. width?: number;
  37094. }
  37095. }
  37096. declare module BABYLON {
  37097. interface IColor4Like {
  37098. r: float;
  37099. g: float;
  37100. b: float;
  37101. a: float;
  37102. }
  37103. /**
  37104. * Class containing a set of static utilities functions
  37105. */
  37106. export class Tools {
  37107. /**
  37108. * Gets or sets the base URL to use to load assets
  37109. */
  37110. static get BaseUrl(): string;
  37111. static set BaseUrl(value: string);
  37112. /**
  37113. * Enable/Disable Custom HTTP Request Headers globally.
  37114. * default = false
  37115. * @see CustomRequestHeaders
  37116. */
  37117. static UseCustomRequestHeaders: boolean;
  37118. /**
  37119. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37120. * i.e. when loading files, where the server/service expects an Authorization header
  37121. */
  37122. static CustomRequestHeaders: {
  37123. [key: string]: string;
  37124. };
  37125. /**
  37126. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37127. */
  37128. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37129. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37130. /**
  37131. * Default behaviour for cors in the application.
  37132. * It can be a string if the expected behavior is identical in the entire app.
  37133. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37134. */
  37135. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37136. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37137. /**
  37138. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37139. * @ignorenaming
  37140. */
  37141. static get UseFallbackTexture(): boolean;
  37142. static set UseFallbackTexture(value: boolean);
  37143. /**
  37144. * Use this object to register external classes like custom textures or material
  37145. * to allow the laoders to instantiate them
  37146. */
  37147. static get RegisteredExternalClasses(): {
  37148. [key: string]: Object;
  37149. };
  37150. static set RegisteredExternalClasses(classes: {
  37151. [key: string]: Object;
  37152. });
  37153. /**
  37154. * Texture content used if a texture cannot loaded
  37155. * @ignorenaming
  37156. */
  37157. static get fallbackTexture(): string;
  37158. static set fallbackTexture(value: string);
  37159. /**
  37160. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37161. * @param u defines the coordinate on X axis
  37162. * @param v defines the coordinate on Y axis
  37163. * @param width defines the width of the source data
  37164. * @param height defines the height of the source data
  37165. * @param pixels defines the source byte array
  37166. * @param color defines the output color
  37167. */
  37168. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37169. /**
  37170. * Interpolates between a and b via alpha
  37171. * @param a The lower value (returned when alpha = 0)
  37172. * @param b The upper value (returned when alpha = 1)
  37173. * @param alpha The interpolation-factor
  37174. * @return The mixed value
  37175. */
  37176. static Mix(a: number, b: number, alpha: number): number;
  37177. /**
  37178. * Tries to instantiate a new object from a given class name
  37179. * @param className defines the class name to instantiate
  37180. * @returns the new object or null if the system was not able to do the instantiation
  37181. */
  37182. static Instantiate(className: string): any;
  37183. /**
  37184. * Provides a slice function that will work even on IE
  37185. * @param data defines the array to slice
  37186. * @param start defines the start of the data (optional)
  37187. * @param end defines the end of the data (optional)
  37188. * @returns the new sliced array
  37189. */
  37190. static Slice<T>(data: T, start?: number, end?: number): T;
  37191. /**
  37192. * Polyfill for setImmediate
  37193. * @param action defines the action to execute after the current execution block
  37194. */
  37195. static SetImmediate(action: () => void): void;
  37196. /**
  37197. * Function indicating if a number is an exponent of 2
  37198. * @param value defines the value to test
  37199. * @returns true if the value is an exponent of 2
  37200. */
  37201. static IsExponentOfTwo(value: number): boolean;
  37202. private static _tmpFloatArray;
  37203. /**
  37204. * Returns the nearest 32-bit single precision float representation of a Number
  37205. * @param value A Number. If the parameter is of a different type, it will get converted
  37206. * to a number or to NaN if it cannot be converted
  37207. * @returns number
  37208. */
  37209. static FloatRound(value: number): number;
  37210. /**
  37211. * Extracts the filename from a path
  37212. * @param path defines the path to use
  37213. * @returns the filename
  37214. */
  37215. static GetFilename(path: string): string;
  37216. /**
  37217. * Extracts the "folder" part of a path (everything before the filename).
  37218. * @param uri The URI to extract the info from
  37219. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37220. * @returns The "folder" part of the path
  37221. */
  37222. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37223. /**
  37224. * Extracts text content from a DOM element hierarchy
  37225. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37226. */
  37227. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37228. /**
  37229. * Convert an angle in radians to degrees
  37230. * @param angle defines the angle to convert
  37231. * @returns the angle in degrees
  37232. */
  37233. static ToDegrees(angle: number): number;
  37234. /**
  37235. * Convert an angle in degrees to radians
  37236. * @param angle defines the angle to convert
  37237. * @returns the angle in radians
  37238. */
  37239. static ToRadians(angle: number): number;
  37240. /**
  37241. * Returns an array if obj is not an array
  37242. * @param obj defines the object to evaluate as an array
  37243. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37244. * @returns either obj directly if obj is an array or a new array containing obj
  37245. */
  37246. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37247. /**
  37248. * Gets the pointer prefix to use
  37249. * @param engine defines the engine we are finding the prefix for
  37250. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37251. */
  37252. static GetPointerPrefix(engine: Engine): string;
  37253. /**
  37254. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37255. * @param url define the url we are trying
  37256. * @param element define the dom element where to configure the cors policy
  37257. */
  37258. static SetCorsBehavior(url: string | string[], element: {
  37259. crossOrigin: string | null;
  37260. }): void;
  37261. /**
  37262. * Removes unwanted characters from an url
  37263. * @param url defines the url to clean
  37264. * @returns the cleaned url
  37265. */
  37266. static CleanUrl(url: string): string;
  37267. /**
  37268. * Gets or sets a function used to pre-process url before using them to load assets
  37269. */
  37270. static get PreprocessUrl(): (url: string) => string;
  37271. static set PreprocessUrl(processor: (url: string) => string);
  37272. /**
  37273. * Loads an image as an HTMLImageElement.
  37274. * @param input url string, ArrayBuffer, or Blob to load
  37275. * @param onLoad callback called when the image successfully loads
  37276. * @param onError callback called when the image fails to load
  37277. * @param offlineProvider offline provider for caching
  37278. * @param mimeType optional mime type
  37279. * @returns the HTMLImageElement of the loaded image
  37280. */
  37281. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37282. /**
  37283. * Loads a file from a url
  37284. * @param url url string, ArrayBuffer, or Blob to load
  37285. * @param onSuccess callback called when the file successfully loads
  37286. * @param onProgress callback called while file is loading (if the server supports this mode)
  37287. * @param offlineProvider defines the offline provider for caching
  37288. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37289. * @param onError callback called when the file fails to load
  37290. * @returns a file request object
  37291. */
  37292. 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;
  37293. /**
  37294. * Loads a file from a url
  37295. * @param url the file url to load
  37296. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37297. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37298. */
  37299. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37300. /**
  37301. * Load a script (identified by an url). When the url returns, the
  37302. * content of this file is added into a new script element, attached to the DOM (body element)
  37303. * @param scriptUrl defines the url of the script to laod
  37304. * @param onSuccess defines the callback called when the script is loaded
  37305. * @param onError defines the callback to call if an error occurs
  37306. * @param scriptId defines the id of the script element
  37307. */
  37308. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37309. /**
  37310. * Load an asynchronous script (identified by an url). When the url returns, the
  37311. * content of this file is added into a new script element, attached to the DOM (body element)
  37312. * @param scriptUrl defines the url of the script to laod
  37313. * @param scriptId defines the id of the script element
  37314. * @returns a promise request object
  37315. */
  37316. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37317. /**
  37318. * Loads a file from a blob
  37319. * @param fileToLoad defines the blob to use
  37320. * @param callback defines the callback to call when data is loaded
  37321. * @param progressCallback defines the callback to call during loading process
  37322. * @returns a file request object
  37323. */
  37324. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37325. /**
  37326. * Reads a file from a File object
  37327. * @param file defines the file to load
  37328. * @param onSuccess defines the callback to call when data is loaded
  37329. * @param onProgress defines the callback to call during loading process
  37330. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37331. * @param onError defines the callback to call when an error occurs
  37332. * @returns a file request object
  37333. */
  37334. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37335. /**
  37336. * Creates a data url from a given string content
  37337. * @param content defines the content to convert
  37338. * @returns the new data url link
  37339. */
  37340. static FileAsURL(content: string): string;
  37341. /**
  37342. * Format the given number to a specific decimal format
  37343. * @param value defines the number to format
  37344. * @param decimals defines the number of decimals to use
  37345. * @returns the formatted string
  37346. */
  37347. static Format(value: number, decimals?: number): string;
  37348. /**
  37349. * Tries to copy an object by duplicating every property
  37350. * @param source defines the source object
  37351. * @param destination defines the target object
  37352. * @param doNotCopyList defines a list of properties to avoid
  37353. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37354. */
  37355. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37356. /**
  37357. * Gets a boolean indicating if the given object has no own property
  37358. * @param obj defines the object to test
  37359. * @returns true if object has no own property
  37360. */
  37361. static IsEmpty(obj: any): boolean;
  37362. /**
  37363. * Function used to register events at window level
  37364. * @param windowElement defines the Window object to use
  37365. * @param events defines the events to register
  37366. */
  37367. static RegisterTopRootEvents(windowElement: Window, events: {
  37368. name: string;
  37369. handler: Nullable<(e: FocusEvent) => any>;
  37370. }[]): void;
  37371. /**
  37372. * Function used to unregister events from window level
  37373. * @param windowElement defines the Window object to use
  37374. * @param events defines the events to unregister
  37375. */
  37376. static UnregisterTopRootEvents(windowElement: Window, events: {
  37377. name: string;
  37378. handler: Nullable<(e: FocusEvent) => any>;
  37379. }[]): void;
  37380. /**
  37381. * @ignore
  37382. */
  37383. static _ScreenshotCanvas: HTMLCanvasElement;
  37384. /**
  37385. * Dumps the current bound framebuffer
  37386. * @param width defines the rendering width
  37387. * @param height defines the rendering height
  37388. * @param engine defines the hosting engine
  37389. * @param successCallback defines the callback triggered once the data are available
  37390. * @param mimeType defines the mime type of the result
  37391. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37392. */
  37393. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37394. /**
  37395. * Converts the canvas data to blob.
  37396. * This acts as a polyfill for browsers not supporting the to blob function.
  37397. * @param canvas Defines the canvas to extract the data from
  37398. * @param successCallback Defines the callback triggered once the data are available
  37399. * @param mimeType Defines the mime type of the result
  37400. */
  37401. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37402. /**
  37403. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37404. * @param successCallback defines the callback triggered once the data are available
  37405. * @param mimeType defines the mime type of the result
  37406. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37407. */
  37408. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37409. /**
  37410. * Downloads a blob in the browser
  37411. * @param blob defines the blob to download
  37412. * @param fileName defines the name of the downloaded file
  37413. */
  37414. static Download(blob: Blob, fileName: string): void;
  37415. /**
  37416. * Captures a screenshot of the current rendering
  37417. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37418. * @param engine defines the rendering engine
  37419. * @param camera defines the source camera
  37420. * @param size This parameter can be set to a single number or to an object with the
  37421. * following (optional) properties: precision, width, height. If a single number is passed,
  37422. * it will be used for both width and height. If an object is passed, the screenshot size
  37423. * will be derived from the parameters. The precision property is a multiplier allowing
  37424. * rendering at a higher or lower resolution
  37425. * @param successCallback defines the callback receives a single parameter which contains the
  37426. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37427. * src parameter of an <img> to display it
  37428. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37429. * Check your browser for supported MIME types
  37430. */
  37431. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37432. /**
  37433. * Captures a screenshot of the current rendering
  37434. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37435. * @param engine defines the rendering engine
  37436. * @param camera defines the source camera
  37437. * @param size This parameter can be set to a single number or to an object with the
  37438. * following (optional) properties: precision, width, height. If a single number is passed,
  37439. * it will be used for both width and height. If an object is passed, the screenshot size
  37440. * will be derived from the parameters. The precision property is a multiplier allowing
  37441. * rendering at a higher or lower resolution
  37442. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37443. * Check your browser for supported MIME types
  37444. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37445. * to the src parameter of an <img> to display it
  37446. */
  37447. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37448. /**
  37449. * Generates an image screenshot from the specified camera.
  37450. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37451. * @param engine The engine to use for rendering
  37452. * @param camera The camera to use for rendering
  37453. * @param size This parameter can be set to a single number or to an object with the
  37454. * following (optional) properties: precision, width, height. If a single number is passed,
  37455. * it will be used for both width and height. If an object is passed, the screenshot size
  37456. * will be derived from the parameters. The precision property is a multiplier allowing
  37457. * rendering at a higher or lower resolution
  37458. * @param successCallback The callback receives a single parameter which contains the
  37459. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37460. * src parameter of an <img> to display it
  37461. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37462. * Check your browser for supported MIME types
  37463. * @param samples Texture samples (default: 1)
  37464. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37465. * @param fileName A name for for the downloaded file.
  37466. */
  37467. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37468. /**
  37469. * Generates an image screenshot from the specified camera.
  37470. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37471. * @param engine The engine to use for rendering
  37472. * @param camera The camera to use for rendering
  37473. * @param size This parameter can be set to a single number or to an object with the
  37474. * following (optional) properties: precision, width, height. If a single number is passed,
  37475. * it will be used for both width and height. If an object is passed, the screenshot size
  37476. * will be derived from the parameters. The precision property is a multiplier allowing
  37477. * rendering at a higher or lower resolution
  37478. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37479. * Check your browser for supported MIME types
  37480. * @param samples Texture samples (default: 1)
  37481. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37482. * @param fileName A name for for the downloaded file.
  37483. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37484. * to the src parameter of an <img> to display it
  37485. */
  37486. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37487. /**
  37488. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37489. * Be aware Math.random() could cause collisions, but:
  37490. * "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"
  37491. * @returns a pseudo random id
  37492. */
  37493. static RandomId(): string;
  37494. /**
  37495. * Test if the given uri is a base64 string
  37496. * @param uri The uri to test
  37497. * @return True if the uri is a base64 string or false otherwise
  37498. */
  37499. static IsBase64(uri: string): boolean;
  37500. /**
  37501. * Decode the given base64 uri.
  37502. * @param uri The uri to decode
  37503. * @return The decoded base64 data.
  37504. */
  37505. static DecodeBase64(uri: string): ArrayBuffer;
  37506. /**
  37507. * Gets the absolute url.
  37508. * @param url the input url
  37509. * @return the absolute url
  37510. */
  37511. static GetAbsoluteUrl(url: string): string;
  37512. /**
  37513. * No log
  37514. */
  37515. static readonly NoneLogLevel: number;
  37516. /**
  37517. * Only message logs
  37518. */
  37519. static readonly MessageLogLevel: number;
  37520. /**
  37521. * Only warning logs
  37522. */
  37523. static readonly WarningLogLevel: number;
  37524. /**
  37525. * Only error logs
  37526. */
  37527. static readonly ErrorLogLevel: number;
  37528. /**
  37529. * All logs
  37530. */
  37531. static readonly AllLogLevel: number;
  37532. /**
  37533. * Gets a value indicating the number of loading errors
  37534. * @ignorenaming
  37535. */
  37536. static get errorsCount(): number;
  37537. /**
  37538. * Callback called when a new log is added
  37539. */
  37540. static OnNewCacheEntry: (entry: string) => void;
  37541. /**
  37542. * Log a message to the console
  37543. * @param message defines the message to log
  37544. */
  37545. static Log(message: string): void;
  37546. /**
  37547. * Write a warning message to the console
  37548. * @param message defines the message to log
  37549. */
  37550. static Warn(message: string): void;
  37551. /**
  37552. * Write an error message to the console
  37553. * @param message defines the message to log
  37554. */
  37555. static Error(message: string): void;
  37556. /**
  37557. * Gets current log cache (list of logs)
  37558. */
  37559. static get LogCache(): string;
  37560. /**
  37561. * Clears the log cache
  37562. */
  37563. static ClearLogCache(): void;
  37564. /**
  37565. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37566. */
  37567. static set LogLevels(level: number);
  37568. /**
  37569. * Checks if the window object exists
  37570. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37571. */
  37572. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37573. /**
  37574. * No performance log
  37575. */
  37576. static readonly PerformanceNoneLogLevel: number;
  37577. /**
  37578. * Use user marks to log performance
  37579. */
  37580. static readonly PerformanceUserMarkLogLevel: number;
  37581. /**
  37582. * Log performance to the console
  37583. */
  37584. static readonly PerformanceConsoleLogLevel: number;
  37585. private static _performance;
  37586. /**
  37587. * Sets the current performance log level
  37588. */
  37589. static set PerformanceLogLevel(level: number);
  37590. private static _StartPerformanceCounterDisabled;
  37591. private static _EndPerformanceCounterDisabled;
  37592. private static _StartUserMark;
  37593. private static _EndUserMark;
  37594. private static _StartPerformanceConsole;
  37595. private static _EndPerformanceConsole;
  37596. /**
  37597. * Starts a performance counter
  37598. */
  37599. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37600. /**
  37601. * Ends a specific performance coutner
  37602. */
  37603. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37604. /**
  37605. * Gets either window.performance.now() if supported or Date.now() else
  37606. */
  37607. static get Now(): number;
  37608. /**
  37609. * This method will return the name of the class used to create the instance of the given object.
  37610. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37611. * @param object the object to get the class name from
  37612. * @param isType defines if the object is actually a type
  37613. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37614. */
  37615. static GetClassName(object: any, isType?: boolean): string;
  37616. /**
  37617. * Gets the first element of an array satisfying a given predicate
  37618. * @param array defines the array to browse
  37619. * @param predicate defines the predicate to use
  37620. * @returns null if not found or the element
  37621. */
  37622. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37623. /**
  37624. * This method will return the name of the full name of the class, including its owning module (if any).
  37625. * 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).
  37626. * @param object the object to get the class name from
  37627. * @param isType defines if the object is actually a type
  37628. * @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.
  37629. * @ignorenaming
  37630. */
  37631. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37632. /**
  37633. * Returns a promise that resolves after the given amount of time.
  37634. * @param delay Number of milliseconds to delay
  37635. * @returns Promise that resolves after the given amount of time
  37636. */
  37637. static DelayAsync(delay: number): Promise<void>;
  37638. /**
  37639. * Utility function to detect if the current user agent is Safari
  37640. * @returns whether or not the current user agent is safari
  37641. */
  37642. static IsSafari(): boolean;
  37643. }
  37644. /**
  37645. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37646. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37647. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37648. * @param name The name of the class, case should be preserved
  37649. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37650. */
  37651. export function className(name: string, module?: string): (target: Object) => void;
  37652. /**
  37653. * An implementation of a loop for asynchronous functions.
  37654. */
  37655. export class AsyncLoop {
  37656. /**
  37657. * Defines the number of iterations for the loop
  37658. */
  37659. iterations: number;
  37660. /**
  37661. * Defines the current index of the loop.
  37662. */
  37663. index: number;
  37664. private _done;
  37665. private _fn;
  37666. private _successCallback;
  37667. /**
  37668. * Constructor.
  37669. * @param iterations the number of iterations.
  37670. * @param func the function to run each iteration
  37671. * @param successCallback the callback that will be called upon succesful execution
  37672. * @param offset starting offset.
  37673. */
  37674. constructor(
  37675. /**
  37676. * Defines the number of iterations for the loop
  37677. */
  37678. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37679. /**
  37680. * Execute the next iteration. Must be called after the last iteration was finished.
  37681. */
  37682. executeNext(): void;
  37683. /**
  37684. * Break the loop and run the success callback.
  37685. */
  37686. breakLoop(): void;
  37687. /**
  37688. * Create and run an async loop.
  37689. * @param iterations the number of iterations.
  37690. * @param fn the function to run each iteration
  37691. * @param successCallback the callback that will be called upon succesful execution
  37692. * @param offset starting offset.
  37693. * @returns the created async loop object
  37694. */
  37695. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37696. /**
  37697. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37698. * @param iterations total number of iterations
  37699. * @param syncedIterations number of synchronous iterations in each async iteration.
  37700. * @param fn the function to call each iteration.
  37701. * @param callback a success call back that will be called when iterating stops.
  37702. * @param breakFunction a break condition (optional)
  37703. * @param timeout timeout settings for the setTimeout function. default - 0.
  37704. * @returns the created async loop object
  37705. */
  37706. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37707. }
  37708. }
  37709. declare module BABYLON {
  37710. /**
  37711. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37712. * The underlying implementation relies on an associative array to ensure the best performances.
  37713. * The value can be anything including 'null' but except 'undefined'
  37714. */
  37715. export class StringDictionary<T> {
  37716. /**
  37717. * This will clear this dictionary and copy the content from the 'source' one.
  37718. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37719. * @param source the dictionary to take the content from and copy to this dictionary
  37720. */
  37721. copyFrom(source: StringDictionary<T>): void;
  37722. /**
  37723. * Get a value based from its key
  37724. * @param key the given key to get the matching value from
  37725. * @return the value if found, otherwise undefined is returned
  37726. */
  37727. get(key: string): T | undefined;
  37728. /**
  37729. * Get a value from its key or add it if it doesn't exist.
  37730. * This method will ensure you that a given key/data will be present in the dictionary.
  37731. * @param key the given key to get the matching value from
  37732. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37733. * The factory will only be invoked if there's no data for the given key.
  37734. * @return the value corresponding to the key.
  37735. */
  37736. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37737. /**
  37738. * Get a value from its key if present in the dictionary otherwise add it
  37739. * @param key the key to get the value from
  37740. * @param val if there's no such key/value pair in the dictionary add it with this value
  37741. * @return the value corresponding to the key
  37742. */
  37743. getOrAdd(key: string, val: T): T;
  37744. /**
  37745. * Check if there's a given key in the dictionary
  37746. * @param key the key to check for
  37747. * @return true if the key is present, false otherwise
  37748. */
  37749. contains(key: string): boolean;
  37750. /**
  37751. * Add a new key and its corresponding value
  37752. * @param key the key to add
  37753. * @param value the value corresponding to the key
  37754. * @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
  37755. */
  37756. add(key: string, value: T): boolean;
  37757. /**
  37758. * Update a specific value associated to a key
  37759. * @param key defines the key to use
  37760. * @param value defines the value to store
  37761. * @returns true if the value was updated (or false if the key was not found)
  37762. */
  37763. set(key: string, value: T): boolean;
  37764. /**
  37765. * Get the element of the given key and remove it from the dictionary
  37766. * @param key defines the key to search
  37767. * @returns the value associated with the key or null if not found
  37768. */
  37769. getAndRemove(key: string): Nullable<T>;
  37770. /**
  37771. * Remove a key/value from the dictionary.
  37772. * @param key the key to remove
  37773. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37774. */
  37775. remove(key: string): boolean;
  37776. /**
  37777. * Clear the whole content of the dictionary
  37778. */
  37779. clear(): void;
  37780. /**
  37781. * Gets the current count
  37782. */
  37783. get count(): number;
  37784. /**
  37785. * Execute a callback on each key/val of the dictionary.
  37786. * Note that you can remove any element in this dictionary in the callback implementation
  37787. * @param callback the callback to execute on a given key/value pair
  37788. */
  37789. forEach(callback: (key: string, val: T) => void): void;
  37790. /**
  37791. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37792. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37793. * Note that you can remove any element in this dictionary in the callback implementation
  37794. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37795. * @returns the first item
  37796. */
  37797. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37798. private _count;
  37799. private _data;
  37800. }
  37801. }
  37802. declare module BABYLON {
  37803. /** @hidden */
  37804. export interface ICollisionCoordinator {
  37805. createCollider(): Collider;
  37806. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37807. init(scene: Scene): void;
  37808. }
  37809. /** @hidden */
  37810. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37811. private _scene;
  37812. private _scaledPosition;
  37813. private _scaledVelocity;
  37814. private _finalPosition;
  37815. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37816. createCollider(): Collider;
  37817. init(scene: Scene): void;
  37818. private _collideWithWorld;
  37819. }
  37820. }
  37821. declare module BABYLON {
  37822. /**
  37823. * Class used to manage all inputs for the scene.
  37824. */
  37825. export class InputManager {
  37826. /** The distance in pixel that you have to move to prevent some events */
  37827. static DragMovementThreshold: number;
  37828. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37829. static LongPressDelay: number;
  37830. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37831. static DoubleClickDelay: number;
  37832. /** If you need to check double click without raising a single click at first click, enable this flag */
  37833. static ExclusiveDoubleClickMode: boolean;
  37834. private _wheelEventName;
  37835. private _onPointerMove;
  37836. private _onPointerDown;
  37837. private _onPointerUp;
  37838. private _initClickEvent;
  37839. private _initActionManager;
  37840. private _delayedSimpleClick;
  37841. private _delayedSimpleClickTimeout;
  37842. private _previousDelayedSimpleClickTimeout;
  37843. private _meshPickProceed;
  37844. private _previousButtonPressed;
  37845. private _currentPickResult;
  37846. private _previousPickResult;
  37847. private _totalPointersPressed;
  37848. private _doubleClickOccured;
  37849. private _pointerOverMesh;
  37850. private _pickedDownMesh;
  37851. private _pickedUpMesh;
  37852. private _pointerX;
  37853. private _pointerY;
  37854. private _unTranslatedPointerX;
  37855. private _unTranslatedPointerY;
  37856. private _startingPointerPosition;
  37857. private _previousStartingPointerPosition;
  37858. private _startingPointerTime;
  37859. private _previousStartingPointerTime;
  37860. private _pointerCaptures;
  37861. private _onKeyDown;
  37862. private _onKeyUp;
  37863. private _onCanvasFocusObserver;
  37864. private _onCanvasBlurObserver;
  37865. private _scene;
  37866. /**
  37867. * Creates a new InputManager
  37868. * @param scene defines the hosting scene
  37869. */
  37870. constructor(scene: Scene);
  37871. /**
  37872. * Gets the mesh that is currently under the pointer
  37873. */
  37874. get meshUnderPointer(): Nullable<AbstractMesh>;
  37875. /**
  37876. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37877. */
  37878. get unTranslatedPointer(): Vector2;
  37879. /**
  37880. * Gets or sets the current on-screen X position of the pointer
  37881. */
  37882. get pointerX(): number;
  37883. set pointerX(value: number);
  37884. /**
  37885. * Gets or sets the current on-screen Y position of the pointer
  37886. */
  37887. get pointerY(): number;
  37888. set pointerY(value: number);
  37889. private _updatePointerPosition;
  37890. private _processPointerMove;
  37891. private _setRayOnPointerInfo;
  37892. private _checkPrePointerObservable;
  37893. /**
  37894. * Use this method to simulate a pointer move on a mesh
  37895. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37896. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37897. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37898. */
  37899. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37900. /**
  37901. * Use this method to simulate a pointer down on a mesh
  37902. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37903. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37904. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37905. */
  37906. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37907. private _processPointerDown;
  37908. /** @hidden */
  37909. _isPointerSwiping(): boolean;
  37910. /**
  37911. * Use this method to simulate a pointer up on a mesh
  37912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37915. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37916. */
  37917. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37918. private _processPointerUp;
  37919. /**
  37920. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37921. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37922. * @returns true if the pointer was captured
  37923. */
  37924. isPointerCaptured(pointerId?: number): boolean;
  37925. /**
  37926. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37927. * @param attachUp defines if you want to attach events to pointerup
  37928. * @param attachDown defines if you want to attach events to pointerdown
  37929. * @param attachMove defines if you want to attach events to pointermove
  37930. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37931. */
  37932. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37933. /**
  37934. * Detaches all event handlers
  37935. */
  37936. detachControl(): void;
  37937. /**
  37938. * Force the value of meshUnderPointer
  37939. * @param mesh defines the mesh to use
  37940. */
  37941. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37942. /**
  37943. * Gets the mesh under the pointer
  37944. * @returns a Mesh or null if no mesh is under the pointer
  37945. */
  37946. getPointerOverMesh(): Nullable<AbstractMesh>;
  37947. }
  37948. }
  37949. declare module BABYLON {
  37950. /**
  37951. * This class defines the direct association between an animation and a target
  37952. */
  37953. export class TargetedAnimation {
  37954. /**
  37955. * Animation to perform
  37956. */
  37957. animation: Animation;
  37958. /**
  37959. * Target to animate
  37960. */
  37961. target: any;
  37962. /**
  37963. * Returns the string "TargetedAnimation"
  37964. * @returns "TargetedAnimation"
  37965. */
  37966. getClassName(): string;
  37967. /**
  37968. * Serialize the object
  37969. * @returns the JSON object representing the current entity
  37970. */
  37971. serialize(): any;
  37972. }
  37973. /**
  37974. * Use this class to create coordinated animations on multiple targets
  37975. */
  37976. export class AnimationGroup implements IDisposable {
  37977. /** The name of the animation group */
  37978. name: string;
  37979. private _scene;
  37980. private _targetedAnimations;
  37981. private _animatables;
  37982. private _from;
  37983. private _to;
  37984. private _isStarted;
  37985. private _isPaused;
  37986. private _speedRatio;
  37987. private _loopAnimation;
  37988. private _isAdditive;
  37989. /**
  37990. * Gets or sets the unique id of the node
  37991. */
  37992. uniqueId: number;
  37993. /**
  37994. * This observable will notify when one animation have ended
  37995. */
  37996. onAnimationEndObservable: Observable<TargetedAnimation>;
  37997. /**
  37998. * Observer raised when one animation loops
  37999. */
  38000. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38001. /**
  38002. * Observer raised when all animations have looped
  38003. */
  38004. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38005. /**
  38006. * This observable will notify when all animations have ended.
  38007. */
  38008. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38009. /**
  38010. * This observable will notify when all animations have paused.
  38011. */
  38012. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38013. /**
  38014. * This observable will notify when all animations are playing.
  38015. */
  38016. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38017. /**
  38018. * Gets the first frame
  38019. */
  38020. get from(): number;
  38021. /**
  38022. * Gets the last frame
  38023. */
  38024. get to(): number;
  38025. /**
  38026. * Define if the animations are started
  38027. */
  38028. get isStarted(): boolean;
  38029. /**
  38030. * Gets a value indicating that the current group is playing
  38031. */
  38032. get isPlaying(): boolean;
  38033. /**
  38034. * Gets or sets the speed ratio to use for all animations
  38035. */
  38036. get speedRatio(): number;
  38037. /**
  38038. * Gets or sets the speed ratio to use for all animations
  38039. */
  38040. set speedRatio(value: number);
  38041. /**
  38042. * Gets or sets if all animations should loop or not
  38043. */
  38044. get loopAnimation(): boolean;
  38045. set loopAnimation(value: boolean);
  38046. /**
  38047. * Gets or sets if all animations should be evaluated additively
  38048. */
  38049. get isAdditive(): boolean;
  38050. set isAdditive(value: boolean);
  38051. /**
  38052. * Gets the targeted animations for this animation group
  38053. */
  38054. get targetedAnimations(): Array<TargetedAnimation>;
  38055. /**
  38056. * returning the list of animatables controlled by this animation group.
  38057. */
  38058. get animatables(): Array<Animatable>;
  38059. /**
  38060. * Gets the list of target animations
  38061. */
  38062. get children(): TargetedAnimation[];
  38063. /**
  38064. * Instantiates a new Animation Group.
  38065. * This helps managing several animations at once.
  38066. * @see http://doc.babylonjs.com/how_to/group
  38067. * @param name Defines the name of the group
  38068. * @param scene Defines the scene the group belongs to
  38069. */
  38070. constructor(
  38071. /** The name of the animation group */
  38072. name: string, scene?: Nullable<Scene>);
  38073. /**
  38074. * Add an animation (with its target) in the group
  38075. * @param animation defines the animation we want to add
  38076. * @param target defines the target of the animation
  38077. * @returns the TargetedAnimation object
  38078. */
  38079. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38080. /**
  38081. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38082. * It can add constant keys at begin or end
  38083. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38084. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38085. * @returns the animation group
  38086. */
  38087. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38088. private _animationLoopCount;
  38089. private _animationLoopFlags;
  38090. private _processLoop;
  38091. /**
  38092. * Start all animations on given targets
  38093. * @param loop defines if animations must loop
  38094. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38095. * @param from defines the from key (optional)
  38096. * @param to defines the to key (optional)
  38097. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38098. * @returns the current animation group
  38099. */
  38100. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38101. /**
  38102. * Pause all animations
  38103. * @returns the animation group
  38104. */
  38105. pause(): AnimationGroup;
  38106. /**
  38107. * Play all animations to initial state
  38108. * This function will start() the animations if they were not started or will restart() them if they were paused
  38109. * @param loop defines if animations must loop
  38110. * @returns the animation group
  38111. */
  38112. play(loop?: boolean): AnimationGroup;
  38113. /**
  38114. * Reset all animations to initial state
  38115. * @returns the animation group
  38116. */
  38117. reset(): AnimationGroup;
  38118. /**
  38119. * Restart animations from key 0
  38120. * @returns the animation group
  38121. */
  38122. restart(): AnimationGroup;
  38123. /**
  38124. * Stop all animations
  38125. * @returns the animation group
  38126. */
  38127. stop(): AnimationGroup;
  38128. /**
  38129. * Set animation weight for all animatables
  38130. * @param weight defines the weight to use
  38131. * @return the animationGroup
  38132. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38133. */
  38134. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38135. /**
  38136. * Synchronize and normalize all animatables with a source animatable
  38137. * @param root defines the root animatable to synchronize with
  38138. * @return the animationGroup
  38139. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38140. */
  38141. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38142. /**
  38143. * Goes to a specific frame in this animation group
  38144. * @param frame the frame number to go to
  38145. * @return the animationGroup
  38146. */
  38147. goToFrame(frame: number): AnimationGroup;
  38148. /**
  38149. * Dispose all associated resources
  38150. */
  38151. dispose(): void;
  38152. private _checkAnimationGroupEnded;
  38153. /**
  38154. * Clone the current animation group and returns a copy
  38155. * @param newName defines the name of the new group
  38156. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38157. * @returns the new aniamtion group
  38158. */
  38159. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38160. /**
  38161. * Serializes the animationGroup to an object
  38162. * @returns Serialized object
  38163. */
  38164. serialize(): any;
  38165. /**
  38166. * Returns a new AnimationGroup object parsed from the source provided.
  38167. * @param parsedAnimationGroup defines the source
  38168. * @param scene defines the scene that will receive the animationGroup
  38169. * @returns a new AnimationGroup
  38170. */
  38171. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38172. /**
  38173. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38174. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38175. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38176. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38177. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38178. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38179. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38180. */
  38181. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38182. /**
  38183. * Returns the string "AnimationGroup"
  38184. * @returns "AnimationGroup"
  38185. */
  38186. getClassName(): string;
  38187. /**
  38188. * Creates a detailled string about the object
  38189. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38190. * @returns a string representing the object
  38191. */
  38192. toString(fullDetails?: boolean): string;
  38193. }
  38194. }
  38195. declare module BABYLON {
  38196. /**
  38197. * Define an interface for all classes that will hold resources
  38198. */
  38199. export interface IDisposable {
  38200. /**
  38201. * Releases all held resources
  38202. */
  38203. dispose(): void;
  38204. }
  38205. /** Interface defining initialization parameters for Scene class */
  38206. export interface SceneOptions {
  38207. /**
  38208. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38209. * It will improve performance when the number of geometries becomes important.
  38210. */
  38211. useGeometryUniqueIdsMap?: boolean;
  38212. /**
  38213. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38214. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38215. */
  38216. useMaterialMeshMap?: boolean;
  38217. /**
  38218. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38219. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38220. */
  38221. useClonedMeshMap?: boolean;
  38222. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38223. virtual?: boolean;
  38224. }
  38225. /**
  38226. * Represents a scene to be rendered by the engine.
  38227. * @see http://doc.babylonjs.com/features/scene
  38228. */
  38229. export class Scene extends AbstractScene implements IAnimatable {
  38230. /** The fog is deactivated */
  38231. static readonly FOGMODE_NONE: number;
  38232. /** The fog density is following an exponential function */
  38233. static readonly FOGMODE_EXP: number;
  38234. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38235. static readonly FOGMODE_EXP2: number;
  38236. /** The fog density is following a linear function. */
  38237. static readonly FOGMODE_LINEAR: number;
  38238. /**
  38239. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38240. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38241. */
  38242. static MinDeltaTime: number;
  38243. /**
  38244. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38245. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38246. */
  38247. static MaxDeltaTime: number;
  38248. /**
  38249. * Factory used to create the default material.
  38250. * @param name The name of the material to create
  38251. * @param scene The scene to create the material for
  38252. * @returns The default material
  38253. */
  38254. static DefaultMaterialFactory(scene: Scene): Material;
  38255. /**
  38256. * Factory used to create the a collision coordinator.
  38257. * @returns The collision coordinator
  38258. */
  38259. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38260. /** @hidden */
  38261. _inputManager: InputManager;
  38262. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38263. cameraToUseForPointers: Nullable<Camera>;
  38264. /** @hidden */
  38265. readonly _isScene: boolean;
  38266. /** @hidden */
  38267. _blockEntityCollection: boolean;
  38268. /**
  38269. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38270. */
  38271. autoClear: boolean;
  38272. /**
  38273. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38274. */
  38275. autoClearDepthAndStencil: boolean;
  38276. /**
  38277. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38278. */
  38279. clearColor: Color4;
  38280. /**
  38281. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38282. */
  38283. ambientColor: Color3;
  38284. /**
  38285. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38286. * It should only be one of the following (if not the default embedded one):
  38287. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38288. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38289. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38290. * The material properties need to be setup according to the type of texture in use.
  38291. */
  38292. environmentBRDFTexture: BaseTexture;
  38293. /** @hidden */
  38294. protected _environmentTexture: Nullable<BaseTexture>;
  38295. /**
  38296. * Texture used in all pbr material as the reflection texture.
  38297. * As in the majority of the scene they are the same (exception for multi room and so on),
  38298. * this is easier to reference from here than from all the materials.
  38299. */
  38300. get environmentTexture(): Nullable<BaseTexture>;
  38301. /**
  38302. * Texture used in all pbr material as the reflection texture.
  38303. * As in the majority of the scene they are the same (exception for multi room and so on),
  38304. * this is easier to set here than in all the materials.
  38305. */
  38306. set environmentTexture(value: Nullable<BaseTexture>);
  38307. /** @hidden */
  38308. protected _environmentIntensity: number;
  38309. /**
  38310. * Intensity of the environment in all pbr material.
  38311. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38312. * As in the majority of the scene they are the same (exception for multi room and so on),
  38313. * this is easier to reference from here than from all the materials.
  38314. */
  38315. get environmentIntensity(): number;
  38316. /**
  38317. * Intensity of the environment in all pbr material.
  38318. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38319. * As in the majority of the scene they are the same (exception for multi room and so on),
  38320. * this is easier to set here than in all the materials.
  38321. */
  38322. set environmentIntensity(value: number);
  38323. /** @hidden */
  38324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38325. /**
  38326. * Default image processing configuration used either in the rendering
  38327. * Forward main pass or through the imageProcessingPostProcess if present.
  38328. * As in the majority of the scene they are the same (exception for multi camera),
  38329. * this is easier to reference from here than from all the materials and post process.
  38330. *
  38331. * No setter as we it is a shared configuration, you can set the values instead.
  38332. */
  38333. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38334. private _forceWireframe;
  38335. /**
  38336. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38337. */
  38338. set forceWireframe(value: boolean);
  38339. get forceWireframe(): boolean;
  38340. private _skipFrustumClipping;
  38341. /**
  38342. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38343. */
  38344. set skipFrustumClipping(value: boolean);
  38345. get skipFrustumClipping(): boolean;
  38346. private _forcePointsCloud;
  38347. /**
  38348. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38349. */
  38350. set forcePointsCloud(value: boolean);
  38351. get forcePointsCloud(): boolean;
  38352. /**
  38353. * Gets or sets the active clipplane 1
  38354. */
  38355. clipPlane: Nullable<Plane>;
  38356. /**
  38357. * Gets or sets the active clipplane 2
  38358. */
  38359. clipPlane2: Nullable<Plane>;
  38360. /**
  38361. * Gets or sets the active clipplane 3
  38362. */
  38363. clipPlane3: Nullable<Plane>;
  38364. /**
  38365. * Gets or sets the active clipplane 4
  38366. */
  38367. clipPlane4: Nullable<Plane>;
  38368. /**
  38369. * Gets or sets the active clipplane 5
  38370. */
  38371. clipPlane5: Nullable<Plane>;
  38372. /**
  38373. * Gets or sets the active clipplane 6
  38374. */
  38375. clipPlane6: Nullable<Plane>;
  38376. /**
  38377. * Gets or sets a boolean indicating if animations are enabled
  38378. */
  38379. animationsEnabled: boolean;
  38380. private _animationPropertiesOverride;
  38381. /**
  38382. * Gets or sets the animation properties override
  38383. */
  38384. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38385. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38386. /**
  38387. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38388. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38389. */
  38390. useConstantAnimationDeltaTime: boolean;
  38391. /**
  38392. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38393. * Please note that it requires to run a ray cast through the scene on every frame
  38394. */
  38395. constantlyUpdateMeshUnderPointer: boolean;
  38396. /**
  38397. * Defines the HTML cursor to use when hovering over interactive elements
  38398. */
  38399. hoverCursor: string;
  38400. /**
  38401. * Defines the HTML default cursor to use (empty by default)
  38402. */
  38403. defaultCursor: string;
  38404. /**
  38405. * Defines whether cursors are handled by the scene.
  38406. */
  38407. doNotHandleCursors: boolean;
  38408. /**
  38409. * This is used to call preventDefault() on pointer down
  38410. * in order to block unwanted artifacts like system double clicks
  38411. */
  38412. preventDefaultOnPointerDown: boolean;
  38413. /**
  38414. * This is used to call preventDefault() on pointer up
  38415. * in order to block unwanted artifacts like system double clicks
  38416. */
  38417. preventDefaultOnPointerUp: boolean;
  38418. /**
  38419. * Gets or sets user defined metadata
  38420. */
  38421. metadata: any;
  38422. /**
  38423. * For internal use only. Please do not use.
  38424. */
  38425. reservedDataStore: any;
  38426. /**
  38427. * Gets the name of the plugin used to load this scene (null by default)
  38428. */
  38429. loadingPluginName: string;
  38430. /**
  38431. * Use this array to add regular expressions used to disable offline support for specific urls
  38432. */
  38433. disableOfflineSupportExceptionRules: RegExp[];
  38434. /**
  38435. * An event triggered when the scene is disposed.
  38436. */
  38437. onDisposeObservable: Observable<Scene>;
  38438. private _onDisposeObserver;
  38439. /** Sets a function to be executed when this scene is disposed. */
  38440. set onDispose(callback: () => void);
  38441. /**
  38442. * An event triggered before rendering the scene (right after animations and physics)
  38443. */
  38444. onBeforeRenderObservable: Observable<Scene>;
  38445. private _onBeforeRenderObserver;
  38446. /** Sets a function to be executed before rendering this scene */
  38447. set beforeRender(callback: Nullable<() => void>);
  38448. /**
  38449. * An event triggered after rendering the scene
  38450. */
  38451. onAfterRenderObservable: Observable<Scene>;
  38452. /**
  38453. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38454. */
  38455. onAfterRenderCameraObservable: Observable<Camera>;
  38456. private _onAfterRenderObserver;
  38457. /** Sets a function to be executed after rendering this scene */
  38458. set afterRender(callback: Nullable<() => void>);
  38459. /**
  38460. * An event triggered before animating the scene
  38461. */
  38462. onBeforeAnimationsObservable: Observable<Scene>;
  38463. /**
  38464. * An event triggered after animations processing
  38465. */
  38466. onAfterAnimationsObservable: Observable<Scene>;
  38467. /**
  38468. * An event triggered before draw calls are ready to be sent
  38469. */
  38470. onBeforeDrawPhaseObservable: Observable<Scene>;
  38471. /**
  38472. * An event triggered after draw calls have been sent
  38473. */
  38474. onAfterDrawPhaseObservable: Observable<Scene>;
  38475. /**
  38476. * An event triggered when the scene is ready
  38477. */
  38478. onReadyObservable: Observable<Scene>;
  38479. /**
  38480. * An event triggered before rendering a camera
  38481. */
  38482. onBeforeCameraRenderObservable: Observable<Camera>;
  38483. private _onBeforeCameraRenderObserver;
  38484. /** Sets a function to be executed before rendering a camera*/
  38485. set beforeCameraRender(callback: () => void);
  38486. /**
  38487. * An event triggered after rendering a camera
  38488. */
  38489. onAfterCameraRenderObservable: Observable<Camera>;
  38490. private _onAfterCameraRenderObserver;
  38491. /** Sets a function to be executed after rendering a camera*/
  38492. set afterCameraRender(callback: () => void);
  38493. /**
  38494. * An event triggered when active meshes evaluation is about to start
  38495. */
  38496. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38497. /**
  38498. * An event triggered when active meshes evaluation is done
  38499. */
  38500. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38501. /**
  38502. * An event triggered when particles rendering is about to start
  38503. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38504. */
  38505. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38506. /**
  38507. * An event triggered when particles rendering is done
  38508. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38509. */
  38510. onAfterParticlesRenderingObservable: Observable<Scene>;
  38511. /**
  38512. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38513. */
  38514. onDataLoadedObservable: Observable<Scene>;
  38515. /**
  38516. * An event triggered when a camera is created
  38517. */
  38518. onNewCameraAddedObservable: Observable<Camera>;
  38519. /**
  38520. * An event triggered when a camera is removed
  38521. */
  38522. onCameraRemovedObservable: Observable<Camera>;
  38523. /**
  38524. * An event triggered when a light is created
  38525. */
  38526. onNewLightAddedObservable: Observable<Light>;
  38527. /**
  38528. * An event triggered when a light is removed
  38529. */
  38530. onLightRemovedObservable: Observable<Light>;
  38531. /**
  38532. * An event triggered when a geometry is created
  38533. */
  38534. onNewGeometryAddedObservable: Observable<Geometry>;
  38535. /**
  38536. * An event triggered when a geometry is removed
  38537. */
  38538. onGeometryRemovedObservable: Observable<Geometry>;
  38539. /**
  38540. * An event triggered when a transform node is created
  38541. */
  38542. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38543. /**
  38544. * An event triggered when a transform node is removed
  38545. */
  38546. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38547. /**
  38548. * An event triggered when a mesh is created
  38549. */
  38550. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38551. /**
  38552. * An event triggered when a mesh is removed
  38553. */
  38554. onMeshRemovedObservable: Observable<AbstractMesh>;
  38555. /**
  38556. * An event triggered when a skeleton is created
  38557. */
  38558. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38559. /**
  38560. * An event triggered when a skeleton is removed
  38561. */
  38562. onSkeletonRemovedObservable: Observable<Skeleton>;
  38563. /**
  38564. * An event triggered when a material is created
  38565. */
  38566. onNewMaterialAddedObservable: Observable<Material>;
  38567. /**
  38568. * An event triggered when a material is removed
  38569. */
  38570. onMaterialRemovedObservable: Observable<Material>;
  38571. /**
  38572. * An event triggered when a texture is created
  38573. */
  38574. onNewTextureAddedObservable: Observable<BaseTexture>;
  38575. /**
  38576. * An event triggered when a texture is removed
  38577. */
  38578. onTextureRemovedObservable: Observable<BaseTexture>;
  38579. /**
  38580. * An event triggered when render targets are about to be rendered
  38581. * Can happen multiple times per frame.
  38582. */
  38583. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38584. /**
  38585. * An event triggered when render targets were rendered.
  38586. * Can happen multiple times per frame.
  38587. */
  38588. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38589. /**
  38590. * An event triggered before calculating deterministic simulation step
  38591. */
  38592. onBeforeStepObservable: Observable<Scene>;
  38593. /**
  38594. * An event triggered after calculating deterministic simulation step
  38595. */
  38596. onAfterStepObservable: Observable<Scene>;
  38597. /**
  38598. * An event triggered when the activeCamera property is updated
  38599. */
  38600. onActiveCameraChanged: Observable<Scene>;
  38601. /**
  38602. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38603. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38604. * 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)
  38605. */
  38606. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38607. /**
  38608. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38609. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38610. * 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)
  38611. */
  38612. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38613. /**
  38614. * This Observable will when a mesh has been imported into the scene.
  38615. */
  38616. onMeshImportedObservable: Observable<AbstractMesh>;
  38617. /**
  38618. * This Observable will when an animation file has been imported into the scene.
  38619. */
  38620. onAnimationFileImportedObservable: Observable<Scene>;
  38621. /**
  38622. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38623. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38624. */
  38625. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38626. /** @hidden */
  38627. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38628. /**
  38629. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38630. */
  38631. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38632. /**
  38633. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38634. */
  38635. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38636. /**
  38637. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38638. */
  38639. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38640. /** Callback called when a pointer move is detected */
  38641. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38642. /** Callback called when a pointer down is detected */
  38643. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38644. /** Callback called when a pointer up is detected */
  38645. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38646. /** Callback called when a pointer pick is detected */
  38647. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38648. /**
  38649. * 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).
  38650. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38651. */
  38652. onPrePointerObservable: Observable<PointerInfoPre>;
  38653. /**
  38654. * Observable event triggered each time an input event is received from the rendering canvas
  38655. */
  38656. onPointerObservable: Observable<PointerInfo>;
  38657. /**
  38658. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38659. */
  38660. get unTranslatedPointer(): Vector2;
  38661. /**
  38662. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38663. */
  38664. static get DragMovementThreshold(): number;
  38665. static set DragMovementThreshold(value: number);
  38666. /**
  38667. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38668. */
  38669. static get LongPressDelay(): number;
  38670. static set LongPressDelay(value: number);
  38671. /**
  38672. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38673. */
  38674. static get DoubleClickDelay(): number;
  38675. static set DoubleClickDelay(value: number);
  38676. /** If you need to check double click without raising a single click at first click, enable this flag */
  38677. static get ExclusiveDoubleClickMode(): boolean;
  38678. static set ExclusiveDoubleClickMode(value: boolean);
  38679. /** @hidden */
  38680. _mirroredCameraPosition: Nullable<Vector3>;
  38681. /**
  38682. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38683. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38684. */
  38685. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38686. /**
  38687. * Observable event triggered each time an keyboard event is received from the hosting window
  38688. */
  38689. onKeyboardObservable: Observable<KeyboardInfo>;
  38690. private _useRightHandedSystem;
  38691. /**
  38692. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38693. */
  38694. set useRightHandedSystem(value: boolean);
  38695. get useRightHandedSystem(): boolean;
  38696. private _timeAccumulator;
  38697. private _currentStepId;
  38698. private _currentInternalStep;
  38699. /**
  38700. * Sets the step Id used by deterministic lock step
  38701. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38702. * @param newStepId defines the step Id
  38703. */
  38704. setStepId(newStepId: number): void;
  38705. /**
  38706. * Gets the step Id used by deterministic lock step
  38707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38708. * @returns the step Id
  38709. */
  38710. getStepId(): number;
  38711. /**
  38712. * Gets the internal step used by deterministic lock step
  38713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38714. * @returns the internal step
  38715. */
  38716. getInternalStep(): number;
  38717. private _fogEnabled;
  38718. /**
  38719. * Gets or sets a boolean indicating if fog is enabled on this scene
  38720. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38721. * (Default is true)
  38722. */
  38723. set fogEnabled(value: boolean);
  38724. get fogEnabled(): boolean;
  38725. private _fogMode;
  38726. /**
  38727. * Gets or sets the fog mode to use
  38728. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38729. * | mode | value |
  38730. * | --- | --- |
  38731. * | FOGMODE_NONE | 0 |
  38732. * | FOGMODE_EXP | 1 |
  38733. * | FOGMODE_EXP2 | 2 |
  38734. * | FOGMODE_LINEAR | 3 |
  38735. */
  38736. set fogMode(value: number);
  38737. get fogMode(): number;
  38738. /**
  38739. * Gets or sets the fog color to use
  38740. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38741. * (Default is Color3(0.2, 0.2, 0.3))
  38742. */
  38743. fogColor: Color3;
  38744. /**
  38745. * Gets or sets the fog density to use
  38746. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38747. * (Default is 0.1)
  38748. */
  38749. fogDensity: number;
  38750. /**
  38751. * Gets or sets the fog start distance to use
  38752. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38753. * (Default is 0)
  38754. */
  38755. fogStart: number;
  38756. /**
  38757. * Gets or sets the fog end distance to use
  38758. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38759. * (Default is 1000)
  38760. */
  38761. fogEnd: number;
  38762. private _shadowsEnabled;
  38763. /**
  38764. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38765. */
  38766. set shadowsEnabled(value: boolean);
  38767. get shadowsEnabled(): boolean;
  38768. private _lightsEnabled;
  38769. /**
  38770. * Gets or sets a boolean indicating if lights are enabled on this scene
  38771. */
  38772. set lightsEnabled(value: boolean);
  38773. get lightsEnabled(): boolean;
  38774. /** All of the active cameras added to this scene. */
  38775. activeCameras: Camera[];
  38776. /** @hidden */
  38777. _activeCamera: Nullable<Camera>;
  38778. /** Gets or sets the current active camera */
  38779. get activeCamera(): Nullable<Camera>;
  38780. set activeCamera(value: Nullable<Camera>);
  38781. private _defaultMaterial;
  38782. /** The default material used on meshes when no material is affected */
  38783. get defaultMaterial(): Material;
  38784. /** The default material used on meshes when no material is affected */
  38785. set defaultMaterial(value: Material);
  38786. private _texturesEnabled;
  38787. /**
  38788. * Gets or sets a boolean indicating if textures are enabled on this scene
  38789. */
  38790. set texturesEnabled(value: boolean);
  38791. get texturesEnabled(): boolean;
  38792. /**
  38793. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38794. */
  38795. physicsEnabled: boolean;
  38796. /**
  38797. * Gets or sets a boolean indicating if particles are enabled on this scene
  38798. */
  38799. particlesEnabled: boolean;
  38800. /**
  38801. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38802. */
  38803. spritesEnabled: boolean;
  38804. private _skeletonsEnabled;
  38805. /**
  38806. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38807. */
  38808. set skeletonsEnabled(value: boolean);
  38809. get skeletonsEnabled(): boolean;
  38810. /**
  38811. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38812. */
  38813. lensFlaresEnabled: boolean;
  38814. /**
  38815. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38817. */
  38818. collisionsEnabled: boolean;
  38819. private _collisionCoordinator;
  38820. /** @hidden */
  38821. get collisionCoordinator(): ICollisionCoordinator;
  38822. /**
  38823. * Defines the gravity applied to this scene (used only for collisions)
  38824. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38825. */
  38826. gravity: Vector3;
  38827. /**
  38828. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38829. */
  38830. postProcessesEnabled: boolean;
  38831. /**
  38832. * The list of postprocesses added to the scene
  38833. */
  38834. postProcesses: PostProcess[];
  38835. /**
  38836. * Gets the current postprocess manager
  38837. */
  38838. postProcessManager: PostProcessManager;
  38839. /**
  38840. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38841. */
  38842. renderTargetsEnabled: boolean;
  38843. /**
  38844. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38845. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38846. */
  38847. dumpNextRenderTargets: boolean;
  38848. /**
  38849. * The list of user defined render targets added to the scene
  38850. */
  38851. customRenderTargets: RenderTargetTexture[];
  38852. /**
  38853. * Defines if texture loading must be delayed
  38854. * If true, textures will only be loaded when they need to be rendered
  38855. */
  38856. useDelayedTextureLoading: boolean;
  38857. /**
  38858. * Gets the list of meshes imported to the scene through SceneLoader
  38859. */
  38860. importedMeshesFiles: String[];
  38861. /**
  38862. * Gets or sets a boolean indicating if probes are enabled on this scene
  38863. */
  38864. probesEnabled: boolean;
  38865. /**
  38866. * Gets or sets the current offline provider to use to store scene data
  38867. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38868. */
  38869. offlineProvider: IOfflineProvider;
  38870. /**
  38871. * Gets or sets the action manager associated with the scene
  38872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38873. */
  38874. actionManager: AbstractActionManager;
  38875. private _meshesForIntersections;
  38876. /**
  38877. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38878. */
  38879. proceduralTexturesEnabled: boolean;
  38880. private _engine;
  38881. private _totalVertices;
  38882. /** @hidden */
  38883. _activeIndices: PerfCounter;
  38884. /** @hidden */
  38885. _activeParticles: PerfCounter;
  38886. /** @hidden */
  38887. _activeBones: PerfCounter;
  38888. private _animationRatio;
  38889. /** @hidden */
  38890. _animationTimeLast: number;
  38891. /** @hidden */
  38892. _animationTime: number;
  38893. /**
  38894. * Gets or sets a general scale for animation speed
  38895. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38896. */
  38897. animationTimeScale: number;
  38898. /** @hidden */
  38899. _cachedMaterial: Nullable<Material>;
  38900. /** @hidden */
  38901. _cachedEffect: Nullable<Effect>;
  38902. /** @hidden */
  38903. _cachedVisibility: Nullable<number>;
  38904. private _renderId;
  38905. private _frameId;
  38906. private _executeWhenReadyTimeoutId;
  38907. private _intermediateRendering;
  38908. private _viewUpdateFlag;
  38909. private _projectionUpdateFlag;
  38910. /** @hidden */
  38911. _toBeDisposed: Nullable<IDisposable>[];
  38912. private _activeRequests;
  38913. /** @hidden */
  38914. _pendingData: any[];
  38915. private _isDisposed;
  38916. /**
  38917. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38918. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38919. */
  38920. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38921. private _activeMeshes;
  38922. private _processedMaterials;
  38923. private _renderTargets;
  38924. /** @hidden */
  38925. _activeParticleSystems: SmartArray<IParticleSystem>;
  38926. private _activeSkeletons;
  38927. private _softwareSkinnedMeshes;
  38928. private _renderingManager;
  38929. /** @hidden */
  38930. _activeAnimatables: Animatable[];
  38931. private _transformMatrix;
  38932. private _sceneUbo;
  38933. /** @hidden */
  38934. _viewMatrix: Matrix;
  38935. private _projectionMatrix;
  38936. /** @hidden */
  38937. _forcedViewPosition: Nullable<Vector3>;
  38938. /** @hidden */
  38939. _frustumPlanes: Plane[];
  38940. /**
  38941. * Gets the list of frustum planes (built from the active camera)
  38942. */
  38943. get frustumPlanes(): Plane[];
  38944. /**
  38945. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38946. * This is useful if there are more lights that the maximum simulteanous authorized
  38947. */
  38948. requireLightSorting: boolean;
  38949. /** @hidden */
  38950. readonly useMaterialMeshMap: boolean;
  38951. /** @hidden */
  38952. readonly useClonedMeshMap: boolean;
  38953. private _externalData;
  38954. private _uid;
  38955. /**
  38956. * @hidden
  38957. * Backing store of defined scene components.
  38958. */
  38959. _components: ISceneComponent[];
  38960. /**
  38961. * @hidden
  38962. * Backing store of defined scene components.
  38963. */
  38964. _serializableComponents: ISceneSerializableComponent[];
  38965. /**
  38966. * List of components to register on the next registration step.
  38967. */
  38968. private _transientComponents;
  38969. /**
  38970. * Registers the transient components if needed.
  38971. */
  38972. private _registerTransientComponents;
  38973. /**
  38974. * @hidden
  38975. * Add a component to the scene.
  38976. * Note that the ccomponent could be registered on th next frame if this is called after
  38977. * the register component stage.
  38978. * @param component Defines the component to add to the scene
  38979. */
  38980. _addComponent(component: ISceneComponent): void;
  38981. /**
  38982. * @hidden
  38983. * Gets a component from the scene.
  38984. * @param name defines the name of the component to retrieve
  38985. * @returns the component or null if not present
  38986. */
  38987. _getComponent(name: string): Nullable<ISceneComponent>;
  38988. /**
  38989. * @hidden
  38990. * Defines the actions happening before camera updates.
  38991. */
  38992. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38993. /**
  38994. * @hidden
  38995. * Defines the actions happening before clear the canvas.
  38996. */
  38997. _beforeClearStage: Stage<SimpleStageAction>;
  38998. /**
  38999. * @hidden
  39000. * Defines the actions when collecting render targets for the frame.
  39001. */
  39002. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39003. /**
  39004. * @hidden
  39005. * Defines the actions happening for one camera in the frame.
  39006. */
  39007. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39008. /**
  39009. * @hidden
  39010. * Defines the actions happening during the per mesh ready checks.
  39011. */
  39012. _isReadyForMeshStage: Stage<MeshStageAction>;
  39013. /**
  39014. * @hidden
  39015. * Defines the actions happening before evaluate active mesh checks.
  39016. */
  39017. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39018. /**
  39019. * @hidden
  39020. * Defines the actions happening during the evaluate sub mesh checks.
  39021. */
  39022. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39023. /**
  39024. * @hidden
  39025. * Defines the actions happening during the active mesh stage.
  39026. */
  39027. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39028. /**
  39029. * @hidden
  39030. * Defines the actions happening during the per camera render target step.
  39031. */
  39032. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39033. /**
  39034. * @hidden
  39035. * Defines the actions happening just before the active camera is drawing.
  39036. */
  39037. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39038. /**
  39039. * @hidden
  39040. * Defines the actions happening just before a render target is drawing.
  39041. */
  39042. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39043. /**
  39044. * @hidden
  39045. * Defines the actions happening just before a rendering group is drawing.
  39046. */
  39047. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39048. /**
  39049. * @hidden
  39050. * Defines the actions happening just before a mesh is drawing.
  39051. */
  39052. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39053. /**
  39054. * @hidden
  39055. * Defines the actions happening just after a mesh has been drawn.
  39056. */
  39057. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39058. /**
  39059. * @hidden
  39060. * Defines the actions happening just after a rendering group has been drawn.
  39061. */
  39062. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39063. /**
  39064. * @hidden
  39065. * Defines the actions happening just after the active camera has been drawn.
  39066. */
  39067. _afterCameraDrawStage: Stage<CameraStageAction>;
  39068. /**
  39069. * @hidden
  39070. * Defines the actions happening just after a render target has been drawn.
  39071. */
  39072. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39073. /**
  39074. * @hidden
  39075. * Defines the actions happening just after rendering all cameras and computing intersections.
  39076. */
  39077. _afterRenderStage: Stage<SimpleStageAction>;
  39078. /**
  39079. * @hidden
  39080. * Defines the actions happening when a pointer move event happens.
  39081. */
  39082. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39083. /**
  39084. * @hidden
  39085. * Defines the actions happening when a pointer down event happens.
  39086. */
  39087. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39088. /**
  39089. * @hidden
  39090. * Defines the actions happening when a pointer up event happens.
  39091. */
  39092. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39093. /**
  39094. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39095. */
  39096. private geometriesByUniqueId;
  39097. /**
  39098. * Creates a new Scene
  39099. * @param engine defines the engine to use to render this scene
  39100. * @param options defines the scene options
  39101. */
  39102. constructor(engine: Engine, options?: SceneOptions);
  39103. /**
  39104. * Gets a string idenfifying the name of the class
  39105. * @returns "Scene" string
  39106. */
  39107. getClassName(): string;
  39108. private _defaultMeshCandidates;
  39109. /**
  39110. * @hidden
  39111. */
  39112. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39113. private _defaultSubMeshCandidates;
  39114. /**
  39115. * @hidden
  39116. */
  39117. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39118. /**
  39119. * Sets the default candidate providers for the scene.
  39120. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39121. * and getCollidingSubMeshCandidates to their default function
  39122. */
  39123. setDefaultCandidateProviders(): void;
  39124. /**
  39125. * Gets the mesh that is currently under the pointer
  39126. */
  39127. get meshUnderPointer(): Nullable<AbstractMesh>;
  39128. /**
  39129. * Gets or sets the current on-screen X position of the pointer
  39130. */
  39131. get pointerX(): number;
  39132. set pointerX(value: number);
  39133. /**
  39134. * Gets or sets the current on-screen Y position of the pointer
  39135. */
  39136. get pointerY(): number;
  39137. set pointerY(value: number);
  39138. /**
  39139. * Gets the cached material (ie. the latest rendered one)
  39140. * @returns the cached material
  39141. */
  39142. getCachedMaterial(): Nullable<Material>;
  39143. /**
  39144. * Gets the cached effect (ie. the latest rendered one)
  39145. * @returns the cached effect
  39146. */
  39147. getCachedEffect(): Nullable<Effect>;
  39148. /**
  39149. * Gets the cached visibility state (ie. the latest rendered one)
  39150. * @returns the cached visibility state
  39151. */
  39152. getCachedVisibility(): Nullable<number>;
  39153. /**
  39154. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39155. * @param material defines the current material
  39156. * @param effect defines the current effect
  39157. * @param visibility defines the current visibility state
  39158. * @returns true if one parameter is not cached
  39159. */
  39160. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39161. /**
  39162. * Gets the engine associated with the scene
  39163. * @returns an Engine
  39164. */
  39165. getEngine(): Engine;
  39166. /**
  39167. * Gets the total number of vertices rendered per frame
  39168. * @returns the total number of vertices rendered per frame
  39169. */
  39170. getTotalVertices(): number;
  39171. /**
  39172. * Gets the performance counter for total vertices
  39173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39174. */
  39175. get totalVerticesPerfCounter(): PerfCounter;
  39176. /**
  39177. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39178. * @returns the total number of active indices rendered per frame
  39179. */
  39180. getActiveIndices(): number;
  39181. /**
  39182. * Gets the performance counter for active indices
  39183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39184. */
  39185. get totalActiveIndicesPerfCounter(): PerfCounter;
  39186. /**
  39187. * Gets the total number of active particles rendered per frame
  39188. * @returns the total number of active particles rendered per frame
  39189. */
  39190. getActiveParticles(): number;
  39191. /**
  39192. * Gets the performance counter for active particles
  39193. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39194. */
  39195. get activeParticlesPerfCounter(): PerfCounter;
  39196. /**
  39197. * Gets the total number of active bones rendered per frame
  39198. * @returns the total number of active bones rendered per frame
  39199. */
  39200. getActiveBones(): number;
  39201. /**
  39202. * Gets the performance counter for active bones
  39203. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39204. */
  39205. get activeBonesPerfCounter(): PerfCounter;
  39206. /**
  39207. * Gets the array of active meshes
  39208. * @returns an array of AbstractMesh
  39209. */
  39210. getActiveMeshes(): SmartArray<AbstractMesh>;
  39211. /**
  39212. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39213. * @returns a number
  39214. */
  39215. getAnimationRatio(): number;
  39216. /**
  39217. * Gets an unique Id for the current render phase
  39218. * @returns a number
  39219. */
  39220. getRenderId(): number;
  39221. /**
  39222. * Gets an unique Id for the current frame
  39223. * @returns a number
  39224. */
  39225. getFrameId(): number;
  39226. /** Call this function if you want to manually increment the render Id*/
  39227. incrementRenderId(): void;
  39228. private _createUbo;
  39229. /**
  39230. * Use this method to simulate a pointer move on a mesh
  39231. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39232. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39233. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39234. * @returns the current scene
  39235. */
  39236. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39237. /**
  39238. * Use this method to simulate a pointer down on a mesh
  39239. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39240. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39241. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39242. * @returns the current scene
  39243. */
  39244. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39245. /**
  39246. * Use this method to simulate a pointer up on a mesh
  39247. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39248. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39249. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39250. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39251. * @returns the current scene
  39252. */
  39253. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39254. /**
  39255. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39256. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39257. * @returns true if the pointer was captured
  39258. */
  39259. isPointerCaptured(pointerId?: number): boolean;
  39260. /**
  39261. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39262. * @param attachUp defines if you want to attach events to pointerup
  39263. * @param attachDown defines if you want to attach events to pointerdown
  39264. * @param attachMove defines if you want to attach events to pointermove
  39265. */
  39266. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39267. /** Detaches all event handlers*/
  39268. detachControl(): void;
  39269. /**
  39270. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39271. * Delay loaded resources are not taking in account
  39272. * @return true if all required resources are ready
  39273. */
  39274. isReady(): boolean;
  39275. /** Resets all cached information relative to material (including effect and visibility) */
  39276. resetCachedMaterial(): void;
  39277. /**
  39278. * Registers a function to be called before every frame render
  39279. * @param func defines the function to register
  39280. */
  39281. registerBeforeRender(func: () => void): void;
  39282. /**
  39283. * Unregisters a function called before every frame render
  39284. * @param func defines the function to unregister
  39285. */
  39286. unregisterBeforeRender(func: () => void): void;
  39287. /**
  39288. * Registers a function to be called after every frame render
  39289. * @param func defines the function to register
  39290. */
  39291. registerAfterRender(func: () => void): void;
  39292. /**
  39293. * Unregisters a function called after every frame render
  39294. * @param func defines the function to unregister
  39295. */
  39296. unregisterAfterRender(func: () => void): void;
  39297. private _executeOnceBeforeRender;
  39298. /**
  39299. * The provided function will run before render once and will be disposed afterwards.
  39300. * A timeout delay can be provided so that the function will be executed in N ms.
  39301. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39302. * @param func The function to be executed.
  39303. * @param timeout optional delay in ms
  39304. */
  39305. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39306. /** @hidden */
  39307. _addPendingData(data: any): void;
  39308. /** @hidden */
  39309. _removePendingData(data: any): void;
  39310. /**
  39311. * Returns the number of items waiting to be loaded
  39312. * @returns the number of items waiting to be loaded
  39313. */
  39314. getWaitingItemsCount(): number;
  39315. /**
  39316. * Returns a boolean indicating if the scene is still loading data
  39317. */
  39318. get isLoading(): boolean;
  39319. /**
  39320. * Registers a function to be executed when the scene is ready
  39321. * @param {Function} func - the function to be executed
  39322. */
  39323. executeWhenReady(func: () => void): void;
  39324. /**
  39325. * Returns a promise that resolves when the scene is ready
  39326. * @returns A promise that resolves when the scene is ready
  39327. */
  39328. whenReadyAsync(): Promise<void>;
  39329. /** @hidden */
  39330. _checkIsReady(): void;
  39331. /**
  39332. * Gets all animatable attached to the scene
  39333. */
  39334. get animatables(): Animatable[];
  39335. /**
  39336. * Resets the last animation time frame.
  39337. * Useful to override when animations start running when loading a scene for the first time.
  39338. */
  39339. resetLastAnimationTimeFrame(): void;
  39340. /**
  39341. * Gets the current view matrix
  39342. * @returns a Matrix
  39343. */
  39344. getViewMatrix(): Matrix;
  39345. /**
  39346. * Gets the current projection matrix
  39347. * @returns a Matrix
  39348. */
  39349. getProjectionMatrix(): Matrix;
  39350. /**
  39351. * Gets the current transform matrix
  39352. * @returns a Matrix made of View * Projection
  39353. */
  39354. getTransformMatrix(): Matrix;
  39355. /**
  39356. * Sets the current transform matrix
  39357. * @param viewL defines the View matrix to use
  39358. * @param projectionL defines the Projection matrix to use
  39359. * @param viewR defines the right View matrix to use (if provided)
  39360. * @param projectionR defines the right Projection matrix to use (if provided)
  39361. */
  39362. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39363. /**
  39364. * Gets the uniform buffer used to store scene data
  39365. * @returns a UniformBuffer
  39366. */
  39367. getSceneUniformBuffer(): UniformBuffer;
  39368. /**
  39369. * Gets an unique (relatively to the current scene) Id
  39370. * @returns an unique number for the scene
  39371. */
  39372. getUniqueId(): number;
  39373. /**
  39374. * Add a mesh to the list of scene's meshes
  39375. * @param newMesh defines the mesh to add
  39376. * @param recursive if all child meshes should also be added to the scene
  39377. */
  39378. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39379. /**
  39380. * Remove a mesh for the list of scene's meshes
  39381. * @param toRemove defines the mesh to remove
  39382. * @param recursive if all child meshes should also be removed from the scene
  39383. * @returns the index where the mesh was in the mesh list
  39384. */
  39385. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39386. /**
  39387. * Add a transform node to the list of scene's transform nodes
  39388. * @param newTransformNode defines the transform node to add
  39389. */
  39390. addTransformNode(newTransformNode: TransformNode): void;
  39391. /**
  39392. * Remove a transform node for the list of scene's transform nodes
  39393. * @param toRemove defines the transform node to remove
  39394. * @returns the index where the transform node was in the transform node list
  39395. */
  39396. removeTransformNode(toRemove: TransformNode): number;
  39397. /**
  39398. * Remove a skeleton for the list of scene's skeletons
  39399. * @param toRemove defines the skeleton to remove
  39400. * @returns the index where the skeleton was in the skeleton list
  39401. */
  39402. removeSkeleton(toRemove: Skeleton): number;
  39403. /**
  39404. * Remove a morph target for the list of scene's morph targets
  39405. * @param toRemove defines the morph target to remove
  39406. * @returns the index where the morph target was in the morph target list
  39407. */
  39408. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39409. /**
  39410. * Remove a light for the list of scene's lights
  39411. * @param toRemove defines the light to remove
  39412. * @returns the index where the light was in the light list
  39413. */
  39414. removeLight(toRemove: Light): number;
  39415. /**
  39416. * Remove a camera for the list of scene's cameras
  39417. * @param toRemove defines the camera to remove
  39418. * @returns the index where the camera was in the camera list
  39419. */
  39420. removeCamera(toRemove: Camera): number;
  39421. /**
  39422. * Remove a particle system for the list of scene's particle systems
  39423. * @param toRemove defines the particle system to remove
  39424. * @returns the index where the particle system was in the particle system list
  39425. */
  39426. removeParticleSystem(toRemove: IParticleSystem): number;
  39427. /**
  39428. * Remove a animation for the list of scene's animations
  39429. * @param toRemove defines the animation to remove
  39430. * @returns the index where the animation was in the animation list
  39431. */
  39432. removeAnimation(toRemove: Animation): number;
  39433. /**
  39434. * Will stop the animation of the given target
  39435. * @param target - the target
  39436. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39437. * @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)
  39438. */
  39439. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39440. /**
  39441. * Removes the given animation group from this scene.
  39442. * @param toRemove The animation group to remove
  39443. * @returns The index of the removed animation group
  39444. */
  39445. removeAnimationGroup(toRemove: AnimationGroup): number;
  39446. /**
  39447. * Removes the given multi-material from this scene.
  39448. * @param toRemove The multi-material to remove
  39449. * @returns The index of the removed multi-material
  39450. */
  39451. removeMultiMaterial(toRemove: MultiMaterial): number;
  39452. /**
  39453. * Removes the given material from this scene.
  39454. * @param toRemove The material to remove
  39455. * @returns The index of the removed material
  39456. */
  39457. removeMaterial(toRemove: Material): number;
  39458. /**
  39459. * Removes the given action manager from this scene.
  39460. * @param toRemove The action manager to remove
  39461. * @returns The index of the removed action manager
  39462. */
  39463. removeActionManager(toRemove: AbstractActionManager): number;
  39464. /**
  39465. * Removes the given texture from this scene.
  39466. * @param toRemove The texture to remove
  39467. * @returns The index of the removed texture
  39468. */
  39469. removeTexture(toRemove: BaseTexture): number;
  39470. /**
  39471. * Adds the given light to this scene
  39472. * @param newLight The light to add
  39473. */
  39474. addLight(newLight: Light): void;
  39475. /**
  39476. * Sorts the list list based on light priorities
  39477. */
  39478. sortLightsByPriority(): void;
  39479. /**
  39480. * Adds the given camera to this scene
  39481. * @param newCamera The camera to add
  39482. */
  39483. addCamera(newCamera: Camera): void;
  39484. /**
  39485. * Adds the given skeleton to this scene
  39486. * @param newSkeleton The skeleton to add
  39487. */
  39488. addSkeleton(newSkeleton: Skeleton): void;
  39489. /**
  39490. * Adds the given particle system to this scene
  39491. * @param newParticleSystem The particle system to add
  39492. */
  39493. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39494. /**
  39495. * Adds the given animation to this scene
  39496. * @param newAnimation The animation to add
  39497. */
  39498. addAnimation(newAnimation: Animation): void;
  39499. /**
  39500. * Adds the given animation group to this scene.
  39501. * @param newAnimationGroup The animation group to add
  39502. */
  39503. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39504. /**
  39505. * Adds the given multi-material to this scene
  39506. * @param newMultiMaterial The multi-material to add
  39507. */
  39508. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39509. /**
  39510. * Adds the given material to this scene
  39511. * @param newMaterial The material to add
  39512. */
  39513. addMaterial(newMaterial: Material): void;
  39514. /**
  39515. * Adds the given morph target to this scene
  39516. * @param newMorphTargetManager The morph target to add
  39517. */
  39518. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39519. /**
  39520. * Adds the given geometry to this scene
  39521. * @param newGeometry The geometry to add
  39522. */
  39523. addGeometry(newGeometry: Geometry): void;
  39524. /**
  39525. * Adds the given action manager to this scene
  39526. * @param newActionManager The action manager to add
  39527. */
  39528. addActionManager(newActionManager: AbstractActionManager): void;
  39529. /**
  39530. * Adds the given texture to this scene.
  39531. * @param newTexture The texture to add
  39532. */
  39533. addTexture(newTexture: BaseTexture): void;
  39534. /**
  39535. * Switch active camera
  39536. * @param newCamera defines the new active camera
  39537. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39538. */
  39539. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39540. /**
  39541. * sets the active camera of the scene using its ID
  39542. * @param id defines the camera's ID
  39543. * @return the new active camera or null if none found.
  39544. */
  39545. setActiveCameraByID(id: string): Nullable<Camera>;
  39546. /**
  39547. * sets the active camera of the scene using its name
  39548. * @param name defines the camera's name
  39549. * @returns the new active camera or null if none found.
  39550. */
  39551. setActiveCameraByName(name: string): Nullable<Camera>;
  39552. /**
  39553. * get an animation group using its name
  39554. * @param name defines the material's name
  39555. * @return the animation group or null if none found.
  39556. */
  39557. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39558. /**
  39559. * Get a material using its unique id
  39560. * @param uniqueId defines the material's unique id
  39561. * @return the material or null if none found.
  39562. */
  39563. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39564. /**
  39565. * get a material using its id
  39566. * @param id defines the material's ID
  39567. * @return the material or null if none found.
  39568. */
  39569. getMaterialByID(id: string): Nullable<Material>;
  39570. /**
  39571. * Gets a the last added material using a given id
  39572. * @param id defines the material's ID
  39573. * @return the last material with the given id or null if none found.
  39574. */
  39575. getLastMaterialByID(id: string): Nullable<Material>;
  39576. /**
  39577. * Gets a material using its name
  39578. * @param name defines the material's name
  39579. * @return the material or null if none found.
  39580. */
  39581. getMaterialByName(name: string): Nullable<Material>;
  39582. /**
  39583. * Get a texture using its unique id
  39584. * @param uniqueId defines the texture's unique id
  39585. * @return the texture or null if none found.
  39586. */
  39587. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39588. /**
  39589. * Gets a camera using its id
  39590. * @param id defines the id to look for
  39591. * @returns the camera or null if not found
  39592. */
  39593. getCameraByID(id: string): Nullable<Camera>;
  39594. /**
  39595. * Gets a camera using its unique id
  39596. * @param uniqueId defines the unique id to look for
  39597. * @returns the camera or null if not found
  39598. */
  39599. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39600. /**
  39601. * Gets a camera using its name
  39602. * @param name defines the camera's name
  39603. * @return the camera or null if none found.
  39604. */
  39605. getCameraByName(name: string): Nullable<Camera>;
  39606. /**
  39607. * Gets a bone using its id
  39608. * @param id defines the bone's id
  39609. * @return the bone or null if not found
  39610. */
  39611. getBoneByID(id: string): Nullable<Bone>;
  39612. /**
  39613. * Gets a bone using its id
  39614. * @param name defines the bone's name
  39615. * @return the bone or null if not found
  39616. */
  39617. getBoneByName(name: string): Nullable<Bone>;
  39618. /**
  39619. * Gets a light node using its name
  39620. * @param name defines the the light's name
  39621. * @return the light or null if none found.
  39622. */
  39623. getLightByName(name: string): Nullable<Light>;
  39624. /**
  39625. * Gets a light node using its id
  39626. * @param id defines the light's id
  39627. * @return the light or null if none found.
  39628. */
  39629. getLightByID(id: string): Nullable<Light>;
  39630. /**
  39631. * Gets a light node using its scene-generated unique ID
  39632. * @param uniqueId defines the light's unique id
  39633. * @return the light or null if none found.
  39634. */
  39635. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39636. /**
  39637. * Gets a particle system by id
  39638. * @param id defines the particle system id
  39639. * @return the corresponding system or null if none found
  39640. */
  39641. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39642. /**
  39643. * Gets a geometry using its ID
  39644. * @param id defines the geometry's id
  39645. * @return the geometry or null if none found.
  39646. */
  39647. getGeometryByID(id: string): Nullable<Geometry>;
  39648. private _getGeometryByUniqueID;
  39649. /**
  39650. * Add a new geometry to this scene
  39651. * @param geometry defines the geometry to be added to the scene.
  39652. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39653. * @return a boolean defining if the geometry was added or not
  39654. */
  39655. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39656. /**
  39657. * Removes an existing geometry
  39658. * @param geometry defines the geometry to be removed from the scene
  39659. * @return a boolean defining if the geometry was removed or not
  39660. */
  39661. removeGeometry(geometry: Geometry): boolean;
  39662. /**
  39663. * Gets the list of geometries attached to the scene
  39664. * @returns an array of Geometry
  39665. */
  39666. getGeometries(): Geometry[];
  39667. /**
  39668. * Gets the first added mesh found of a given ID
  39669. * @param id defines the id to search for
  39670. * @return the mesh found or null if not found at all
  39671. */
  39672. getMeshByID(id: string): Nullable<AbstractMesh>;
  39673. /**
  39674. * Gets a list of meshes using their id
  39675. * @param id defines the id to search for
  39676. * @returns a list of meshes
  39677. */
  39678. getMeshesByID(id: string): Array<AbstractMesh>;
  39679. /**
  39680. * Gets the first added transform node found of a given ID
  39681. * @param id defines the id to search for
  39682. * @return the found transform node or null if not found at all.
  39683. */
  39684. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39685. /**
  39686. * Gets a transform node with its auto-generated unique id
  39687. * @param uniqueId efines the unique id to search for
  39688. * @return the found transform node or null if not found at all.
  39689. */
  39690. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39691. /**
  39692. * Gets a list of transform nodes using their id
  39693. * @param id defines the id to search for
  39694. * @returns a list of transform nodes
  39695. */
  39696. getTransformNodesByID(id: string): Array<TransformNode>;
  39697. /**
  39698. * Gets a mesh with its auto-generated unique id
  39699. * @param uniqueId defines the unique id to search for
  39700. * @return the found mesh or null if not found at all.
  39701. */
  39702. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39703. /**
  39704. * Gets a the last added mesh using a given id
  39705. * @param id defines the id to search for
  39706. * @return the found mesh or null if not found at all.
  39707. */
  39708. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39709. /**
  39710. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39711. * @param id defines the id to search for
  39712. * @return the found node or null if not found at all
  39713. */
  39714. getLastEntryByID(id: string): Nullable<Node>;
  39715. /**
  39716. * Gets a node (Mesh, Camera, Light) using a given id
  39717. * @param id defines the id to search for
  39718. * @return the found node or null if not found at all
  39719. */
  39720. getNodeByID(id: string): Nullable<Node>;
  39721. /**
  39722. * Gets a node (Mesh, Camera, Light) using a given name
  39723. * @param name defines the name to search for
  39724. * @return the found node or null if not found at all.
  39725. */
  39726. getNodeByName(name: string): Nullable<Node>;
  39727. /**
  39728. * Gets a mesh using a given name
  39729. * @param name defines the name to search for
  39730. * @return the found mesh or null if not found at all.
  39731. */
  39732. getMeshByName(name: string): Nullable<AbstractMesh>;
  39733. /**
  39734. * Gets a transform node using a given name
  39735. * @param name defines the name to search for
  39736. * @return the found transform node or null if not found at all.
  39737. */
  39738. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39739. /**
  39740. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39741. * @param id defines the id to search for
  39742. * @return the found skeleton or null if not found at all.
  39743. */
  39744. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39745. /**
  39746. * Gets a skeleton using a given auto generated unique id
  39747. * @param uniqueId defines the unique id to search for
  39748. * @return the found skeleton or null if not found at all.
  39749. */
  39750. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39751. /**
  39752. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39753. * @param id defines the id to search for
  39754. * @return the found skeleton or null if not found at all.
  39755. */
  39756. getSkeletonById(id: string): Nullable<Skeleton>;
  39757. /**
  39758. * Gets a skeleton using a given name
  39759. * @param name defines the name to search for
  39760. * @return the found skeleton or null if not found at all.
  39761. */
  39762. getSkeletonByName(name: string): Nullable<Skeleton>;
  39763. /**
  39764. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39765. * @param id defines the id to search for
  39766. * @return the found morph target manager or null if not found at all.
  39767. */
  39768. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39769. /**
  39770. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39771. * @param id defines the id to search for
  39772. * @return the found morph target or null if not found at all.
  39773. */
  39774. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39775. /**
  39776. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39777. * @param name defines the name to search for
  39778. * @return the found morph target or null if not found at all.
  39779. */
  39780. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39781. /**
  39782. * Gets a boolean indicating if the given mesh is active
  39783. * @param mesh defines the mesh to look for
  39784. * @returns true if the mesh is in the active list
  39785. */
  39786. isActiveMesh(mesh: AbstractMesh): boolean;
  39787. /**
  39788. * Return a unique id as a string which can serve as an identifier for the scene
  39789. */
  39790. get uid(): string;
  39791. /**
  39792. * Add an externaly attached data from its key.
  39793. * This method call will fail and return false, if such key already exists.
  39794. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39795. * @param key the unique key that identifies the data
  39796. * @param data the data object to associate to the key for this Engine instance
  39797. * @return true if no such key were already present and the data was added successfully, false otherwise
  39798. */
  39799. addExternalData<T>(key: string, data: T): boolean;
  39800. /**
  39801. * Get an externaly attached data from its key
  39802. * @param key the unique key that identifies the data
  39803. * @return the associated data, if present (can be null), or undefined if not present
  39804. */
  39805. getExternalData<T>(key: string): Nullable<T>;
  39806. /**
  39807. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39808. * @param key the unique key that identifies the data
  39809. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39810. * @return the associated data, can be null if the factory returned null.
  39811. */
  39812. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39813. /**
  39814. * Remove an externaly attached data from the Engine instance
  39815. * @param key the unique key that identifies the data
  39816. * @return true if the data was successfully removed, false if it doesn't exist
  39817. */
  39818. removeExternalData(key: string): boolean;
  39819. private _evaluateSubMesh;
  39820. /**
  39821. * Clear the processed materials smart array preventing retention point in material dispose.
  39822. */
  39823. freeProcessedMaterials(): void;
  39824. private _preventFreeActiveMeshesAndRenderingGroups;
  39825. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39826. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39827. * when disposing several meshes in a row or a hierarchy of meshes.
  39828. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39829. */
  39830. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39831. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39832. /**
  39833. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39834. */
  39835. freeActiveMeshes(): void;
  39836. /**
  39837. * Clear the info related to rendering groups preventing retention points during dispose.
  39838. */
  39839. freeRenderingGroups(): void;
  39840. /** @hidden */
  39841. _isInIntermediateRendering(): boolean;
  39842. /**
  39843. * Lambda returning the list of potentially active meshes.
  39844. */
  39845. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39846. /**
  39847. * Lambda returning the list of potentially active sub meshes.
  39848. */
  39849. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39850. /**
  39851. * Lambda returning the list of potentially intersecting sub meshes.
  39852. */
  39853. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39854. /**
  39855. * Lambda returning the list of potentially colliding sub meshes.
  39856. */
  39857. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39858. private _activeMeshesFrozen;
  39859. private _skipEvaluateActiveMeshesCompletely;
  39860. /**
  39861. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39862. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39863. * @returns the current scene
  39864. */
  39865. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39866. /**
  39867. * Use this function to restart evaluating active meshes on every frame
  39868. * @returns the current scene
  39869. */
  39870. unfreezeActiveMeshes(): Scene;
  39871. private _evaluateActiveMeshes;
  39872. private _activeMesh;
  39873. /**
  39874. * Update the transform matrix to update from the current active camera
  39875. * @param force defines a boolean used to force the update even if cache is up to date
  39876. */
  39877. updateTransformMatrix(force?: boolean): void;
  39878. private _bindFrameBuffer;
  39879. /** @hidden */
  39880. _allowPostProcessClearColor: boolean;
  39881. /** @hidden */
  39882. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39883. private _processSubCameras;
  39884. private _checkIntersections;
  39885. /** @hidden */
  39886. _advancePhysicsEngineStep(step: number): void;
  39887. /**
  39888. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39889. */
  39890. getDeterministicFrameTime: () => number;
  39891. /** @hidden */
  39892. _animate(): void;
  39893. /** Execute all animations (for a frame) */
  39894. animate(): void;
  39895. /**
  39896. * Render the scene
  39897. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39898. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39899. */
  39900. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39901. /**
  39902. * Freeze all materials
  39903. * A frozen material will not be updatable but should be faster to render
  39904. */
  39905. freezeMaterials(): void;
  39906. /**
  39907. * Unfreeze all materials
  39908. * A frozen material will not be updatable but should be faster to render
  39909. */
  39910. unfreezeMaterials(): void;
  39911. /**
  39912. * Releases all held ressources
  39913. */
  39914. dispose(): void;
  39915. /**
  39916. * Gets if the scene is already disposed
  39917. */
  39918. get isDisposed(): boolean;
  39919. /**
  39920. * Call this function to reduce memory footprint of the scene.
  39921. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39922. */
  39923. clearCachedVertexData(): void;
  39924. /**
  39925. * This function will remove the local cached buffer data from texture.
  39926. * It will save memory but will prevent the texture from being rebuilt
  39927. */
  39928. cleanCachedTextureBuffer(): void;
  39929. /**
  39930. * Get the world extend vectors with an optional filter
  39931. *
  39932. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39933. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39934. */
  39935. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39936. min: Vector3;
  39937. max: Vector3;
  39938. };
  39939. /**
  39940. * Creates a ray that can be used to pick in the scene
  39941. * @param x defines the x coordinate of the origin (on-screen)
  39942. * @param y defines the y coordinate of the origin (on-screen)
  39943. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39944. * @param camera defines the camera to use for the picking
  39945. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39946. * @returns a Ray
  39947. */
  39948. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39949. /**
  39950. * Creates a ray that can be used to pick in the scene
  39951. * @param x defines the x coordinate of the origin (on-screen)
  39952. * @param y defines the y coordinate of the origin (on-screen)
  39953. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39954. * @param result defines the ray where to store the picking ray
  39955. * @param camera defines the camera to use for the picking
  39956. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39957. * @returns the current scene
  39958. */
  39959. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39960. /**
  39961. * Creates a ray that can be used to pick in the scene
  39962. * @param x defines the x coordinate of the origin (on-screen)
  39963. * @param y defines the y coordinate of the origin (on-screen)
  39964. * @param camera defines the camera to use for the picking
  39965. * @returns a Ray
  39966. */
  39967. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39968. /**
  39969. * Creates a ray that can be used to pick in the scene
  39970. * @param x defines the x coordinate of the origin (on-screen)
  39971. * @param y defines the y coordinate of the origin (on-screen)
  39972. * @param result defines the ray where to store the picking ray
  39973. * @param camera defines the camera to use for the picking
  39974. * @returns the current scene
  39975. */
  39976. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39977. /** Launch a ray to try to pick a mesh in the scene
  39978. * @param x position on screen
  39979. * @param y position on screen
  39980. * @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
  39981. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39982. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39983. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39984. * @returns a PickingInfo
  39985. */
  39986. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39987. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39988. * @param x position on screen
  39989. * @param y position on screen
  39990. * @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
  39991. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39992. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39993. * @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)
  39994. */
  39995. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39996. /** Use the given ray to pick a mesh in the scene
  39997. * @param ray The ray to use to pick meshes
  39998. * @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
  39999. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40000. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40001. * @returns a PickingInfo
  40002. */
  40003. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40004. /**
  40005. * Launch a ray to try to pick a mesh in the scene
  40006. * @param x X position on screen
  40007. * @param y Y position on screen
  40008. * @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
  40009. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40010. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40011. * @returns an array of PickingInfo
  40012. */
  40013. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40014. /**
  40015. * Launch a ray to try to pick a mesh in the scene
  40016. * @param ray Ray to use
  40017. * @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
  40018. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40019. * @returns an array of PickingInfo
  40020. */
  40021. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40022. /**
  40023. * Force the value of meshUnderPointer
  40024. * @param mesh defines the mesh to use
  40025. */
  40026. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40027. /**
  40028. * Gets the mesh under the pointer
  40029. * @returns a Mesh or null if no mesh is under the pointer
  40030. */
  40031. getPointerOverMesh(): Nullable<AbstractMesh>;
  40032. /** @hidden */
  40033. _rebuildGeometries(): void;
  40034. /** @hidden */
  40035. _rebuildTextures(): void;
  40036. private _getByTags;
  40037. /**
  40038. * Get a list of meshes by tags
  40039. * @param tagsQuery defines the tags query to use
  40040. * @param forEach defines a predicate used to filter results
  40041. * @returns an array of Mesh
  40042. */
  40043. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40044. /**
  40045. * Get a list of cameras by tags
  40046. * @param tagsQuery defines the tags query to use
  40047. * @param forEach defines a predicate used to filter results
  40048. * @returns an array of Camera
  40049. */
  40050. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40051. /**
  40052. * Get a list of lights by tags
  40053. * @param tagsQuery defines the tags query to use
  40054. * @param forEach defines a predicate used to filter results
  40055. * @returns an array of Light
  40056. */
  40057. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40058. /**
  40059. * Get a list of materials by tags
  40060. * @param tagsQuery defines the tags query to use
  40061. * @param forEach defines a predicate used to filter results
  40062. * @returns an array of Material
  40063. */
  40064. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40065. /**
  40066. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40067. * This allowed control for front to back rendering or reversly depending of the special needs.
  40068. *
  40069. * @param renderingGroupId The rendering group id corresponding to its index
  40070. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40071. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40072. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40073. */
  40074. 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;
  40075. /**
  40076. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40077. *
  40078. * @param renderingGroupId The rendering group id corresponding to its index
  40079. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40080. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40081. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40082. */
  40083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40084. /**
  40085. * Gets the current auto clear configuration for one rendering group of the rendering
  40086. * manager.
  40087. * @param index the rendering group index to get the information for
  40088. * @returns The auto clear setup for the requested rendering group
  40089. */
  40090. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40091. private _blockMaterialDirtyMechanism;
  40092. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40093. get blockMaterialDirtyMechanism(): boolean;
  40094. set blockMaterialDirtyMechanism(value: boolean);
  40095. /**
  40096. * Will flag all materials as dirty to trigger new shader compilation
  40097. * @param flag defines the flag used to specify which material part must be marked as dirty
  40098. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40099. */
  40100. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40101. /** @hidden */
  40102. _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;
  40103. /** @hidden */
  40104. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40105. /** @hidden */
  40106. _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;
  40107. /** @hidden */
  40108. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40109. /** @hidden */
  40110. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40111. /** @hidden */
  40112. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40113. }
  40114. }
  40115. declare module BABYLON {
  40116. /**
  40117. * Set of assets to keep when moving a scene into an asset container.
  40118. */
  40119. export class KeepAssets extends AbstractScene {
  40120. }
  40121. /**
  40122. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40123. */
  40124. export class InstantiatedEntries {
  40125. /**
  40126. * List of new root nodes (eg. nodes with no parent)
  40127. */
  40128. rootNodes: TransformNode[];
  40129. /**
  40130. * List of new skeletons
  40131. */
  40132. skeletons: Skeleton[];
  40133. /**
  40134. * List of new animation groups
  40135. */
  40136. animationGroups: AnimationGroup[];
  40137. }
  40138. /**
  40139. * Container with a set of assets that can be added or removed from a scene.
  40140. */
  40141. export class AssetContainer extends AbstractScene {
  40142. private _wasAddedToScene;
  40143. /**
  40144. * The scene the AssetContainer belongs to.
  40145. */
  40146. scene: Scene;
  40147. /**
  40148. * Instantiates an AssetContainer.
  40149. * @param scene The scene the AssetContainer belongs to.
  40150. */
  40151. constructor(scene: Scene);
  40152. /**
  40153. * Instantiate or clone all meshes and add the new ones to the scene.
  40154. * Skeletons and animation groups will all be cloned
  40155. * @param nameFunction defines an optional function used to get new names for clones
  40156. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40157. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40158. */
  40159. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40160. /**
  40161. * Adds all the assets from the container to the scene.
  40162. */
  40163. addAllToScene(): void;
  40164. /**
  40165. * Removes all the assets in the container from the scene
  40166. */
  40167. removeAllFromScene(): void;
  40168. /**
  40169. * Disposes all the assets in the container
  40170. */
  40171. dispose(): void;
  40172. private _moveAssets;
  40173. /**
  40174. * Removes all the assets contained in the scene and adds them to the container.
  40175. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40176. */
  40177. moveAllFromScene(keepAssets?: KeepAssets): void;
  40178. /**
  40179. * 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.
  40180. * @returns the root mesh
  40181. */
  40182. createRootMesh(): Mesh;
  40183. /**
  40184. * Merge animations (direct and animation groups) from this asset container into a scene
  40185. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40186. * @param animatables set of animatables to retarget to a node from the scene
  40187. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40188. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40189. */
  40190. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40191. }
  40192. }
  40193. declare module BABYLON {
  40194. /**
  40195. * Defines how the parser contract is defined.
  40196. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40197. */
  40198. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40199. /**
  40200. * Defines how the individual parser contract is defined.
  40201. * These parser can parse an individual asset
  40202. */
  40203. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40204. /**
  40205. * Base class of the scene acting as a container for the different elements composing a scene.
  40206. * This class is dynamically extended by the different components of the scene increasing
  40207. * flexibility and reducing coupling
  40208. */
  40209. export abstract class AbstractScene {
  40210. /**
  40211. * Stores the list of available parsers in the application.
  40212. */
  40213. private static _BabylonFileParsers;
  40214. /**
  40215. * Stores the list of available individual parsers in the application.
  40216. */
  40217. private static _IndividualBabylonFileParsers;
  40218. /**
  40219. * Adds a parser in the list of available ones
  40220. * @param name Defines the name of the parser
  40221. * @param parser Defines the parser to add
  40222. */
  40223. static AddParser(name: string, parser: BabylonFileParser): void;
  40224. /**
  40225. * Gets a general parser from the list of avaialble ones
  40226. * @param name Defines the name of the parser
  40227. * @returns the requested parser or null
  40228. */
  40229. static GetParser(name: string): Nullable<BabylonFileParser>;
  40230. /**
  40231. * Adds n individual parser in the list of available ones
  40232. * @param name Defines the name of the parser
  40233. * @param parser Defines the parser to add
  40234. */
  40235. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40236. /**
  40237. * Gets an individual parser from the list of avaialble ones
  40238. * @param name Defines the name of the parser
  40239. * @returns the requested parser or null
  40240. */
  40241. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40242. /**
  40243. * Parser json data and populate both a scene and its associated container object
  40244. * @param jsonData Defines the data to parse
  40245. * @param scene Defines the scene to parse the data for
  40246. * @param container Defines the container attached to the parsing sequence
  40247. * @param rootUrl Defines the root url of the data
  40248. */
  40249. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40250. /**
  40251. * Gets the list of root nodes (ie. nodes with no parent)
  40252. */
  40253. rootNodes: Node[];
  40254. /** All of the cameras added to this scene
  40255. * @see http://doc.babylonjs.com/babylon101/cameras
  40256. */
  40257. cameras: Camera[];
  40258. /**
  40259. * All of the lights added to this scene
  40260. * @see http://doc.babylonjs.com/babylon101/lights
  40261. */
  40262. lights: Light[];
  40263. /**
  40264. * All of the (abstract) meshes added to this scene
  40265. */
  40266. meshes: AbstractMesh[];
  40267. /**
  40268. * The list of skeletons added to the scene
  40269. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40270. */
  40271. skeletons: Skeleton[];
  40272. /**
  40273. * All of the particle systems added to this scene
  40274. * @see http://doc.babylonjs.com/babylon101/particles
  40275. */
  40276. particleSystems: IParticleSystem[];
  40277. /**
  40278. * Gets a list of Animations associated with the scene
  40279. */
  40280. animations: Animation[];
  40281. /**
  40282. * All of the animation groups added to this scene
  40283. * @see http://doc.babylonjs.com/how_to/group
  40284. */
  40285. animationGroups: AnimationGroup[];
  40286. /**
  40287. * All of the multi-materials added to this scene
  40288. * @see http://doc.babylonjs.com/how_to/multi_materials
  40289. */
  40290. multiMaterials: MultiMaterial[];
  40291. /**
  40292. * All of the materials added to this scene
  40293. * In the context of a Scene, it is not supposed to be modified manually.
  40294. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40295. * Note also that the order of the Material within the array is not significant and might change.
  40296. * @see http://doc.babylonjs.com/babylon101/materials
  40297. */
  40298. materials: Material[];
  40299. /**
  40300. * The list of morph target managers added to the scene
  40301. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40302. */
  40303. morphTargetManagers: MorphTargetManager[];
  40304. /**
  40305. * The list of geometries used in the scene.
  40306. */
  40307. geometries: Geometry[];
  40308. /**
  40309. * All of the tranform nodes added to this scene
  40310. * In the context of a Scene, it is not supposed to be modified manually.
  40311. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40312. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40313. * @see http://doc.babylonjs.com/how_to/transformnode
  40314. */
  40315. transformNodes: TransformNode[];
  40316. /**
  40317. * ActionManagers available on the scene.
  40318. */
  40319. actionManagers: AbstractActionManager[];
  40320. /**
  40321. * Textures to keep.
  40322. */
  40323. textures: BaseTexture[];
  40324. /**
  40325. * Environment texture for the scene
  40326. */
  40327. environmentTexture: Nullable<BaseTexture>;
  40328. /**
  40329. * @returns all meshes, lights, cameras, transformNodes and bones
  40330. */
  40331. getNodes(): Array<Node>;
  40332. }
  40333. }
  40334. declare module BABYLON {
  40335. /**
  40336. * Interface used to define options for Sound class
  40337. */
  40338. export interface ISoundOptions {
  40339. /**
  40340. * Does the sound autoplay once loaded.
  40341. */
  40342. autoplay?: boolean;
  40343. /**
  40344. * Does the sound loop after it finishes playing once.
  40345. */
  40346. loop?: boolean;
  40347. /**
  40348. * Sound's volume
  40349. */
  40350. volume?: number;
  40351. /**
  40352. * Is it a spatial sound?
  40353. */
  40354. spatialSound?: boolean;
  40355. /**
  40356. * Maximum distance to hear that sound
  40357. */
  40358. maxDistance?: number;
  40359. /**
  40360. * Uses user defined attenuation function
  40361. */
  40362. useCustomAttenuation?: boolean;
  40363. /**
  40364. * Define the roll off factor of spatial sounds.
  40365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40366. */
  40367. rolloffFactor?: number;
  40368. /**
  40369. * Define the reference distance the sound should be heard perfectly.
  40370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40371. */
  40372. refDistance?: number;
  40373. /**
  40374. * Define the distance attenuation model the sound will follow.
  40375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40376. */
  40377. distanceModel?: string;
  40378. /**
  40379. * Defines the playback speed (1 by default)
  40380. */
  40381. playbackRate?: number;
  40382. /**
  40383. * Defines if the sound is from a streaming source
  40384. */
  40385. streaming?: boolean;
  40386. /**
  40387. * Defines an optional length (in seconds) inside the sound file
  40388. */
  40389. length?: number;
  40390. /**
  40391. * Defines an optional offset (in seconds) inside the sound file
  40392. */
  40393. offset?: number;
  40394. /**
  40395. * If true, URLs will not be required to state the audio file codec to use.
  40396. */
  40397. skipCodecCheck?: boolean;
  40398. }
  40399. /**
  40400. * Defines a sound that can be played in the application.
  40401. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40403. */
  40404. export class Sound {
  40405. /**
  40406. * The name of the sound in the scene.
  40407. */
  40408. name: string;
  40409. /**
  40410. * Does the sound autoplay once loaded.
  40411. */
  40412. autoplay: boolean;
  40413. /**
  40414. * Does the sound loop after it finishes playing once.
  40415. */
  40416. loop: boolean;
  40417. /**
  40418. * Does the sound use a custom attenuation curve to simulate the falloff
  40419. * happening when the source gets further away from the camera.
  40420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40421. */
  40422. useCustomAttenuation: boolean;
  40423. /**
  40424. * The sound track id this sound belongs to.
  40425. */
  40426. soundTrackId: number;
  40427. /**
  40428. * Is this sound currently played.
  40429. */
  40430. isPlaying: boolean;
  40431. /**
  40432. * Is this sound currently paused.
  40433. */
  40434. isPaused: boolean;
  40435. /**
  40436. * Does this sound enables spatial sound.
  40437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40438. */
  40439. spatialSound: boolean;
  40440. /**
  40441. * Define the reference distance the sound should be heard perfectly.
  40442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40443. */
  40444. refDistance: number;
  40445. /**
  40446. * Define the roll off factor of spatial sounds.
  40447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40448. */
  40449. rolloffFactor: number;
  40450. /**
  40451. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40453. */
  40454. maxDistance: number;
  40455. /**
  40456. * Define the distance attenuation model the sound will follow.
  40457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40458. */
  40459. distanceModel: string;
  40460. /**
  40461. * @hidden
  40462. * Back Compat
  40463. **/
  40464. onended: () => any;
  40465. /**
  40466. * Gets or sets an object used to store user defined information for the sound.
  40467. */
  40468. metadata: any;
  40469. /**
  40470. * Observable event when the current playing sound finishes.
  40471. */
  40472. onEndedObservable: Observable<Sound>;
  40473. private _panningModel;
  40474. private _playbackRate;
  40475. private _streaming;
  40476. private _startTime;
  40477. private _startOffset;
  40478. private _position;
  40479. /** @hidden */
  40480. _positionInEmitterSpace: boolean;
  40481. private _localDirection;
  40482. private _volume;
  40483. private _isReadyToPlay;
  40484. private _isDirectional;
  40485. private _readyToPlayCallback;
  40486. private _audioBuffer;
  40487. private _soundSource;
  40488. private _streamingSource;
  40489. private _soundPanner;
  40490. private _soundGain;
  40491. private _inputAudioNode;
  40492. private _outputAudioNode;
  40493. private _coneInnerAngle;
  40494. private _coneOuterAngle;
  40495. private _coneOuterGain;
  40496. private _scene;
  40497. private _connectedTransformNode;
  40498. private _customAttenuationFunction;
  40499. private _registerFunc;
  40500. private _isOutputConnected;
  40501. private _htmlAudioElement;
  40502. private _urlType;
  40503. private _length?;
  40504. private _offset?;
  40505. /** @hidden */
  40506. static _SceneComponentInitialization: (scene: Scene) => void;
  40507. /**
  40508. * Create a sound and attach it to a scene
  40509. * @param name Name of your sound
  40510. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40511. * @param scene defines the scene the sound belongs to
  40512. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40513. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40514. */
  40515. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40516. /**
  40517. * Release the sound and its associated resources
  40518. */
  40519. dispose(): void;
  40520. /**
  40521. * Gets if the sounds is ready to be played or not.
  40522. * @returns true if ready, otherwise false
  40523. */
  40524. isReady(): boolean;
  40525. private _soundLoaded;
  40526. /**
  40527. * Sets the data of the sound from an audiobuffer
  40528. * @param audioBuffer The audioBuffer containing the data
  40529. */
  40530. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40531. /**
  40532. * Updates the current sounds options such as maxdistance, loop...
  40533. * @param options A JSON object containing values named as the object properties
  40534. */
  40535. updateOptions(options: ISoundOptions): void;
  40536. private _createSpatialParameters;
  40537. private _updateSpatialParameters;
  40538. /**
  40539. * Switch the panning model to HRTF:
  40540. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40542. */
  40543. switchPanningModelToHRTF(): void;
  40544. /**
  40545. * Switch the panning model to Equal Power:
  40546. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40548. */
  40549. switchPanningModelToEqualPower(): void;
  40550. private _switchPanningModel;
  40551. /**
  40552. * Connect this sound to a sound track audio node like gain...
  40553. * @param soundTrackAudioNode the sound track audio node to connect to
  40554. */
  40555. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40556. /**
  40557. * Transform this sound into a directional source
  40558. * @param coneInnerAngle Size of the inner cone in degree
  40559. * @param coneOuterAngle Size of the outer cone in degree
  40560. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40561. */
  40562. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40563. /**
  40564. * Gets or sets the inner angle for the directional cone.
  40565. */
  40566. get directionalConeInnerAngle(): number;
  40567. /**
  40568. * Gets or sets the inner angle for the directional cone.
  40569. */
  40570. set directionalConeInnerAngle(value: number);
  40571. /**
  40572. * Gets or sets the outer angle for the directional cone.
  40573. */
  40574. get directionalConeOuterAngle(): number;
  40575. /**
  40576. * Gets or sets the outer angle for the directional cone.
  40577. */
  40578. set directionalConeOuterAngle(value: number);
  40579. /**
  40580. * Sets the position of the emitter if spatial sound is enabled
  40581. * @param newPosition Defines the new posisiton
  40582. */
  40583. setPosition(newPosition: Vector3): void;
  40584. /**
  40585. * Sets the local direction of the emitter if spatial sound is enabled
  40586. * @param newLocalDirection Defines the new local direction
  40587. */
  40588. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40589. private _updateDirection;
  40590. /** @hidden */
  40591. updateDistanceFromListener(): void;
  40592. /**
  40593. * Sets a new custom attenuation function for the sound.
  40594. * @param callback Defines the function used for the attenuation
  40595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40596. */
  40597. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40598. /**
  40599. * Play the sound
  40600. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40601. * @param offset (optional) Start the sound at a specific time in seconds
  40602. * @param length (optional) Sound duration (in seconds)
  40603. */
  40604. play(time?: number, offset?: number, length?: number): void;
  40605. private _onended;
  40606. /**
  40607. * Stop the sound
  40608. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40609. */
  40610. stop(time?: number): void;
  40611. /**
  40612. * Put the sound in pause
  40613. */
  40614. pause(): void;
  40615. /**
  40616. * Sets a dedicated volume for this sounds
  40617. * @param newVolume Define the new volume of the sound
  40618. * @param time Define time for gradual change to new volume
  40619. */
  40620. setVolume(newVolume: number, time?: number): void;
  40621. /**
  40622. * Set the sound play back rate
  40623. * @param newPlaybackRate Define the playback rate the sound should be played at
  40624. */
  40625. setPlaybackRate(newPlaybackRate: number): void;
  40626. /**
  40627. * Gets the volume of the sound.
  40628. * @returns the volume of the sound
  40629. */
  40630. getVolume(): number;
  40631. /**
  40632. * Attach the sound to a dedicated mesh
  40633. * @param transformNode The transform node to connect the sound with
  40634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40635. */
  40636. attachToMesh(transformNode: TransformNode): void;
  40637. /**
  40638. * Detach the sound from the previously attached mesh
  40639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40640. */
  40641. detachFromMesh(): void;
  40642. private _onRegisterAfterWorldMatrixUpdate;
  40643. /**
  40644. * Clone the current sound in the scene.
  40645. * @returns the new sound clone
  40646. */
  40647. clone(): Nullable<Sound>;
  40648. /**
  40649. * Gets the current underlying audio buffer containing the data
  40650. * @returns the audio buffer
  40651. */
  40652. getAudioBuffer(): Nullable<AudioBuffer>;
  40653. /**
  40654. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40655. * @returns the source node
  40656. */
  40657. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40658. /**
  40659. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40660. * @returns the gain node
  40661. */
  40662. getSoundGain(): Nullable<GainNode>;
  40663. /**
  40664. * Serializes the Sound in a JSON representation
  40665. * @returns the JSON representation of the sound
  40666. */
  40667. serialize(): any;
  40668. /**
  40669. * Parse a JSON representation of a sound to innstantiate in a given scene
  40670. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40671. * @param scene Define the scene the new parsed sound should be created in
  40672. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40673. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40674. * @returns the newly parsed sound
  40675. */
  40676. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40677. }
  40678. }
  40679. declare module BABYLON {
  40680. /**
  40681. * This defines an action helpful to play a defined sound on a triggered action.
  40682. */
  40683. export class PlaySoundAction extends Action {
  40684. private _sound;
  40685. /**
  40686. * Instantiate the action
  40687. * @param triggerOptions defines the trigger options
  40688. * @param sound defines the sound to play
  40689. * @param condition defines the trigger related conditions
  40690. */
  40691. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40692. /** @hidden */
  40693. _prepare(): void;
  40694. /**
  40695. * Execute the action and play the sound.
  40696. */
  40697. execute(): void;
  40698. /**
  40699. * Serializes the actions and its related information.
  40700. * @param parent defines the object to serialize in
  40701. * @returns the serialized object
  40702. */
  40703. serialize(parent: any): any;
  40704. }
  40705. /**
  40706. * This defines an action helpful to stop a defined sound on a triggered action.
  40707. */
  40708. export class StopSoundAction extends Action {
  40709. private _sound;
  40710. /**
  40711. * Instantiate the action
  40712. * @param triggerOptions defines the trigger options
  40713. * @param sound defines the sound to stop
  40714. * @param condition defines the trigger related conditions
  40715. */
  40716. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40717. /** @hidden */
  40718. _prepare(): void;
  40719. /**
  40720. * Execute the action and stop the sound.
  40721. */
  40722. execute(): void;
  40723. /**
  40724. * Serializes the actions and its related information.
  40725. * @param parent defines the object to serialize in
  40726. * @returns the serialized object
  40727. */
  40728. serialize(parent: any): any;
  40729. }
  40730. }
  40731. declare module BABYLON {
  40732. /**
  40733. * This defines an action responsible to change the value of a property
  40734. * by interpolating between its current value and the newly set one once triggered.
  40735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40736. */
  40737. export class InterpolateValueAction extends Action {
  40738. /**
  40739. * Defines the path of the property where the value should be interpolated
  40740. */
  40741. propertyPath: string;
  40742. /**
  40743. * Defines the target value at the end of the interpolation.
  40744. */
  40745. value: any;
  40746. /**
  40747. * Defines the time it will take for the property to interpolate to the value.
  40748. */
  40749. duration: number;
  40750. /**
  40751. * Defines if the other scene animations should be stopped when the action has been triggered
  40752. */
  40753. stopOtherAnimations?: boolean;
  40754. /**
  40755. * Defines a callback raised once the interpolation animation has been done.
  40756. */
  40757. onInterpolationDone?: () => void;
  40758. /**
  40759. * Observable triggered once the interpolation animation has been done.
  40760. */
  40761. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40762. private _target;
  40763. private _effectiveTarget;
  40764. private _property;
  40765. /**
  40766. * Instantiate the action
  40767. * @param triggerOptions defines the trigger options
  40768. * @param target defines the object containing the value to interpolate
  40769. * @param propertyPath defines the path to the property in the target object
  40770. * @param value defines the target value at the end of the interpolation
  40771. * @param duration deines the time it will take for the property to interpolate to the value.
  40772. * @param condition defines the trigger related conditions
  40773. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40774. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40775. */
  40776. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40777. /** @hidden */
  40778. _prepare(): void;
  40779. /**
  40780. * Execute the action starts the value interpolation.
  40781. */
  40782. execute(): void;
  40783. /**
  40784. * Serializes the actions and its related information.
  40785. * @param parent defines the object to serialize in
  40786. * @returns the serialized object
  40787. */
  40788. serialize(parent: any): any;
  40789. }
  40790. }
  40791. declare module BABYLON {
  40792. /**
  40793. * Options allowed during the creation of a sound track.
  40794. */
  40795. export interface ISoundTrackOptions {
  40796. /**
  40797. * The volume the sound track should take during creation
  40798. */
  40799. volume?: number;
  40800. /**
  40801. * Define if the sound track is the main sound track of the scene
  40802. */
  40803. mainTrack?: boolean;
  40804. }
  40805. /**
  40806. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40807. * It will be also used in a future release to apply effects on a specific track.
  40808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40809. */
  40810. export class SoundTrack {
  40811. /**
  40812. * The unique identifier of the sound track in the scene.
  40813. */
  40814. id: number;
  40815. /**
  40816. * The list of sounds included in the sound track.
  40817. */
  40818. soundCollection: Array<Sound>;
  40819. private _outputAudioNode;
  40820. private _scene;
  40821. private _connectedAnalyser;
  40822. private _options;
  40823. private _isInitialized;
  40824. /**
  40825. * Creates a new sound track.
  40826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40827. * @param scene Define the scene the sound track belongs to
  40828. * @param options
  40829. */
  40830. constructor(scene: Scene, options?: ISoundTrackOptions);
  40831. private _initializeSoundTrackAudioGraph;
  40832. /**
  40833. * Release the sound track and its associated resources
  40834. */
  40835. dispose(): void;
  40836. /**
  40837. * Adds a sound to this sound track
  40838. * @param sound define the cound to add
  40839. * @ignoreNaming
  40840. */
  40841. AddSound(sound: Sound): void;
  40842. /**
  40843. * Removes a sound to this sound track
  40844. * @param sound define the cound to remove
  40845. * @ignoreNaming
  40846. */
  40847. RemoveSound(sound: Sound): void;
  40848. /**
  40849. * Set a global volume for the full sound track.
  40850. * @param newVolume Define the new volume of the sound track
  40851. */
  40852. setVolume(newVolume: number): void;
  40853. /**
  40854. * Switch the panning model to HRTF:
  40855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40857. */
  40858. switchPanningModelToHRTF(): void;
  40859. /**
  40860. * Switch the panning model to Equal Power:
  40861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40863. */
  40864. switchPanningModelToEqualPower(): void;
  40865. /**
  40866. * Connect the sound track to an audio analyser allowing some amazing
  40867. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40869. * @param analyser The analyser to connect to the engine
  40870. */
  40871. connectToAnalyser(analyser: Analyser): void;
  40872. }
  40873. }
  40874. declare module BABYLON {
  40875. interface AbstractScene {
  40876. /**
  40877. * The list of sounds used in the scene.
  40878. */
  40879. sounds: Nullable<Array<Sound>>;
  40880. }
  40881. interface Scene {
  40882. /**
  40883. * @hidden
  40884. * Backing field
  40885. */
  40886. _mainSoundTrack: SoundTrack;
  40887. /**
  40888. * The main sound track played by the scene.
  40889. * It cotains your primary collection of sounds.
  40890. */
  40891. mainSoundTrack: SoundTrack;
  40892. /**
  40893. * The list of sound tracks added to the scene
  40894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40895. */
  40896. soundTracks: Nullable<Array<SoundTrack>>;
  40897. /**
  40898. * Gets a sound using a given name
  40899. * @param name defines the name to search for
  40900. * @return the found sound or null if not found at all.
  40901. */
  40902. getSoundByName(name: string): Nullable<Sound>;
  40903. /**
  40904. * Gets or sets if audio support is enabled
  40905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40906. */
  40907. audioEnabled: boolean;
  40908. /**
  40909. * Gets or sets if audio will be output to headphones
  40910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40911. */
  40912. headphone: boolean;
  40913. /**
  40914. * Gets or sets custom audio listener position provider
  40915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40916. */
  40917. audioListenerPositionProvider: Nullable<() => Vector3>;
  40918. /**
  40919. * Gets or sets a refresh rate when using 3D audio positioning
  40920. */
  40921. audioPositioningRefreshRate: number;
  40922. }
  40923. /**
  40924. * Defines the sound scene component responsible to manage any sounds
  40925. * in a given scene.
  40926. */
  40927. export class AudioSceneComponent implements ISceneSerializableComponent {
  40928. /**
  40929. * The component name helpfull to identify the component in the list of scene components.
  40930. */
  40931. readonly name: string;
  40932. /**
  40933. * The scene the component belongs to.
  40934. */
  40935. scene: Scene;
  40936. private _audioEnabled;
  40937. /**
  40938. * Gets whether audio is enabled or not.
  40939. * Please use related enable/disable method to switch state.
  40940. */
  40941. get audioEnabled(): boolean;
  40942. private _headphone;
  40943. /**
  40944. * Gets whether audio is outputing to headphone or not.
  40945. * Please use the according Switch methods to change output.
  40946. */
  40947. get headphone(): boolean;
  40948. /**
  40949. * Gets or sets a refresh rate when using 3D audio positioning
  40950. */
  40951. audioPositioningRefreshRate: number;
  40952. private _audioListenerPositionProvider;
  40953. /**
  40954. * Gets the current audio listener position provider
  40955. */
  40956. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40957. /**
  40958. * Sets a custom listener position for all sounds in the scene
  40959. * By default, this is the position of the first active camera
  40960. */
  40961. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40962. /**
  40963. * Creates a new instance of the component for the given scene
  40964. * @param scene Defines the scene to register the component in
  40965. */
  40966. constructor(scene: Scene);
  40967. /**
  40968. * Registers the component in a given scene
  40969. */
  40970. register(): void;
  40971. /**
  40972. * Rebuilds the elements related to this component in case of
  40973. * context lost for instance.
  40974. */
  40975. rebuild(): void;
  40976. /**
  40977. * Serializes the component data to the specified json object
  40978. * @param serializationObject The object to serialize to
  40979. */
  40980. serialize(serializationObject: any): void;
  40981. /**
  40982. * Adds all the elements from the container to the scene
  40983. * @param container the container holding the elements
  40984. */
  40985. addFromContainer(container: AbstractScene): void;
  40986. /**
  40987. * Removes all the elements in the container from the scene
  40988. * @param container contains the elements to remove
  40989. * @param dispose if the removed element should be disposed (default: false)
  40990. */
  40991. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40992. /**
  40993. * Disposes the component and the associated ressources.
  40994. */
  40995. dispose(): void;
  40996. /**
  40997. * Disables audio in the associated scene.
  40998. */
  40999. disableAudio(): void;
  41000. /**
  41001. * Enables audio in the associated scene.
  41002. */
  41003. enableAudio(): void;
  41004. /**
  41005. * Switch audio to headphone output.
  41006. */
  41007. switchAudioModeForHeadphones(): void;
  41008. /**
  41009. * Switch audio to normal speakers.
  41010. */
  41011. switchAudioModeForNormalSpeakers(): void;
  41012. private _cachedCameraDirection;
  41013. private _cachedCameraPosition;
  41014. private _lastCheck;
  41015. private _afterRender;
  41016. }
  41017. }
  41018. declare module BABYLON {
  41019. /**
  41020. * Wraps one or more Sound objects and selects one with random weight for playback.
  41021. */
  41022. export class WeightedSound {
  41023. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41024. loop: boolean;
  41025. private _coneInnerAngle;
  41026. private _coneOuterAngle;
  41027. private _volume;
  41028. /** A Sound is currently playing. */
  41029. isPlaying: boolean;
  41030. /** A Sound is currently paused. */
  41031. isPaused: boolean;
  41032. private _sounds;
  41033. private _weights;
  41034. private _currentIndex?;
  41035. /**
  41036. * Creates a new WeightedSound from the list of sounds given.
  41037. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41038. * @param sounds Array of Sounds that will be selected from.
  41039. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41040. */
  41041. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41042. /**
  41043. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41044. */
  41045. get directionalConeInnerAngle(): number;
  41046. /**
  41047. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41048. */
  41049. set directionalConeInnerAngle(value: number);
  41050. /**
  41051. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41052. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41053. */
  41054. get directionalConeOuterAngle(): number;
  41055. /**
  41056. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41057. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41058. */
  41059. set directionalConeOuterAngle(value: number);
  41060. /**
  41061. * Playback volume.
  41062. */
  41063. get volume(): number;
  41064. /**
  41065. * Playback volume.
  41066. */
  41067. set volume(value: number);
  41068. private _onended;
  41069. /**
  41070. * Suspend playback
  41071. */
  41072. pause(): void;
  41073. /**
  41074. * Stop playback
  41075. */
  41076. stop(): void;
  41077. /**
  41078. * Start playback.
  41079. * @param startOffset Position the clip head at a specific time in seconds.
  41080. */
  41081. play(startOffset?: number): void;
  41082. }
  41083. }
  41084. declare module BABYLON {
  41085. /**
  41086. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41087. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41088. */
  41089. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41090. /**
  41091. * Gets the name of the behavior.
  41092. */
  41093. get name(): string;
  41094. /**
  41095. * The easing function used by animations
  41096. */
  41097. static EasingFunction: BackEase;
  41098. /**
  41099. * The easing mode used by animations
  41100. */
  41101. static EasingMode: number;
  41102. /**
  41103. * The duration of the animation, in milliseconds
  41104. */
  41105. transitionDuration: number;
  41106. /**
  41107. * Length of the distance animated by the transition when lower radius is reached
  41108. */
  41109. lowerRadiusTransitionRange: number;
  41110. /**
  41111. * Length of the distance animated by the transition when upper radius is reached
  41112. */
  41113. upperRadiusTransitionRange: number;
  41114. private _autoTransitionRange;
  41115. /**
  41116. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41117. */
  41118. get autoTransitionRange(): boolean;
  41119. /**
  41120. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41121. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41122. */
  41123. set autoTransitionRange(value: boolean);
  41124. private _attachedCamera;
  41125. private _onAfterCheckInputsObserver;
  41126. private _onMeshTargetChangedObserver;
  41127. /**
  41128. * Initializes the behavior.
  41129. */
  41130. init(): void;
  41131. /**
  41132. * Attaches the behavior to its arc rotate camera.
  41133. * @param camera Defines the camera to attach the behavior to
  41134. */
  41135. attach(camera: ArcRotateCamera): void;
  41136. /**
  41137. * Detaches the behavior from its current arc rotate camera.
  41138. */
  41139. detach(): void;
  41140. private _radiusIsAnimating;
  41141. private _radiusBounceTransition;
  41142. private _animatables;
  41143. private _cachedWheelPrecision;
  41144. /**
  41145. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41146. * @param radiusLimit The limit to check against.
  41147. * @return Bool to indicate if at limit.
  41148. */
  41149. private _isRadiusAtLimit;
  41150. /**
  41151. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41152. * @param radiusDelta The delta by which to animate to. Can be negative.
  41153. */
  41154. private _applyBoundRadiusAnimation;
  41155. /**
  41156. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41157. */
  41158. protected _clearAnimationLocks(): void;
  41159. /**
  41160. * Stops and removes all animations that have been applied to the camera
  41161. */
  41162. stopAllAnimations(): void;
  41163. }
  41164. }
  41165. declare module BABYLON {
  41166. /**
  41167. * 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.
  41168. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41169. */
  41170. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41171. /**
  41172. * Gets the name of the behavior.
  41173. */
  41174. get name(): string;
  41175. private _mode;
  41176. private _radiusScale;
  41177. private _positionScale;
  41178. private _defaultElevation;
  41179. private _elevationReturnTime;
  41180. private _elevationReturnWaitTime;
  41181. private _zoomStopsAnimation;
  41182. private _framingTime;
  41183. /**
  41184. * The easing function used by animations
  41185. */
  41186. static EasingFunction: ExponentialEase;
  41187. /**
  41188. * The easing mode used by animations
  41189. */
  41190. static EasingMode: number;
  41191. /**
  41192. * Sets the current mode used by the behavior
  41193. */
  41194. set mode(mode: number);
  41195. /**
  41196. * Gets current mode used by the behavior.
  41197. */
  41198. get mode(): number;
  41199. /**
  41200. * Sets the scale applied to the radius (1 by default)
  41201. */
  41202. set radiusScale(radius: number);
  41203. /**
  41204. * Gets the scale applied to the radius
  41205. */
  41206. get radiusScale(): number;
  41207. /**
  41208. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41209. */
  41210. set positionScale(scale: number);
  41211. /**
  41212. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41213. */
  41214. get positionScale(): number;
  41215. /**
  41216. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41217. * behaviour is triggered, in radians.
  41218. */
  41219. set defaultElevation(elevation: number);
  41220. /**
  41221. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41222. * behaviour is triggered, in radians.
  41223. */
  41224. get defaultElevation(): number;
  41225. /**
  41226. * Sets the time (in milliseconds) taken to return to the default beta position.
  41227. * Negative value indicates camera should not return to default.
  41228. */
  41229. set elevationReturnTime(speed: number);
  41230. /**
  41231. * Gets the time (in milliseconds) taken to return to the default beta position.
  41232. * Negative value indicates camera should not return to default.
  41233. */
  41234. get elevationReturnTime(): number;
  41235. /**
  41236. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41237. */
  41238. set elevationReturnWaitTime(time: number);
  41239. /**
  41240. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41241. */
  41242. get elevationReturnWaitTime(): number;
  41243. /**
  41244. * Sets the flag that indicates if user zooming should stop animation.
  41245. */
  41246. set zoomStopsAnimation(flag: boolean);
  41247. /**
  41248. * Gets the flag that indicates if user zooming should stop animation.
  41249. */
  41250. get zoomStopsAnimation(): boolean;
  41251. /**
  41252. * Sets the transition time when framing the mesh, in milliseconds
  41253. */
  41254. set framingTime(time: number);
  41255. /**
  41256. * Gets the transition time when framing the mesh, in milliseconds
  41257. */
  41258. get framingTime(): number;
  41259. /**
  41260. * Define if the behavior should automatically change the configured
  41261. * camera limits and sensibilities.
  41262. */
  41263. autoCorrectCameraLimitsAndSensibility: boolean;
  41264. private _onPrePointerObservableObserver;
  41265. private _onAfterCheckInputsObserver;
  41266. private _onMeshTargetChangedObserver;
  41267. private _attachedCamera;
  41268. private _isPointerDown;
  41269. private _lastInteractionTime;
  41270. /**
  41271. * Initializes the behavior.
  41272. */
  41273. init(): void;
  41274. /**
  41275. * Attaches the behavior to its arc rotate camera.
  41276. * @param camera Defines the camera to attach the behavior to
  41277. */
  41278. attach(camera: ArcRotateCamera): void;
  41279. /**
  41280. * Detaches the behavior from its current arc rotate camera.
  41281. */
  41282. detach(): void;
  41283. private _animatables;
  41284. private _betaIsAnimating;
  41285. private _betaTransition;
  41286. private _radiusTransition;
  41287. private _vectorTransition;
  41288. /**
  41289. * Targets the given mesh and updates zoom level accordingly.
  41290. * @param mesh The mesh to target.
  41291. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41292. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41293. */
  41294. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41295. /**
  41296. * Targets the given mesh with its children and updates zoom level accordingly.
  41297. * @param mesh The mesh to target.
  41298. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41299. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41300. */
  41301. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41302. /**
  41303. * Targets the given meshes with their children and updates zoom level accordingly.
  41304. * @param meshes The mesh to target.
  41305. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41306. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41307. */
  41308. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41309. /**
  41310. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41311. * @param minimumWorld Determines the smaller position of the bounding box extend
  41312. * @param maximumWorld Determines the bigger position of the bounding box extend
  41313. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41314. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41315. */
  41316. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41317. /**
  41318. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41319. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41320. * frustum width.
  41321. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41322. * to fully enclose the mesh in the viewing frustum.
  41323. */
  41324. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41325. /**
  41326. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41327. * is automatically returned to its default position (expected to be above ground plane).
  41328. */
  41329. private _maintainCameraAboveGround;
  41330. /**
  41331. * Returns the frustum slope based on the canvas ratio and camera FOV
  41332. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41333. */
  41334. private _getFrustumSlope;
  41335. /**
  41336. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41337. */
  41338. private _clearAnimationLocks;
  41339. /**
  41340. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41341. */
  41342. private _applyUserInteraction;
  41343. /**
  41344. * Stops and removes all animations that have been applied to the camera
  41345. */
  41346. stopAllAnimations(): void;
  41347. /**
  41348. * Gets a value indicating if the user is moving the camera
  41349. */
  41350. get isUserIsMoving(): boolean;
  41351. /**
  41352. * The camera can move all the way towards the mesh.
  41353. */
  41354. static IgnoreBoundsSizeMode: number;
  41355. /**
  41356. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41357. */
  41358. static FitFrustumSidesMode: number;
  41359. }
  41360. }
  41361. declare module BABYLON {
  41362. /**
  41363. * Base class for Camera Pointer Inputs.
  41364. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41365. * for example usage.
  41366. */
  41367. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41368. /**
  41369. * Defines the camera the input is attached to.
  41370. */
  41371. abstract camera: Camera;
  41372. /**
  41373. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41374. */
  41375. protected _altKey: boolean;
  41376. protected _ctrlKey: boolean;
  41377. protected _metaKey: boolean;
  41378. protected _shiftKey: boolean;
  41379. /**
  41380. * Which mouse buttons were pressed at time of last mouse event.
  41381. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41382. */
  41383. protected _buttonsPressed: number;
  41384. /**
  41385. * Defines the buttons associated with the input to handle camera move.
  41386. */
  41387. buttons: number[];
  41388. /**
  41389. * Attach the input controls to a specific dom element to get the input from.
  41390. * @param element Defines the element the controls should be listened from
  41391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41392. */
  41393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41394. /**
  41395. * Detach the current controls from the specified dom element.
  41396. * @param element Defines the element to stop listening the inputs from
  41397. */
  41398. detachControl(element: Nullable<HTMLElement>): void;
  41399. /**
  41400. * Gets the class name of the current input.
  41401. * @returns the class name
  41402. */
  41403. getClassName(): string;
  41404. /**
  41405. * Get the friendly name associated with the input class.
  41406. * @returns the input friendly name
  41407. */
  41408. getSimpleName(): string;
  41409. /**
  41410. * Called on pointer POINTERDOUBLETAP event.
  41411. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41412. */
  41413. protected onDoubleTap(type: string): void;
  41414. /**
  41415. * Called on pointer POINTERMOVE event if only a single touch is active.
  41416. * Override this method to provide functionality.
  41417. */
  41418. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41419. /**
  41420. * Called on pointer POINTERMOVE event if multiple touches are active.
  41421. * Override this method to provide functionality.
  41422. */
  41423. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41424. /**
  41425. * Called on JS contextmenu event.
  41426. * Override this method to provide functionality.
  41427. */
  41428. protected onContextMenu(evt: PointerEvent): void;
  41429. /**
  41430. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41431. * press.
  41432. * Override this method to provide functionality.
  41433. */
  41434. protected onButtonDown(evt: PointerEvent): void;
  41435. /**
  41436. * Called each time a new POINTERUP event occurs. Ie, for each button
  41437. * release.
  41438. * Override this method to provide functionality.
  41439. */
  41440. protected onButtonUp(evt: PointerEvent): void;
  41441. /**
  41442. * Called when window becomes inactive.
  41443. * Override this method to provide functionality.
  41444. */
  41445. protected onLostFocus(): void;
  41446. private _pointerInput;
  41447. private _observer;
  41448. private _onLostFocus;
  41449. private pointA;
  41450. private pointB;
  41451. }
  41452. }
  41453. declare module BABYLON {
  41454. /**
  41455. * Manage the pointers inputs to control an arc rotate camera.
  41456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41457. */
  41458. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41459. /**
  41460. * Defines the camera the input is attached to.
  41461. */
  41462. camera: ArcRotateCamera;
  41463. /**
  41464. * Gets the class name of the current input.
  41465. * @returns the class name
  41466. */
  41467. getClassName(): string;
  41468. /**
  41469. * Defines the buttons associated with the input to handle camera move.
  41470. */
  41471. buttons: number[];
  41472. /**
  41473. * Defines the pointer angular sensibility along the X axis or how fast is
  41474. * the camera rotating.
  41475. */
  41476. angularSensibilityX: number;
  41477. /**
  41478. * Defines the pointer angular sensibility along the Y axis or how fast is
  41479. * the camera rotating.
  41480. */
  41481. angularSensibilityY: number;
  41482. /**
  41483. * Defines the pointer pinch precision or how fast is the camera zooming.
  41484. */
  41485. pinchPrecision: number;
  41486. /**
  41487. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41488. * from 0.
  41489. * It defines the percentage of current camera.radius to use as delta when
  41490. * pinch zoom is used.
  41491. */
  41492. pinchDeltaPercentage: number;
  41493. /**
  41494. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41495. * that any object in the plane at the camera's target point will scale
  41496. * perfectly with finger motion.
  41497. * Overrides pinchDeltaPercentage and pinchPrecision.
  41498. */
  41499. useNaturalPinchZoom: boolean;
  41500. /**
  41501. * Defines the pointer panning sensibility or how fast is the camera moving.
  41502. */
  41503. panningSensibility: number;
  41504. /**
  41505. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41506. */
  41507. multiTouchPanning: boolean;
  41508. /**
  41509. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41510. * zoom (pinch) through multitouch.
  41511. */
  41512. multiTouchPanAndZoom: boolean;
  41513. /**
  41514. * Revers pinch action direction.
  41515. */
  41516. pinchInwards: boolean;
  41517. private _isPanClick;
  41518. private _twoFingerActivityCount;
  41519. private _isPinching;
  41520. /**
  41521. * Called on pointer POINTERMOVE event if only a single touch is active.
  41522. */
  41523. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41524. /**
  41525. * Called on pointer POINTERDOUBLETAP event.
  41526. */
  41527. protected onDoubleTap(type: string): void;
  41528. /**
  41529. * Called on pointer POINTERMOVE event if multiple touches are active.
  41530. */
  41531. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41532. /**
  41533. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41534. * press.
  41535. */
  41536. protected onButtonDown(evt: PointerEvent): void;
  41537. /**
  41538. * Called each time a new POINTERUP event occurs. Ie, for each button
  41539. * release.
  41540. */
  41541. protected onButtonUp(evt: PointerEvent): void;
  41542. /**
  41543. * Called when window becomes inactive.
  41544. */
  41545. protected onLostFocus(): void;
  41546. }
  41547. }
  41548. declare module BABYLON {
  41549. /**
  41550. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41552. */
  41553. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41554. /**
  41555. * Defines the camera the input is attached to.
  41556. */
  41557. camera: ArcRotateCamera;
  41558. /**
  41559. * Defines the list of key codes associated with the up action (increase alpha)
  41560. */
  41561. keysUp: number[];
  41562. /**
  41563. * Defines the list of key codes associated with the down action (decrease alpha)
  41564. */
  41565. keysDown: number[];
  41566. /**
  41567. * Defines the list of key codes associated with the left action (increase beta)
  41568. */
  41569. keysLeft: number[];
  41570. /**
  41571. * Defines the list of key codes associated with the right action (decrease beta)
  41572. */
  41573. keysRight: number[];
  41574. /**
  41575. * Defines the list of key codes associated with the reset action.
  41576. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41577. */
  41578. keysReset: number[];
  41579. /**
  41580. * Defines the panning sensibility of the inputs.
  41581. * (How fast is the camera panning)
  41582. */
  41583. panningSensibility: number;
  41584. /**
  41585. * Defines the zooming sensibility of the inputs.
  41586. * (How fast is the camera zooming)
  41587. */
  41588. zoomingSensibility: number;
  41589. /**
  41590. * Defines whether maintaining the alt key down switch the movement mode from
  41591. * orientation to zoom.
  41592. */
  41593. useAltToZoom: boolean;
  41594. /**
  41595. * Rotation speed of the camera
  41596. */
  41597. angularSpeed: number;
  41598. private _keys;
  41599. private _ctrlPressed;
  41600. private _altPressed;
  41601. private _onCanvasBlurObserver;
  41602. private _onKeyboardObserver;
  41603. private _engine;
  41604. private _scene;
  41605. /**
  41606. * Attach the input controls to a specific dom element to get the input from.
  41607. * @param element Defines the element the controls should be listened from
  41608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41609. */
  41610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41611. /**
  41612. * Detach the current controls from the specified dom element.
  41613. * @param element Defines the element to stop listening the inputs from
  41614. */
  41615. detachControl(element: Nullable<HTMLElement>): void;
  41616. /**
  41617. * Update the current camera state depending on the inputs that have been used this frame.
  41618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41619. */
  41620. checkInputs(): void;
  41621. /**
  41622. * Gets the class name of the current intput.
  41623. * @returns the class name
  41624. */
  41625. getClassName(): string;
  41626. /**
  41627. * Get the friendly name associated with the input class.
  41628. * @returns the input friendly name
  41629. */
  41630. getSimpleName(): string;
  41631. }
  41632. }
  41633. declare module BABYLON {
  41634. /**
  41635. * Manage the mouse wheel inputs to control an arc rotate camera.
  41636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41637. */
  41638. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41639. /**
  41640. * Defines the camera the input is attached to.
  41641. */
  41642. camera: ArcRotateCamera;
  41643. /**
  41644. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41645. */
  41646. wheelPrecision: number;
  41647. /**
  41648. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41649. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41650. */
  41651. wheelDeltaPercentage: number;
  41652. private _wheel;
  41653. private _observer;
  41654. private computeDeltaFromMouseWheelLegacyEvent;
  41655. /**
  41656. * Attach the input controls to a specific dom element to get the input from.
  41657. * @param element Defines the element the controls should be listened from
  41658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41659. */
  41660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41661. /**
  41662. * Detach the current controls from the specified dom element.
  41663. * @param element Defines the element to stop listening the inputs from
  41664. */
  41665. detachControl(element: Nullable<HTMLElement>): void;
  41666. /**
  41667. * Gets the class name of the current intput.
  41668. * @returns the class name
  41669. */
  41670. getClassName(): string;
  41671. /**
  41672. * Get the friendly name associated with the input class.
  41673. * @returns the input friendly name
  41674. */
  41675. getSimpleName(): string;
  41676. }
  41677. }
  41678. declare module BABYLON {
  41679. /**
  41680. * Default Inputs manager for the ArcRotateCamera.
  41681. * It groups all the default supported inputs for ease of use.
  41682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41683. */
  41684. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41685. /**
  41686. * Instantiates a new ArcRotateCameraInputsManager.
  41687. * @param camera Defines the camera the inputs belong to
  41688. */
  41689. constructor(camera: ArcRotateCamera);
  41690. /**
  41691. * Add mouse wheel input support to the input manager.
  41692. * @returns the current input manager
  41693. */
  41694. addMouseWheel(): ArcRotateCameraInputsManager;
  41695. /**
  41696. * Add pointers input support to the input manager.
  41697. * @returns the current input manager
  41698. */
  41699. addPointers(): ArcRotateCameraInputsManager;
  41700. /**
  41701. * Add keyboard input support to the input manager.
  41702. * @returns the current input manager
  41703. */
  41704. addKeyboard(): ArcRotateCameraInputsManager;
  41705. }
  41706. }
  41707. declare module BABYLON {
  41708. /**
  41709. * This represents an orbital type of camera.
  41710. *
  41711. * 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.
  41712. * 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.
  41713. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41714. */
  41715. export class ArcRotateCamera extends TargetCamera {
  41716. /**
  41717. * Defines the rotation angle of the camera along the longitudinal axis.
  41718. */
  41719. alpha: number;
  41720. /**
  41721. * Defines the rotation angle of the camera along the latitudinal axis.
  41722. */
  41723. beta: number;
  41724. /**
  41725. * Defines the radius of the camera from it s target point.
  41726. */
  41727. radius: number;
  41728. protected _target: Vector3;
  41729. protected _targetHost: Nullable<AbstractMesh>;
  41730. /**
  41731. * Defines the target point of the camera.
  41732. * The camera looks towards it form the radius distance.
  41733. */
  41734. get target(): Vector3;
  41735. set target(value: Vector3);
  41736. /**
  41737. * Define the current local position of the camera in the scene
  41738. */
  41739. get position(): Vector3;
  41740. set position(newPosition: Vector3);
  41741. protected _upVector: Vector3;
  41742. protected _upToYMatrix: Matrix;
  41743. protected _YToUpMatrix: Matrix;
  41744. /**
  41745. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41746. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41747. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41748. */
  41749. set upVector(vec: Vector3);
  41750. get upVector(): Vector3;
  41751. /**
  41752. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41753. */
  41754. setMatUp(): void;
  41755. /**
  41756. * Current inertia value on the longitudinal axis.
  41757. * The bigger this number the longer it will take for the camera to stop.
  41758. */
  41759. inertialAlphaOffset: number;
  41760. /**
  41761. * Current inertia value on the latitudinal axis.
  41762. * The bigger this number the longer it will take for the camera to stop.
  41763. */
  41764. inertialBetaOffset: number;
  41765. /**
  41766. * Current inertia value on the radius axis.
  41767. * The bigger this number the longer it will take for the camera to stop.
  41768. */
  41769. inertialRadiusOffset: number;
  41770. /**
  41771. * Minimum allowed angle on the longitudinal axis.
  41772. * This can help limiting how the Camera is able to move in the scene.
  41773. */
  41774. lowerAlphaLimit: Nullable<number>;
  41775. /**
  41776. * Maximum allowed angle on the longitudinal axis.
  41777. * This can help limiting how the Camera is able to move in the scene.
  41778. */
  41779. upperAlphaLimit: Nullable<number>;
  41780. /**
  41781. * Minimum allowed angle on the latitudinal axis.
  41782. * This can help limiting how the Camera is able to move in the scene.
  41783. */
  41784. lowerBetaLimit: number;
  41785. /**
  41786. * Maximum allowed angle on the latitudinal axis.
  41787. * This can help limiting how the Camera is able to move in the scene.
  41788. */
  41789. upperBetaLimit: number;
  41790. /**
  41791. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41792. * This can help limiting how the Camera is able to move in the scene.
  41793. */
  41794. lowerRadiusLimit: Nullable<number>;
  41795. /**
  41796. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41797. * This can help limiting how the Camera is able to move in the scene.
  41798. */
  41799. upperRadiusLimit: Nullable<number>;
  41800. /**
  41801. * Defines the current inertia value used during panning of the camera along the X axis.
  41802. */
  41803. inertialPanningX: number;
  41804. /**
  41805. * Defines the current inertia value used during panning of the camera along the Y axis.
  41806. */
  41807. inertialPanningY: number;
  41808. /**
  41809. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41810. * Basically if your fingers moves away from more than this distance you will be considered
  41811. * in pinch mode.
  41812. */
  41813. pinchToPanMaxDistance: number;
  41814. /**
  41815. * Defines the maximum distance the camera can pan.
  41816. * This could help keeping the cammera always in your scene.
  41817. */
  41818. panningDistanceLimit: Nullable<number>;
  41819. /**
  41820. * Defines the target of the camera before paning.
  41821. */
  41822. panningOriginTarget: Vector3;
  41823. /**
  41824. * Defines the value of the inertia used during panning.
  41825. * 0 would mean stop inertia and one would mean no decelleration at all.
  41826. */
  41827. panningInertia: number;
  41828. /**
  41829. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41830. */
  41831. get angularSensibilityX(): number;
  41832. set angularSensibilityX(value: number);
  41833. /**
  41834. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41835. */
  41836. get angularSensibilityY(): number;
  41837. set angularSensibilityY(value: number);
  41838. /**
  41839. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41840. */
  41841. get pinchPrecision(): number;
  41842. set pinchPrecision(value: number);
  41843. /**
  41844. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41845. * It will be used instead of pinchDeltaPrecision if different from 0.
  41846. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41847. */
  41848. get pinchDeltaPercentage(): number;
  41849. set pinchDeltaPercentage(value: number);
  41850. /**
  41851. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41852. * and pinch delta percentage.
  41853. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41854. * that any object in the plane at the camera's target point will scale
  41855. * perfectly with finger motion.
  41856. */
  41857. get useNaturalPinchZoom(): boolean;
  41858. set useNaturalPinchZoom(value: boolean);
  41859. /**
  41860. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41861. */
  41862. get panningSensibility(): number;
  41863. set panningSensibility(value: number);
  41864. /**
  41865. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41866. */
  41867. get keysUp(): number[];
  41868. set keysUp(value: number[]);
  41869. /**
  41870. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41871. */
  41872. get keysDown(): number[];
  41873. set keysDown(value: number[]);
  41874. /**
  41875. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41876. */
  41877. get keysLeft(): number[];
  41878. set keysLeft(value: number[]);
  41879. /**
  41880. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41881. */
  41882. get keysRight(): number[];
  41883. set keysRight(value: number[]);
  41884. /**
  41885. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41886. */
  41887. get wheelPrecision(): number;
  41888. set wheelPrecision(value: number);
  41889. /**
  41890. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41891. * It will be used instead of pinchDeltaPrecision if different from 0.
  41892. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41893. */
  41894. get wheelDeltaPercentage(): number;
  41895. set wheelDeltaPercentage(value: number);
  41896. /**
  41897. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41898. */
  41899. zoomOnFactor: number;
  41900. /**
  41901. * Defines a screen offset for the camera position.
  41902. */
  41903. targetScreenOffset: Vector2;
  41904. /**
  41905. * Allows the camera to be completely reversed.
  41906. * If false the camera can not arrive upside down.
  41907. */
  41908. allowUpsideDown: boolean;
  41909. /**
  41910. * Define if double tap/click is used to restore the previously saved state of the camera.
  41911. */
  41912. useInputToRestoreState: boolean;
  41913. /** @hidden */
  41914. _viewMatrix: Matrix;
  41915. /** @hidden */
  41916. _useCtrlForPanning: boolean;
  41917. /** @hidden */
  41918. _panningMouseButton: number;
  41919. /**
  41920. * Defines the input associated to the camera.
  41921. */
  41922. inputs: ArcRotateCameraInputsManager;
  41923. /** @hidden */
  41924. _reset: () => void;
  41925. /**
  41926. * Defines the allowed panning axis.
  41927. */
  41928. panningAxis: Vector3;
  41929. protected _localDirection: Vector3;
  41930. protected _transformedDirection: Vector3;
  41931. private _bouncingBehavior;
  41932. /**
  41933. * Gets the bouncing behavior of the camera if it has been enabled.
  41934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41935. */
  41936. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41937. /**
  41938. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41939. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41940. */
  41941. get useBouncingBehavior(): boolean;
  41942. set useBouncingBehavior(value: boolean);
  41943. private _framingBehavior;
  41944. /**
  41945. * Gets the framing behavior of the camera if it has been enabled.
  41946. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41947. */
  41948. get framingBehavior(): Nullable<FramingBehavior>;
  41949. /**
  41950. * Defines if the framing behavior of the camera is enabled on the camera.
  41951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41952. */
  41953. get useFramingBehavior(): boolean;
  41954. set useFramingBehavior(value: boolean);
  41955. private _autoRotationBehavior;
  41956. /**
  41957. * Gets the auto rotation behavior of the camera if it has been enabled.
  41958. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41959. */
  41960. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41961. /**
  41962. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41963. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41964. */
  41965. get useAutoRotationBehavior(): boolean;
  41966. set useAutoRotationBehavior(value: boolean);
  41967. /**
  41968. * Observable triggered when the mesh target has been changed on the camera.
  41969. */
  41970. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41971. /**
  41972. * Event raised when the camera is colliding with a mesh.
  41973. */
  41974. onCollide: (collidedMesh: AbstractMesh) => void;
  41975. /**
  41976. * Defines whether the camera should check collision with the objects oh the scene.
  41977. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41978. */
  41979. checkCollisions: boolean;
  41980. /**
  41981. * Defines the collision radius of the camera.
  41982. * This simulates a sphere around the camera.
  41983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41984. */
  41985. collisionRadius: Vector3;
  41986. protected _collider: Collider;
  41987. protected _previousPosition: Vector3;
  41988. protected _collisionVelocity: Vector3;
  41989. protected _newPosition: Vector3;
  41990. protected _previousAlpha: number;
  41991. protected _previousBeta: number;
  41992. protected _previousRadius: number;
  41993. protected _collisionTriggered: boolean;
  41994. protected _targetBoundingCenter: Nullable<Vector3>;
  41995. private _computationVector;
  41996. /**
  41997. * Instantiates a new ArcRotateCamera in a given scene
  41998. * @param name Defines the name of the camera
  41999. * @param alpha Defines the camera rotation along the logitudinal axis
  42000. * @param beta Defines the camera rotation along the latitudinal axis
  42001. * @param radius Defines the camera distance from its target
  42002. * @param target Defines the camera target
  42003. * @param scene Defines the scene the camera belongs to
  42004. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42005. */
  42006. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42007. /** @hidden */
  42008. _initCache(): void;
  42009. /** @hidden */
  42010. _updateCache(ignoreParentClass?: boolean): void;
  42011. protected _getTargetPosition(): Vector3;
  42012. private _storedAlpha;
  42013. private _storedBeta;
  42014. private _storedRadius;
  42015. private _storedTarget;
  42016. private _storedTargetScreenOffset;
  42017. /**
  42018. * Stores the current state of the camera (alpha, beta, radius and target)
  42019. * @returns the camera itself
  42020. */
  42021. storeState(): Camera;
  42022. /**
  42023. * @hidden
  42024. * Restored camera state. You must call storeState() first
  42025. */
  42026. _restoreStateValues(): boolean;
  42027. /** @hidden */
  42028. _isSynchronizedViewMatrix(): boolean;
  42029. /**
  42030. * Attached controls to the current camera.
  42031. * @param element Defines the element the controls should be listened from
  42032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42033. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42034. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42035. */
  42036. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42037. /**
  42038. * Detach the current controls from the camera.
  42039. * The camera will stop reacting to inputs.
  42040. * @param element Defines the element to stop listening the inputs from
  42041. */
  42042. detachControl(element: HTMLElement): void;
  42043. /** @hidden */
  42044. _checkInputs(): void;
  42045. protected _checkLimits(): void;
  42046. /**
  42047. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42048. */
  42049. rebuildAnglesAndRadius(): void;
  42050. /**
  42051. * Use a position to define the current camera related information like alpha, beta and radius
  42052. * @param position Defines the position to set the camera at
  42053. */
  42054. setPosition(position: Vector3): void;
  42055. /**
  42056. * Defines the target the camera should look at.
  42057. * This will automatically adapt alpha beta and radius to fit within the new target.
  42058. * @param target Defines the new target as a Vector or a mesh
  42059. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42060. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42061. */
  42062. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42063. /** @hidden */
  42064. _getViewMatrix(): Matrix;
  42065. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42066. /**
  42067. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42068. * @param meshes Defines the mesh to zoom on
  42069. * @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)
  42070. */
  42071. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42072. /**
  42073. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42074. * The target will be changed but the radius
  42075. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42076. * @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)
  42077. */
  42078. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42079. min: Vector3;
  42080. max: Vector3;
  42081. distance: number;
  42082. }, doNotUpdateMaxZ?: boolean): void;
  42083. /**
  42084. * @override
  42085. * Override Camera.createRigCamera
  42086. */
  42087. createRigCamera(name: string, cameraIndex: number): Camera;
  42088. /**
  42089. * @hidden
  42090. * @override
  42091. * Override Camera._updateRigCameras
  42092. */
  42093. _updateRigCameras(): void;
  42094. /**
  42095. * Destroy the camera and release the current resources hold by it.
  42096. */
  42097. dispose(): void;
  42098. /**
  42099. * Gets the current object class name.
  42100. * @return the class name
  42101. */
  42102. getClassName(): string;
  42103. }
  42104. }
  42105. declare module BABYLON {
  42106. /**
  42107. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42108. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42109. */
  42110. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42111. /**
  42112. * Gets the name of the behavior.
  42113. */
  42114. get name(): string;
  42115. private _zoomStopsAnimation;
  42116. private _idleRotationSpeed;
  42117. private _idleRotationWaitTime;
  42118. private _idleRotationSpinupTime;
  42119. /**
  42120. * Sets the flag that indicates if user zooming should stop animation.
  42121. */
  42122. set zoomStopsAnimation(flag: boolean);
  42123. /**
  42124. * Gets the flag that indicates if user zooming should stop animation.
  42125. */
  42126. get zoomStopsAnimation(): boolean;
  42127. /**
  42128. * Sets the default speed at which the camera rotates around the model.
  42129. */
  42130. set idleRotationSpeed(speed: number);
  42131. /**
  42132. * Gets the default speed at which the camera rotates around the model.
  42133. */
  42134. get idleRotationSpeed(): number;
  42135. /**
  42136. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42137. */
  42138. set idleRotationWaitTime(time: number);
  42139. /**
  42140. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42141. */
  42142. get idleRotationWaitTime(): number;
  42143. /**
  42144. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42145. */
  42146. set idleRotationSpinupTime(time: number);
  42147. /**
  42148. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42149. */
  42150. get idleRotationSpinupTime(): number;
  42151. /**
  42152. * Gets a value indicating if the camera is currently rotating because of this behavior
  42153. */
  42154. get rotationInProgress(): boolean;
  42155. private _onPrePointerObservableObserver;
  42156. private _onAfterCheckInputsObserver;
  42157. private _attachedCamera;
  42158. private _isPointerDown;
  42159. private _lastFrameTime;
  42160. private _lastInteractionTime;
  42161. private _cameraRotationSpeed;
  42162. /**
  42163. * Initializes the behavior.
  42164. */
  42165. init(): void;
  42166. /**
  42167. * Attaches the behavior to its arc rotate camera.
  42168. * @param camera Defines the camera to attach the behavior to
  42169. */
  42170. attach(camera: ArcRotateCamera): void;
  42171. /**
  42172. * Detaches the behavior from its current arc rotate camera.
  42173. */
  42174. detach(): void;
  42175. /**
  42176. * Returns true if user is scrolling.
  42177. * @return true if user is scrolling.
  42178. */
  42179. private _userIsZooming;
  42180. private _lastFrameRadius;
  42181. private _shouldAnimationStopForInteraction;
  42182. /**
  42183. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42184. */
  42185. private _applyUserInteraction;
  42186. private _userIsMoving;
  42187. }
  42188. }
  42189. declare module BABYLON {
  42190. /**
  42191. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42192. */
  42193. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42194. private ui;
  42195. /**
  42196. * The name of the behavior
  42197. */
  42198. name: string;
  42199. /**
  42200. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42201. */
  42202. distanceAwayFromFace: number;
  42203. /**
  42204. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42205. */
  42206. distanceAwayFromBottomOfFace: number;
  42207. private _faceVectors;
  42208. private _target;
  42209. private _scene;
  42210. private _onRenderObserver;
  42211. private _tmpMatrix;
  42212. private _tmpVector;
  42213. /**
  42214. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42215. * @param ui The transform node that should be attched to the mesh
  42216. */
  42217. constructor(ui: TransformNode);
  42218. /**
  42219. * Initializes the behavior
  42220. */
  42221. init(): void;
  42222. private _closestFace;
  42223. private _zeroVector;
  42224. private _lookAtTmpMatrix;
  42225. private _lookAtToRef;
  42226. /**
  42227. * Attaches the AttachToBoxBehavior to the passed in mesh
  42228. * @param target The mesh that the specified node will be attached to
  42229. */
  42230. attach(target: Mesh): void;
  42231. /**
  42232. * Detaches the behavior from the mesh
  42233. */
  42234. detach(): void;
  42235. }
  42236. }
  42237. declare module BABYLON {
  42238. /**
  42239. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42240. */
  42241. export class FadeInOutBehavior implements Behavior<Mesh> {
  42242. /**
  42243. * Time in milliseconds to delay before fading in (Default: 0)
  42244. */
  42245. delay: number;
  42246. /**
  42247. * Time in milliseconds for the mesh to fade in (Default: 300)
  42248. */
  42249. fadeInTime: number;
  42250. private _millisecondsPerFrame;
  42251. private _hovered;
  42252. private _hoverValue;
  42253. private _ownerNode;
  42254. /**
  42255. * Instatiates the FadeInOutBehavior
  42256. */
  42257. constructor();
  42258. /**
  42259. * The name of the behavior
  42260. */
  42261. get name(): string;
  42262. /**
  42263. * Initializes the behavior
  42264. */
  42265. init(): void;
  42266. /**
  42267. * Attaches the fade behavior on the passed in mesh
  42268. * @param ownerNode The mesh that will be faded in/out once attached
  42269. */
  42270. attach(ownerNode: Mesh): void;
  42271. /**
  42272. * Detaches the behavior from the mesh
  42273. */
  42274. detach(): void;
  42275. /**
  42276. * Triggers the mesh to begin fading in or out
  42277. * @param value if the object should fade in or out (true to fade in)
  42278. */
  42279. fadeIn(value: boolean): void;
  42280. private _update;
  42281. private _setAllVisibility;
  42282. }
  42283. }
  42284. declare module BABYLON {
  42285. /**
  42286. * Class containing a set of static utilities functions for managing Pivots
  42287. * @hidden
  42288. */
  42289. export class PivotTools {
  42290. private static _PivotCached;
  42291. private static _OldPivotPoint;
  42292. private static _PivotTranslation;
  42293. private static _PivotTmpVector;
  42294. /** @hidden */
  42295. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42296. /** @hidden */
  42297. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42298. }
  42299. }
  42300. declare module BABYLON {
  42301. /**
  42302. * Class containing static functions to help procedurally build meshes
  42303. */
  42304. export class PlaneBuilder {
  42305. /**
  42306. * Creates a plane mesh
  42307. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42308. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42309. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42311. * * 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
  42312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42313. * @param name defines the name of the mesh
  42314. * @param options defines the options used to create the mesh
  42315. * @param scene defines the hosting scene
  42316. * @returns the plane mesh
  42317. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42318. */
  42319. static CreatePlane(name: string, options: {
  42320. size?: number;
  42321. width?: number;
  42322. height?: number;
  42323. sideOrientation?: number;
  42324. frontUVs?: Vector4;
  42325. backUVs?: Vector4;
  42326. updatable?: boolean;
  42327. sourcePlane?: Plane;
  42328. }, scene?: Nullable<Scene>): Mesh;
  42329. }
  42330. }
  42331. declare module BABYLON {
  42332. /**
  42333. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42334. */
  42335. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42336. private static _AnyMouseID;
  42337. /**
  42338. * Abstract mesh the behavior is set on
  42339. */
  42340. attachedNode: AbstractMesh;
  42341. private _dragPlane;
  42342. private _scene;
  42343. private _pointerObserver;
  42344. private _beforeRenderObserver;
  42345. private static _planeScene;
  42346. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42347. /**
  42348. * 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)
  42349. */
  42350. maxDragAngle: number;
  42351. /**
  42352. * @hidden
  42353. */
  42354. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42355. /**
  42356. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42357. */
  42358. currentDraggingPointerID: number;
  42359. /**
  42360. * The last position where the pointer hit the drag plane in world space
  42361. */
  42362. lastDragPosition: Vector3;
  42363. /**
  42364. * If the behavior is currently in a dragging state
  42365. */
  42366. dragging: boolean;
  42367. /**
  42368. * 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)
  42369. */
  42370. dragDeltaRatio: number;
  42371. /**
  42372. * If the drag plane orientation should be updated during the dragging (Default: true)
  42373. */
  42374. updateDragPlane: boolean;
  42375. private _debugMode;
  42376. private _moving;
  42377. /**
  42378. * Fires each time the attached mesh is dragged with the pointer
  42379. * * delta between last drag position and current drag position in world space
  42380. * * dragDistance along the drag axis
  42381. * * dragPlaneNormal normal of the current drag plane used during the drag
  42382. * * dragPlanePoint in world space where the drag intersects the drag plane
  42383. */
  42384. onDragObservable: Observable<{
  42385. delta: Vector3;
  42386. dragPlanePoint: Vector3;
  42387. dragPlaneNormal: Vector3;
  42388. dragDistance: number;
  42389. pointerId: number;
  42390. }>;
  42391. /**
  42392. * Fires each time a drag begins (eg. mouse down on mesh)
  42393. */
  42394. onDragStartObservable: Observable<{
  42395. dragPlanePoint: Vector3;
  42396. pointerId: number;
  42397. }>;
  42398. /**
  42399. * Fires each time a drag ends (eg. mouse release after drag)
  42400. */
  42401. onDragEndObservable: Observable<{
  42402. dragPlanePoint: Vector3;
  42403. pointerId: number;
  42404. }>;
  42405. /**
  42406. * If the attached mesh should be moved when dragged
  42407. */
  42408. moveAttached: boolean;
  42409. /**
  42410. * If the drag behavior will react to drag events (Default: true)
  42411. */
  42412. enabled: boolean;
  42413. /**
  42414. * If pointer events should start and release the drag (Default: true)
  42415. */
  42416. startAndReleaseDragOnPointerEvents: boolean;
  42417. /**
  42418. * If camera controls should be detached during the drag
  42419. */
  42420. detachCameraControls: boolean;
  42421. /**
  42422. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42423. */
  42424. useObjectOrientationForDragging: boolean;
  42425. private _options;
  42426. /**
  42427. * Gets the options used by the behavior
  42428. */
  42429. get options(): {
  42430. dragAxis?: Vector3;
  42431. dragPlaneNormal?: Vector3;
  42432. };
  42433. /**
  42434. * Sets the options used by the behavior
  42435. */
  42436. set options(options: {
  42437. dragAxis?: Vector3;
  42438. dragPlaneNormal?: Vector3;
  42439. });
  42440. /**
  42441. * Creates a pointer drag behavior that can be attached to a mesh
  42442. * @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)
  42443. */
  42444. constructor(options?: {
  42445. dragAxis?: Vector3;
  42446. dragPlaneNormal?: Vector3;
  42447. });
  42448. /**
  42449. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42450. */
  42451. validateDrag: (targetPosition: Vector3) => boolean;
  42452. /**
  42453. * The name of the behavior
  42454. */
  42455. get name(): string;
  42456. /**
  42457. * Initializes the behavior
  42458. */
  42459. init(): void;
  42460. private _tmpVector;
  42461. private _alternatePickedPoint;
  42462. private _worldDragAxis;
  42463. private _targetPosition;
  42464. private _attachedElement;
  42465. /**
  42466. * Attaches the drag behavior the passed in mesh
  42467. * @param ownerNode The mesh that will be dragged around once attached
  42468. * @param predicate Predicate to use for pick filtering
  42469. */
  42470. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42471. /**
  42472. * Force relase the drag action by code.
  42473. */
  42474. releaseDrag(): void;
  42475. private _startDragRay;
  42476. private _lastPointerRay;
  42477. /**
  42478. * Simulates the start of a pointer drag event on the behavior
  42479. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42480. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42481. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42482. */
  42483. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42484. private _startDrag;
  42485. private _dragDelta;
  42486. private _moveDrag;
  42487. private _pickWithRayOnDragPlane;
  42488. private _pointA;
  42489. private _pointB;
  42490. private _pointC;
  42491. private _lineA;
  42492. private _lineB;
  42493. private _localAxis;
  42494. private _lookAt;
  42495. private _updateDragPlanePosition;
  42496. /**
  42497. * Detaches the behavior from the mesh
  42498. */
  42499. detach(): void;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /**
  42504. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42505. */
  42506. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42507. private _dragBehaviorA;
  42508. private _dragBehaviorB;
  42509. private _startDistance;
  42510. private _initialScale;
  42511. private _targetScale;
  42512. private _ownerNode;
  42513. private _sceneRenderObserver;
  42514. /**
  42515. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42516. */
  42517. constructor();
  42518. /**
  42519. * The name of the behavior
  42520. */
  42521. get name(): string;
  42522. /**
  42523. * Initializes the behavior
  42524. */
  42525. init(): void;
  42526. private _getCurrentDistance;
  42527. /**
  42528. * Attaches the scale behavior the passed in mesh
  42529. * @param ownerNode The mesh that will be scaled around once attached
  42530. */
  42531. attach(ownerNode: Mesh): void;
  42532. /**
  42533. * Detaches the behavior from the mesh
  42534. */
  42535. detach(): void;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /**
  42540. * 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
  42541. */
  42542. export class SixDofDragBehavior implements Behavior<Mesh> {
  42543. private static _virtualScene;
  42544. private _ownerNode;
  42545. private _sceneRenderObserver;
  42546. private _scene;
  42547. private _targetPosition;
  42548. private _virtualOriginMesh;
  42549. private _virtualDragMesh;
  42550. private _pointerObserver;
  42551. private _moving;
  42552. private _startingOrientation;
  42553. private _attachedElement;
  42554. /**
  42555. * 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)
  42556. */
  42557. private zDragFactor;
  42558. /**
  42559. * If the object should rotate to face the drag origin
  42560. */
  42561. rotateDraggedObject: boolean;
  42562. /**
  42563. * If the behavior is currently in a dragging state
  42564. */
  42565. dragging: boolean;
  42566. /**
  42567. * 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)
  42568. */
  42569. dragDeltaRatio: number;
  42570. /**
  42571. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42572. */
  42573. currentDraggingPointerID: number;
  42574. /**
  42575. * If camera controls should be detached during the drag
  42576. */
  42577. detachCameraControls: boolean;
  42578. /**
  42579. * Fires each time a drag starts
  42580. */
  42581. onDragStartObservable: Observable<{}>;
  42582. /**
  42583. * Fires each time a drag ends (eg. mouse release after drag)
  42584. */
  42585. onDragEndObservable: Observable<{}>;
  42586. /**
  42587. * 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
  42588. */
  42589. constructor();
  42590. /**
  42591. * The name of the behavior
  42592. */
  42593. get name(): string;
  42594. /**
  42595. * Initializes the behavior
  42596. */
  42597. init(): void;
  42598. /**
  42599. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42600. */
  42601. private get _pointerCamera();
  42602. /**
  42603. * Attaches the scale behavior the passed in mesh
  42604. * @param ownerNode The mesh that will be scaled around once attached
  42605. */
  42606. attach(ownerNode: Mesh): void;
  42607. /**
  42608. * Detaches the behavior from the mesh
  42609. */
  42610. detach(): void;
  42611. }
  42612. }
  42613. declare module BABYLON {
  42614. /**
  42615. * Class used to apply inverse kinematics to bones
  42616. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42617. */
  42618. export class BoneIKController {
  42619. private static _tmpVecs;
  42620. private static _tmpQuat;
  42621. private static _tmpMats;
  42622. /**
  42623. * Gets or sets the target mesh
  42624. */
  42625. targetMesh: AbstractMesh;
  42626. /** Gets or sets the mesh used as pole */
  42627. poleTargetMesh: AbstractMesh;
  42628. /**
  42629. * Gets or sets the bone used as pole
  42630. */
  42631. poleTargetBone: Nullable<Bone>;
  42632. /**
  42633. * Gets or sets the target position
  42634. */
  42635. targetPosition: Vector3;
  42636. /**
  42637. * Gets or sets the pole target position
  42638. */
  42639. poleTargetPosition: Vector3;
  42640. /**
  42641. * Gets or sets the pole target local offset
  42642. */
  42643. poleTargetLocalOffset: Vector3;
  42644. /**
  42645. * Gets or sets the pole angle
  42646. */
  42647. poleAngle: number;
  42648. /**
  42649. * Gets or sets the mesh associated with the controller
  42650. */
  42651. mesh: AbstractMesh;
  42652. /**
  42653. * 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)
  42654. */
  42655. slerpAmount: number;
  42656. private _bone1Quat;
  42657. private _bone1Mat;
  42658. private _bone2Ang;
  42659. private _bone1;
  42660. private _bone2;
  42661. private _bone1Length;
  42662. private _bone2Length;
  42663. private _maxAngle;
  42664. private _maxReach;
  42665. private _rightHandedSystem;
  42666. private _bendAxis;
  42667. private _slerping;
  42668. private _adjustRoll;
  42669. /**
  42670. * Gets or sets maximum allowed angle
  42671. */
  42672. get maxAngle(): number;
  42673. set maxAngle(value: number);
  42674. /**
  42675. * Creates a new BoneIKController
  42676. * @param mesh defines the mesh to control
  42677. * @param bone defines the bone to control
  42678. * @param options defines options to set up the controller
  42679. */
  42680. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42681. targetMesh?: AbstractMesh;
  42682. poleTargetMesh?: AbstractMesh;
  42683. poleTargetBone?: Bone;
  42684. poleTargetLocalOffset?: Vector3;
  42685. poleAngle?: number;
  42686. bendAxis?: Vector3;
  42687. maxAngle?: number;
  42688. slerpAmount?: number;
  42689. });
  42690. private _setMaxAngle;
  42691. /**
  42692. * Force the controller to update the bones
  42693. */
  42694. update(): void;
  42695. }
  42696. }
  42697. declare module BABYLON {
  42698. /**
  42699. * Class used to make a bone look toward a point in space
  42700. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42701. */
  42702. export class BoneLookController {
  42703. private static _tmpVecs;
  42704. private static _tmpQuat;
  42705. private static _tmpMats;
  42706. /**
  42707. * The target Vector3 that the bone will look at
  42708. */
  42709. target: Vector3;
  42710. /**
  42711. * The mesh that the bone is attached to
  42712. */
  42713. mesh: AbstractMesh;
  42714. /**
  42715. * The bone that will be looking to the target
  42716. */
  42717. bone: Bone;
  42718. /**
  42719. * The up axis of the coordinate system that is used when the bone is rotated
  42720. */
  42721. upAxis: Vector3;
  42722. /**
  42723. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42724. */
  42725. upAxisSpace: Space;
  42726. /**
  42727. * Used to make an adjustment to the yaw of the bone
  42728. */
  42729. adjustYaw: number;
  42730. /**
  42731. * Used to make an adjustment to the pitch of the bone
  42732. */
  42733. adjustPitch: number;
  42734. /**
  42735. * Used to make an adjustment to the roll of the bone
  42736. */
  42737. adjustRoll: number;
  42738. /**
  42739. * 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)
  42740. */
  42741. slerpAmount: number;
  42742. private _minYaw;
  42743. private _maxYaw;
  42744. private _minPitch;
  42745. private _maxPitch;
  42746. private _minYawSin;
  42747. private _minYawCos;
  42748. private _maxYawSin;
  42749. private _maxYawCos;
  42750. private _midYawConstraint;
  42751. private _minPitchTan;
  42752. private _maxPitchTan;
  42753. private _boneQuat;
  42754. private _slerping;
  42755. private _transformYawPitch;
  42756. private _transformYawPitchInv;
  42757. private _firstFrameSkipped;
  42758. private _yawRange;
  42759. private _fowardAxis;
  42760. /**
  42761. * Gets or sets the minimum yaw angle that the bone can look to
  42762. */
  42763. get minYaw(): number;
  42764. set minYaw(value: number);
  42765. /**
  42766. * Gets or sets the maximum yaw angle that the bone can look to
  42767. */
  42768. get maxYaw(): number;
  42769. set maxYaw(value: number);
  42770. /**
  42771. * Gets or sets the minimum pitch angle that the bone can look to
  42772. */
  42773. get minPitch(): number;
  42774. set minPitch(value: number);
  42775. /**
  42776. * Gets or sets the maximum pitch angle that the bone can look to
  42777. */
  42778. get maxPitch(): number;
  42779. set maxPitch(value: number);
  42780. /**
  42781. * Create a BoneLookController
  42782. * @param mesh the mesh that the bone belongs to
  42783. * @param bone the bone that will be looking to the target
  42784. * @param target the target Vector3 to look at
  42785. * @param options optional settings:
  42786. * * maxYaw: the maximum angle the bone will yaw to
  42787. * * minYaw: the minimum angle the bone will yaw to
  42788. * * maxPitch: the maximum angle the bone will pitch to
  42789. * * minPitch: the minimum angle the bone will yaw to
  42790. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42791. * * upAxis: the up axis of the coordinate system
  42792. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42793. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42794. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42795. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42796. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42797. * * adjustRoll: used to make an adjustment to the roll of the bone
  42798. **/
  42799. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42800. maxYaw?: number;
  42801. minYaw?: number;
  42802. maxPitch?: number;
  42803. minPitch?: number;
  42804. slerpAmount?: number;
  42805. upAxis?: Vector3;
  42806. upAxisSpace?: Space;
  42807. yawAxis?: Vector3;
  42808. pitchAxis?: Vector3;
  42809. adjustYaw?: number;
  42810. adjustPitch?: number;
  42811. adjustRoll?: number;
  42812. });
  42813. /**
  42814. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42815. */
  42816. update(): void;
  42817. private _getAngleDiff;
  42818. private _getAngleBetween;
  42819. private _isAngleBetween;
  42820. }
  42821. }
  42822. declare module BABYLON {
  42823. /**
  42824. * Manage the gamepad inputs to control an arc rotate camera.
  42825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42826. */
  42827. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42828. /**
  42829. * Defines the camera the input is attached to.
  42830. */
  42831. camera: ArcRotateCamera;
  42832. /**
  42833. * Defines the gamepad the input is gathering event from.
  42834. */
  42835. gamepad: Nullable<Gamepad>;
  42836. /**
  42837. * Defines the gamepad rotation sensiblity.
  42838. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42839. */
  42840. gamepadRotationSensibility: number;
  42841. /**
  42842. * Defines the gamepad move sensiblity.
  42843. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42844. */
  42845. gamepadMoveSensibility: number;
  42846. private _yAxisScale;
  42847. /**
  42848. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42849. */
  42850. get invertYAxis(): boolean;
  42851. set invertYAxis(value: boolean);
  42852. private _onGamepadConnectedObserver;
  42853. private _onGamepadDisconnectedObserver;
  42854. /**
  42855. * Attach the input controls to a specific dom element to get the input from.
  42856. * @param element Defines the element the controls should be listened from
  42857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42858. */
  42859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42860. /**
  42861. * Detach the current controls from the specified dom element.
  42862. * @param element Defines the element to stop listening the inputs from
  42863. */
  42864. detachControl(element: Nullable<HTMLElement>): void;
  42865. /**
  42866. * Update the current camera state depending on the inputs that have been used this frame.
  42867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42868. */
  42869. checkInputs(): void;
  42870. /**
  42871. * Gets the class name of the current intput.
  42872. * @returns the class name
  42873. */
  42874. getClassName(): string;
  42875. /**
  42876. * Get the friendly name associated with the input class.
  42877. * @returns the input friendly name
  42878. */
  42879. getSimpleName(): string;
  42880. }
  42881. }
  42882. declare module BABYLON {
  42883. interface ArcRotateCameraInputsManager {
  42884. /**
  42885. * Add orientation input support to the input manager.
  42886. * @returns the current input manager
  42887. */
  42888. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42889. }
  42890. /**
  42891. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42893. */
  42894. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42895. /**
  42896. * Defines the camera the input is attached to.
  42897. */
  42898. camera: ArcRotateCamera;
  42899. /**
  42900. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42901. */
  42902. alphaCorrection: number;
  42903. /**
  42904. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42905. */
  42906. gammaCorrection: number;
  42907. private _alpha;
  42908. private _gamma;
  42909. private _dirty;
  42910. private _deviceOrientationHandler;
  42911. /**
  42912. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42913. */
  42914. constructor();
  42915. /**
  42916. * Attach the input controls to a specific dom element to get the input from.
  42917. * @param element Defines the element the controls should be listened from
  42918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42919. */
  42920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42921. /** @hidden */
  42922. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42923. /**
  42924. * Update the current camera state depending on the inputs that have been used this frame.
  42925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42926. */
  42927. checkInputs(): void;
  42928. /**
  42929. * Detach the current controls from the specified dom element.
  42930. * @param element Defines the element to stop listening the inputs from
  42931. */
  42932. detachControl(element: Nullable<HTMLElement>): void;
  42933. /**
  42934. * Gets the class name of the current intput.
  42935. * @returns the class name
  42936. */
  42937. getClassName(): string;
  42938. /**
  42939. * Get the friendly name associated with the input class.
  42940. * @returns the input friendly name
  42941. */
  42942. getSimpleName(): string;
  42943. }
  42944. }
  42945. declare module BABYLON {
  42946. /**
  42947. * Listen to mouse events to control the camera.
  42948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42949. */
  42950. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42951. /**
  42952. * Defines the camera the input is attached to.
  42953. */
  42954. camera: FlyCamera;
  42955. /**
  42956. * Defines if touch is enabled. (Default is true.)
  42957. */
  42958. touchEnabled: boolean;
  42959. /**
  42960. * Defines the buttons associated with the input to handle camera rotation.
  42961. */
  42962. buttons: number[];
  42963. /**
  42964. * Assign buttons for Yaw control.
  42965. */
  42966. buttonsYaw: number[];
  42967. /**
  42968. * Assign buttons for Pitch control.
  42969. */
  42970. buttonsPitch: number[];
  42971. /**
  42972. * Assign buttons for Roll control.
  42973. */
  42974. buttonsRoll: number[];
  42975. /**
  42976. * Detect if any button is being pressed while mouse is moved.
  42977. * -1 = Mouse locked.
  42978. * 0 = Left button.
  42979. * 1 = Middle Button.
  42980. * 2 = Right Button.
  42981. */
  42982. activeButton: number;
  42983. /**
  42984. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42985. * Higher values reduce its sensitivity.
  42986. */
  42987. angularSensibility: number;
  42988. private _mousemoveCallback;
  42989. private _observer;
  42990. private _rollObserver;
  42991. private previousPosition;
  42992. private noPreventDefault;
  42993. private element;
  42994. /**
  42995. * Listen to mouse events to control the camera.
  42996. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42998. */
  42999. constructor(touchEnabled?: boolean);
  43000. /**
  43001. * Attach the mouse control to the HTML DOM element.
  43002. * @param element Defines the element that listens to the input events.
  43003. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43004. */
  43005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43006. /**
  43007. * Detach the current controls from the specified dom element.
  43008. * @param element Defines the element to stop listening the inputs from
  43009. */
  43010. detachControl(element: Nullable<HTMLElement>): void;
  43011. /**
  43012. * Gets the class name of the current input.
  43013. * @returns the class name.
  43014. */
  43015. getClassName(): string;
  43016. /**
  43017. * Get the friendly name associated with the input class.
  43018. * @returns the input's friendly name.
  43019. */
  43020. getSimpleName(): string;
  43021. private _pointerInput;
  43022. private _onMouseMove;
  43023. /**
  43024. * Rotate camera by mouse offset.
  43025. */
  43026. private rotateCamera;
  43027. }
  43028. }
  43029. declare module BABYLON {
  43030. /**
  43031. * Default Inputs manager for the FlyCamera.
  43032. * It groups all the default supported inputs for ease of use.
  43033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43034. */
  43035. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43036. /**
  43037. * Instantiates a new FlyCameraInputsManager.
  43038. * @param camera Defines the camera the inputs belong to.
  43039. */
  43040. constructor(camera: FlyCamera);
  43041. /**
  43042. * Add keyboard input support to the input manager.
  43043. * @returns the new FlyCameraKeyboardMoveInput().
  43044. */
  43045. addKeyboard(): FlyCameraInputsManager;
  43046. /**
  43047. * Add mouse input support to the input manager.
  43048. * @param touchEnabled Enable touch screen support.
  43049. * @returns the new FlyCameraMouseInput().
  43050. */
  43051. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43052. }
  43053. }
  43054. declare module BABYLON {
  43055. /**
  43056. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43057. * such as in a 3D Space Shooter or a Flight Simulator.
  43058. */
  43059. export class FlyCamera extends TargetCamera {
  43060. /**
  43061. * Define the collision ellipsoid of the camera.
  43062. * This is helpful for simulating a camera body, like a player's body.
  43063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43064. */
  43065. ellipsoid: Vector3;
  43066. /**
  43067. * Define an offset for the position of the ellipsoid around the camera.
  43068. * This can be helpful if the camera is attached away from the player's body center,
  43069. * such as at its head.
  43070. */
  43071. ellipsoidOffset: Vector3;
  43072. /**
  43073. * Enable or disable collisions of the camera with the rest of the scene objects.
  43074. */
  43075. checkCollisions: boolean;
  43076. /**
  43077. * Enable or disable gravity on the camera.
  43078. */
  43079. applyGravity: boolean;
  43080. /**
  43081. * Define the current direction the camera is moving to.
  43082. */
  43083. cameraDirection: Vector3;
  43084. /**
  43085. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43086. * This overrides and empties cameraRotation.
  43087. */
  43088. rotationQuaternion: Quaternion;
  43089. /**
  43090. * Track Roll to maintain the wanted Rolling when looking around.
  43091. */
  43092. _trackRoll: number;
  43093. /**
  43094. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43095. */
  43096. rollCorrect: number;
  43097. /**
  43098. * Mimic a banked turn, Rolling the camera when Yawing.
  43099. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43100. */
  43101. bankedTurn: boolean;
  43102. /**
  43103. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43104. */
  43105. bankedTurnLimit: number;
  43106. /**
  43107. * Value of 0 disables the banked Roll.
  43108. * Value of 1 is equal to the Yaw angle in radians.
  43109. */
  43110. bankedTurnMultiplier: number;
  43111. /**
  43112. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43113. */
  43114. inputs: FlyCameraInputsManager;
  43115. /**
  43116. * Gets the input sensibility for mouse input.
  43117. * Higher values reduce sensitivity.
  43118. */
  43119. get angularSensibility(): number;
  43120. /**
  43121. * Sets the input sensibility for a mouse input.
  43122. * Higher values reduce sensitivity.
  43123. */
  43124. set angularSensibility(value: number);
  43125. /**
  43126. * Get the keys for camera movement forward.
  43127. */
  43128. get keysForward(): number[];
  43129. /**
  43130. * Set the keys for camera movement forward.
  43131. */
  43132. set keysForward(value: number[]);
  43133. /**
  43134. * Get the keys for camera movement backward.
  43135. */
  43136. get keysBackward(): number[];
  43137. set keysBackward(value: number[]);
  43138. /**
  43139. * Get the keys for camera movement up.
  43140. */
  43141. get keysUp(): number[];
  43142. /**
  43143. * Set the keys for camera movement up.
  43144. */
  43145. set keysUp(value: number[]);
  43146. /**
  43147. * Get the keys for camera movement down.
  43148. */
  43149. get keysDown(): number[];
  43150. /**
  43151. * Set the keys for camera movement down.
  43152. */
  43153. set keysDown(value: number[]);
  43154. /**
  43155. * Get the keys for camera movement left.
  43156. */
  43157. get keysLeft(): number[];
  43158. /**
  43159. * Set the keys for camera movement left.
  43160. */
  43161. set keysLeft(value: number[]);
  43162. /**
  43163. * Set the keys for camera movement right.
  43164. */
  43165. get keysRight(): number[];
  43166. /**
  43167. * Set the keys for camera movement right.
  43168. */
  43169. set keysRight(value: number[]);
  43170. /**
  43171. * Event raised when the camera collides with a mesh in the scene.
  43172. */
  43173. onCollide: (collidedMesh: AbstractMesh) => void;
  43174. private _collider;
  43175. private _needMoveForGravity;
  43176. private _oldPosition;
  43177. private _diffPosition;
  43178. private _newPosition;
  43179. /** @hidden */
  43180. _localDirection: Vector3;
  43181. /** @hidden */
  43182. _transformedDirection: Vector3;
  43183. /**
  43184. * Instantiates a FlyCamera.
  43185. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43186. * such as in a 3D Space Shooter or a Flight Simulator.
  43187. * @param name Define the name of the camera in the scene.
  43188. * @param position Define the starting position of the camera in the scene.
  43189. * @param scene Define the scene the camera belongs to.
  43190. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43191. */
  43192. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43193. /**
  43194. * Attach a control to the HTML DOM element.
  43195. * @param element Defines the element that listens to the input events.
  43196. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43197. */
  43198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43199. /**
  43200. * Detach a control from the HTML DOM element.
  43201. * The camera will stop reacting to that input.
  43202. * @param element Defines the element that listens to the input events.
  43203. */
  43204. detachControl(element: HTMLElement): void;
  43205. private _collisionMask;
  43206. /**
  43207. * Get the mask that the camera ignores in collision events.
  43208. */
  43209. get collisionMask(): number;
  43210. /**
  43211. * Set the mask that the camera ignores in collision events.
  43212. */
  43213. set collisionMask(mask: number);
  43214. /** @hidden */
  43215. _collideWithWorld(displacement: Vector3): void;
  43216. /** @hidden */
  43217. private _onCollisionPositionChange;
  43218. /** @hidden */
  43219. _checkInputs(): void;
  43220. /** @hidden */
  43221. _decideIfNeedsToMove(): boolean;
  43222. /** @hidden */
  43223. _updatePosition(): void;
  43224. /**
  43225. * Restore the Roll to its target value at the rate specified.
  43226. * @param rate - Higher means slower restoring.
  43227. * @hidden
  43228. */
  43229. restoreRoll(rate: number): void;
  43230. /**
  43231. * Destroy the camera and release the current resources held by it.
  43232. */
  43233. dispose(): void;
  43234. /**
  43235. * Get the current object class name.
  43236. * @returns the class name.
  43237. */
  43238. getClassName(): string;
  43239. }
  43240. }
  43241. declare module BABYLON {
  43242. /**
  43243. * Listen to keyboard events to control the camera.
  43244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43245. */
  43246. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43247. /**
  43248. * Defines the camera the input is attached to.
  43249. */
  43250. camera: FlyCamera;
  43251. /**
  43252. * The list of keyboard keys used to control the forward move of the camera.
  43253. */
  43254. keysForward: number[];
  43255. /**
  43256. * The list of keyboard keys used to control the backward move of the camera.
  43257. */
  43258. keysBackward: number[];
  43259. /**
  43260. * The list of keyboard keys used to control the forward move of the camera.
  43261. */
  43262. keysUp: number[];
  43263. /**
  43264. * The list of keyboard keys used to control the backward move of the camera.
  43265. */
  43266. keysDown: number[];
  43267. /**
  43268. * The list of keyboard keys used to control the right strafe move of the camera.
  43269. */
  43270. keysRight: number[];
  43271. /**
  43272. * The list of keyboard keys used to control the left strafe move of the camera.
  43273. */
  43274. keysLeft: number[];
  43275. private _keys;
  43276. private _onCanvasBlurObserver;
  43277. private _onKeyboardObserver;
  43278. private _engine;
  43279. private _scene;
  43280. /**
  43281. * Attach the input controls to a specific dom element to get the input from.
  43282. * @param element Defines the element the controls should be listened from
  43283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43284. */
  43285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43286. /**
  43287. * Detach the current controls from the specified dom element.
  43288. * @param element Defines the element to stop listening the inputs from
  43289. */
  43290. detachControl(element: Nullable<HTMLElement>): void;
  43291. /**
  43292. * Gets the class name of the current intput.
  43293. * @returns the class name
  43294. */
  43295. getClassName(): string;
  43296. /** @hidden */
  43297. _onLostFocus(e: FocusEvent): void;
  43298. /**
  43299. * Get the friendly name associated with the input class.
  43300. * @returns the input friendly name
  43301. */
  43302. getSimpleName(): string;
  43303. /**
  43304. * Update the current camera state depending on the inputs that have been used this frame.
  43305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43306. */
  43307. checkInputs(): void;
  43308. }
  43309. }
  43310. declare module BABYLON {
  43311. /**
  43312. * Manage the mouse wheel inputs to control a follow camera.
  43313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43314. */
  43315. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43316. /**
  43317. * Defines the camera the input is attached to.
  43318. */
  43319. camera: FollowCamera;
  43320. /**
  43321. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43322. */
  43323. axisControlRadius: boolean;
  43324. /**
  43325. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43326. */
  43327. axisControlHeight: boolean;
  43328. /**
  43329. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43330. */
  43331. axisControlRotation: boolean;
  43332. /**
  43333. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43334. * relation to mouseWheel events.
  43335. */
  43336. wheelPrecision: number;
  43337. /**
  43338. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43339. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43340. */
  43341. wheelDeltaPercentage: number;
  43342. private _wheel;
  43343. private _observer;
  43344. /**
  43345. * Attach the input controls to a specific dom element to get the input from.
  43346. * @param element Defines the element the controls should be listened from
  43347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43348. */
  43349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43350. /**
  43351. * Detach the current controls from the specified dom element.
  43352. * @param element Defines the element to stop listening the inputs from
  43353. */
  43354. detachControl(element: Nullable<HTMLElement>): void;
  43355. /**
  43356. * Gets the class name of the current intput.
  43357. * @returns the class name
  43358. */
  43359. getClassName(): string;
  43360. /**
  43361. * Get the friendly name associated with the input class.
  43362. * @returns the input friendly name
  43363. */
  43364. getSimpleName(): string;
  43365. }
  43366. }
  43367. declare module BABYLON {
  43368. /**
  43369. * Manage the pointers inputs to control an follow camera.
  43370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43371. */
  43372. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43373. /**
  43374. * Defines the camera the input is attached to.
  43375. */
  43376. camera: FollowCamera;
  43377. /**
  43378. * Gets the class name of the current input.
  43379. * @returns the class name
  43380. */
  43381. getClassName(): string;
  43382. /**
  43383. * Defines the pointer angular sensibility along the X axis or how fast is
  43384. * the camera rotating.
  43385. * A negative number will reverse the axis direction.
  43386. */
  43387. angularSensibilityX: number;
  43388. /**
  43389. * Defines the pointer angular sensibility along the Y axis or how fast is
  43390. * the camera rotating.
  43391. * A negative number will reverse the axis direction.
  43392. */
  43393. angularSensibilityY: number;
  43394. /**
  43395. * Defines the pointer pinch precision or how fast is the camera zooming.
  43396. * A negative number will reverse the axis direction.
  43397. */
  43398. pinchPrecision: number;
  43399. /**
  43400. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43401. * from 0.
  43402. * It defines the percentage of current camera.radius to use as delta when
  43403. * pinch zoom is used.
  43404. */
  43405. pinchDeltaPercentage: number;
  43406. /**
  43407. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43408. */
  43409. axisXControlRadius: boolean;
  43410. /**
  43411. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43412. */
  43413. axisXControlHeight: boolean;
  43414. /**
  43415. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43416. */
  43417. axisXControlRotation: boolean;
  43418. /**
  43419. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43420. */
  43421. axisYControlRadius: boolean;
  43422. /**
  43423. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43424. */
  43425. axisYControlHeight: boolean;
  43426. /**
  43427. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43428. */
  43429. axisYControlRotation: boolean;
  43430. /**
  43431. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43432. */
  43433. axisPinchControlRadius: boolean;
  43434. /**
  43435. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43436. */
  43437. axisPinchControlHeight: boolean;
  43438. /**
  43439. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43440. */
  43441. axisPinchControlRotation: boolean;
  43442. /**
  43443. * Log error messages if basic misconfiguration has occurred.
  43444. */
  43445. warningEnable: boolean;
  43446. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43447. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43448. private _warningCounter;
  43449. private _warning;
  43450. }
  43451. }
  43452. declare module BABYLON {
  43453. /**
  43454. * Default Inputs manager for the FollowCamera.
  43455. * It groups all the default supported inputs for ease of use.
  43456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43457. */
  43458. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43459. /**
  43460. * Instantiates a new FollowCameraInputsManager.
  43461. * @param camera Defines the camera the inputs belong to
  43462. */
  43463. constructor(camera: FollowCamera);
  43464. /**
  43465. * Add keyboard input support to the input manager.
  43466. * @returns the current input manager
  43467. */
  43468. addKeyboard(): FollowCameraInputsManager;
  43469. /**
  43470. * Add mouse wheel input support to the input manager.
  43471. * @returns the current input manager
  43472. */
  43473. addMouseWheel(): FollowCameraInputsManager;
  43474. /**
  43475. * Add pointers input support to the input manager.
  43476. * @returns the current input manager
  43477. */
  43478. addPointers(): FollowCameraInputsManager;
  43479. /**
  43480. * Add orientation input support to the input manager.
  43481. * @returns the current input manager
  43482. */
  43483. addVRDeviceOrientation(): FollowCameraInputsManager;
  43484. }
  43485. }
  43486. declare module BABYLON {
  43487. /**
  43488. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43489. * an arc rotate version arcFollowCamera are available.
  43490. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43491. */
  43492. export class FollowCamera extends TargetCamera {
  43493. /**
  43494. * Distance the follow camera should follow an object at
  43495. */
  43496. radius: number;
  43497. /**
  43498. * Minimum allowed distance of the camera to the axis of rotation
  43499. * (The camera can not get closer).
  43500. * This can help limiting how the Camera is able to move in the scene.
  43501. */
  43502. lowerRadiusLimit: Nullable<number>;
  43503. /**
  43504. * Maximum allowed distance of the camera to the axis of rotation
  43505. * (The camera can not get further).
  43506. * This can help limiting how the Camera is able to move in the scene.
  43507. */
  43508. upperRadiusLimit: Nullable<number>;
  43509. /**
  43510. * Define a rotation offset between the camera and the object it follows
  43511. */
  43512. rotationOffset: number;
  43513. /**
  43514. * Minimum allowed angle to camera position relative to target object.
  43515. * This can help limiting how the Camera is able to move in the scene.
  43516. */
  43517. lowerRotationOffsetLimit: Nullable<number>;
  43518. /**
  43519. * Maximum allowed angle to camera position relative to target object.
  43520. * This can help limiting how the Camera is able to move in the scene.
  43521. */
  43522. upperRotationOffsetLimit: Nullable<number>;
  43523. /**
  43524. * Define a height offset between the camera and the object it follows.
  43525. * It can help following an object from the top (like a car chaing a plane)
  43526. */
  43527. heightOffset: number;
  43528. /**
  43529. * Minimum allowed height of camera position relative to target object.
  43530. * This can help limiting how the Camera is able to move in the scene.
  43531. */
  43532. lowerHeightOffsetLimit: Nullable<number>;
  43533. /**
  43534. * Maximum allowed height of camera position relative to target object.
  43535. * This can help limiting how the Camera is able to move in the scene.
  43536. */
  43537. upperHeightOffsetLimit: Nullable<number>;
  43538. /**
  43539. * Define how fast the camera can accelerate to follow it s target.
  43540. */
  43541. cameraAcceleration: number;
  43542. /**
  43543. * Define the speed limit of the camera following an object.
  43544. */
  43545. maxCameraSpeed: number;
  43546. /**
  43547. * Define the target of the camera.
  43548. */
  43549. lockedTarget: Nullable<AbstractMesh>;
  43550. /**
  43551. * Defines the input associated with the camera.
  43552. */
  43553. inputs: FollowCameraInputsManager;
  43554. /**
  43555. * Instantiates the follow camera.
  43556. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43557. * @param name Define the name of the camera in the scene
  43558. * @param position Define the position of the camera
  43559. * @param scene Define the scene the camera belong to
  43560. * @param lockedTarget Define the target of the camera
  43561. */
  43562. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43563. private _follow;
  43564. /**
  43565. * Attached controls to the current camera.
  43566. * @param element Defines the element the controls should be listened from
  43567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43568. */
  43569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43570. /**
  43571. * Detach the current controls from the camera.
  43572. * The camera will stop reacting to inputs.
  43573. * @param element Defines the element to stop listening the inputs from
  43574. */
  43575. detachControl(element: HTMLElement): void;
  43576. /** @hidden */
  43577. _checkInputs(): void;
  43578. private _checkLimits;
  43579. /**
  43580. * Gets the camera class name.
  43581. * @returns the class name
  43582. */
  43583. getClassName(): string;
  43584. }
  43585. /**
  43586. * Arc Rotate version of the follow camera.
  43587. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43588. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43589. */
  43590. export class ArcFollowCamera extends TargetCamera {
  43591. /** The longitudinal angle of the camera */
  43592. alpha: number;
  43593. /** The latitudinal angle of the camera */
  43594. beta: number;
  43595. /** The radius of the camera from its target */
  43596. radius: number;
  43597. /** Define the camera target (the mesh it should follow) */
  43598. target: Nullable<AbstractMesh>;
  43599. private _cartesianCoordinates;
  43600. /**
  43601. * Instantiates a new ArcFollowCamera
  43602. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43603. * @param name Define the name of the camera
  43604. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43605. * @param beta Define the rotation angle of the camera around the elevation axis
  43606. * @param radius Define the radius of the camera from its target point
  43607. * @param target Define the target of the camera
  43608. * @param scene Define the scene the camera belongs to
  43609. */
  43610. constructor(name: string,
  43611. /** The longitudinal angle of the camera */
  43612. alpha: number,
  43613. /** The latitudinal angle of the camera */
  43614. beta: number,
  43615. /** The radius of the camera from its target */
  43616. radius: number,
  43617. /** Define the camera target (the mesh it should follow) */
  43618. target: Nullable<AbstractMesh>, scene: Scene);
  43619. private _follow;
  43620. /** @hidden */
  43621. _checkInputs(): void;
  43622. /**
  43623. * Returns the class name of the object.
  43624. * It is mostly used internally for serialization purposes.
  43625. */
  43626. getClassName(): string;
  43627. }
  43628. }
  43629. declare module BABYLON {
  43630. /**
  43631. * Manage the keyboard inputs to control the movement of a follow camera.
  43632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43633. */
  43634. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43635. /**
  43636. * Defines the camera the input is attached to.
  43637. */
  43638. camera: FollowCamera;
  43639. /**
  43640. * Defines the list of key codes associated with the up action (increase heightOffset)
  43641. */
  43642. keysHeightOffsetIncr: number[];
  43643. /**
  43644. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43645. */
  43646. keysHeightOffsetDecr: number[];
  43647. /**
  43648. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43649. */
  43650. keysHeightOffsetModifierAlt: boolean;
  43651. /**
  43652. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43653. */
  43654. keysHeightOffsetModifierCtrl: boolean;
  43655. /**
  43656. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43657. */
  43658. keysHeightOffsetModifierShift: boolean;
  43659. /**
  43660. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43661. */
  43662. keysRotationOffsetIncr: number[];
  43663. /**
  43664. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43665. */
  43666. keysRotationOffsetDecr: number[];
  43667. /**
  43668. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43669. */
  43670. keysRotationOffsetModifierAlt: boolean;
  43671. /**
  43672. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43673. */
  43674. keysRotationOffsetModifierCtrl: boolean;
  43675. /**
  43676. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43677. */
  43678. keysRotationOffsetModifierShift: boolean;
  43679. /**
  43680. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43681. */
  43682. keysRadiusIncr: number[];
  43683. /**
  43684. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43685. */
  43686. keysRadiusDecr: number[];
  43687. /**
  43688. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43689. */
  43690. keysRadiusModifierAlt: boolean;
  43691. /**
  43692. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43693. */
  43694. keysRadiusModifierCtrl: boolean;
  43695. /**
  43696. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43697. */
  43698. keysRadiusModifierShift: boolean;
  43699. /**
  43700. * Defines the rate of change of heightOffset.
  43701. */
  43702. heightSensibility: number;
  43703. /**
  43704. * Defines the rate of change of rotationOffset.
  43705. */
  43706. rotationSensibility: number;
  43707. /**
  43708. * Defines the rate of change of radius.
  43709. */
  43710. radiusSensibility: number;
  43711. private _keys;
  43712. private _ctrlPressed;
  43713. private _altPressed;
  43714. private _shiftPressed;
  43715. private _onCanvasBlurObserver;
  43716. private _onKeyboardObserver;
  43717. private _engine;
  43718. private _scene;
  43719. /**
  43720. * Attach the input controls to a specific dom element to get the input from.
  43721. * @param element Defines the element the controls should be listened from
  43722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43723. */
  43724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43725. /**
  43726. * Detach the current controls from the specified dom element.
  43727. * @param element Defines the element to stop listening the inputs from
  43728. */
  43729. detachControl(element: Nullable<HTMLElement>): void;
  43730. /**
  43731. * Update the current camera state depending on the inputs that have been used this frame.
  43732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43733. */
  43734. checkInputs(): void;
  43735. /**
  43736. * Gets the class name of the current input.
  43737. * @returns the class name
  43738. */
  43739. getClassName(): string;
  43740. /**
  43741. * Get the friendly name associated with the input class.
  43742. * @returns the input friendly name
  43743. */
  43744. getSimpleName(): string;
  43745. /**
  43746. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43747. * allow modification of the heightOffset value.
  43748. */
  43749. private _modifierHeightOffset;
  43750. /**
  43751. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43752. * allow modification of the rotationOffset value.
  43753. */
  43754. private _modifierRotationOffset;
  43755. /**
  43756. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43757. * allow modification of the radius value.
  43758. */
  43759. private _modifierRadius;
  43760. }
  43761. }
  43762. declare module BABYLON {
  43763. interface FreeCameraInputsManager {
  43764. /**
  43765. * @hidden
  43766. */
  43767. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43768. /**
  43769. * Add orientation input support to the input manager.
  43770. * @returns the current input manager
  43771. */
  43772. addDeviceOrientation(): FreeCameraInputsManager;
  43773. }
  43774. /**
  43775. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43776. * Screen rotation is taken into account.
  43777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43778. */
  43779. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43780. private _camera;
  43781. private _screenOrientationAngle;
  43782. private _constantTranform;
  43783. private _screenQuaternion;
  43784. private _alpha;
  43785. private _beta;
  43786. private _gamma;
  43787. /**
  43788. * Can be used to detect if a device orientation sensor is available on a device
  43789. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43790. * @returns a promise that will resolve on orientation change
  43791. */
  43792. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43793. /**
  43794. * @hidden
  43795. */
  43796. _onDeviceOrientationChangedObservable: Observable<void>;
  43797. /**
  43798. * Instantiates a new input
  43799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43800. */
  43801. constructor();
  43802. /**
  43803. * Define the camera controlled by the input.
  43804. */
  43805. get camera(): FreeCamera;
  43806. set camera(camera: FreeCamera);
  43807. /**
  43808. * Attach the input controls to a specific dom element to get the input from.
  43809. * @param element Defines the element the controls should be listened from
  43810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43811. */
  43812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43813. private _orientationChanged;
  43814. private _deviceOrientation;
  43815. /**
  43816. * Detach the current controls from the specified dom element.
  43817. * @param element Defines the element to stop listening the inputs from
  43818. */
  43819. detachControl(element: Nullable<HTMLElement>): void;
  43820. /**
  43821. * Update the current camera state depending on the inputs that have been used this frame.
  43822. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43823. */
  43824. checkInputs(): void;
  43825. /**
  43826. * Gets the class name of the current intput.
  43827. * @returns the class name
  43828. */
  43829. getClassName(): string;
  43830. /**
  43831. * Get the friendly name associated with the input class.
  43832. * @returns the input friendly name
  43833. */
  43834. getSimpleName(): string;
  43835. }
  43836. }
  43837. declare module BABYLON {
  43838. /**
  43839. * Manage the gamepad inputs to control a free camera.
  43840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43841. */
  43842. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43843. /**
  43844. * Define the camera the input is attached to.
  43845. */
  43846. camera: FreeCamera;
  43847. /**
  43848. * Define the Gamepad controlling the input
  43849. */
  43850. gamepad: Nullable<Gamepad>;
  43851. /**
  43852. * Defines the gamepad rotation sensiblity.
  43853. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43854. */
  43855. gamepadAngularSensibility: number;
  43856. /**
  43857. * Defines the gamepad move sensiblity.
  43858. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43859. */
  43860. gamepadMoveSensibility: number;
  43861. private _yAxisScale;
  43862. /**
  43863. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43864. */
  43865. get invertYAxis(): boolean;
  43866. set invertYAxis(value: boolean);
  43867. private _onGamepadConnectedObserver;
  43868. private _onGamepadDisconnectedObserver;
  43869. private _cameraTransform;
  43870. private _deltaTransform;
  43871. private _vector3;
  43872. private _vector2;
  43873. /**
  43874. * Attach the input controls to a specific dom element to get the input from.
  43875. * @param element Defines the element the controls should be listened from
  43876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43877. */
  43878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43879. /**
  43880. * Detach the current controls from the specified dom element.
  43881. * @param element Defines the element to stop listening the inputs from
  43882. */
  43883. detachControl(element: Nullable<HTMLElement>): void;
  43884. /**
  43885. * Update the current camera state depending on the inputs that have been used this frame.
  43886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43887. */
  43888. checkInputs(): void;
  43889. /**
  43890. * Gets the class name of the current intput.
  43891. * @returns the class name
  43892. */
  43893. getClassName(): string;
  43894. /**
  43895. * Get the friendly name associated with the input class.
  43896. * @returns the input friendly name
  43897. */
  43898. getSimpleName(): string;
  43899. }
  43900. }
  43901. declare module BABYLON {
  43902. /**
  43903. * Defines the potential axis of a Joystick
  43904. */
  43905. export enum JoystickAxis {
  43906. /** X axis */
  43907. X = 0,
  43908. /** Y axis */
  43909. Y = 1,
  43910. /** Z axis */
  43911. Z = 2
  43912. }
  43913. /**
  43914. * Class used to define virtual joystick (used in touch mode)
  43915. */
  43916. export class VirtualJoystick {
  43917. /**
  43918. * Gets or sets a boolean indicating that left and right values must be inverted
  43919. */
  43920. reverseLeftRight: boolean;
  43921. /**
  43922. * Gets or sets a boolean indicating that up and down values must be inverted
  43923. */
  43924. reverseUpDown: boolean;
  43925. /**
  43926. * Gets the offset value for the position (ie. the change of the position value)
  43927. */
  43928. deltaPosition: Vector3;
  43929. /**
  43930. * Gets a boolean indicating if the virtual joystick was pressed
  43931. */
  43932. pressed: boolean;
  43933. /**
  43934. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43935. */
  43936. static Canvas: Nullable<HTMLCanvasElement>;
  43937. private static _globalJoystickIndex;
  43938. private static vjCanvasContext;
  43939. private static vjCanvasWidth;
  43940. private static vjCanvasHeight;
  43941. private static halfWidth;
  43942. private _action;
  43943. private _axisTargetedByLeftAndRight;
  43944. private _axisTargetedByUpAndDown;
  43945. private _joystickSensibility;
  43946. private _inversedSensibility;
  43947. private _joystickPointerID;
  43948. private _joystickColor;
  43949. private _joystickPointerPos;
  43950. private _joystickPreviousPointerPos;
  43951. private _joystickPointerStartPos;
  43952. private _deltaJoystickVector;
  43953. private _leftJoystick;
  43954. private _touches;
  43955. private _onPointerDownHandlerRef;
  43956. private _onPointerMoveHandlerRef;
  43957. private _onPointerUpHandlerRef;
  43958. private _onResize;
  43959. /**
  43960. * Creates a new virtual joystick
  43961. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43962. */
  43963. constructor(leftJoystick?: boolean);
  43964. /**
  43965. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43966. * @param newJoystickSensibility defines the new sensibility
  43967. */
  43968. setJoystickSensibility(newJoystickSensibility: number): void;
  43969. private _onPointerDown;
  43970. private _onPointerMove;
  43971. private _onPointerUp;
  43972. /**
  43973. * Change the color of the virtual joystick
  43974. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43975. */
  43976. setJoystickColor(newColor: string): void;
  43977. /**
  43978. * Defines a callback to call when the joystick is touched
  43979. * @param action defines the callback
  43980. */
  43981. setActionOnTouch(action: () => any): void;
  43982. /**
  43983. * Defines which axis you'd like to control for left & right
  43984. * @param axis defines the axis to use
  43985. */
  43986. setAxisForLeftRight(axis: JoystickAxis): void;
  43987. /**
  43988. * Defines which axis you'd like to control for up & down
  43989. * @param axis defines the axis to use
  43990. */
  43991. setAxisForUpDown(axis: JoystickAxis): void;
  43992. private _drawVirtualJoystick;
  43993. /**
  43994. * Release internal HTML canvas
  43995. */
  43996. releaseCanvas(): void;
  43997. }
  43998. }
  43999. declare module BABYLON {
  44000. interface FreeCameraInputsManager {
  44001. /**
  44002. * Add virtual joystick input support to the input manager.
  44003. * @returns the current input manager
  44004. */
  44005. addVirtualJoystick(): FreeCameraInputsManager;
  44006. }
  44007. /**
  44008. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44010. */
  44011. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44012. /**
  44013. * Defines the camera the input is attached to.
  44014. */
  44015. camera: FreeCamera;
  44016. private _leftjoystick;
  44017. private _rightjoystick;
  44018. /**
  44019. * Gets the left stick of the virtual joystick.
  44020. * @returns The virtual Joystick
  44021. */
  44022. getLeftJoystick(): VirtualJoystick;
  44023. /**
  44024. * Gets the right stick of the virtual joystick.
  44025. * @returns The virtual Joystick
  44026. */
  44027. getRightJoystick(): VirtualJoystick;
  44028. /**
  44029. * Update the current camera state depending on the inputs that have been used this frame.
  44030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44031. */
  44032. checkInputs(): void;
  44033. /**
  44034. * Attach the input controls to a specific dom element to get the input from.
  44035. * @param element Defines the element the controls should be listened from
  44036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44037. */
  44038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44039. /**
  44040. * Detach the current controls from the specified dom element.
  44041. * @param element Defines the element to stop listening the inputs from
  44042. */
  44043. detachControl(element: Nullable<HTMLElement>): void;
  44044. /**
  44045. * Gets the class name of the current intput.
  44046. * @returns the class name
  44047. */
  44048. getClassName(): string;
  44049. /**
  44050. * Get the friendly name associated with the input class.
  44051. * @returns the input friendly name
  44052. */
  44053. getSimpleName(): string;
  44054. }
  44055. }
  44056. declare module BABYLON {
  44057. /**
  44058. * This represents a FPS type of camera controlled by touch.
  44059. * This is like a universal camera minus the Gamepad controls.
  44060. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44061. */
  44062. export class TouchCamera extends FreeCamera {
  44063. /**
  44064. * Defines the touch sensibility for rotation.
  44065. * The higher the faster.
  44066. */
  44067. get touchAngularSensibility(): number;
  44068. set touchAngularSensibility(value: number);
  44069. /**
  44070. * Defines the touch sensibility for move.
  44071. * The higher the faster.
  44072. */
  44073. get touchMoveSensibility(): number;
  44074. set touchMoveSensibility(value: number);
  44075. /**
  44076. * Instantiates a new touch camera.
  44077. * This represents a FPS type of camera controlled by touch.
  44078. * This is like a universal camera minus the Gamepad controls.
  44079. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44080. * @param name Define the name of the camera in the scene
  44081. * @param position Define the start position of the camera in the scene
  44082. * @param scene Define the scene the camera belongs to
  44083. */
  44084. constructor(name: string, position: Vector3, scene: Scene);
  44085. /**
  44086. * Gets the current object class name.
  44087. * @return the class name
  44088. */
  44089. getClassName(): string;
  44090. /** @hidden */
  44091. _setupInputs(): void;
  44092. }
  44093. }
  44094. declare module BABYLON {
  44095. /**
  44096. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44097. * being tilted forward or back and left or right.
  44098. */
  44099. export class DeviceOrientationCamera extends FreeCamera {
  44100. private _initialQuaternion;
  44101. private _quaternionCache;
  44102. private _tmpDragQuaternion;
  44103. private _disablePointerInputWhenUsingDeviceOrientation;
  44104. /**
  44105. * Creates a new device orientation camera
  44106. * @param name The name of the camera
  44107. * @param position The start position camera
  44108. * @param scene The scene the camera belongs to
  44109. */
  44110. constructor(name: string, position: Vector3, scene: Scene);
  44111. /**
  44112. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44113. */
  44114. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44115. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44116. private _dragFactor;
  44117. /**
  44118. * Enabled turning on the y axis when the orientation sensor is active
  44119. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44120. */
  44121. enableHorizontalDragging(dragFactor?: number): void;
  44122. /**
  44123. * Gets the current instance class name ("DeviceOrientationCamera").
  44124. * This helps avoiding instanceof at run time.
  44125. * @returns the class name
  44126. */
  44127. getClassName(): string;
  44128. /**
  44129. * @hidden
  44130. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44131. */
  44132. _checkInputs(): void;
  44133. /**
  44134. * Reset the camera to its default orientation on the specified axis only.
  44135. * @param axis The axis to reset
  44136. */
  44137. resetToCurrentRotation(axis?: Axis): void;
  44138. }
  44139. }
  44140. declare module BABYLON {
  44141. /**
  44142. * Defines supported buttons for XBox360 compatible gamepads
  44143. */
  44144. export enum Xbox360Button {
  44145. /** A */
  44146. A = 0,
  44147. /** B */
  44148. B = 1,
  44149. /** X */
  44150. X = 2,
  44151. /** Y */
  44152. Y = 3,
  44153. /** Left button */
  44154. LB = 4,
  44155. /** Right button */
  44156. RB = 5,
  44157. /** Back */
  44158. Back = 8,
  44159. /** Start */
  44160. Start = 9,
  44161. /** Left stick */
  44162. LeftStick = 10,
  44163. /** Right stick */
  44164. RightStick = 11
  44165. }
  44166. /** Defines values for XBox360 DPad */
  44167. export enum Xbox360Dpad {
  44168. /** Up */
  44169. Up = 12,
  44170. /** Down */
  44171. Down = 13,
  44172. /** Left */
  44173. Left = 14,
  44174. /** Right */
  44175. Right = 15
  44176. }
  44177. /**
  44178. * Defines a XBox360 gamepad
  44179. */
  44180. export class Xbox360Pad extends Gamepad {
  44181. private _leftTrigger;
  44182. private _rightTrigger;
  44183. private _onlefttriggerchanged;
  44184. private _onrighttriggerchanged;
  44185. private _onbuttondown;
  44186. private _onbuttonup;
  44187. private _ondpaddown;
  44188. private _ondpadup;
  44189. /** Observable raised when a button is pressed */
  44190. onButtonDownObservable: Observable<Xbox360Button>;
  44191. /** Observable raised when a button is released */
  44192. onButtonUpObservable: Observable<Xbox360Button>;
  44193. /** Observable raised when a pad is pressed */
  44194. onPadDownObservable: Observable<Xbox360Dpad>;
  44195. /** Observable raised when a pad is released */
  44196. onPadUpObservable: Observable<Xbox360Dpad>;
  44197. private _buttonA;
  44198. private _buttonB;
  44199. private _buttonX;
  44200. private _buttonY;
  44201. private _buttonBack;
  44202. private _buttonStart;
  44203. private _buttonLB;
  44204. private _buttonRB;
  44205. private _buttonLeftStick;
  44206. private _buttonRightStick;
  44207. private _dPadUp;
  44208. private _dPadDown;
  44209. private _dPadLeft;
  44210. private _dPadRight;
  44211. private _isXboxOnePad;
  44212. /**
  44213. * Creates a new XBox360 gamepad object
  44214. * @param id defines the id of this gamepad
  44215. * @param index defines its index
  44216. * @param gamepad defines the internal HTML gamepad object
  44217. * @param xboxOne defines if it is a XBox One gamepad
  44218. */
  44219. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44220. /**
  44221. * Defines the callback to call when left trigger is pressed
  44222. * @param callback defines the callback to use
  44223. */
  44224. onlefttriggerchanged(callback: (value: number) => void): void;
  44225. /**
  44226. * Defines the callback to call when right trigger is pressed
  44227. * @param callback defines the callback to use
  44228. */
  44229. onrighttriggerchanged(callback: (value: number) => void): void;
  44230. /**
  44231. * Gets the left trigger value
  44232. */
  44233. get leftTrigger(): number;
  44234. /**
  44235. * Sets the left trigger value
  44236. */
  44237. set leftTrigger(newValue: number);
  44238. /**
  44239. * Gets the right trigger value
  44240. */
  44241. get rightTrigger(): number;
  44242. /**
  44243. * Sets the right trigger value
  44244. */
  44245. set rightTrigger(newValue: number);
  44246. /**
  44247. * Defines the callback to call when a button is pressed
  44248. * @param callback defines the callback to use
  44249. */
  44250. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44251. /**
  44252. * Defines the callback to call when a button is released
  44253. * @param callback defines the callback to use
  44254. */
  44255. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44256. /**
  44257. * Defines the callback to call when a pad is pressed
  44258. * @param callback defines the callback to use
  44259. */
  44260. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44261. /**
  44262. * Defines the callback to call when a pad is released
  44263. * @param callback defines the callback to use
  44264. */
  44265. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44266. private _setButtonValue;
  44267. private _setDPadValue;
  44268. /**
  44269. * Gets the value of the `A` button
  44270. */
  44271. get buttonA(): number;
  44272. /**
  44273. * Sets the value of the `A` button
  44274. */
  44275. set buttonA(value: number);
  44276. /**
  44277. * Gets the value of the `B` button
  44278. */
  44279. get buttonB(): number;
  44280. /**
  44281. * Sets the value of the `B` button
  44282. */
  44283. set buttonB(value: number);
  44284. /**
  44285. * Gets the value of the `X` button
  44286. */
  44287. get buttonX(): number;
  44288. /**
  44289. * Sets the value of the `X` button
  44290. */
  44291. set buttonX(value: number);
  44292. /**
  44293. * Gets the value of the `Y` button
  44294. */
  44295. get buttonY(): number;
  44296. /**
  44297. * Sets the value of the `Y` button
  44298. */
  44299. set buttonY(value: number);
  44300. /**
  44301. * Gets the value of the `Start` button
  44302. */
  44303. get buttonStart(): number;
  44304. /**
  44305. * Sets the value of the `Start` button
  44306. */
  44307. set buttonStart(value: number);
  44308. /**
  44309. * Gets the value of the `Back` button
  44310. */
  44311. get buttonBack(): number;
  44312. /**
  44313. * Sets the value of the `Back` button
  44314. */
  44315. set buttonBack(value: number);
  44316. /**
  44317. * Gets the value of the `Left` button
  44318. */
  44319. get buttonLB(): number;
  44320. /**
  44321. * Sets the value of the `Left` button
  44322. */
  44323. set buttonLB(value: number);
  44324. /**
  44325. * Gets the value of the `Right` button
  44326. */
  44327. get buttonRB(): number;
  44328. /**
  44329. * Sets the value of the `Right` button
  44330. */
  44331. set buttonRB(value: number);
  44332. /**
  44333. * Gets the value of the Left joystick
  44334. */
  44335. get buttonLeftStick(): number;
  44336. /**
  44337. * Sets the value of the Left joystick
  44338. */
  44339. set buttonLeftStick(value: number);
  44340. /**
  44341. * Gets the value of the Right joystick
  44342. */
  44343. get buttonRightStick(): number;
  44344. /**
  44345. * Sets the value of the Right joystick
  44346. */
  44347. set buttonRightStick(value: number);
  44348. /**
  44349. * Gets the value of D-pad up
  44350. */
  44351. get dPadUp(): number;
  44352. /**
  44353. * Sets the value of D-pad up
  44354. */
  44355. set dPadUp(value: number);
  44356. /**
  44357. * Gets the value of D-pad down
  44358. */
  44359. get dPadDown(): number;
  44360. /**
  44361. * Sets the value of D-pad down
  44362. */
  44363. set dPadDown(value: number);
  44364. /**
  44365. * Gets the value of D-pad left
  44366. */
  44367. get dPadLeft(): number;
  44368. /**
  44369. * Sets the value of D-pad left
  44370. */
  44371. set dPadLeft(value: number);
  44372. /**
  44373. * Gets the value of D-pad right
  44374. */
  44375. get dPadRight(): number;
  44376. /**
  44377. * Sets the value of D-pad right
  44378. */
  44379. set dPadRight(value: number);
  44380. /**
  44381. * Force the gamepad to synchronize with device values
  44382. */
  44383. update(): void;
  44384. /**
  44385. * Disposes the gamepad
  44386. */
  44387. dispose(): void;
  44388. }
  44389. }
  44390. declare module BABYLON {
  44391. /**
  44392. * Defines supported buttons for DualShock compatible gamepads
  44393. */
  44394. export enum DualShockButton {
  44395. /** Cross */
  44396. Cross = 0,
  44397. /** Circle */
  44398. Circle = 1,
  44399. /** Square */
  44400. Square = 2,
  44401. /** Triangle */
  44402. Triangle = 3,
  44403. /** L1 */
  44404. L1 = 4,
  44405. /** R1 */
  44406. R1 = 5,
  44407. /** Share */
  44408. Share = 8,
  44409. /** Options */
  44410. Options = 9,
  44411. /** Left stick */
  44412. LeftStick = 10,
  44413. /** Right stick */
  44414. RightStick = 11
  44415. }
  44416. /** Defines values for DualShock DPad */
  44417. export enum DualShockDpad {
  44418. /** Up */
  44419. Up = 12,
  44420. /** Down */
  44421. Down = 13,
  44422. /** Left */
  44423. Left = 14,
  44424. /** Right */
  44425. Right = 15
  44426. }
  44427. /**
  44428. * Defines a DualShock gamepad
  44429. */
  44430. export class DualShockPad extends Gamepad {
  44431. private _leftTrigger;
  44432. private _rightTrigger;
  44433. private _onlefttriggerchanged;
  44434. private _onrighttriggerchanged;
  44435. private _onbuttondown;
  44436. private _onbuttonup;
  44437. private _ondpaddown;
  44438. private _ondpadup;
  44439. /** Observable raised when a button is pressed */
  44440. onButtonDownObservable: Observable<DualShockButton>;
  44441. /** Observable raised when a button is released */
  44442. onButtonUpObservable: Observable<DualShockButton>;
  44443. /** Observable raised when a pad is pressed */
  44444. onPadDownObservable: Observable<DualShockDpad>;
  44445. /** Observable raised when a pad is released */
  44446. onPadUpObservable: Observable<DualShockDpad>;
  44447. private _buttonCross;
  44448. private _buttonCircle;
  44449. private _buttonSquare;
  44450. private _buttonTriangle;
  44451. private _buttonShare;
  44452. private _buttonOptions;
  44453. private _buttonL1;
  44454. private _buttonR1;
  44455. private _buttonLeftStick;
  44456. private _buttonRightStick;
  44457. private _dPadUp;
  44458. private _dPadDown;
  44459. private _dPadLeft;
  44460. private _dPadRight;
  44461. /**
  44462. * Creates a new DualShock gamepad object
  44463. * @param id defines the id of this gamepad
  44464. * @param index defines its index
  44465. * @param gamepad defines the internal HTML gamepad object
  44466. */
  44467. constructor(id: string, index: number, gamepad: any);
  44468. /**
  44469. * Defines the callback to call when left trigger is pressed
  44470. * @param callback defines the callback to use
  44471. */
  44472. onlefttriggerchanged(callback: (value: number) => void): void;
  44473. /**
  44474. * Defines the callback to call when right trigger is pressed
  44475. * @param callback defines the callback to use
  44476. */
  44477. onrighttriggerchanged(callback: (value: number) => void): void;
  44478. /**
  44479. * Gets the left trigger value
  44480. */
  44481. get leftTrigger(): number;
  44482. /**
  44483. * Sets the left trigger value
  44484. */
  44485. set leftTrigger(newValue: number);
  44486. /**
  44487. * Gets the right trigger value
  44488. */
  44489. get rightTrigger(): number;
  44490. /**
  44491. * Sets the right trigger value
  44492. */
  44493. set rightTrigger(newValue: number);
  44494. /**
  44495. * Defines the callback to call when a button is pressed
  44496. * @param callback defines the callback to use
  44497. */
  44498. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44499. /**
  44500. * Defines the callback to call when a button is released
  44501. * @param callback defines the callback to use
  44502. */
  44503. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44504. /**
  44505. * Defines the callback to call when a pad is pressed
  44506. * @param callback defines the callback to use
  44507. */
  44508. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44509. /**
  44510. * Defines the callback to call when a pad is released
  44511. * @param callback defines the callback to use
  44512. */
  44513. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44514. private _setButtonValue;
  44515. private _setDPadValue;
  44516. /**
  44517. * Gets the value of the `Cross` button
  44518. */
  44519. get buttonCross(): number;
  44520. /**
  44521. * Sets the value of the `Cross` button
  44522. */
  44523. set buttonCross(value: number);
  44524. /**
  44525. * Gets the value of the `Circle` button
  44526. */
  44527. get buttonCircle(): number;
  44528. /**
  44529. * Sets the value of the `Circle` button
  44530. */
  44531. set buttonCircle(value: number);
  44532. /**
  44533. * Gets the value of the `Square` button
  44534. */
  44535. get buttonSquare(): number;
  44536. /**
  44537. * Sets the value of the `Square` button
  44538. */
  44539. set buttonSquare(value: number);
  44540. /**
  44541. * Gets the value of the `Triangle` button
  44542. */
  44543. get buttonTriangle(): number;
  44544. /**
  44545. * Sets the value of the `Triangle` button
  44546. */
  44547. set buttonTriangle(value: number);
  44548. /**
  44549. * Gets the value of the `Options` button
  44550. */
  44551. get buttonOptions(): number;
  44552. /**
  44553. * Sets the value of the `Options` button
  44554. */
  44555. set buttonOptions(value: number);
  44556. /**
  44557. * Gets the value of the `Share` button
  44558. */
  44559. get buttonShare(): number;
  44560. /**
  44561. * Sets the value of the `Share` button
  44562. */
  44563. set buttonShare(value: number);
  44564. /**
  44565. * Gets the value of the `L1` button
  44566. */
  44567. get buttonL1(): number;
  44568. /**
  44569. * Sets the value of the `L1` button
  44570. */
  44571. set buttonL1(value: number);
  44572. /**
  44573. * Gets the value of the `R1` button
  44574. */
  44575. get buttonR1(): number;
  44576. /**
  44577. * Sets the value of the `R1` button
  44578. */
  44579. set buttonR1(value: number);
  44580. /**
  44581. * Gets the value of the Left joystick
  44582. */
  44583. get buttonLeftStick(): number;
  44584. /**
  44585. * Sets the value of the Left joystick
  44586. */
  44587. set buttonLeftStick(value: number);
  44588. /**
  44589. * Gets the value of the Right joystick
  44590. */
  44591. get buttonRightStick(): number;
  44592. /**
  44593. * Sets the value of the Right joystick
  44594. */
  44595. set buttonRightStick(value: number);
  44596. /**
  44597. * Gets the value of D-pad up
  44598. */
  44599. get dPadUp(): number;
  44600. /**
  44601. * Sets the value of D-pad up
  44602. */
  44603. set dPadUp(value: number);
  44604. /**
  44605. * Gets the value of D-pad down
  44606. */
  44607. get dPadDown(): number;
  44608. /**
  44609. * Sets the value of D-pad down
  44610. */
  44611. set dPadDown(value: number);
  44612. /**
  44613. * Gets the value of D-pad left
  44614. */
  44615. get dPadLeft(): number;
  44616. /**
  44617. * Sets the value of D-pad left
  44618. */
  44619. set dPadLeft(value: number);
  44620. /**
  44621. * Gets the value of D-pad right
  44622. */
  44623. get dPadRight(): number;
  44624. /**
  44625. * Sets the value of D-pad right
  44626. */
  44627. set dPadRight(value: number);
  44628. /**
  44629. * Force the gamepad to synchronize with device values
  44630. */
  44631. update(): void;
  44632. /**
  44633. * Disposes the gamepad
  44634. */
  44635. dispose(): void;
  44636. }
  44637. }
  44638. declare module BABYLON {
  44639. /**
  44640. * Manager for handling gamepads
  44641. */
  44642. export class GamepadManager {
  44643. private _scene?;
  44644. private _babylonGamepads;
  44645. private _oneGamepadConnected;
  44646. /** @hidden */
  44647. _isMonitoring: boolean;
  44648. private _gamepadEventSupported;
  44649. private _gamepadSupport?;
  44650. /**
  44651. * observable to be triggered when the gamepad controller has been connected
  44652. */
  44653. onGamepadConnectedObservable: Observable<Gamepad>;
  44654. /**
  44655. * observable to be triggered when the gamepad controller has been disconnected
  44656. */
  44657. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44658. private _onGamepadConnectedEvent;
  44659. private _onGamepadDisconnectedEvent;
  44660. /**
  44661. * Initializes the gamepad manager
  44662. * @param _scene BabylonJS scene
  44663. */
  44664. constructor(_scene?: Scene | undefined);
  44665. /**
  44666. * The gamepads in the game pad manager
  44667. */
  44668. get gamepads(): Gamepad[];
  44669. /**
  44670. * Get the gamepad controllers based on type
  44671. * @param type The type of gamepad controller
  44672. * @returns Nullable gamepad
  44673. */
  44674. getGamepadByType(type?: number): Nullable<Gamepad>;
  44675. /**
  44676. * Disposes the gamepad manager
  44677. */
  44678. dispose(): void;
  44679. private _addNewGamepad;
  44680. private _startMonitoringGamepads;
  44681. private _stopMonitoringGamepads;
  44682. /** @hidden */
  44683. _checkGamepadsStatus(): void;
  44684. private _updateGamepadObjects;
  44685. }
  44686. }
  44687. declare module BABYLON {
  44688. interface Scene {
  44689. /** @hidden */
  44690. _gamepadManager: Nullable<GamepadManager>;
  44691. /**
  44692. * Gets the gamepad manager associated with the scene
  44693. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44694. */
  44695. gamepadManager: GamepadManager;
  44696. }
  44697. /**
  44698. * Interface representing a free camera inputs manager
  44699. */
  44700. interface FreeCameraInputsManager {
  44701. /**
  44702. * Adds gamepad input support to the FreeCameraInputsManager.
  44703. * @returns the FreeCameraInputsManager
  44704. */
  44705. addGamepad(): FreeCameraInputsManager;
  44706. }
  44707. /**
  44708. * Interface representing an arc rotate camera inputs manager
  44709. */
  44710. interface ArcRotateCameraInputsManager {
  44711. /**
  44712. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44713. * @returns the camera inputs manager
  44714. */
  44715. addGamepad(): ArcRotateCameraInputsManager;
  44716. }
  44717. /**
  44718. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44719. */
  44720. export class GamepadSystemSceneComponent implements ISceneComponent {
  44721. /**
  44722. * The component name helpfull to identify the component in the list of scene components.
  44723. */
  44724. readonly name: string;
  44725. /**
  44726. * The scene the component belongs to.
  44727. */
  44728. scene: Scene;
  44729. /**
  44730. * Creates a new instance of the component for the given scene
  44731. * @param scene Defines the scene to register the component in
  44732. */
  44733. constructor(scene: Scene);
  44734. /**
  44735. * Registers the component in a given scene
  44736. */
  44737. register(): void;
  44738. /**
  44739. * Rebuilds the elements related to this component in case of
  44740. * context lost for instance.
  44741. */
  44742. rebuild(): void;
  44743. /**
  44744. * Disposes the component and the associated ressources
  44745. */
  44746. dispose(): void;
  44747. private _beforeCameraUpdate;
  44748. }
  44749. }
  44750. declare module BABYLON {
  44751. /**
  44752. * 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,
  44753. * which still works and will still be found in many Playgrounds.
  44754. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44755. */
  44756. export class UniversalCamera extends TouchCamera {
  44757. /**
  44758. * Defines the gamepad rotation sensiblity.
  44759. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44760. */
  44761. get gamepadAngularSensibility(): number;
  44762. set gamepadAngularSensibility(value: number);
  44763. /**
  44764. * Defines the gamepad move sensiblity.
  44765. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44766. */
  44767. get gamepadMoveSensibility(): number;
  44768. set gamepadMoveSensibility(value: number);
  44769. /**
  44770. * 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,
  44771. * which still works and will still be found in many Playgrounds.
  44772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44773. * @param name Define the name of the camera in the scene
  44774. * @param position Define the start position of the camera in the scene
  44775. * @param scene Define the scene the camera belongs to
  44776. */
  44777. constructor(name: string, position: Vector3, scene: Scene);
  44778. /**
  44779. * Gets the current object class name.
  44780. * @return the class name
  44781. */
  44782. getClassName(): string;
  44783. }
  44784. }
  44785. declare module BABYLON {
  44786. /**
  44787. * This represents a FPS type of camera. This is only here for back compat purpose.
  44788. * Please use the UniversalCamera instead as both are identical.
  44789. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44790. */
  44791. export class GamepadCamera extends UniversalCamera {
  44792. /**
  44793. * Instantiates a new Gamepad Camera
  44794. * This represents a FPS type of camera. This is only here for back compat purpose.
  44795. * Please use the UniversalCamera instead as both are identical.
  44796. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44797. * @param name Define the name of the camera in the scene
  44798. * @param position Define the start position of the camera in the scene
  44799. * @param scene Define the scene the camera belongs to
  44800. */
  44801. constructor(name: string, position: Vector3, scene: Scene);
  44802. /**
  44803. * Gets the current object class name.
  44804. * @return the class name
  44805. */
  44806. getClassName(): string;
  44807. }
  44808. }
  44809. declare module BABYLON {
  44810. /** @hidden */
  44811. export var passPixelShader: {
  44812. name: string;
  44813. shader: string;
  44814. };
  44815. }
  44816. declare module BABYLON {
  44817. /** @hidden */
  44818. export var passCubePixelShader: {
  44819. name: string;
  44820. shader: string;
  44821. };
  44822. }
  44823. declare module BABYLON {
  44824. /**
  44825. * PassPostProcess which produces an output the same as it's input
  44826. */
  44827. export class PassPostProcess extends PostProcess {
  44828. /**
  44829. * Creates the PassPostProcess
  44830. * @param name The name of the effect.
  44831. * @param options The required width/height ratio to downsize to before computing the render pass.
  44832. * @param camera The camera to apply the render pass to.
  44833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44834. * @param engine The engine which the post process will be applied. (default: current engine)
  44835. * @param reusable If the post process can be reused on the same frame. (default: false)
  44836. * @param textureType The type of texture to be used when performing the post processing.
  44837. * @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)
  44838. */
  44839. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44840. }
  44841. /**
  44842. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44843. */
  44844. export class PassCubePostProcess extends PostProcess {
  44845. private _face;
  44846. /**
  44847. * Gets or sets the cube face to display.
  44848. * * 0 is +X
  44849. * * 1 is -X
  44850. * * 2 is +Y
  44851. * * 3 is -Y
  44852. * * 4 is +Z
  44853. * * 5 is -Z
  44854. */
  44855. get face(): number;
  44856. set face(value: number);
  44857. /**
  44858. * Creates the PassCubePostProcess
  44859. * @param name The name of the effect.
  44860. * @param options The required width/height ratio to downsize to before computing the render pass.
  44861. * @param camera The camera to apply the render pass to.
  44862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44863. * @param engine The engine which the post process will be applied. (default: current engine)
  44864. * @param reusable If the post process can be reused on the same frame. (default: false)
  44865. * @param textureType The type of texture to be used when performing the post processing.
  44866. * @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)
  44867. */
  44868. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44869. }
  44870. }
  44871. declare module BABYLON {
  44872. /** @hidden */
  44873. export var anaglyphPixelShader: {
  44874. name: string;
  44875. shader: string;
  44876. };
  44877. }
  44878. declare module BABYLON {
  44879. /**
  44880. * Postprocess used to generate anaglyphic rendering
  44881. */
  44882. export class AnaglyphPostProcess extends PostProcess {
  44883. private _passedProcess;
  44884. /**
  44885. * Creates a new AnaglyphPostProcess
  44886. * @param name defines postprocess name
  44887. * @param options defines creation options or target ratio scale
  44888. * @param rigCameras defines cameras using this postprocess
  44889. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44890. * @param engine defines hosting engine
  44891. * @param reusable defines if the postprocess will be reused multiple times per frame
  44892. */
  44893. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44894. }
  44895. }
  44896. declare module BABYLON {
  44897. /**
  44898. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44899. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44900. */
  44901. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44902. /**
  44903. * Creates a new AnaglyphArcRotateCamera
  44904. * @param name defines camera name
  44905. * @param alpha defines alpha angle (in radians)
  44906. * @param beta defines beta angle (in radians)
  44907. * @param radius defines radius
  44908. * @param target defines camera target
  44909. * @param interaxialDistance defines distance between each color axis
  44910. * @param scene defines the hosting scene
  44911. */
  44912. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44913. /**
  44914. * Gets camera class name
  44915. * @returns AnaglyphArcRotateCamera
  44916. */
  44917. getClassName(): string;
  44918. }
  44919. }
  44920. declare module BABYLON {
  44921. /**
  44922. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44923. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44924. */
  44925. export class AnaglyphFreeCamera extends FreeCamera {
  44926. /**
  44927. * Creates a new AnaglyphFreeCamera
  44928. * @param name defines camera name
  44929. * @param position defines initial position
  44930. * @param interaxialDistance defines distance between each color axis
  44931. * @param scene defines the hosting scene
  44932. */
  44933. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44934. /**
  44935. * Gets camera class name
  44936. * @returns AnaglyphFreeCamera
  44937. */
  44938. getClassName(): string;
  44939. }
  44940. }
  44941. declare module BABYLON {
  44942. /**
  44943. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44944. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44945. */
  44946. export class AnaglyphGamepadCamera extends GamepadCamera {
  44947. /**
  44948. * Creates a new AnaglyphGamepadCamera
  44949. * @param name defines camera name
  44950. * @param position defines initial position
  44951. * @param interaxialDistance defines distance between each color axis
  44952. * @param scene defines the hosting scene
  44953. */
  44954. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44955. /**
  44956. * Gets camera class name
  44957. * @returns AnaglyphGamepadCamera
  44958. */
  44959. getClassName(): string;
  44960. }
  44961. }
  44962. declare module BABYLON {
  44963. /**
  44964. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44965. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44966. */
  44967. export class AnaglyphUniversalCamera extends UniversalCamera {
  44968. /**
  44969. * Creates a new AnaglyphUniversalCamera
  44970. * @param name defines camera name
  44971. * @param position defines initial position
  44972. * @param interaxialDistance defines distance between each color axis
  44973. * @param scene defines the hosting scene
  44974. */
  44975. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44976. /**
  44977. * Gets camera class name
  44978. * @returns AnaglyphUniversalCamera
  44979. */
  44980. getClassName(): string;
  44981. }
  44982. }
  44983. declare module BABYLON {
  44984. /**
  44985. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44986. * @see http://doc.babylonjs.com/features/cameras
  44987. */
  44988. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44989. /**
  44990. * Creates a new StereoscopicArcRotateCamera
  44991. * @param name defines camera name
  44992. * @param alpha defines alpha angle (in radians)
  44993. * @param beta defines beta angle (in radians)
  44994. * @param radius defines radius
  44995. * @param target defines camera target
  44996. * @param interaxialDistance defines distance between each color axis
  44997. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44998. * @param scene defines the hosting scene
  44999. */
  45000. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45001. /**
  45002. * Gets camera class name
  45003. * @returns StereoscopicArcRotateCamera
  45004. */
  45005. getClassName(): string;
  45006. }
  45007. }
  45008. declare module BABYLON {
  45009. /**
  45010. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45011. * @see http://doc.babylonjs.com/features/cameras
  45012. */
  45013. export class StereoscopicFreeCamera extends FreeCamera {
  45014. /**
  45015. * Creates a new StereoscopicFreeCamera
  45016. * @param name defines camera name
  45017. * @param position defines initial position
  45018. * @param interaxialDistance defines distance between each color axis
  45019. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45020. * @param scene defines the hosting scene
  45021. */
  45022. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45023. /**
  45024. * Gets camera class name
  45025. * @returns StereoscopicFreeCamera
  45026. */
  45027. getClassName(): string;
  45028. }
  45029. }
  45030. declare module BABYLON {
  45031. /**
  45032. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45033. * @see http://doc.babylonjs.com/features/cameras
  45034. */
  45035. export class StereoscopicGamepadCamera extends GamepadCamera {
  45036. /**
  45037. * Creates a new StereoscopicGamepadCamera
  45038. * @param name defines camera name
  45039. * @param position defines initial position
  45040. * @param interaxialDistance defines distance between each color axis
  45041. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45042. * @param scene defines the hosting scene
  45043. */
  45044. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45045. /**
  45046. * Gets camera class name
  45047. * @returns StereoscopicGamepadCamera
  45048. */
  45049. getClassName(): string;
  45050. }
  45051. }
  45052. declare module BABYLON {
  45053. /**
  45054. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45055. * @see http://doc.babylonjs.com/features/cameras
  45056. */
  45057. export class StereoscopicUniversalCamera extends UniversalCamera {
  45058. /**
  45059. * Creates a new StereoscopicUniversalCamera
  45060. * @param name defines camera name
  45061. * @param position defines initial position
  45062. * @param interaxialDistance defines distance between each color axis
  45063. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45064. * @param scene defines the hosting scene
  45065. */
  45066. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45067. /**
  45068. * Gets camera class name
  45069. * @returns StereoscopicUniversalCamera
  45070. */
  45071. getClassName(): string;
  45072. }
  45073. }
  45074. declare module BABYLON {
  45075. /**
  45076. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45077. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45078. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45079. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45080. */
  45081. export class VirtualJoysticksCamera extends FreeCamera {
  45082. /**
  45083. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45084. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45085. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45086. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45087. * @param name Define the name of the camera in the scene
  45088. * @param position Define the start position of the camera in the scene
  45089. * @param scene Define the scene the camera belongs to
  45090. */
  45091. constructor(name: string, position: Vector3, scene: Scene);
  45092. /**
  45093. * Gets the current object class name.
  45094. * @return the class name
  45095. */
  45096. getClassName(): string;
  45097. }
  45098. }
  45099. declare module BABYLON {
  45100. /**
  45101. * This represents all the required metrics to create a VR camera.
  45102. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45103. */
  45104. export class VRCameraMetrics {
  45105. /**
  45106. * Define the horizontal resolution off the screen.
  45107. */
  45108. hResolution: number;
  45109. /**
  45110. * Define the vertical resolution off the screen.
  45111. */
  45112. vResolution: number;
  45113. /**
  45114. * Define the horizontal screen size.
  45115. */
  45116. hScreenSize: number;
  45117. /**
  45118. * Define the vertical screen size.
  45119. */
  45120. vScreenSize: number;
  45121. /**
  45122. * Define the vertical screen center position.
  45123. */
  45124. vScreenCenter: number;
  45125. /**
  45126. * Define the distance of the eyes to the screen.
  45127. */
  45128. eyeToScreenDistance: number;
  45129. /**
  45130. * Define the distance between both lenses
  45131. */
  45132. lensSeparationDistance: number;
  45133. /**
  45134. * Define the distance between both viewer's eyes.
  45135. */
  45136. interpupillaryDistance: number;
  45137. /**
  45138. * Define the distortion factor of the VR postprocess.
  45139. * Please, touch with care.
  45140. */
  45141. distortionK: number[];
  45142. /**
  45143. * Define the chromatic aberration correction factors for the VR post process.
  45144. */
  45145. chromaAbCorrection: number[];
  45146. /**
  45147. * Define the scale factor of the post process.
  45148. * The smaller the better but the slower.
  45149. */
  45150. postProcessScaleFactor: number;
  45151. /**
  45152. * Define an offset for the lens center.
  45153. */
  45154. lensCenterOffset: number;
  45155. /**
  45156. * Define if the current vr camera should compensate the distortion of the lense or not.
  45157. */
  45158. compensateDistortion: boolean;
  45159. /**
  45160. * Defines if multiview should be enabled when rendering (Default: false)
  45161. */
  45162. multiviewEnabled: boolean;
  45163. /**
  45164. * Gets the rendering aspect ratio based on the provided resolutions.
  45165. */
  45166. get aspectRatio(): number;
  45167. /**
  45168. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45169. */
  45170. get aspectRatioFov(): number;
  45171. /**
  45172. * @hidden
  45173. */
  45174. get leftHMatrix(): Matrix;
  45175. /**
  45176. * @hidden
  45177. */
  45178. get rightHMatrix(): Matrix;
  45179. /**
  45180. * @hidden
  45181. */
  45182. get leftPreViewMatrix(): Matrix;
  45183. /**
  45184. * @hidden
  45185. */
  45186. get rightPreViewMatrix(): Matrix;
  45187. /**
  45188. * Get the default VRMetrics based on the most generic setup.
  45189. * @returns the default vr metrics
  45190. */
  45191. static GetDefault(): VRCameraMetrics;
  45192. }
  45193. }
  45194. declare module BABYLON {
  45195. /** @hidden */
  45196. export var vrDistortionCorrectionPixelShader: {
  45197. name: string;
  45198. shader: string;
  45199. };
  45200. }
  45201. declare module BABYLON {
  45202. /**
  45203. * VRDistortionCorrectionPostProcess used for mobile VR
  45204. */
  45205. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45206. private _isRightEye;
  45207. private _distortionFactors;
  45208. private _postProcessScaleFactor;
  45209. private _lensCenterOffset;
  45210. private _scaleIn;
  45211. private _scaleFactor;
  45212. private _lensCenter;
  45213. /**
  45214. * Initializes the VRDistortionCorrectionPostProcess
  45215. * @param name The name of the effect.
  45216. * @param camera The camera to apply the render pass to.
  45217. * @param isRightEye If this is for the right eye distortion
  45218. * @param vrMetrics All the required metrics for the VR camera
  45219. */
  45220. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45221. }
  45222. }
  45223. declare module BABYLON {
  45224. /**
  45225. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45226. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45227. */
  45228. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45229. /**
  45230. * Creates a new VRDeviceOrientationArcRotateCamera
  45231. * @param name defines camera name
  45232. * @param alpha defines the camera rotation along the logitudinal axis
  45233. * @param beta defines the camera rotation along the latitudinal axis
  45234. * @param radius defines the camera distance from its target
  45235. * @param target defines the camera target
  45236. * @param scene defines the scene the camera belongs to
  45237. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45238. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45239. */
  45240. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45241. /**
  45242. * Gets camera class name
  45243. * @returns VRDeviceOrientationArcRotateCamera
  45244. */
  45245. getClassName(): string;
  45246. }
  45247. }
  45248. declare module BABYLON {
  45249. /**
  45250. * Camera used to simulate VR rendering (based on FreeCamera)
  45251. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45252. */
  45253. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45254. /**
  45255. * Creates a new VRDeviceOrientationFreeCamera
  45256. * @param name defines camera name
  45257. * @param position defines the start position of the camera
  45258. * @param scene defines the scene the camera belongs to
  45259. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45260. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45261. */
  45262. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45263. /**
  45264. * Gets camera class name
  45265. * @returns VRDeviceOrientationFreeCamera
  45266. */
  45267. getClassName(): string;
  45268. }
  45269. }
  45270. declare module BABYLON {
  45271. /**
  45272. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45273. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45274. */
  45275. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45276. /**
  45277. * Creates a new VRDeviceOrientationGamepadCamera
  45278. * @param name defines camera name
  45279. * @param position defines the start position of the camera
  45280. * @param scene defines the scene the camera belongs to
  45281. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45282. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45283. */
  45284. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45285. /**
  45286. * Gets camera class name
  45287. * @returns VRDeviceOrientationGamepadCamera
  45288. */
  45289. getClassName(): string;
  45290. }
  45291. }
  45292. declare module BABYLON {
  45293. /** @hidden */
  45294. export var imageProcessingPixelShader: {
  45295. name: string;
  45296. shader: string;
  45297. };
  45298. }
  45299. declare module BABYLON {
  45300. /**
  45301. * ImageProcessingPostProcess
  45302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45303. */
  45304. export class ImageProcessingPostProcess extends PostProcess {
  45305. /**
  45306. * Default configuration related to image processing available in the PBR Material.
  45307. */
  45308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45309. /**
  45310. * Gets the image processing configuration used either in this material.
  45311. */
  45312. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45313. /**
  45314. * Sets the Default image processing configuration used either in the this material.
  45315. *
  45316. * If sets to null, the scene one is in use.
  45317. */
  45318. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45319. /**
  45320. * Keep track of the image processing observer to allow dispose and replace.
  45321. */
  45322. private _imageProcessingObserver;
  45323. /**
  45324. * Attaches a new image processing configuration to the PBR Material.
  45325. * @param configuration
  45326. */
  45327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45328. /**
  45329. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45330. */
  45331. get colorCurves(): Nullable<ColorCurves>;
  45332. /**
  45333. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45334. */
  45335. set colorCurves(value: Nullable<ColorCurves>);
  45336. /**
  45337. * Gets wether the color curves effect is enabled.
  45338. */
  45339. get colorCurvesEnabled(): boolean;
  45340. /**
  45341. * Sets wether the color curves effect is enabled.
  45342. */
  45343. set colorCurvesEnabled(value: boolean);
  45344. /**
  45345. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45346. */
  45347. get colorGradingTexture(): Nullable<BaseTexture>;
  45348. /**
  45349. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45350. */
  45351. set colorGradingTexture(value: Nullable<BaseTexture>);
  45352. /**
  45353. * Gets wether the color grading effect is enabled.
  45354. */
  45355. get colorGradingEnabled(): boolean;
  45356. /**
  45357. * Gets wether the color grading effect is enabled.
  45358. */
  45359. set colorGradingEnabled(value: boolean);
  45360. /**
  45361. * Gets exposure used in the effect.
  45362. */
  45363. get exposure(): number;
  45364. /**
  45365. * Sets exposure used in the effect.
  45366. */
  45367. set exposure(value: number);
  45368. /**
  45369. * Gets wether tonemapping is enabled or not.
  45370. */
  45371. get toneMappingEnabled(): boolean;
  45372. /**
  45373. * Sets wether tonemapping is enabled or not
  45374. */
  45375. set toneMappingEnabled(value: boolean);
  45376. /**
  45377. * Gets the type of tone mapping effect.
  45378. */
  45379. get toneMappingType(): number;
  45380. /**
  45381. * Sets the type of tone mapping effect.
  45382. */
  45383. set toneMappingType(value: number);
  45384. /**
  45385. * Gets contrast used in the effect.
  45386. */
  45387. get contrast(): number;
  45388. /**
  45389. * Sets contrast used in the effect.
  45390. */
  45391. set contrast(value: number);
  45392. /**
  45393. * Gets Vignette stretch size.
  45394. */
  45395. get vignetteStretch(): number;
  45396. /**
  45397. * Sets Vignette stretch size.
  45398. */
  45399. set vignetteStretch(value: number);
  45400. /**
  45401. * Gets Vignette centre X Offset.
  45402. */
  45403. get vignetteCentreX(): number;
  45404. /**
  45405. * Sets Vignette centre X Offset.
  45406. */
  45407. set vignetteCentreX(value: number);
  45408. /**
  45409. * Gets Vignette centre Y Offset.
  45410. */
  45411. get vignetteCentreY(): number;
  45412. /**
  45413. * Sets Vignette centre Y Offset.
  45414. */
  45415. set vignetteCentreY(value: number);
  45416. /**
  45417. * Gets Vignette weight or intensity of the vignette effect.
  45418. */
  45419. get vignetteWeight(): number;
  45420. /**
  45421. * Sets Vignette weight or intensity of the vignette effect.
  45422. */
  45423. set vignetteWeight(value: number);
  45424. /**
  45425. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45426. * if vignetteEnabled is set to true.
  45427. */
  45428. get vignetteColor(): Color4;
  45429. /**
  45430. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45431. * if vignetteEnabled is set to true.
  45432. */
  45433. set vignetteColor(value: Color4);
  45434. /**
  45435. * Gets Camera field of view used by the Vignette effect.
  45436. */
  45437. get vignetteCameraFov(): number;
  45438. /**
  45439. * Sets Camera field of view used by the Vignette effect.
  45440. */
  45441. set vignetteCameraFov(value: number);
  45442. /**
  45443. * Gets the vignette blend mode allowing different kind of effect.
  45444. */
  45445. get vignetteBlendMode(): number;
  45446. /**
  45447. * Sets the vignette blend mode allowing different kind of effect.
  45448. */
  45449. set vignetteBlendMode(value: number);
  45450. /**
  45451. * Gets wether the vignette effect is enabled.
  45452. */
  45453. get vignetteEnabled(): boolean;
  45454. /**
  45455. * Sets wether the vignette effect is enabled.
  45456. */
  45457. set vignetteEnabled(value: boolean);
  45458. private _fromLinearSpace;
  45459. /**
  45460. * Gets wether the input of the processing is in Gamma or Linear Space.
  45461. */
  45462. get fromLinearSpace(): boolean;
  45463. /**
  45464. * Sets wether the input of the processing is in Gamma or Linear Space.
  45465. */
  45466. set fromLinearSpace(value: boolean);
  45467. /**
  45468. * Defines cache preventing GC.
  45469. */
  45470. private _defines;
  45471. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45472. /**
  45473. * "ImageProcessingPostProcess"
  45474. * @returns "ImageProcessingPostProcess"
  45475. */
  45476. getClassName(): string;
  45477. protected _updateParameters(): void;
  45478. dispose(camera?: Camera): void;
  45479. }
  45480. }
  45481. declare module BABYLON {
  45482. /**
  45483. * Class containing static functions to help procedurally build meshes
  45484. */
  45485. export class GroundBuilder {
  45486. /**
  45487. * Creates a ground mesh
  45488. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45489. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45491. * @param name defines the name of the mesh
  45492. * @param options defines the options used to create the mesh
  45493. * @param scene defines the hosting scene
  45494. * @returns the ground mesh
  45495. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45496. */
  45497. static CreateGround(name: string, options: {
  45498. width?: number;
  45499. height?: number;
  45500. subdivisions?: number;
  45501. subdivisionsX?: number;
  45502. subdivisionsY?: number;
  45503. updatable?: boolean;
  45504. }, scene: any): Mesh;
  45505. /**
  45506. * Creates a tiled ground mesh
  45507. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45508. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45509. * * 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
  45510. * * 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
  45511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45512. * @param name defines the name of the mesh
  45513. * @param options defines the options used to create the mesh
  45514. * @param scene defines the hosting scene
  45515. * @returns the tiled ground mesh
  45516. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45517. */
  45518. static CreateTiledGround(name: string, options: {
  45519. xmin: number;
  45520. zmin: number;
  45521. xmax: number;
  45522. zmax: number;
  45523. subdivisions?: {
  45524. w: number;
  45525. h: number;
  45526. };
  45527. precision?: {
  45528. w: number;
  45529. h: number;
  45530. };
  45531. updatable?: boolean;
  45532. }, scene?: Nullable<Scene>): Mesh;
  45533. /**
  45534. * Creates a ground mesh from a height map
  45535. * * The parameter `url` sets the URL of the height map image resource.
  45536. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45537. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45538. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45539. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45540. * * 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.
  45541. * * 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).
  45542. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45544. * @param name defines the name of the mesh
  45545. * @param url defines the url to the height map
  45546. * @param options defines the options used to create the mesh
  45547. * @param scene defines the hosting scene
  45548. * @returns the ground mesh
  45549. * @see https://doc.babylonjs.com/babylon101/height_map
  45550. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45551. */
  45552. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45553. width?: number;
  45554. height?: number;
  45555. subdivisions?: number;
  45556. minHeight?: number;
  45557. maxHeight?: number;
  45558. colorFilter?: Color3;
  45559. alphaFilter?: number;
  45560. updatable?: boolean;
  45561. onReady?: (mesh: GroundMesh) => void;
  45562. }, scene?: Nullable<Scene>): GroundMesh;
  45563. }
  45564. }
  45565. declare module BABYLON {
  45566. /**
  45567. * Class containing static functions to help procedurally build meshes
  45568. */
  45569. export class TorusBuilder {
  45570. /**
  45571. * Creates a torus mesh
  45572. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45573. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45574. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45576. * * 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
  45577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45578. * @param name defines the name of the mesh
  45579. * @param options defines the options used to create the mesh
  45580. * @param scene defines the hosting scene
  45581. * @returns the torus mesh
  45582. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45583. */
  45584. static CreateTorus(name: string, options: {
  45585. diameter?: number;
  45586. thickness?: number;
  45587. tessellation?: number;
  45588. updatable?: boolean;
  45589. sideOrientation?: number;
  45590. frontUVs?: Vector4;
  45591. backUVs?: Vector4;
  45592. }, scene: any): Mesh;
  45593. }
  45594. }
  45595. declare module BABYLON {
  45596. /**
  45597. * Class containing static functions to help procedurally build meshes
  45598. */
  45599. export class CylinderBuilder {
  45600. /**
  45601. * Creates a cylinder or a cone mesh
  45602. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45603. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45604. * * 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.
  45605. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45606. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45607. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45608. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45609. * * 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).
  45610. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45611. * * 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).
  45612. * * 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
  45613. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45614. * * 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
  45615. * * 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.
  45616. * * If `enclose` is false, a ring surface is one element.
  45617. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45618. * * 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
  45619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45620. * * 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
  45621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45622. * @param name defines the name of the mesh
  45623. * @param options defines the options used to create the mesh
  45624. * @param scene defines the hosting scene
  45625. * @returns the cylinder mesh
  45626. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45627. */
  45628. static CreateCylinder(name: string, options: {
  45629. height?: number;
  45630. diameterTop?: number;
  45631. diameterBottom?: number;
  45632. diameter?: number;
  45633. tessellation?: number;
  45634. subdivisions?: number;
  45635. arc?: number;
  45636. faceColors?: Color4[];
  45637. faceUV?: Vector4[];
  45638. updatable?: boolean;
  45639. hasRings?: boolean;
  45640. enclose?: boolean;
  45641. cap?: number;
  45642. sideOrientation?: number;
  45643. frontUVs?: Vector4;
  45644. backUVs?: Vector4;
  45645. }, scene: any): Mesh;
  45646. }
  45647. }
  45648. declare module BABYLON {
  45649. /**
  45650. * States of the webXR experience
  45651. */
  45652. export enum WebXRState {
  45653. /**
  45654. * Transitioning to being in XR mode
  45655. */
  45656. ENTERING_XR = 0,
  45657. /**
  45658. * Transitioning to non XR mode
  45659. */
  45660. EXITING_XR = 1,
  45661. /**
  45662. * In XR mode and presenting
  45663. */
  45664. IN_XR = 2,
  45665. /**
  45666. * Not entered XR mode
  45667. */
  45668. NOT_IN_XR = 3
  45669. }
  45670. /**
  45671. * Abstraction of the XR render target
  45672. */
  45673. export interface WebXRRenderTarget extends IDisposable {
  45674. /**
  45675. * xrpresent context of the canvas which can be used to display/mirror xr content
  45676. */
  45677. canvasContext: WebGLRenderingContext;
  45678. /**
  45679. * xr layer for the canvas
  45680. */
  45681. xrLayer: Nullable<XRWebGLLayer>;
  45682. /**
  45683. * Initializes the xr layer for the session
  45684. * @param xrSession xr session
  45685. * @returns a promise that will resolve once the XR Layer has been created
  45686. */
  45687. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45688. }
  45689. }
  45690. declare module BABYLON {
  45691. /**
  45692. * COnfiguration object for WebXR output canvas
  45693. */
  45694. export class WebXRManagedOutputCanvasOptions {
  45695. /**
  45696. * An optional canvas in case you wish to create it yourself and provide it here.
  45697. * If not provided, a new canvas will be created
  45698. */
  45699. canvasElement?: HTMLCanvasElement;
  45700. /**
  45701. * Options for this XR Layer output
  45702. */
  45703. canvasOptions?: XRWebGLLayerOptions;
  45704. /**
  45705. * CSS styling for a newly created canvas (if not provided)
  45706. */
  45707. newCanvasCssStyle?: string;
  45708. /**
  45709. * Get the default values of the configuration object
  45710. * @returns default values of this configuration object
  45711. */
  45712. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45713. }
  45714. /**
  45715. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45716. */
  45717. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45718. private _options;
  45719. private _canvas;
  45720. private _engine;
  45721. /**
  45722. * Rendering context of the canvas which can be used to display/mirror xr content
  45723. */
  45724. canvasContext: WebGLRenderingContext;
  45725. /**
  45726. * xr layer for the canvas
  45727. */
  45728. xrLayer: Nullable<XRWebGLLayer>;
  45729. /**
  45730. * Initializes the canvas to be added/removed upon entering/exiting xr
  45731. * @param _xrSessionManager The XR Session manager
  45732. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45733. */
  45734. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45735. /**
  45736. * Disposes of the object
  45737. */
  45738. dispose(): void;
  45739. /**
  45740. * Initializes the xr layer for the session
  45741. * @param xrSession xr session
  45742. * @returns a promise that will resolve once the XR Layer has been created
  45743. */
  45744. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45745. private _addCanvas;
  45746. private _removeCanvas;
  45747. private _setManagedOutputCanvas;
  45748. }
  45749. }
  45750. declare module BABYLON {
  45751. /**
  45752. * Manages an XRSession to work with Babylon's engine
  45753. * @see https://doc.babylonjs.com/how_to/webxr
  45754. */
  45755. export class WebXRSessionManager implements IDisposable {
  45756. /** The scene which the session should be created for */
  45757. scene: Scene;
  45758. private _referenceSpace;
  45759. private _rttProvider;
  45760. private _sessionEnded;
  45761. private _xrNavigator;
  45762. private baseLayer;
  45763. /**
  45764. * The base reference space from which the session started. good if you want to reset your
  45765. * reference space
  45766. */
  45767. baseReferenceSpace: XRReferenceSpace;
  45768. /**
  45769. * Current XR frame
  45770. */
  45771. currentFrame: Nullable<XRFrame>;
  45772. /** WebXR timestamp updated every frame */
  45773. currentTimestamp: number;
  45774. /**
  45775. * Used just in case of a failure to initialize an immersive session.
  45776. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45777. */
  45778. defaultHeightCompensation: number;
  45779. /**
  45780. * Fires every time a new xrFrame arrives which can be used to update the camera
  45781. */
  45782. onXRFrameObservable: Observable<XRFrame>;
  45783. /**
  45784. * Fires when the reference space changed
  45785. */
  45786. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45787. /**
  45788. * Fires when the xr session is ended either by the device or manually done
  45789. */
  45790. onXRSessionEnded: Observable<any>;
  45791. /**
  45792. * Fires when the xr session is ended either by the device or manually done
  45793. */
  45794. onXRSessionInit: Observable<XRSession>;
  45795. /**
  45796. * Underlying xr session
  45797. */
  45798. session: XRSession;
  45799. /**
  45800. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45801. * or get the offset the player is currently at.
  45802. */
  45803. viewerReferenceSpace: XRReferenceSpace;
  45804. /**
  45805. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45806. * @param scene The scene which the session should be created for
  45807. */
  45808. constructor(
  45809. /** The scene which the session should be created for */
  45810. scene: Scene);
  45811. /**
  45812. * The current reference space used in this session. This reference space can constantly change!
  45813. * It is mainly used to offset the camera's position.
  45814. */
  45815. get referenceSpace(): XRReferenceSpace;
  45816. /**
  45817. * Set a new reference space and triggers the observable
  45818. */
  45819. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45820. /**
  45821. * Disposes of the session manager
  45822. */
  45823. dispose(): void;
  45824. /**
  45825. * Stops the xrSession and restores the render loop
  45826. * @returns Promise which resolves after it exits XR
  45827. */
  45828. exitXRAsync(): Promise<void>;
  45829. /**
  45830. * Gets the correct render target texture to be rendered this frame for this eye
  45831. * @param eye the eye for which to get the render target
  45832. * @returns the render target for the specified eye
  45833. */
  45834. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45835. /**
  45836. * Creates a WebXRRenderTarget object for the XR session
  45837. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45838. * @param options optional options to provide when creating a new render target
  45839. * @returns a WebXR render target to which the session can render
  45840. */
  45841. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45842. /**
  45843. * Initializes the manager
  45844. * After initialization enterXR can be called to start an XR session
  45845. * @returns Promise which resolves after it is initialized
  45846. */
  45847. initializeAsync(): Promise<void>;
  45848. /**
  45849. * Initializes an xr session
  45850. * @param xrSessionMode mode to initialize
  45851. * @param xrSessionInit defines optional and required values to pass to the session builder
  45852. * @returns a promise which will resolve once the session has been initialized
  45853. */
  45854. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45855. /**
  45856. * Checks if a session would be supported for the creation options specified
  45857. * @param sessionMode session mode to check if supported eg. immersive-vr
  45858. * @returns A Promise that resolves to true if supported and false if not
  45859. */
  45860. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45861. /**
  45862. * Resets the reference space to the one started the session
  45863. */
  45864. resetReferenceSpace(): void;
  45865. /**
  45866. * Starts rendering to the xr layer
  45867. */
  45868. runXRRenderLoop(): void;
  45869. /**
  45870. * Sets the reference space on the xr session
  45871. * @param referenceSpaceType space to set
  45872. * @returns a promise that will resolve once the reference space has been set
  45873. */
  45874. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45875. /**
  45876. * Updates the render state of the session
  45877. * @param state state to set
  45878. * @returns a promise that resolves once the render state has been updated
  45879. */
  45880. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45881. /**
  45882. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45883. * @param sessionMode defines the session to test
  45884. * @returns a promise with boolean as final value
  45885. */
  45886. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45887. private _createRenderTargetTexture;
  45888. }
  45889. }
  45890. declare module BABYLON {
  45891. /**
  45892. * WebXR Camera which holds the views for the xrSession
  45893. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45894. */
  45895. export class WebXRCamera extends FreeCamera {
  45896. private _xrSessionManager;
  45897. private _firstFrame;
  45898. private _referenceQuaternion;
  45899. private _referencedPosition;
  45900. private _xrInvPositionCache;
  45901. private _xrInvQuaternionCache;
  45902. /**
  45903. * Should position compensation execute on first frame.
  45904. * This is used when copying the position from a native (non XR) camera
  45905. */
  45906. compensateOnFirstFrame: boolean;
  45907. /**
  45908. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45909. * @param name the name of the camera
  45910. * @param scene the scene to add the camera to
  45911. * @param _xrSessionManager a constructed xr session manager
  45912. */
  45913. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45914. /**
  45915. * Return the user's height, unrelated to the current ground.
  45916. * This will be the y position of this camera, when ground level is 0.
  45917. */
  45918. get realWorldHeight(): number;
  45919. /** @hidden */
  45920. _updateForDualEyeDebugging(): void;
  45921. /**
  45922. * Sets this camera's transformation based on a non-vr camera
  45923. * @param otherCamera the non-vr camera to copy the transformation from
  45924. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45925. */
  45926. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45927. /**
  45928. * Gets the current instance class name ("WebXRCamera").
  45929. * @returns the class name
  45930. */
  45931. getClassName(): string;
  45932. /**
  45933. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45934. */
  45935. _getViewMatrix(): Matrix;
  45936. private _updateFromXRSession;
  45937. private _updateNumberOfRigCameras;
  45938. private _updateReferenceSpace;
  45939. private _updateReferenceSpaceOffset;
  45940. }
  45941. }
  45942. declare module BABYLON {
  45943. /**
  45944. * Defining the interface required for a (webxr) feature
  45945. */
  45946. export interface IWebXRFeature extends IDisposable {
  45947. /**
  45948. * Is this feature attached
  45949. */
  45950. attached: boolean;
  45951. /**
  45952. * Should auto-attach be disabled?
  45953. */
  45954. disableAutoAttach: boolean;
  45955. /**
  45956. * Attach the feature to the session
  45957. * Will usually be called by the features manager
  45958. *
  45959. * @param force should attachment be forced (even when already attached)
  45960. * @returns true if successful.
  45961. */
  45962. attach(force?: boolean): boolean;
  45963. /**
  45964. * Detach the feature from the session
  45965. * Will usually be called by the features manager
  45966. *
  45967. * @returns true if successful.
  45968. */
  45969. detach(): boolean;
  45970. }
  45971. /**
  45972. * A list of the currently available features without referencing them
  45973. */
  45974. export class WebXRFeatureName {
  45975. /**
  45976. * The name of the anchor system feature
  45977. */
  45978. static ANCHOR_SYSTEM: string;
  45979. /**
  45980. * The name of the background remover feature
  45981. */
  45982. static BACKGROUND_REMOVER: string;
  45983. /**
  45984. * The name of the hit test feature
  45985. */
  45986. static HIT_TEST: string;
  45987. /**
  45988. * physics impostors for xr controllers feature
  45989. */
  45990. static PHYSICS_CONTROLLERS: string;
  45991. /**
  45992. * The name of the plane detection feature
  45993. */
  45994. static PLANE_DETECTION: string;
  45995. /**
  45996. * The name of the pointer selection feature
  45997. */
  45998. static POINTER_SELECTION: string;
  45999. /**
  46000. * The name of the teleportation feature
  46001. */
  46002. static TELEPORTATION: string;
  46003. }
  46004. /**
  46005. * Defining the constructor of a feature. Used to register the modules.
  46006. */
  46007. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46008. /**
  46009. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46010. * It is mainly used in AR sessions.
  46011. *
  46012. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46013. */
  46014. export class WebXRFeaturesManager implements IDisposable {
  46015. private _xrSessionManager;
  46016. private static readonly _AvailableFeatures;
  46017. private _features;
  46018. /**
  46019. * constructs a new features manages.
  46020. *
  46021. * @param _xrSessionManager an instance of WebXRSessionManager
  46022. */
  46023. constructor(_xrSessionManager: WebXRSessionManager);
  46024. /**
  46025. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46026. * Mainly used internally.
  46027. *
  46028. * @param featureName the name of the feature to register
  46029. * @param constructorFunction the function used to construct the module
  46030. * @param version the (babylon) version of the module
  46031. * @param stable is that a stable version of this module
  46032. */
  46033. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46034. /**
  46035. * Returns a constructor of a specific feature.
  46036. *
  46037. * @param featureName the name of the feature to construct
  46038. * @param version the version of the feature to load
  46039. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46040. * @param options optional options provided to the module.
  46041. * @returns a function that, when called, will return a new instance of this feature
  46042. */
  46043. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46044. /**
  46045. * Can be used to return the list of features currently registered
  46046. *
  46047. * @returns an Array of available features
  46048. */
  46049. static GetAvailableFeatures(): string[];
  46050. /**
  46051. * Gets the versions available for a specific feature
  46052. * @param featureName the name of the feature
  46053. * @returns an array with the available versions
  46054. */
  46055. static GetAvailableVersions(featureName: string): string[];
  46056. /**
  46057. * Return the latest unstable version of this feature
  46058. * @param featureName the name of the feature to search
  46059. * @returns the version number. if not found will return -1
  46060. */
  46061. static GetLatestVersionOfFeature(featureName: string): number;
  46062. /**
  46063. * Return the latest stable version of this feature
  46064. * @param featureName the name of the feature to search
  46065. * @returns the version number. if not found will return -1
  46066. */
  46067. static GetStableVersionOfFeature(featureName: string): number;
  46068. /**
  46069. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46070. * Can be used during a session to start a feature
  46071. * @param featureName the name of feature to attach
  46072. */
  46073. attachFeature(featureName: string): void;
  46074. /**
  46075. * Can be used inside a session or when the session ends to detach a specific feature
  46076. * @param featureName the name of the feature to detach
  46077. */
  46078. detachFeature(featureName: string): void;
  46079. /**
  46080. * Used to disable an already-enabled feature
  46081. * The feature will be disposed and will be recreated once enabled.
  46082. * @param featureName the feature to disable
  46083. * @returns true if disable was successful
  46084. */
  46085. disableFeature(featureName: string | {
  46086. Name: string;
  46087. }): boolean;
  46088. /**
  46089. * dispose this features manager
  46090. */
  46091. dispose(): void;
  46092. /**
  46093. * 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.
  46094. * 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.
  46095. *
  46096. * @param featureName the name of the feature to load or the class of the feature
  46097. * @param version optional version to load. if not provided the latest version will be enabled
  46098. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46099. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46100. * @returns a new constructed feature or throws an error if feature not found.
  46101. */
  46102. enableFeature(featureName: string | {
  46103. Name: string;
  46104. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46105. /**
  46106. * get the implementation of an enabled feature.
  46107. * @param featureName the name of the feature to load
  46108. * @returns the feature class, if found
  46109. */
  46110. getEnabledFeature(featureName: string): IWebXRFeature;
  46111. /**
  46112. * Get the list of enabled features
  46113. * @returns an array of enabled features
  46114. */
  46115. getEnabledFeatures(): string[];
  46116. }
  46117. }
  46118. declare module BABYLON {
  46119. /**
  46120. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46121. * @see https://doc.babylonjs.com/how_to/webxr
  46122. */
  46123. export class WebXRExperienceHelper implements IDisposable {
  46124. private scene;
  46125. private _nonVRCamera;
  46126. private _originalSceneAutoClear;
  46127. private _supported;
  46128. /**
  46129. * Camera used to render xr content
  46130. */
  46131. camera: WebXRCamera;
  46132. /** A features manager for this xr session */
  46133. featuresManager: WebXRFeaturesManager;
  46134. /**
  46135. * Observers registered here will be triggered after the camera's initial transformation is set
  46136. * This can be used to set a different ground level or an extra rotation.
  46137. *
  46138. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46139. * to the position set after this observable is done executing.
  46140. */
  46141. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46142. /**
  46143. * Fires when the state of the experience helper has changed
  46144. */
  46145. onStateChangedObservable: Observable<WebXRState>;
  46146. /** Session manager used to keep track of xr session */
  46147. sessionManager: WebXRSessionManager;
  46148. /**
  46149. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46150. */
  46151. state: WebXRState;
  46152. /**
  46153. * Creates a WebXRExperienceHelper
  46154. * @param scene The scene the helper should be created in
  46155. */
  46156. private constructor();
  46157. /**
  46158. * Creates the experience helper
  46159. * @param scene the scene to attach the experience helper to
  46160. * @returns a promise for the experience helper
  46161. */
  46162. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46163. /**
  46164. * Disposes of the experience helper
  46165. */
  46166. dispose(): void;
  46167. /**
  46168. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46169. * @param sessionMode options for the XR session
  46170. * @param referenceSpaceType frame of reference of the XR session
  46171. * @param renderTarget the output canvas that will be used to enter XR mode
  46172. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46173. * @returns promise that resolves after xr mode has entered
  46174. */
  46175. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46176. /**
  46177. * Exits XR mode and returns the scene to its original state
  46178. * @returns promise that resolves after xr mode has exited
  46179. */
  46180. exitXRAsync(): Promise<void>;
  46181. private _nonXRToXRCamera;
  46182. private _setState;
  46183. }
  46184. }
  46185. declare module BABYLON {
  46186. /**
  46187. * X-Y values for axes in WebXR
  46188. */
  46189. export interface IWebXRMotionControllerAxesValue {
  46190. /**
  46191. * The value of the x axis
  46192. */
  46193. x: number;
  46194. /**
  46195. * The value of the y-axis
  46196. */
  46197. y: number;
  46198. }
  46199. /**
  46200. * changed / previous values for the values of this component
  46201. */
  46202. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46203. /**
  46204. * current (this frame) value
  46205. */
  46206. current: T;
  46207. /**
  46208. * previous (last change) value
  46209. */
  46210. previous: T;
  46211. }
  46212. /**
  46213. * Represents changes in the component between current frame and last values recorded
  46214. */
  46215. export interface IWebXRMotionControllerComponentChanges {
  46216. /**
  46217. * will be populated with previous and current values if axes changed
  46218. */
  46219. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46220. /**
  46221. * will be populated with previous and current values if pressed changed
  46222. */
  46223. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46224. /**
  46225. * will be populated with previous and current values if touched changed
  46226. */
  46227. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46228. /**
  46229. * will be populated with previous and current values if value changed
  46230. */
  46231. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46232. }
  46233. /**
  46234. * This class represents a single component (for example button or thumbstick) of a motion controller
  46235. */
  46236. export class WebXRControllerComponent implements IDisposable {
  46237. /**
  46238. * the id of this component
  46239. */
  46240. id: string;
  46241. /**
  46242. * the type of the component
  46243. */
  46244. type: MotionControllerComponentType;
  46245. private _buttonIndex;
  46246. private _axesIndices;
  46247. private _axes;
  46248. private _changes;
  46249. private _currentValue;
  46250. private _hasChanges;
  46251. private _pressed;
  46252. private _touched;
  46253. /**
  46254. * button component type
  46255. */
  46256. static BUTTON_TYPE: MotionControllerComponentType;
  46257. /**
  46258. * squeeze component type
  46259. */
  46260. static SQUEEZE_TYPE: MotionControllerComponentType;
  46261. /**
  46262. * Thumbstick component type
  46263. */
  46264. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46265. /**
  46266. * Touchpad component type
  46267. */
  46268. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46269. /**
  46270. * trigger component type
  46271. */
  46272. static TRIGGER_TYPE: MotionControllerComponentType;
  46273. /**
  46274. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46275. * the axes data changes
  46276. */
  46277. onAxisValueChangedObservable: Observable<{
  46278. x: number;
  46279. y: number;
  46280. }>;
  46281. /**
  46282. * Observers registered here will be triggered when the state of a button changes
  46283. * State change is either pressed / touched / value
  46284. */
  46285. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46286. /**
  46287. * Creates a new component for a motion controller.
  46288. * It is created by the motion controller itself
  46289. *
  46290. * @param id the id of this component
  46291. * @param type the type of the component
  46292. * @param _buttonIndex index in the buttons array of the gamepad
  46293. * @param _axesIndices indices of the values in the axes array of the gamepad
  46294. */
  46295. constructor(
  46296. /**
  46297. * the id of this component
  46298. */
  46299. id: string,
  46300. /**
  46301. * the type of the component
  46302. */
  46303. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46304. /**
  46305. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46306. */
  46307. get axes(): IWebXRMotionControllerAxesValue;
  46308. /**
  46309. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46310. */
  46311. get changes(): IWebXRMotionControllerComponentChanges;
  46312. /**
  46313. * Return whether or not the component changed the last frame
  46314. */
  46315. get hasChanges(): boolean;
  46316. /**
  46317. * is the button currently pressed
  46318. */
  46319. get pressed(): boolean;
  46320. /**
  46321. * is the button currently touched
  46322. */
  46323. get touched(): boolean;
  46324. /**
  46325. * Get the current value of this component
  46326. */
  46327. get value(): number;
  46328. /**
  46329. * Dispose this component
  46330. */
  46331. dispose(): void;
  46332. /**
  46333. * Are there axes correlating to this component
  46334. * @return true is axes data is available
  46335. */
  46336. isAxes(): boolean;
  46337. /**
  46338. * Is this component a button (hence - pressable)
  46339. * @returns true if can be pressed
  46340. */
  46341. isButton(): boolean;
  46342. /**
  46343. * update this component using the gamepad object it is in. Called on every frame
  46344. * @param nativeController the native gamepad controller object
  46345. */
  46346. update(nativeController: IMinimalMotionControllerObject): void;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. /**
  46351. * Class used to represent data loading progression
  46352. */
  46353. export class SceneLoaderProgressEvent {
  46354. /** defines if data length to load can be evaluated */
  46355. readonly lengthComputable: boolean;
  46356. /** defines the loaded data length */
  46357. readonly loaded: number;
  46358. /** defines the data length to load */
  46359. readonly total: number;
  46360. /**
  46361. * Create a new progress event
  46362. * @param lengthComputable defines if data length to load can be evaluated
  46363. * @param loaded defines the loaded data length
  46364. * @param total defines the data length to load
  46365. */
  46366. constructor(
  46367. /** defines if data length to load can be evaluated */
  46368. lengthComputable: boolean,
  46369. /** defines the loaded data length */
  46370. loaded: number,
  46371. /** defines the data length to load */
  46372. total: number);
  46373. /**
  46374. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46375. * @param event defines the source event
  46376. * @returns a new SceneLoaderProgressEvent
  46377. */
  46378. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46379. }
  46380. /**
  46381. * Interface used by SceneLoader plugins to define supported file extensions
  46382. */
  46383. export interface ISceneLoaderPluginExtensions {
  46384. /**
  46385. * Defines the list of supported extensions
  46386. */
  46387. [extension: string]: {
  46388. isBinary: boolean;
  46389. };
  46390. }
  46391. /**
  46392. * Interface used by SceneLoader plugin factory
  46393. */
  46394. export interface ISceneLoaderPluginFactory {
  46395. /**
  46396. * Defines the name of the factory
  46397. */
  46398. name: string;
  46399. /**
  46400. * Function called to create a new plugin
  46401. * @return the new plugin
  46402. */
  46403. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46404. /**
  46405. * The callback that returns true if the data can be directly loaded.
  46406. * @param data string containing the file data
  46407. * @returns if the data can be loaded directly
  46408. */
  46409. canDirectLoad?(data: string): boolean;
  46410. }
  46411. /**
  46412. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46413. */
  46414. export interface ISceneLoaderPluginBase {
  46415. /**
  46416. * The friendly name of this plugin.
  46417. */
  46418. name: string;
  46419. /**
  46420. * The file extensions supported by this plugin.
  46421. */
  46422. extensions: string | ISceneLoaderPluginExtensions;
  46423. /**
  46424. * The callback called when loading from a url.
  46425. * @param scene scene loading this url
  46426. * @param url url to load
  46427. * @param onSuccess callback called when the file successfully loads
  46428. * @param onProgress callback called while file is loading (if the server supports this mode)
  46429. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46430. * @param onError callback called when the file fails to load
  46431. * @returns a file request object
  46432. */
  46433. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46434. /**
  46435. * The callback called when loading from a file object.
  46436. * @param scene scene loading this file
  46437. * @param file defines the file to load
  46438. * @param onSuccess defines the callback to call when data is loaded
  46439. * @param onProgress defines the callback to call during loading process
  46440. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46441. * @param onError defines the callback to call when an error occurs
  46442. * @returns a file request object
  46443. */
  46444. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46445. /**
  46446. * The callback that returns true if the data can be directly loaded.
  46447. * @param data string containing the file data
  46448. * @returns if the data can be loaded directly
  46449. */
  46450. canDirectLoad?(data: string): boolean;
  46451. /**
  46452. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46453. * @param scene scene loading this data
  46454. * @param data string containing the data
  46455. * @returns data to pass to the plugin
  46456. */
  46457. directLoad?(scene: Scene, data: string): any;
  46458. /**
  46459. * The callback that allows custom handling of the root url based on the response url.
  46460. * @param rootUrl the original root url
  46461. * @param responseURL the response url if available
  46462. * @returns the new root url
  46463. */
  46464. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46465. }
  46466. /**
  46467. * Interface used to define a SceneLoader plugin
  46468. */
  46469. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46470. /**
  46471. * Import meshes into a scene.
  46472. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46473. * @param scene The scene to import into
  46474. * @param data The data to import
  46475. * @param rootUrl The root url for scene and resources
  46476. * @param meshes The meshes array to import into
  46477. * @param particleSystems The particle systems array to import into
  46478. * @param skeletons The skeletons array to import into
  46479. * @param onError The callback when import fails
  46480. * @returns True if successful or false otherwise
  46481. */
  46482. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46483. /**
  46484. * Load into a scene.
  46485. * @param scene The scene to load into
  46486. * @param data The data to import
  46487. * @param rootUrl The root url for scene and resources
  46488. * @param onError The callback when import fails
  46489. * @returns True if successful or false otherwise
  46490. */
  46491. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46492. /**
  46493. * Load into an asset container.
  46494. * @param scene The scene to load into
  46495. * @param data The data to import
  46496. * @param rootUrl The root url for scene and resources
  46497. * @param onError The callback when import fails
  46498. * @returns The loaded asset container
  46499. */
  46500. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46501. }
  46502. /**
  46503. * Interface used to define an async SceneLoader plugin
  46504. */
  46505. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46506. /**
  46507. * Import meshes into a scene.
  46508. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46509. * @param scene The scene to import into
  46510. * @param data The data to import
  46511. * @param rootUrl The root url for scene and resources
  46512. * @param onProgress The callback when the load progresses
  46513. * @param fileName Defines the name of the file to load
  46514. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46515. */
  46516. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46517. meshes: AbstractMesh[];
  46518. particleSystems: IParticleSystem[];
  46519. skeletons: Skeleton[];
  46520. animationGroups: AnimationGroup[];
  46521. }>;
  46522. /**
  46523. * Load into a scene.
  46524. * @param scene The scene to load into
  46525. * @param data The data to import
  46526. * @param rootUrl The root url for scene and resources
  46527. * @param onProgress The callback when the load progresses
  46528. * @param fileName Defines the name of the file to load
  46529. * @returns Nothing
  46530. */
  46531. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46532. /**
  46533. * Load into an asset container.
  46534. * @param scene The scene to load into
  46535. * @param data The data to import
  46536. * @param rootUrl The root url for scene and resources
  46537. * @param onProgress The callback when the load progresses
  46538. * @param fileName Defines the name of the file to load
  46539. * @returns The loaded asset container
  46540. */
  46541. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46542. }
  46543. /**
  46544. * Mode that determines how to handle old animation groups before loading new ones.
  46545. */
  46546. export enum SceneLoaderAnimationGroupLoadingMode {
  46547. /**
  46548. * Reset all old animations to initial state then dispose them.
  46549. */
  46550. Clean = 0,
  46551. /**
  46552. * Stop all old animations.
  46553. */
  46554. Stop = 1,
  46555. /**
  46556. * Restart old animations from first frame.
  46557. */
  46558. Sync = 2,
  46559. /**
  46560. * Old animations remains untouched.
  46561. */
  46562. NoSync = 3
  46563. }
  46564. /**
  46565. * Class used to load scene from various file formats using registered plugins
  46566. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46567. */
  46568. export class SceneLoader {
  46569. /**
  46570. * No logging while loading
  46571. */
  46572. static readonly NO_LOGGING: number;
  46573. /**
  46574. * Minimal logging while loading
  46575. */
  46576. static readonly MINIMAL_LOGGING: number;
  46577. /**
  46578. * Summary logging while loading
  46579. */
  46580. static readonly SUMMARY_LOGGING: number;
  46581. /**
  46582. * Detailled logging while loading
  46583. */
  46584. static readonly DETAILED_LOGGING: number;
  46585. /**
  46586. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46587. */
  46588. static get ForceFullSceneLoadingForIncremental(): boolean;
  46589. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46590. /**
  46591. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46592. */
  46593. static get ShowLoadingScreen(): boolean;
  46594. static set ShowLoadingScreen(value: boolean);
  46595. /**
  46596. * Defines the current logging level (while loading the scene)
  46597. * @ignorenaming
  46598. */
  46599. static get loggingLevel(): number;
  46600. static set loggingLevel(value: number);
  46601. /**
  46602. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46603. */
  46604. static get CleanBoneMatrixWeights(): boolean;
  46605. static set CleanBoneMatrixWeights(value: boolean);
  46606. /**
  46607. * Event raised when a plugin is used to load a scene
  46608. */
  46609. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46610. private static _registeredPlugins;
  46611. private static _getDefaultPlugin;
  46612. private static _getPluginForExtension;
  46613. private static _getPluginForDirectLoad;
  46614. private static _getPluginForFilename;
  46615. private static _getDirectLoad;
  46616. private static _loadData;
  46617. private static _getFileInfo;
  46618. /**
  46619. * Gets a plugin that can load the given extension
  46620. * @param extension defines the extension to load
  46621. * @returns a plugin or null if none works
  46622. */
  46623. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46624. /**
  46625. * Gets a boolean indicating that the given extension can be loaded
  46626. * @param extension defines the extension to load
  46627. * @returns true if the extension is supported
  46628. */
  46629. static IsPluginForExtensionAvailable(extension: string): boolean;
  46630. /**
  46631. * Adds a new plugin to the list of registered plugins
  46632. * @param plugin defines the plugin to add
  46633. */
  46634. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46635. /**
  46636. * Import meshes into a scene
  46637. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46638. * @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)
  46639. * @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)
  46640. * @param scene the instance of BABYLON.Scene to append to
  46641. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46642. * @param onProgress a callback with a progress event for each file being loaded
  46643. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46644. * @param pluginExtension the extension used to determine the plugin
  46645. * @returns The loaded plugin
  46646. */
  46647. 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>;
  46648. /**
  46649. * Import meshes into a scene
  46650. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 or a File object (default: empty string)
  46653. * @param scene the instance of BABYLON.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 list of imported meshes, particle systems, skeletons, and animation groups
  46657. */
  46658. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46659. meshes: AbstractMesh[];
  46660. particleSystems: IParticleSystem[];
  46661. skeletons: Skeleton[];
  46662. animationGroups: AnimationGroup[];
  46663. }>;
  46664. /**
  46665. * Load a scene
  46666. * @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)
  46667. * @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)
  46668. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46669. * @param onSuccess a callback with the scene when import succeeds
  46670. * @param onProgress a callback with a progress event for each file being loaded
  46671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46672. * @param pluginExtension the extension used to determine the plugin
  46673. * @returns The loaded plugin
  46674. */
  46675. 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>;
  46676. /**
  46677. * Load a scene
  46678. * @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)
  46679. * @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)
  46680. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46681. * @param onProgress a callback with a progress event for each file being loaded
  46682. * @param pluginExtension the extension used to determine the plugin
  46683. * @returns The loaded scene
  46684. */
  46685. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46686. /**
  46687. * Append a scene
  46688. * @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)
  46689. * @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)
  46690. * @param scene is the instance of BABYLON.Scene to append to
  46691. * @param onSuccess a callback with the scene when import succeeds
  46692. * @param onProgress a callback with a progress event for each file being loaded
  46693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46694. * @param pluginExtension the extension used to determine the plugin
  46695. * @returns The loaded plugin
  46696. */
  46697. 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>;
  46698. /**
  46699. * Append a scene
  46700. * @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)
  46701. * @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)
  46702. * @param scene is the instance of BABYLON.Scene to append to
  46703. * @param onProgress a callback with a progress event for each file being loaded
  46704. * @param pluginExtension the extension used to determine the plugin
  46705. * @returns The given scene
  46706. */
  46707. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46708. /**
  46709. * Load a scene into an asset container
  46710. * @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)
  46711. * @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)
  46712. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46713. * @param onSuccess a callback with the scene when import succeeds
  46714. * @param onProgress a callback with a progress event for each file being loaded
  46715. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46716. * @param pluginExtension the extension used to determine the plugin
  46717. * @returns The loaded plugin
  46718. */
  46719. 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>;
  46720. /**
  46721. * Load a scene into an asset container
  46722. * @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)
  46723. * @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)
  46724. * @param scene is the instance of Scene to append to
  46725. * @param onProgress a callback with a progress event for each file being loaded
  46726. * @param pluginExtension the extension used to determine the plugin
  46727. * @returns The loaded asset container
  46728. */
  46729. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46730. /**
  46731. * Import animations from a file into a scene
  46732. * @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)
  46733. * @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)
  46734. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46735. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46736. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46737. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46738. * @param onSuccess a callback with the scene when import succeeds
  46739. * @param onProgress a callback with a progress event for each file being loaded
  46740. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46741. */
  46742. 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;
  46743. /**
  46744. * Import animations from a file into a scene
  46745. * @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)
  46746. * @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)
  46747. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46748. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46749. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46750. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46751. * @param onSuccess a callback with the scene when import succeeds
  46752. * @param onProgress a callback with a progress event for each file being loaded
  46753. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46754. * @returns the updated scene with imported animations
  46755. */
  46756. 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>;
  46757. }
  46758. }
  46759. declare module BABYLON {
  46760. /**
  46761. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46762. */
  46763. export type MotionControllerHandedness = "none" | "left" | "right";
  46764. /**
  46765. * The type of components available in motion controllers.
  46766. * This is not the name of the component.
  46767. */
  46768. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46769. /**
  46770. * The state of a controller component
  46771. */
  46772. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46773. /**
  46774. * The schema of motion controller layout.
  46775. * No object will be initialized using this interface
  46776. * This is used just to define the profile.
  46777. */
  46778. export interface IMotionControllerLayout {
  46779. /**
  46780. * Path to load the assets. Usually relative to the base path
  46781. */
  46782. assetPath: string;
  46783. /**
  46784. * Available components (unsorted)
  46785. */
  46786. components: {
  46787. /**
  46788. * A map of component Ids
  46789. */
  46790. [componentId: string]: {
  46791. /**
  46792. * The type of input the component outputs
  46793. */
  46794. type: MotionControllerComponentType;
  46795. /**
  46796. * The indices of this component in the gamepad object
  46797. */
  46798. gamepadIndices: {
  46799. /**
  46800. * Index of button
  46801. */
  46802. button?: number;
  46803. /**
  46804. * If available, index of x-axis
  46805. */
  46806. xAxis?: number;
  46807. /**
  46808. * If available, index of y-axis
  46809. */
  46810. yAxis?: number;
  46811. };
  46812. /**
  46813. * The mesh's root node name
  46814. */
  46815. rootNodeName: string;
  46816. /**
  46817. * Animation definitions for this model
  46818. */
  46819. visualResponses: {
  46820. [stateKey: string]: {
  46821. /**
  46822. * What property will be animated
  46823. */
  46824. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46825. /**
  46826. * What states influence this visual response
  46827. */
  46828. states: MotionControllerComponentStateType[];
  46829. /**
  46830. * Type of animation - movement or visibility
  46831. */
  46832. valueNodeProperty: "transform" | "visibility";
  46833. /**
  46834. * Base node name to move. Its position will be calculated according to the min and max nodes
  46835. */
  46836. valueNodeName?: string;
  46837. /**
  46838. * Minimum movement node
  46839. */
  46840. minNodeName?: string;
  46841. /**
  46842. * Max movement node
  46843. */
  46844. maxNodeName?: string;
  46845. };
  46846. };
  46847. /**
  46848. * If touch enabled, what is the name of node to display user feedback
  46849. */
  46850. touchPointNodeName?: string;
  46851. };
  46852. };
  46853. /**
  46854. * Is it xr standard mapping or not
  46855. */
  46856. gamepadMapping: "" | "xr-standard";
  46857. /**
  46858. * Base root node of this entire model
  46859. */
  46860. rootNodeName: string;
  46861. /**
  46862. * Defines the main button component id
  46863. */
  46864. selectComponentId: string;
  46865. }
  46866. /**
  46867. * A definition for the layout map in the input profile
  46868. */
  46869. export interface IMotionControllerLayoutMap {
  46870. /**
  46871. * Layouts with handedness type as a key
  46872. */
  46873. [handedness: string]: IMotionControllerLayout;
  46874. }
  46875. /**
  46876. * The XR Input profile schema
  46877. * Profiles can be found here:
  46878. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46879. */
  46880. export interface IMotionControllerProfile {
  46881. /**
  46882. * fallback profiles for this profileId
  46883. */
  46884. fallbackProfileIds: string[];
  46885. /**
  46886. * The layout map, with handedness as key
  46887. */
  46888. layouts: IMotionControllerLayoutMap;
  46889. /**
  46890. * The id of this profile
  46891. * correlates to the profile(s) in the xrInput.profiles array
  46892. */
  46893. profileId: string;
  46894. }
  46895. /**
  46896. * A helper-interface for the 3 meshes needed for controller button animation
  46897. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46898. */
  46899. export interface IMotionControllerButtonMeshMap {
  46900. /**
  46901. * the mesh that defines the pressed value mesh position.
  46902. * This is used to find the max-position of this button
  46903. */
  46904. pressedMesh: AbstractMesh;
  46905. /**
  46906. * the mesh that defines the unpressed value mesh position.
  46907. * This is used to find the min (or initial) position of this button
  46908. */
  46909. unpressedMesh: AbstractMesh;
  46910. /**
  46911. * The mesh that will be changed when value changes
  46912. */
  46913. valueMesh: AbstractMesh;
  46914. }
  46915. /**
  46916. * A helper-interface for the 3 meshes needed for controller axis animation.
  46917. * This will be expanded when touchpad animations are fully supported
  46918. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46919. */
  46920. export interface IMotionControllerMeshMap {
  46921. /**
  46922. * the mesh that defines the maximum value mesh position.
  46923. */
  46924. maxMesh?: AbstractMesh;
  46925. /**
  46926. * the mesh that defines the minimum value mesh position.
  46927. */
  46928. minMesh?: AbstractMesh;
  46929. /**
  46930. * The mesh that will be changed when axis value changes
  46931. */
  46932. valueMesh: AbstractMesh;
  46933. }
  46934. /**
  46935. * The elements needed for change-detection of the gamepad objects in motion controllers
  46936. */
  46937. export interface IMinimalMotionControllerObject {
  46938. /**
  46939. * Available axes of this controller
  46940. */
  46941. axes: number[];
  46942. /**
  46943. * An array of available buttons
  46944. */
  46945. buttons: Array<{
  46946. /**
  46947. * Value of the button/trigger
  46948. */
  46949. value: number;
  46950. /**
  46951. * If the button/trigger is currently touched
  46952. */
  46953. touched: boolean;
  46954. /**
  46955. * If the button/trigger is currently pressed
  46956. */
  46957. pressed: boolean;
  46958. }>;
  46959. /**
  46960. * EXPERIMENTAL haptic support.
  46961. */
  46962. hapticActuators?: Array<{
  46963. pulse: (value: number, duration: number) => Promise<boolean>;
  46964. }>;
  46965. }
  46966. /**
  46967. * An Abstract Motion controller
  46968. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46969. * Each component has an observable to check for changes in value and state
  46970. */
  46971. export abstract class WebXRAbstractMotionController implements IDisposable {
  46972. protected scene: Scene;
  46973. protected layout: IMotionControllerLayout;
  46974. /**
  46975. * The gamepad object correlating to this controller
  46976. */
  46977. gamepadObject: IMinimalMotionControllerObject;
  46978. /**
  46979. * handedness (left/right/none) of this controller
  46980. */
  46981. handedness: MotionControllerHandedness;
  46982. private _initComponent;
  46983. private _modelReady;
  46984. /**
  46985. * A map of components (WebXRControllerComponent) in this motion controller
  46986. * Components have a ComponentType and can also have both button and axis definitions
  46987. */
  46988. readonly components: {
  46989. [id: string]: WebXRControllerComponent;
  46990. };
  46991. /**
  46992. * Disable the model's animation. Can be set at any time.
  46993. */
  46994. disableAnimation: boolean;
  46995. /**
  46996. * Observers registered here will be triggered when the model of this controller is done loading
  46997. */
  46998. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46999. /**
  47000. * The profile id of this motion controller
  47001. */
  47002. abstract profileId: string;
  47003. /**
  47004. * The root mesh of the model. It is null if the model was not yet initialized
  47005. */
  47006. rootMesh: Nullable<AbstractMesh>;
  47007. /**
  47008. * constructs a new abstract motion controller
  47009. * @param scene the scene to which the model of the controller will be added
  47010. * @param layout The profile layout to load
  47011. * @param gamepadObject The gamepad object correlating to this controller
  47012. * @param handedness handedness (left/right/none) of this controller
  47013. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47014. */
  47015. constructor(scene: Scene, layout: IMotionControllerLayout,
  47016. /**
  47017. * The gamepad object correlating to this controller
  47018. */
  47019. gamepadObject: IMinimalMotionControllerObject,
  47020. /**
  47021. * handedness (left/right/none) of this controller
  47022. */
  47023. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47024. /**
  47025. * Dispose this controller, the model mesh and all its components
  47026. */
  47027. dispose(): void;
  47028. /**
  47029. * Returns all components of specific type
  47030. * @param type the type to search for
  47031. * @return an array of components with this type
  47032. */
  47033. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47034. /**
  47035. * get a component based an its component id as defined in layout.components
  47036. * @param id the id of the component
  47037. * @returns the component correlates to the id or undefined if not found
  47038. */
  47039. getComponent(id: string): WebXRControllerComponent;
  47040. /**
  47041. * Get the list of components available in this motion controller
  47042. * @returns an array of strings correlating to available components
  47043. */
  47044. getComponentIds(): string[];
  47045. /**
  47046. * Get the first component of specific type
  47047. * @param type type of component to find
  47048. * @return a controller component or null if not found
  47049. */
  47050. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47051. /**
  47052. * Get the main (Select) component of this controller as defined in the layout
  47053. * @returns the main component of this controller
  47054. */
  47055. getMainComponent(): WebXRControllerComponent;
  47056. /**
  47057. * Loads the model correlating to this controller
  47058. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47059. * @returns A promise fulfilled with the result of the model loading
  47060. */
  47061. loadModel(): Promise<boolean>;
  47062. /**
  47063. * Update this model using the current XRFrame
  47064. * @param xrFrame the current xr frame to use and update the model
  47065. */
  47066. updateFromXRFrame(xrFrame: XRFrame): void;
  47067. /**
  47068. * Backwards compatibility due to a deeply-integrated typo
  47069. */
  47070. get handness(): XREye;
  47071. /**
  47072. * Pulse (vibrate) this controller
  47073. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47074. * Consecutive calls to this function will cancel the last pulse call
  47075. *
  47076. * @param value the strength of the pulse in 0.0...1.0 range
  47077. * @param duration Duration of the pulse in milliseconds
  47078. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47079. * @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
  47080. */
  47081. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47082. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47083. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47084. /**
  47085. * Moves the axis on the controller mesh based on its current state
  47086. * @param axis the index of the axis
  47087. * @param axisValue the value of the axis which determines the meshes new position
  47088. * @hidden
  47089. */
  47090. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47091. /**
  47092. * Update the model itself with the current frame data
  47093. * @param xrFrame the frame to use for updating the model mesh
  47094. */
  47095. protected updateModel(xrFrame: XRFrame): void;
  47096. /**
  47097. * Get the filename and path for this controller's model
  47098. * @returns a map of filename and path
  47099. */
  47100. protected abstract _getFilenameAndPath(): {
  47101. filename: string;
  47102. path: string;
  47103. };
  47104. /**
  47105. * This function is called before the mesh is loaded. It checks for loading constraints.
  47106. * For example, this function can check if the GLB loader is available
  47107. * If this function returns false, the generic controller will be loaded instead
  47108. * @returns Is the client ready to load the mesh
  47109. */
  47110. protected abstract _getModelLoadingConstraints(): boolean;
  47111. /**
  47112. * This function will be called after the model was successfully loaded and can be used
  47113. * for mesh transformations before it is available for the user
  47114. * @param meshes the loaded meshes
  47115. */
  47116. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47117. /**
  47118. * Set the root mesh for this controller. Important for the WebXR controller class
  47119. * @param meshes the loaded meshes
  47120. */
  47121. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47122. /**
  47123. * A function executed each frame that updates the mesh (if needed)
  47124. * @param xrFrame the current xrFrame
  47125. */
  47126. protected abstract _updateModel(xrFrame: XRFrame): void;
  47127. private _getGenericFilenameAndPath;
  47128. private _getGenericParentMesh;
  47129. }
  47130. }
  47131. declare module BABYLON {
  47132. /**
  47133. * A generic trigger-only motion controller for WebXR
  47134. */
  47135. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47136. /**
  47137. * Static version of the profile id of this controller
  47138. */
  47139. static ProfileId: string;
  47140. profileId: string;
  47141. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47142. protected _getFilenameAndPath(): {
  47143. filename: string;
  47144. path: string;
  47145. };
  47146. protected _getModelLoadingConstraints(): boolean;
  47147. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47148. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47149. protected _updateModel(): void;
  47150. }
  47151. }
  47152. declare module BABYLON {
  47153. /**
  47154. * Class containing static functions to help procedurally build meshes
  47155. */
  47156. export class SphereBuilder {
  47157. /**
  47158. * Creates a sphere mesh
  47159. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47160. * * 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`)
  47161. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47162. * * 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
  47163. * * 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)
  47164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47165. * * 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
  47166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47167. * @param name defines the name of the mesh
  47168. * @param options defines the options used to create the mesh
  47169. * @param scene defines the hosting scene
  47170. * @returns the sphere mesh
  47171. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47172. */
  47173. static CreateSphere(name: string, options: {
  47174. segments?: number;
  47175. diameter?: number;
  47176. diameterX?: number;
  47177. diameterY?: number;
  47178. diameterZ?: number;
  47179. arc?: number;
  47180. slice?: number;
  47181. sideOrientation?: number;
  47182. frontUVs?: Vector4;
  47183. backUVs?: Vector4;
  47184. updatable?: boolean;
  47185. }, scene?: Nullable<Scene>): Mesh;
  47186. }
  47187. }
  47188. declare module BABYLON {
  47189. /**
  47190. * A profiled motion controller has its profile loaded from an online repository.
  47191. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47192. */
  47193. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47194. private _repositoryUrl;
  47195. private _buttonMeshMapping;
  47196. private _touchDots;
  47197. /**
  47198. * The profile ID of this controller. Will be populated when the controller initializes.
  47199. */
  47200. profileId: string;
  47201. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47202. dispose(): void;
  47203. protected _getFilenameAndPath(): {
  47204. filename: string;
  47205. path: string;
  47206. };
  47207. protected _getModelLoadingConstraints(): boolean;
  47208. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47209. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47210. protected _updateModel(_xrFrame: XRFrame): void;
  47211. }
  47212. }
  47213. declare module BABYLON {
  47214. /**
  47215. * A construction function type to create a new controller based on an xrInput object
  47216. */
  47217. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47218. /**
  47219. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47220. *
  47221. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47222. * it should be replaced with auto-loaded controllers.
  47223. *
  47224. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47225. */
  47226. export class WebXRMotionControllerManager {
  47227. private static _AvailableControllers;
  47228. private static _Fallbacks;
  47229. private static _ProfileLoadingPromises;
  47230. private static _ProfilesList;
  47231. /**
  47232. * The base URL of the online controller repository. Can be changed at any time.
  47233. */
  47234. static BaseRepositoryUrl: string;
  47235. /**
  47236. * Which repository gets priority - local or online
  47237. */
  47238. static PrioritizeOnlineRepository: boolean;
  47239. /**
  47240. * Use the online repository, or use only locally-defined controllers
  47241. */
  47242. static UseOnlineRepository: boolean;
  47243. /**
  47244. * Clear the cache used for profile loading and reload when requested again
  47245. */
  47246. static ClearProfilesCache(): void;
  47247. /**
  47248. * Register the default fallbacks.
  47249. * This function is called automatically when this file is imported.
  47250. */
  47251. static DefaultFallbacks(): void;
  47252. /**
  47253. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47254. * @param profileId the profile to which a fallback needs to be found
  47255. * @return an array with corresponding fallback profiles
  47256. */
  47257. static FindFallbackWithProfileId(profileId: string): string[];
  47258. /**
  47259. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47260. * The order of search:
  47261. *
  47262. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47263. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47264. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47265. * 4) return the generic trigger controller if none were found
  47266. *
  47267. * @param xrInput the xrInput to which a new controller is initialized
  47268. * @param scene the scene to which the model will be added
  47269. * @param forceProfile force a certain profile for this controller
  47270. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47271. */
  47272. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47273. /**
  47274. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47275. *
  47276. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47277. *
  47278. * @param type the profile type to register
  47279. * @param constructFunction the function to be called when loading this profile
  47280. */
  47281. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47282. /**
  47283. * Register a fallback to a specific profile.
  47284. * @param profileId the profileId that will receive the fallbacks
  47285. * @param fallbacks A list of fallback profiles
  47286. */
  47287. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47288. /**
  47289. * Will update the list of profiles available in the repository
  47290. * @return a promise that resolves to a map of profiles available online
  47291. */
  47292. static UpdateProfilesList(): Promise<{
  47293. [profile: string]: string;
  47294. }>;
  47295. private static _LoadProfileFromRepository;
  47296. private static _LoadProfilesFromAvailableControllers;
  47297. }
  47298. }
  47299. declare module BABYLON {
  47300. /**
  47301. * Configuration options for the WebXR controller creation
  47302. */
  47303. export interface IWebXRControllerOptions {
  47304. /**
  47305. * Should the controller mesh be animated when a user interacts with it
  47306. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47307. */
  47308. disableMotionControllerAnimation?: boolean;
  47309. /**
  47310. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47311. */
  47312. doNotLoadControllerMesh?: boolean;
  47313. /**
  47314. * Force a specific controller type for this controller.
  47315. * This can be used when creating your own profile or when testing different controllers
  47316. */
  47317. forceControllerProfile?: string;
  47318. /**
  47319. * Defines a rendering group ID for meshes that will be loaded.
  47320. * This is for the default controllers only.
  47321. */
  47322. renderingGroupId?: number;
  47323. }
  47324. /**
  47325. * Represents an XR controller
  47326. */
  47327. export class WebXRInputSource {
  47328. private _scene;
  47329. /** The underlying input source for the controller */
  47330. inputSource: XRInputSource;
  47331. private _options;
  47332. private _tmpVector;
  47333. private _uniqueId;
  47334. /**
  47335. * 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
  47336. */
  47337. grip?: AbstractMesh;
  47338. /**
  47339. * If available, this is the gamepad object related to this controller.
  47340. * Using this object it is possible to get click events and trackpad changes of the
  47341. * webxr controller that is currently being used.
  47342. */
  47343. motionController?: WebXRAbstractMotionController;
  47344. /**
  47345. * Event that fires when the controller is removed/disposed.
  47346. * The object provided as event data is this controller, after associated assets were disposed.
  47347. * uniqueId is still available.
  47348. */
  47349. onDisposeObservable: Observable<WebXRInputSource>;
  47350. /**
  47351. * Will be triggered when the mesh associated with the motion controller is done loading.
  47352. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47353. * A shortened version of controller -> motion controller -> on mesh loaded.
  47354. */
  47355. onMeshLoadedObservable: Observable<AbstractMesh>;
  47356. /**
  47357. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47358. */
  47359. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47360. /**
  47361. * Pointer which can be used to select objects or attach a visible laser to
  47362. */
  47363. pointer: AbstractMesh;
  47364. /**
  47365. * Creates the controller
  47366. * @see https://doc.babylonjs.com/how_to/webxr
  47367. * @param _scene the scene which the controller should be associated to
  47368. * @param inputSource the underlying input source for the controller
  47369. * @param _options options for this controller creation
  47370. */
  47371. constructor(_scene: Scene,
  47372. /** The underlying input source for the controller */
  47373. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47374. /**
  47375. * Get this controllers unique id
  47376. */
  47377. get uniqueId(): string;
  47378. /**
  47379. * Disposes of the object
  47380. */
  47381. dispose(): void;
  47382. /**
  47383. * Gets a world space ray coming from the pointer or grip
  47384. * @param result the resulting ray
  47385. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47386. */
  47387. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47388. /**
  47389. * Updates the controller pose based on the given XRFrame
  47390. * @param xrFrame xr frame to update the pose with
  47391. * @param referenceSpace reference space to use
  47392. */
  47393. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47394. }
  47395. }
  47396. declare module BABYLON {
  47397. /**
  47398. * The schema for initialization options of the XR Input class
  47399. */
  47400. export interface IWebXRInputOptions {
  47401. /**
  47402. * If set to true no model will be automatically loaded
  47403. */
  47404. doNotLoadControllerMeshes?: boolean;
  47405. /**
  47406. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47407. * If not found, the xr input profile data will be used.
  47408. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47409. */
  47410. forceInputProfile?: string;
  47411. /**
  47412. * Do not send a request to the controller repository to load the profile.
  47413. *
  47414. * Instead, use the controllers available in babylon itself.
  47415. */
  47416. disableOnlineControllerRepository?: boolean;
  47417. /**
  47418. * A custom URL for the controllers repository
  47419. */
  47420. customControllersRepositoryURL?: string;
  47421. /**
  47422. * Should the controller model's components not move according to the user input
  47423. */
  47424. disableControllerAnimation?: boolean;
  47425. /**
  47426. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47427. */
  47428. controllerOptions?: IWebXRControllerOptions;
  47429. }
  47430. /**
  47431. * XR input used to track XR inputs such as controllers/rays
  47432. */
  47433. export class WebXRInput implements IDisposable {
  47434. /**
  47435. * the xr session manager for this session
  47436. */
  47437. xrSessionManager: WebXRSessionManager;
  47438. /**
  47439. * the WebXR camera for this session. Mainly used for teleportation
  47440. */
  47441. xrCamera: WebXRCamera;
  47442. private readonly options;
  47443. /**
  47444. * XR controllers being tracked
  47445. */
  47446. controllers: Array<WebXRInputSource>;
  47447. private _frameObserver;
  47448. private _sessionEndedObserver;
  47449. private _sessionInitObserver;
  47450. /**
  47451. * Event when a controller has been connected/added
  47452. */
  47453. onControllerAddedObservable: Observable<WebXRInputSource>;
  47454. /**
  47455. * Event when a controller has been removed/disconnected
  47456. */
  47457. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47458. /**
  47459. * Initializes the WebXRInput
  47460. * @param xrSessionManager the xr session manager for this session
  47461. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47462. * @param options = initialization options for this xr input
  47463. */
  47464. constructor(
  47465. /**
  47466. * the xr session manager for this session
  47467. */
  47468. xrSessionManager: WebXRSessionManager,
  47469. /**
  47470. * the WebXR camera for this session. Mainly used for teleportation
  47471. */
  47472. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47473. private _onInputSourcesChange;
  47474. private _addAndRemoveControllers;
  47475. /**
  47476. * Disposes of the object
  47477. */
  47478. dispose(): void;
  47479. }
  47480. }
  47481. declare module BABYLON {
  47482. /**
  47483. * This is the base class for all WebXR features.
  47484. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47485. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47486. */
  47487. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47488. protected _xrSessionManager: WebXRSessionManager;
  47489. private _attached;
  47490. private _removeOnDetach;
  47491. /**
  47492. * Should auto-attach be disabled?
  47493. */
  47494. disableAutoAttach: boolean;
  47495. /**
  47496. * Construct a new (abstract) WebXR feature
  47497. * @param _xrSessionManager the xr session manager for this feature
  47498. */
  47499. constructor(_xrSessionManager: WebXRSessionManager);
  47500. /**
  47501. * Is this feature attached
  47502. */
  47503. get attached(): boolean;
  47504. /**
  47505. * attach this feature
  47506. *
  47507. * @param force should attachment be forced (even when already attached)
  47508. * @returns true if successful, false is failed or already attached
  47509. */
  47510. attach(force?: boolean): boolean;
  47511. /**
  47512. * detach this feature.
  47513. *
  47514. * @returns true if successful, false if failed or already detached
  47515. */
  47516. detach(): boolean;
  47517. /**
  47518. * Dispose this feature and all of the resources attached
  47519. */
  47520. dispose(): void;
  47521. /**
  47522. * This is used to register callbacks that will automatically be removed when detach is called.
  47523. * @param observable the observable to which the observer will be attached
  47524. * @param callback the callback to register
  47525. */
  47526. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47527. /**
  47528. * Code in this function will be executed on each xrFrame received from the browser.
  47529. * This function will not execute after the feature is detached.
  47530. * @param _xrFrame the current frame
  47531. */
  47532. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47533. }
  47534. }
  47535. declare module BABYLON {
  47536. /**
  47537. * Renders a layer on top of an existing scene
  47538. */
  47539. export class UtilityLayerRenderer implements IDisposable {
  47540. /** the original scene that will be rendered on top of */
  47541. originalScene: Scene;
  47542. private _pointerCaptures;
  47543. private _lastPointerEvents;
  47544. private static _DefaultUtilityLayer;
  47545. private static _DefaultKeepDepthUtilityLayer;
  47546. private _sharedGizmoLight;
  47547. private _renderCamera;
  47548. /**
  47549. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47550. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47551. * @returns the camera that is used when rendering the utility layer
  47552. */
  47553. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47554. /**
  47555. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47556. * @param cam the camera that should be used when rendering the utility layer
  47557. */
  47558. setRenderCamera(cam: Nullable<Camera>): void;
  47559. /**
  47560. * @hidden
  47561. * Light which used by gizmos to get light shading
  47562. */
  47563. _getSharedGizmoLight(): HemisphericLight;
  47564. /**
  47565. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47566. */
  47567. pickUtilitySceneFirst: boolean;
  47568. /**
  47569. * 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)
  47570. */
  47571. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47572. /**
  47573. * 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)
  47574. */
  47575. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47576. /**
  47577. * The scene that is rendered on top of the original scene
  47578. */
  47579. utilityLayerScene: Scene;
  47580. /**
  47581. * If the utility layer should automatically be rendered on top of existing scene
  47582. */
  47583. shouldRender: boolean;
  47584. /**
  47585. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47586. */
  47587. onlyCheckPointerDownEvents: boolean;
  47588. /**
  47589. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47590. */
  47591. processAllEvents: boolean;
  47592. /**
  47593. * Observable raised when the pointer move from the utility layer scene to the main scene
  47594. */
  47595. onPointerOutObservable: Observable<number>;
  47596. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47597. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47598. private _afterRenderObserver;
  47599. private _sceneDisposeObserver;
  47600. private _originalPointerObserver;
  47601. /**
  47602. * Instantiates a UtilityLayerRenderer
  47603. * @param originalScene the original scene that will be rendered on top of
  47604. * @param handleEvents boolean indicating if the utility layer should handle events
  47605. */
  47606. constructor(
  47607. /** the original scene that will be rendered on top of */
  47608. originalScene: Scene, handleEvents?: boolean);
  47609. private _notifyObservers;
  47610. /**
  47611. * Renders the utility layers scene on top of the original scene
  47612. */
  47613. render(): void;
  47614. /**
  47615. * Disposes of the renderer
  47616. */
  47617. dispose(): void;
  47618. private _updateCamera;
  47619. }
  47620. }
  47621. declare module BABYLON {
  47622. /**
  47623. * Options interface for the pointer selection module
  47624. */
  47625. export interface IWebXRControllerPointerSelectionOptions {
  47626. /**
  47627. * if provided, this scene will be used to render meshes.
  47628. */
  47629. customUtilityLayerScene?: Scene;
  47630. /**
  47631. * 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)
  47632. * If not disabled, the last picked point will be used to execute a pointer up event
  47633. * If disabled, pointer up event will be triggered right after the pointer down event.
  47634. * Used in screen and gaze target ray mode only
  47635. */
  47636. disablePointerUpOnTouchOut: boolean;
  47637. /**
  47638. * For gaze mode (time to select instead of press)
  47639. */
  47640. forceGazeMode: boolean;
  47641. /**
  47642. * 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
  47643. * to start a new countdown to the pointer down event.
  47644. * Defaults to 1.
  47645. */
  47646. gazeModePointerMovedFactor?: number;
  47647. /**
  47648. * Different button type to use instead of the main component
  47649. */
  47650. overrideButtonId?: string;
  47651. /**
  47652. * use this rendering group id for the meshes (optional)
  47653. */
  47654. renderingGroupId?: number;
  47655. /**
  47656. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47657. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47658. * 3000 means 3 seconds between pointing at something and selecting it
  47659. */
  47660. timeToSelect?: number;
  47661. /**
  47662. * Should meshes created here be added to a utility layer or the main scene
  47663. */
  47664. useUtilityLayer?: boolean;
  47665. /**
  47666. * the xr input to use with this pointer selection
  47667. */
  47668. xrInput: WebXRInput;
  47669. }
  47670. /**
  47671. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47672. */
  47673. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47674. private readonly _options;
  47675. private static _idCounter;
  47676. private _attachController;
  47677. private _controllers;
  47678. private _scene;
  47679. private _tmpVectorForPickCompare;
  47680. /**
  47681. * The module's name
  47682. */
  47683. static readonly Name: string;
  47684. /**
  47685. * The (Babylon) version of this module.
  47686. * This is an integer representing the implementation version.
  47687. * This number does not correspond to the WebXR specs version
  47688. */
  47689. static readonly Version: number;
  47690. /**
  47691. * Disable lighting on the laser pointer (so it will always be visible)
  47692. */
  47693. disablePointerLighting: boolean;
  47694. /**
  47695. * Disable lighting on the selection mesh (so it will always be visible)
  47696. */
  47697. disableSelectionMeshLighting: boolean;
  47698. /**
  47699. * Should the laser pointer be displayed
  47700. */
  47701. displayLaserPointer: boolean;
  47702. /**
  47703. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47704. */
  47705. displaySelectionMesh: boolean;
  47706. /**
  47707. * This color will be set to the laser pointer when selection is triggered
  47708. */
  47709. laserPointerPickedColor: Color3;
  47710. /**
  47711. * Default color of the laser pointer
  47712. */
  47713. laserPointerDefaultColor: Color3;
  47714. /**
  47715. * default color of the selection ring
  47716. */
  47717. selectionMeshDefaultColor: Color3;
  47718. /**
  47719. * This color will be applied to the selection ring when selection is triggered
  47720. */
  47721. selectionMeshPickedColor: Color3;
  47722. /**
  47723. * Optional filter to be used for ray selection. This predicate shares behavior with
  47724. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47725. */
  47726. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47727. /**
  47728. * constructs a new background remover module
  47729. * @param _xrSessionManager the session manager for this module
  47730. * @param _options read-only options to be used in this module
  47731. */
  47732. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47733. /**
  47734. * attach this feature
  47735. * Will usually be called by the features manager
  47736. *
  47737. * @returns true if successful.
  47738. */
  47739. attach(): boolean;
  47740. /**
  47741. * detach this feature.
  47742. * Will usually be called by the features manager
  47743. *
  47744. * @returns true if successful.
  47745. */
  47746. detach(): boolean;
  47747. /**
  47748. * Will get the mesh under a specific pointer.
  47749. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47750. * @param controllerId the controllerId to check
  47751. * @returns The mesh under pointer or null if no mesh is under the pointer
  47752. */
  47753. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47754. /**
  47755. * Get the xr controller that correlates to the pointer id in the pointer event
  47756. *
  47757. * @param id the pointer id to search for
  47758. * @returns the controller that correlates to this id or null if not found
  47759. */
  47760. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47761. protected _onXRFrame(_xrFrame: XRFrame): void;
  47762. private _attachGazeMode;
  47763. private _attachScreenRayMode;
  47764. private _attachTrackedPointerRayMode;
  47765. private _convertNormalToDirectionOfRay;
  47766. private _detachController;
  47767. private _generateNewMeshPair;
  47768. private _pickingMoved;
  47769. private _updatePointerDistance;
  47770. /** @hidden */
  47771. get lasterPointerDefaultColor(): Color3;
  47772. }
  47773. }
  47774. declare module BABYLON {
  47775. /**
  47776. * Button which can be used to enter a different mode of XR
  47777. */
  47778. export class WebXREnterExitUIButton {
  47779. /** button element */
  47780. element: HTMLElement;
  47781. /** XR initialization options for the button */
  47782. sessionMode: XRSessionMode;
  47783. /** Reference space type */
  47784. referenceSpaceType: XRReferenceSpaceType;
  47785. /**
  47786. * Creates a WebXREnterExitUIButton
  47787. * @param element button element
  47788. * @param sessionMode XR initialization session mode
  47789. * @param referenceSpaceType the type of reference space to be used
  47790. */
  47791. constructor(
  47792. /** button element */
  47793. element: HTMLElement,
  47794. /** XR initialization options for the button */
  47795. sessionMode: XRSessionMode,
  47796. /** Reference space type */
  47797. referenceSpaceType: XRReferenceSpaceType);
  47798. /**
  47799. * Extendable function which can be used to update the button's visuals when the state changes
  47800. * @param activeButton the current active button in the UI
  47801. */
  47802. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47803. }
  47804. /**
  47805. * Options to create the webXR UI
  47806. */
  47807. export class WebXREnterExitUIOptions {
  47808. /**
  47809. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47810. */
  47811. customButtons?: Array<WebXREnterExitUIButton>;
  47812. /**
  47813. * A reference space type to use when creating the default button.
  47814. * Default is local-floor
  47815. */
  47816. referenceSpaceType?: XRReferenceSpaceType;
  47817. /**
  47818. * Context to enter xr with
  47819. */
  47820. renderTarget?: Nullable<WebXRRenderTarget>;
  47821. /**
  47822. * A session mode to use when creating the default button.
  47823. * Default is immersive-vr
  47824. */
  47825. sessionMode?: XRSessionMode;
  47826. /**
  47827. * A list of optional features to init the session with
  47828. */
  47829. optionalFeatures?: string[];
  47830. }
  47831. /**
  47832. * UI to allow the user to enter/exit XR mode
  47833. */
  47834. export class WebXREnterExitUI implements IDisposable {
  47835. private scene;
  47836. /** version of the options passed to this UI */
  47837. options: WebXREnterExitUIOptions;
  47838. private _activeButton;
  47839. private _buttons;
  47840. private _overlay;
  47841. /**
  47842. * Fired every time the active button is changed.
  47843. *
  47844. * When xr is entered via a button that launches xr that button will be the callback parameter
  47845. *
  47846. * When exiting xr the callback parameter will be null)
  47847. */
  47848. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47849. /**
  47850. *
  47851. * @param scene babylon scene object to use
  47852. * @param options (read-only) version of the options passed to this UI
  47853. */
  47854. private constructor();
  47855. /**
  47856. * Creates UI to allow the user to enter/exit XR mode
  47857. * @param scene the scene to add the ui to
  47858. * @param helper the xr experience helper to enter/exit xr with
  47859. * @param options options to configure the UI
  47860. * @returns the created ui
  47861. */
  47862. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47863. /**
  47864. * Disposes of the XR UI component
  47865. */
  47866. dispose(): void;
  47867. private _updateButtons;
  47868. }
  47869. }
  47870. declare module BABYLON {
  47871. /**
  47872. * Class containing static functions to help procedurally build meshes
  47873. */
  47874. export class LinesBuilder {
  47875. /**
  47876. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47877. * * 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
  47878. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47879. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47880. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47881. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47882. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47883. * * 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
  47884. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47887. * @param name defines the name of the new line system
  47888. * @param options defines the options used to create the line system
  47889. * @param scene defines the hosting scene
  47890. * @returns a new line system mesh
  47891. */
  47892. static CreateLineSystem(name: string, options: {
  47893. lines: Vector3[][];
  47894. updatable?: boolean;
  47895. instance?: Nullable<LinesMesh>;
  47896. colors?: Nullable<Color4[][]>;
  47897. useVertexAlpha?: boolean;
  47898. }, scene: Nullable<Scene>): LinesMesh;
  47899. /**
  47900. * Creates a line mesh
  47901. * 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
  47902. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47903. * * The parameter `points` is an array successive Vector3
  47904. * * 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
  47905. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47906. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47907. * * When updating an instance, remember that only point positions can change, not the number of points
  47908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47910. * @param name defines the name of the new line system
  47911. * @param options defines the options used to create the line system
  47912. * @param scene defines the hosting scene
  47913. * @returns a new line mesh
  47914. */
  47915. static CreateLines(name: string, options: {
  47916. points: Vector3[];
  47917. updatable?: boolean;
  47918. instance?: Nullable<LinesMesh>;
  47919. colors?: Color4[];
  47920. useVertexAlpha?: boolean;
  47921. }, scene?: Nullable<Scene>): LinesMesh;
  47922. /**
  47923. * Creates a dashed line mesh
  47924. * * 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
  47925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47926. * * The parameter `points` is an array successive Vector3
  47927. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47928. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47929. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47930. * * 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
  47931. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47932. * * When updating an instance, remember that only point positions can change, not the number of points
  47933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47934. * @param name defines the name of the mesh
  47935. * @param options defines the options used to create the mesh
  47936. * @param scene defines the hosting scene
  47937. * @returns the dashed line mesh
  47938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47939. */
  47940. static CreateDashedLines(name: string, options: {
  47941. points: Vector3[];
  47942. dashSize?: number;
  47943. gapSize?: number;
  47944. dashNb?: number;
  47945. updatable?: boolean;
  47946. instance?: LinesMesh;
  47947. useVertexAlpha?: boolean;
  47948. }, scene?: Nullable<Scene>): LinesMesh;
  47949. }
  47950. }
  47951. declare module BABYLON {
  47952. /**
  47953. * Construction options for a timer
  47954. */
  47955. export interface ITimerOptions<T> {
  47956. /**
  47957. * Time-to-end
  47958. */
  47959. timeout: number;
  47960. /**
  47961. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  47962. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  47963. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  47964. */
  47965. contextObservable: Observable<T>;
  47966. /**
  47967. * Optional parameters when adding an observer to the observable
  47968. */
  47969. observableParameters?: {
  47970. mask?: number;
  47971. insertFirst?: boolean;
  47972. scope?: any;
  47973. };
  47974. /**
  47975. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  47976. */
  47977. breakCondition?: (data?: ITimerData<T>) => boolean;
  47978. /**
  47979. * Will be triggered when the time condition has met
  47980. */
  47981. onEnded?: (data: ITimerData<any>) => void;
  47982. /**
  47983. * Will be triggered when the break condition has met (prematurely ended)
  47984. */
  47985. onAborted?: (data: ITimerData<any>) => void;
  47986. /**
  47987. * Optional function to execute on each tick (or count)
  47988. */
  47989. onTick?: (data: ITimerData<any>) => void;
  47990. }
  47991. /**
  47992. * An interface defining the data sent by the timer
  47993. */
  47994. export interface ITimerData<T> {
  47995. /**
  47996. * When did it start
  47997. */
  47998. startTime: number;
  47999. /**
  48000. * Time now
  48001. */
  48002. currentTime: number;
  48003. /**
  48004. * Time passed since started
  48005. */
  48006. deltaTime: number;
  48007. /**
  48008. * How much is completed, in [0.0...1.0].
  48009. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48010. */
  48011. completeRate: number;
  48012. /**
  48013. * What the registered observable sent in the last count
  48014. */
  48015. payload: T;
  48016. }
  48017. /**
  48018. * The current state of the timer
  48019. */
  48020. export enum TimerState {
  48021. /**
  48022. * Timer initialized, not yet started
  48023. */
  48024. INIT = 0,
  48025. /**
  48026. * Timer started and counting
  48027. */
  48028. STARTED = 1,
  48029. /**
  48030. * Timer ended (whether aborted or time reached)
  48031. */
  48032. ENDED = 2
  48033. }
  48034. /**
  48035. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48036. *
  48037. * @param options options with which to initialize this timer
  48038. */
  48039. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48040. /**
  48041. * An advanced implementation of a timer class
  48042. */
  48043. export class AdvancedTimer<T = any> implements IDisposable {
  48044. /**
  48045. * Will notify each time the timer calculates the remaining time
  48046. */
  48047. onEachCountObservable: Observable<ITimerData<T>>;
  48048. /**
  48049. * Will trigger when the timer was aborted due to the break condition
  48050. */
  48051. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48052. /**
  48053. * Will trigger when the timer ended successfully
  48054. */
  48055. onTimerEndedObservable: Observable<ITimerData<T>>;
  48056. /**
  48057. * Will trigger when the timer state has changed
  48058. */
  48059. onStateChangedObservable: Observable<TimerState>;
  48060. private _observer;
  48061. private _contextObservable;
  48062. private _observableParameters;
  48063. private _startTime;
  48064. private _timer;
  48065. private _state;
  48066. private _breakCondition;
  48067. private _timeToEnd;
  48068. private _breakOnNextTick;
  48069. /**
  48070. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48071. * @param options construction options for this advanced timer
  48072. */
  48073. constructor(options: ITimerOptions<T>);
  48074. /**
  48075. * set a breaking condition for this timer. Default is to never break during count
  48076. * @param predicate the new break condition. Returns true to break, false otherwise
  48077. */
  48078. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48079. /**
  48080. * Reset ALL associated observables in this advanced timer
  48081. */
  48082. clearObservables(): void;
  48083. /**
  48084. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48085. *
  48086. * @param timeToEnd how much time to measure until timer ended
  48087. */
  48088. start(timeToEnd?: number): void;
  48089. /**
  48090. * Will force a stop on the next tick.
  48091. */
  48092. stop(): void;
  48093. /**
  48094. * Dispose this timer, clearing all resources
  48095. */
  48096. dispose(): void;
  48097. private _setState;
  48098. private _tick;
  48099. private _stop;
  48100. }
  48101. }
  48102. declare module BABYLON {
  48103. /**
  48104. * The options container for the teleportation module
  48105. */
  48106. export interface IWebXRTeleportationOptions {
  48107. /**
  48108. * if provided, this scene will be used to render meshes.
  48109. */
  48110. customUtilityLayerScene?: Scene;
  48111. /**
  48112. * Values to configure the default target mesh
  48113. */
  48114. defaultTargetMeshOptions?: {
  48115. /**
  48116. * Fill color of the teleportation area
  48117. */
  48118. teleportationFillColor?: string;
  48119. /**
  48120. * Border color for the teleportation area
  48121. */
  48122. teleportationBorderColor?: string;
  48123. /**
  48124. * Disable the mesh's animation sequence
  48125. */
  48126. disableAnimation?: boolean;
  48127. /**
  48128. * Disable lighting on the material or the ring and arrow
  48129. */
  48130. disableLighting?: boolean;
  48131. /**
  48132. * Override the default material of the torus and arrow
  48133. */
  48134. torusArrowMaterial?: Material;
  48135. };
  48136. /**
  48137. * A list of meshes to use as floor meshes.
  48138. * Meshes can be added and removed after initializing the feature using the
  48139. * addFloorMesh and removeFloorMesh functions
  48140. * If empty, rotation will still work
  48141. */
  48142. floorMeshes?: AbstractMesh[];
  48143. /**
  48144. * use this rendering group id for the meshes (optional)
  48145. */
  48146. renderingGroupId?: number;
  48147. /**
  48148. * Should teleportation move only to snap points
  48149. */
  48150. snapPointsOnly?: boolean;
  48151. /**
  48152. * An array of points to which the teleportation will snap to.
  48153. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48154. */
  48155. snapPositions?: Vector3[];
  48156. /**
  48157. * How close should the teleportation ray be in order to snap to position.
  48158. * Default to 0.8 units (meters)
  48159. */
  48160. snapToPositionRadius?: number;
  48161. /**
  48162. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48163. * If you want to support rotation, make sure your mesh has a direction indicator.
  48164. *
  48165. * When left untouched, the default mesh will be initialized.
  48166. */
  48167. teleportationTargetMesh?: AbstractMesh;
  48168. /**
  48169. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48170. */
  48171. timeToTeleport?: number;
  48172. /**
  48173. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48174. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48175. */
  48176. useMainComponentOnly?: boolean;
  48177. /**
  48178. * Should meshes created here be added to a utility layer or the main scene
  48179. */
  48180. useUtilityLayer?: boolean;
  48181. /**
  48182. * Babylon XR Input class for controller
  48183. */
  48184. xrInput: WebXRInput;
  48185. }
  48186. /**
  48187. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48188. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48189. * the input of the attached controllers.
  48190. */
  48191. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48192. private _options;
  48193. private _controllers;
  48194. private _currentTeleportationControllerId;
  48195. private _floorMeshes;
  48196. private _quadraticBezierCurve;
  48197. private _selectionFeature;
  48198. private _snapToPositions;
  48199. private _snappedToPoint;
  48200. private _teleportationRingMaterial?;
  48201. private _tmpRay;
  48202. private _tmpVector;
  48203. /**
  48204. * The module's name
  48205. */
  48206. static readonly Name: string;
  48207. /**
  48208. * The (Babylon) version of this module.
  48209. * This is an integer representing the implementation version.
  48210. * This number does not correspond to the webxr specs version
  48211. */
  48212. static readonly Version: number;
  48213. /**
  48214. * Is movement backwards enabled
  48215. */
  48216. backwardsMovementEnabled: boolean;
  48217. /**
  48218. * Distance to travel when moving backwards
  48219. */
  48220. backwardsTeleportationDistance: number;
  48221. /**
  48222. * The distance from the user to the inspection point in the direction of the controller
  48223. * A higher number will allow the user to move further
  48224. * defaults to 5 (meters, in xr units)
  48225. */
  48226. parabolicCheckRadius: number;
  48227. /**
  48228. * Should the module support parabolic ray on top of direct ray
  48229. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48230. * Very helpful when moving between floors / different heights
  48231. */
  48232. parabolicRayEnabled: boolean;
  48233. /**
  48234. * How much rotation should be applied when rotating right and left
  48235. */
  48236. rotationAngle: number;
  48237. /**
  48238. * Is rotation enabled when moving forward?
  48239. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48240. */
  48241. rotationEnabled: boolean;
  48242. /**
  48243. * constructs a new anchor system
  48244. * @param _xrSessionManager an instance of WebXRSessionManager
  48245. * @param _options configuration object for this feature
  48246. */
  48247. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48248. /**
  48249. * Get the snapPointsOnly flag
  48250. */
  48251. get snapPointsOnly(): boolean;
  48252. /**
  48253. * Sets the snapPointsOnly flag
  48254. * @param snapToPoints should teleportation be exclusively to snap points
  48255. */
  48256. set snapPointsOnly(snapToPoints: boolean);
  48257. /**
  48258. * Add a new mesh to the floor meshes array
  48259. * @param mesh the mesh to use as floor mesh
  48260. */
  48261. addFloorMesh(mesh: AbstractMesh): void;
  48262. /**
  48263. * Add a new snap-to point to fix teleportation to this position
  48264. * @param newSnapPoint The new Snap-To point
  48265. */
  48266. addSnapPoint(newSnapPoint: Vector3): void;
  48267. attach(): boolean;
  48268. detach(): boolean;
  48269. dispose(): void;
  48270. /**
  48271. * Remove a mesh from the floor meshes array
  48272. * @param mesh the mesh to remove
  48273. */
  48274. removeFloorMesh(mesh: AbstractMesh): void;
  48275. /**
  48276. * Remove a mesh from the floor meshes array using its name
  48277. * @param name the mesh name to remove
  48278. */
  48279. removeFloorMeshByName(name: string): void;
  48280. /**
  48281. * 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
  48282. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48283. * @returns was the point found and removed or not
  48284. */
  48285. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48286. /**
  48287. * This function sets a selection feature that will be disabled when
  48288. * the forward ray is shown and will be reattached when hidden.
  48289. * This is used to remove the selection rays when moving.
  48290. * @param selectionFeature the feature to disable when forward movement is enabled
  48291. */
  48292. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48293. protected _onXRFrame(_xrFrame: XRFrame): void;
  48294. private _attachController;
  48295. private _createDefaultTargetMesh;
  48296. private _detachController;
  48297. private _findClosestSnapPointWithRadius;
  48298. private _setTargetMeshPosition;
  48299. private _setTargetMeshVisibility;
  48300. private _showParabolicPath;
  48301. private _teleportForward;
  48302. }
  48303. }
  48304. declare module BABYLON {
  48305. /**
  48306. * Options for the default xr helper
  48307. */
  48308. export class WebXRDefaultExperienceOptions {
  48309. /**
  48310. * Enable or disable default UI to enter XR
  48311. */
  48312. disableDefaultUI?: boolean;
  48313. /**
  48314. * Should teleportation not initialize. defaults to false.
  48315. */
  48316. disableTeleportation?: boolean;
  48317. /**
  48318. * Floor meshes that will be used for teleport
  48319. */
  48320. floorMeshes?: Array<AbstractMesh>;
  48321. /**
  48322. * If set to true, the first frame will not be used to reset position
  48323. * The first frame is mainly used when copying transformation from the old camera
  48324. * Mainly used in AR
  48325. */
  48326. ignoreNativeCameraTransformation?: boolean;
  48327. /**
  48328. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48329. */
  48330. inputOptions?: IWebXRInputOptions;
  48331. /**
  48332. * optional configuration for the output canvas
  48333. */
  48334. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48335. /**
  48336. * optional UI options. This can be used among other to change session mode and reference space type
  48337. */
  48338. uiOptions?: WebXREnterExitUIOptions;
  48339. /**
  48340. * When loading teleportation and pointer select, use stable versions instead of latest.
  48341. */
  48342. useStablePlugins?: boolean;
  48343. /**
  48344. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48345. */
  48346. renderingGroupId?: number;
  48347. /**
  48348. * A list of optional features to init the session with
  48349. * If set to true, all features we support will be added
  48350. */
  48351. optionalFeatures?: boolean | string[];
  48352. }
  48353. /**
  48354. * Default experience which provides a similar setup to the previous webVRExperience
  48355. */
  48356. export class WebXRDefaultExperience {
  48357. /**
  48358. * Base experience
  48359. */
  48360. baseExperience: WebXRExperienceHelper;
  48361. /**
  48362. * Enables ui for entering/exiting xr
  48363. */
  48364. enterExitUI: WebXREnterExitUI;
  48365. /**
  48366. * Input experience extension
  48367. */
  48368. input: WebXRInput;
  48369. /**
  48370. * Enables laser pointer and selection
  48371. */
  48372. pointerSelection: WebXRControllerPointerSelection;
  48373. /**
  48374. * Default target xr should render to
  48375. */
  48376. renderTarget: WebXRRenderTarget;
  48377. /**
  48378. * Enables teleportation
  48379. */
  48380. teleportation: WebXRMotionControllerTeleportation;
  48381. private constructor();
  48382. /**
  48383. * Creates the default xr experience
  48384. * @param scene scene
  48385. * @param options options for basic configuration
  48386. * @returns resulting WebXRDefaultExperience
  48387. */
  48388. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48389. /**
  48390. * DIsposes of the experience helper
  48391. */
  48392. dispose(): void;
  48393. }
  48394. }
  48395. declare module BABYLON {
  48396. /**
  48397. * Options to modify the vr teleportation behavior.
  48398. */
  48399. export interface VRTeleportationOptions {
  48400. /**
  48401. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48402. */
  48403. floorMeshName?: string;
  48404. /**
  48405. * A list of meshes to be used as the teleportation floor. (default: empty)
  48406. */
  48407. floorMeshes?: Mesh[];
  48408. /**
  48409. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48410. */
  48411. teleportationMode?: number;
  48412. /**
  48413. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48414. */
  48415. teleportationTime?: number;
  48416. /**
  48417. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48418. */
  48419. teleportationSpeed?: number;
  48420. /**
  48421. * The easing function used in the animation or null for Linear. (default CircleEase)
  48422. */
  48423. easingFunction?: EasingFunction;
  48424. }
  48425. /**
  48426. * Options to modify the vr experience helper's behavior.
  48427. */
  48428. export interface VRExperienceHelperOptions extends WebVROptions {
  48429. /**
  48430. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48431. */
  48432. createDeviceOrientationCamera?: boolean;
  48433. /**
  48434. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48435. */
  48436. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48437. /**
  48438. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48439. */
  48440. laserToggle?: boolean;
  48441. /**
  48442. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48443. */
  48444. floorMeshes?: Mesh[];
  48445. /**
  48446. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48447. */
  48448. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48449. /**
  48450. * Defines if WebXR should be used instead of WebVR (if available)
  48451. */
  48452. useXR?: boolean;
  48453. }
  48454. /**
  48455. * Event containing information after VR has been entered
  48456. */
  48457. export class OnAfterEnteringVRObservableEvent {
  48458. /**
  48459. * If entering vr was successful
  48460. */
  48461. success: boolean;
  48462. }
  48463. /**
  48464. * Helps to quickly add VR support to an existing scene.
  48465. * See http://doc.babylonjs.com/how_to/webvr_helper
  48466. */
  48467. export class VRExperienceHelper {
  48468. /** Options to modify the vr experience helper's behavior. */
  48469. webVROptions: VRExperienceHelperOptions;
  48470. private _scene;
  48471. private _position;
  48472. private _btnVR;
  48473. private _btnVRDisplayed;
  48474. private _webVRsupported;
  48475. private _webVRready;
  48476. private _webVRrequesting;
  48477. private _webVRpresenting;
  48478. private _hasEnteredVR;
  48479. private _fullscreenVRpresenting;
  48480. private _inputElement;
  48481. private _webVRCamera;
  48482. private _vrDeviceOrientationCamera;
  48483. private _deviceOrientationCamera;
  48484. private _existingCamera;
  48485. private _onKeyDown;
  48486. private _onVrDisplayPresentChange;
  48487. private _onVRDisplayChanged;
  48488. private _onVRRequestPresentStart;
  48489. private _onVRRequestPresentComplete;
  48490. /**
  48491. * 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)
  48492. */
  48493. enableGazeEvenWhenNoPointerLock: boolean;
  48494. /**
  48495. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48496. */
  48497. exitVROnDoubleTap: boolean;
  48498. /**
  48499. * Observable raised right before entering VR.
  48500. */
  48501. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48502. /**
  48503. * Observable raised when entering VR has completed.
  48504. */
  48505. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48506. /**
  48507. * Observable raised when exiting VR.
  48508. */
  48509. onExitingVRObservable: Observable<VRExperienceHelper>;
  48510. /**
  48511. * Observable raised when controller mesh is loaded.
  48512. */
  48513. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48514. /** Return this.onEnteringVRObservable
  48515. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48516. */
  48517. get onEnteringVR(): Observable<VRExperienceHelper>;
  48518. /** Return this.onExitingVRObservable
  48519. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48520. */
  48521. get onExitingVR(): Observable<VRExperienceHelper>;
  48522. /** Return this.onControllerMeshLoadedObservable
  48523. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48524. */
  48525. get onControllerMeshLoaded(): Observable<WebVRController>;
  48526. private _rayLength;
  48527. private _useCustomVRButton;
  48528. private _teleportationRequested;
  48529. private _teleportActive;
  48530. private _floorMeshName;
  48531. private _floorMeshesCollection;
  48532. private _teleportationMode;
  48533. private _teleportationTime;
  48534. private _teleportationSpeed;
  48535. private _teleportationEasing;
  48536. private _rotationAllowed;
  48537. private _teleportBackwardsVector;
  48538. private _teleportationTarget;
  48539. private _isDefaultTeleportationTarget;
  48540. private _postProcessMove;
  48541. private _teleportationFillColor;
  48542. private _teleportationBorderColor;
  48543. private _rotationAngle;
  48544. private _haloCenter;
  48545. private _cameraGazer;
  48546. private _padSensibilityUp;
  48547. private _padSensibilityDown;
  48548. private _leftController;
  48549. private _rightController;
  48550. private _gazeColor;
  48551. private _laserColor;
  48552. private _pickedLaserColor;
  48553. private _pickedGazeColor;
  48554. /**
  48555. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48556. */
  48557. onNewMeshSelected: Observable<AbstractMesh>;
  48558. /**
  48559. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48560. * This observable will provide the mesh and the controller used to select the mesh
  48561. */
  48562. onMeshSelectedWithController: Observable<{
  48563. mesh: AbstractMesh;
  48564. controller: WebVRController;
  48565. }>;
  48566. /**
  48567. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48568. */
  48569. onNewMeshPicked: Observable<PickingInfo>;
  48570. private _circleEase;
  48571. /**
  48572. * Observable raised before camera teleportation
  48573. */
  48574. onBeforeCameraTeleport: Observable<Vector3>;
  48575. /**
  48576. * Observable raised after camera teleportation
  48577. */
  48578. onAfterCameraTeleport: Observable<Vector3>;
  48579. /**
  48580. * Observable raised when current selected mesh gets unselected
  48581. */
  48582. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48583. private _raySelectionPredicate;
  48584. /**
  48585. * To be optionaly changed by user to define custom ray selection
  48586. */
  48587. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48588. /**
  48589. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48590. */
  48591. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48592. /**
  48593. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48594. */
  48595. teleportationEnabled: boolean;
  48596. private _defaultHeight;
  48597. private _teleportationInitialized;
  48598. private _interactionsEnabled;
  48599. private _interactionsRequested;
  48600. private _displayGaze;
  48601. private _displayLaserPointer;
  48602. /**
  48603. * The mesh used to display where the user is going to teleport.
  48604. */
  48605. get teleportationTarget(): Mesh;
  48606. /**
  48607. * Sets the mesh to be used to display where the user is going to teleport.
  48608. */
  48609. set teleportationTarget(value: Mesh);
  48610. /**
  48611. * 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
  48612. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48613. * See http://doc.babylonjs.com/resources/baking_transformations
  48614. */
  48615. get gazeTrackerMesh(): Mesh;
  48616. set gazeTrackerMesh(value: Mesh);
  48617. /**
  48618. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48619. */
  48620. updateGazeTrackerScale: boolean;
  48621. /**
  48622. * If the gaze trackers color should be updated when selecting meshes
  48623. */
  48624. updateGazeTrackerColor: boolean;
  48625. /**
  48626. * If the controller laser color should be updated when selecting meshes
  48627. */
  48628. updateControllerLaserColor: boolean;
  48629. /**
  48630. * The gaze tracking mesh corresponding to the left controller
  48631. */
  48632. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48633. /**
  48634. * The gaze tracking mesh corresponding to the right controller
  48635. */
  48636. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48637. /**
  48638. * If the ray of the gaze should be displayed.
  48639. */
  48640. get displayGaze(): boolean;
  48641. /**
  48642. * Sets if the ray of the gaze should be displayed.
  48643. */
  48644. set displayGaze(value: boolean);
  48645. /**
  48646. * If the ray of the LaserPointer should be displayed.
  48647. */
  48648. get displayLaserPointer(): boolean;
  48649. /**
  48650. * Sets if the ray of the LaserPointer should be displayed.
  48651. */
  48652. set displayLaserPointer(value: boolean);
  48653. /**
  48654. * The deviceOrientationCamera used as the camera when not in VR.
  48655. */
  48656. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48657. /**
  48658. * Based on the current WebVR support, returns the current VR camera used.
  48659. */
  48660. get currentVRCamera(): Nullable<Camera>;
  48661. /**
  48662. * The webVRCamera which is used when in VR.
  48663. */
  48664. get webVRCamera(): WebVRFreeCamera;
  48665. /**
  48666. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48667. */
  48668. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48669. /**
  48670. * The html button that is used to trigger entering into VR.
  48671. */
  48672. get vrButton(): Nullable<HTMLButtonElement>;
  48673. private get _teleportationRequestInitiated();
  48674. /**
  48675. * Defines whether or not Pointer lock should be requested when switching to
  48676. * full screen.
  48677. */
  48678. requestPointerLockOnFullScreen: boolean;
  48679. /**
  48680. * If asking to force XR, this will be populated with the default xr experience
  48681. */
  48682. xr: WebXRDefaultExperience;
  48683. /**
  48684. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48685. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48686. */
  48687. xrTestDone: boolean;
  48688. /**
  48689. * Instantiates a VRExperienceHelper.
  48690. * Helps to quickly add VR support to an existing scene.
  48691. * @param scene The scene the VRExperienceHelper belongs to.
  48692. * @param webVROptions Options to modify the vr experience helper's behavior.
  48693. */
  48694. constructor(scene: Scene,
  48695. /** Options to modify the vr experience helper's behavior. */
  48696. webVROptions?: VRExperienceHelperOptions);
  48697. private completeVRInit;
  48698. private _onDefaultMeshLoaded;
  48699. private _onResize;
  48700. private _onFullscreenChange;
  48701. /**
  48702. * Gets a value indicating if we are currently in VR mode.
  48703. */
  48704. get isInVRMode(): boolean;
  48705. private onVrDisplayPresentChange;
  48706. private onVRDisplayChanged;
  48707. private moveButtonToBottomRight;
  48708. private displayVRButton;
  48709. private updateButtonVisibility;
  48710. private _cachedAngularSensibility;
  48711. /**
  48712. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48713. * Otherwise, will use the fullscreen API.
  48714. */
  48715. enterVR(): void;
  48716. /**
  48717. * Attempt to exit VR, or fullscreen.
  48718. */
  48719. exitVR(): void;
  48720. /**
  48721. * The position of the vr experience helper.
  48722. */
  48723. get position(): Vector3;
  48724. /**
  48725. * Sets the position of the vr experience helper.
  48726. */
  48727. set position(value: Vector3);
  48728. /**
  48729. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48730. */
  48731. enableInteractions(): void;
  48732. private get _noControllerIsActive();
  48733. private beforeRender;
  48734. private _isTeleportationFloor;
  48735. /**
  48736. * Adds a floor mesh to be used for teleportation.
  48737. * @param floorMesh the mesh to be used for teleportation.
  48738. */
  48739. addFloorMesh(floorMesh: Mesh): void;
  48740. /**
  48741. * Removes a floor mesh from being used for teleportation.
  48742. * @param floorMesh the mesh to be removed.
  48743. */
  48744. removeFloorMesh(floorMesh: Mesh): void;
  48745. /**
  48746. * Enables interactions and teleportation using the VR controllers and gaze.
  48747. * @param vrTeleportationOptions options to modify teleportation behavior.
  48748. */
  48749. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48750. private _onNewGamepadConnected;
  48751. private _tryEnableInteractionOnController;
  48752. private _onNewGamepadDisconnected;
  48753. private _enableInteractionOnController;
  48754. private _checkTeleportWithRay;
  48755. private _checkRotate;
  48756. private _checkTeleportBackwards;
  48757. private _enableTeleportationOnController;
  48758. private _createTeleportationCircles;
  48759. private _displayTeleportationTarget;
  48760. private _hideTeleportationTarget;
  48761. private _rotateCamera;
  48762. private _moveTeleportationSelectorTo;
  48763. private _workingVector;
  48764. private _workingQuaternion;
  48765. private _workingMatrix;
  48766. /**
  48767. * Time Constant Teleportation Mode
  48768. */
  48769. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48770. /**
  48771. * Speed Constant Teleportation Mode
  48772. */
  48773. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48774. /**
  48775. * Teleports the users feet to the desired location
  48776. * @param location The location where the user's feet should be placed
  48777. */
  48778. teleportCamera(location: Vector3): void;
  48779. private _convertNormalToDirectionOfRay;
  48780. private _castRayAndSelectObject;
  48781. private _notifySelectedMeshUnselected;
  48782. /**
  48783. * Permanently set new colors for the laser pointer
  48784. * @param color the new laser color
  48785. * @param pickedColor the new laser color when picked mesh detected
  48786. */
  48787. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48788. /**
  48789. * Set lighting enabled / disabled on the laser pointer of both controllers
  48790. * @param enabled should the lighting be enabled on the laser pointer
  48791. */
  48792. setLaserLightingState(enabled?: boolean): void;
  48793. /**
  48794. * Permanently set new colors for the gaze pointer
  48795. * @param color the new gaze color
  48796. * @param pickedColor the new gaze color when picked mesh detected
  48797. */
  48798. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48799. /**
  48800. * Sets the color of the laser ray from the vr controllers.
  48801. * @param color new color for the ray.
  48802. */
  48803. changeLaserColor(color: Color3): void;
  48804. /**
  48805. * Sets the color of the ray from the vr headsets gaze.
  48806. * @param color new color for the ray.
  48807. */
  48808. changeGazeColor(color: Color3): void;
  48809. /**
  48810. * Exits VR and disposes of the vr experience helper
  48811. */
  48812. dispose(): void;
  48813. /**
  48814. * Gets the name of the VRExperienceHelper class
  48815. * @returns "VRExperienceHelper"
  48816. */
  48817. getClassName(): string;
  48818. }
  48819. }
  48820. declare module BABYLON {
  48821. /**
  48822. * Contains an array of blocks representing the octree
  48823. */
  48824. export interface IOctreeContainer<T> {
  48825. /**
  48826. * Blocks within the octree
  48827. */
  48828. blocks: Array<OctreeBlock<T>>;
  48829. }
  48830. /**
  48831. * Class used to store a cell in an octree
  48832. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48833. */
  48834. export class OctreeBlock<T> {
  48835. /**
  48836. * Gets the content of the current block
  48837. */
  48838. entries: T[];
  48839. /**
  48840. * Gets the list of block children
  48841. */
  48842. blocks: Array<OctreeBlock<T>>;
  48843. private _depth;
  48844. private _maxDepth;
  48845. private _capacity;
  48846. private _minPoint;
  48847. private _maxPoint;
  48848. private _boundingVectors;
  48849. private _creationFunc;
  48850. /**
  48851. * Creates a new block
  48852. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48853. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48854. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48855. * @param depth defines the current depth of this block in the octree
  48856. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48857. * @param creationFunc defines a callback to call when an element is added to the block
  48858. */
  48859. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48860. /**
  48861. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48862. */
  48863. get capacity(): number;
  48864. /**
  48865. * Gets the minimum vector (in world space) of the block's bounding box
  48866. */
  48867. get minPoint(): Vector3;
  48868. /**
  48869. * Gets the maximum vector (in world space) of the block's bounding box
  48870. */
  48871. get maxPoint(): Vector3;
  48872. /**
  48873. * Add a new element to this block
  48874. * @param entry defines the element to add
  48875. */
  48876. addEntry(entry: T): void;
  48877. /**
  48878. * Remove an element from this block
  48879. * @param entry defines the element to remove
  48880. */
  48881. removeEntry(entry: T): void;
  48882. /**
  48883. * Add an array of elements to this block
  48884. * @param entries defines the array of elements to add
  48885. */
  48886. addEntries(entries: T[]): void;
  48887. /**
  48888. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48889. * @param frustumPlanes defines the frustum planes to test
  48890. * @param selection defines the array to store current content if selection is positive
  48891. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48892. */
  48893. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48894. /**
  48895. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48896. * @param sphereCenter defines the bounding sphere center
  48897. * @param sphereRadius defines the bounding sphere radius
  48898. * @param selection defines the array to store current content if selection is positive
  48899. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48900. */
  48901. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48902. /**
  48903. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48904. * @param ray defines the ray to test with
  48905. * @param selection defines the array to store current content if selection is positive
  48906. */
  48907. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48908. /**
  48909. * Subdivide the content into child blocks (this block will then be empty)
  48910. */
  48911. createInnerBlocks(): void;
  48912. /**
  48913. * @hidden
  48914. */
  48915. 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;
  48916. }
  48917. }
  48918. declare module BABYLON {
  48919. /**
  48920. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48921. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48922. */
  48923. export class Octree<T> {
  48924. /** 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.) */
  48925. maxDepth: number;
  48926. /**
  48927. * Blocks within the octree containing objects
  48928. */
  48929. blocks: Array<OctreeBlock<T>>;
  48930. /**
  48931. * Content stored in the octree
  48932. */
  48933. dynamicContent: T[];
  48934. private _maxBlockCapacity;
  48935. private _selectionContent;
  48936. private _creationFunc;
  48937. /**
  48938. * Creates a octree
  48939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48940. * @param creationFunc function to be used to instatiate the octree
  48941. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48942. * @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.)
  48943. */
  48944. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48945. /** 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.) */
  48946. maxDepth?: number);
  48947. /**
  48948. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48949. * @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);
  48950. * @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);
  48951. * @param entries meshes to be added to the octree blocks
  48952. */
  48953. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48954. /**
  48955. * Adds a mesh to the octree
  48956. * @param entry Mesh to add to the octree
  48957. */
  48958. addMesh(entry: T): void;
  48959. /**
  48960. * Remove an element from the octree
  48961. * @param entry defines the element to remove
  48962. */
  48963. removeMesh(entry: T): void;
  48964. /**
  48965. * Selects an array of meshes within the frustum
  48966. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48967. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48968. * @returns array of meshes within the frustum
  48969. */
  48970. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48971. /**
  48972. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48973. * @param sphereCenter defines the bounding sphere center
  48974. * @param sphereRadius defines the bounding sphere radius
  48975. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48976. * @returns an array of objects that intersect the sphere
  48977. */
  48978. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48979. /**
  48980. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48981. * @param ray defines the ray to test with
  48982. * @returns array of intersected objects
  48983. */
  48984. intersectsRay(ray: Ray): SmartArray<T>;
  48985. /**
  48986. * Adds a mesh into the octree block if it intersects the block
  48987. */
  48988. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48989. /**
  48990. * Adds a submesh into the octree block if it intersects the block
  48991. */
  48992. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48993. }
  48994. }
  48995. declare module BABYLON {
  48996. interface Scene {
  48997. /**
  48998. * @hidden
  48999. * Backing Filed
  49000. */
  49001. _selectionOctree: Octree<AbstractMesh>;
  49002. /**
  49003. * Gets the octree used to boost mesh selection (picking)
  49004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49005. */
  49006. selectionOctree: Octree<AbstractMesh>;
  49007. /**
  49008. * Creates or updates the octree used to boost selection (picking)
  49009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49010. * @param maxCapacity defines the maximum capacity per leaf
  49011. * @param maxDepth defines the maximum depth of the octree
  49012. * @returns an octree of AbstractMesh
  49013. */
  49014. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49015. }
  49016. interface AbstractMesh {
  49017. /**
  49018. * @hidden
  49019. * Backing Field
  49020. */
  49021. _submeshesOctree: Octree<SubMesh>;
  49022. /**
  49023. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49024. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49025. * @param maxCapacity defines the maximum size of each block (64 by default)
  49026. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49027. * @returns the new octree
  49028. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49030. */
  49031. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49032. }
  49033. /**
  49034. * Defines the octree scene component responsible to manage any octrees
  49035. * in a given scene.
  49036. */
  49037. export class OctreeSceneComponent {
  49038. /**
  49039. * The component name help to identify the component in the list of scene components.
  49040. */
  49041. readonly name: string;
  49042. /**
  49043. * The scene the component belongs to.
  49044. */
  49045. scene: Scene;
  49046. /**
  49047. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49048. */
  49049. readonly checksIsEnabled: boolean;
  49050. /**
  49051. * Creates a new instance of the component for the given scene
  49052. * @param scene Defines the scene to register the component in
  49053. */
  49054. constructor(scene: Scene);
  49055. /**
  49056. * Registers the component in a given scene
  49057. */
  49058. register(): void;
  49059. /**
  49060. * Return the list of active meshes
  49061. * @returns the list of active meshes
  49062. */
  49063. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49064. /**
  49065. * Return the list of active sub meshes
  49066. * @param mesh The mesh to get the candidates sub meshes from
  49067. * @returns the list of active sub meshes
  49068. */
  49069. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49070. private _tempRay;
  49071. /**
  49072. * Return the list of sub meshes intersecting with a given local ray
  49073. * @param mesh defines the mesh to find the submesh for
  49074. * @param localRay defines the ray in local space
  49075. * @returns the list of intersecting sub meshes
  49076. */
  49077. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49078. /**
  49079. * Return the list of sub meshes colliding with a collider
  49080. * @param mesh defines the mesh to find the submesh for
  49081. * @param collider defines the collider to evaluate the collision against
  49082. * @returns the list of colliding sub meshes
  49083. */
  49084. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49085. /**
  49086. * Rebuilds the elements related to this component in case of
  49087. * context lost for instance.
  49088. */
  49089. rebuild(): void;
  49090. /**
  49091. * Disposes the component and the associated ressources.
  49092. */
  49093. dispose(): void;
  49094. }
  49095. }
  49096. declare module BABYLON {
  49097. /**
  49098. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49099. */
  49100. export class Gizmo implements IDisposable {
  49101. /** The utility layer the gizmo will be added to */
  49102. gizmoLayer: UtilityLayerRenderer;
  49103. /**
  49104. * The root mesh of the gizmo
  49105. */
  49106. _rootMesh: Mesh;
  49107. private _attachedMesh;
  49108. /**
  49109. * Ratio for the scale of the gizmo (Default: 1)
  49110. */
  49111. scaleRatio: number;
  49112. /**
  49113. * If a custom mesh has been set (Default: false)
  49114. */
  49115. protected _customMeshSet: boolean;
  49116. /**
  49117. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49118. * * When set, interactions will be enabled
  49119. */
  49120. get attachedMesh(): Nullable<AbstractMesh>;
  49121. set attachedMesh(value: Nullable<AbstractMesh>);
  49122. /**
  49123. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49124. * @param mesh The mesh to replace the default mesh of the gizmo
  49125. */
  49126. setCustomMesh(mesh: Mesh): void;
  49127. /**
  49128. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49129. */
  49130. updateGizmoRotationToMatchAttachedMesh: boolean;
  49131. /**
  49132. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49133. */
  49134. updateGizmoPositionToMatchAttachedMesh: boolean;
  49135. /**
  49136. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49137. */
  49138. updateScale: boolean;
  49139. protected _interactionsEnabled: boolean;
  49140. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49141. private _beforeRenderObserver;
  49142. private _tempVector;
  49143. /**
  49144. * Creates a gizmo
  49145. * @param gizmoLayer The utility layer the gizmo will be added to
  49146. */
  49147. constructor(
  49148. /** The utility layer the gizmo will be added to */
  49149. gizmoLayer?: UtilityLayerRenderer);
  49150. /**
  49151. * Updates the gizmo to match the attached mesh's position/rotation
  49152. */
  49153. protected _update(): void;
  49154. /**
  49155. * Disposes of the gizmo
  49156. */
  49157. dispose(): void;
  49158. }
  49159. }
  49160. declare module BABYLON {
  49161. /**
  49162. * Single plane drag gizmo
  49163. */
  49164. export class PlaneDragGizmo extends Gizmo {
  49165. /**
  49166. * Drag behavior responsible for the gizmos dragging interactions
  49167. */
  49168. dragBehavior: PointerDragBehavior;
  49169. private _pointerObserver;
  49170. /**
  49171. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49172. */
  49173. snapDistance: number;
  49174. /**
  49175. * Event that fires each time the gizmo snaps to a new location.
  49176. * * snapDistance is the the change in distance
  49177. */
  49178. onSnapObservable: Observable<{
  49179. snapDistance: number;
  49180. }>;
  49181. private _plane;
  49182. private _coloredMaterial;
  49183. private _hoverMaterial;
  49184. private _isEnabled;
  49185. private _parent;
  49186. /** @hidden */
  49187. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49188. /** @hidden */
  49189. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49190. /**
  49191. * Creates a PlaneDragGizmo
  49192. * @param gizmoLayer The utility layer the gizmo will be added to
  49193. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49194. * @param color The color of the gizmo
  49195. */
  49196. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49197. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49198. /**
  49199. * If the gizmo is enabled
  49200. */
  49201. set isEnabled(value: boolean);
  49202. get isEnabled(): boolean;
  49203. /**
  49204. * Disposes of the gizmo
  49205. */
  49206. dispose(): void;
  49207. }
  49208. }
  49209. declare module BABYLON {
  49210. /**
  49211. * Gizmo that enables dragging a mesh along 3 axis
  49212. */
  49213. export class PositionGizmo extends Gizmo {
  49214. /**
  49215. * Internal gizmo used for interactions on the x axis
  49216. */
  49217. xGizmo: AxisDragGizmo;
  49218. /**
  49219. * Internal gizmo used for interactions on the y axis
  49220. */
  49221. yGizmo: AxisDragGizmo;
  49222. /**
  49223. * Internal gizmo used for interactions on the z axis
  49224. */
  49225. zGizmo: AxisDragGizmo;
  49226. /**
  49227. * Internal gizmo used for interactions on the yz plane
  49228. */
  49229. xPlaneGizmo: PlaneDragGizmo;
  49230. /**
  49231. * Internal gizmo used for interactions on the xz plane
  49232. */
  49233. yPlaneGizmo: PlaneDragGizmo;
  49234. /**
  49235. * Internal gizmo used for interactions on the xy plane
  49236. */
  49237. zPlaneGizmo: PlaneDragGizmo;
  49238. /**
  49239. * private variables
  49240. */
  49241. private _meshAttached;
  49242. private _updateGizmoRotationToMatchAttachedMesh;
  49243. private _snapDistance;
  49244. private _scaleRatio;
  49245. /** Fires an event when any of it's sub gizmos are dragged */
  49246. onDragStartObservable: Observable<unknown>;
  49247. /** Fires an event when any of it's sub gizmos are released from dragging */
  49248. onDragEndObservable: Observable<unknown>;
  49249. /**
  49250. * If set to true, planar drag is enabled
  49251. */
  49252. private _planarGizmoEnabled;
  49253. get attachedMesh(): Nullable<AbstractMesh>;
  49254. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49255. /**
  49256. * Creates a PositionGizmo
  49257. * @param gizmoLayer The utility layer the gizmo will be added to
  49258. */
  49259. constructor(gizmoLayer?: UtilityLayerRenderer);
  49260. /**
  49261. * If the planar drag gizmo is enabled
  49262. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49263. */
  49264. set planarGizmoEnabled(value: boolean);
  49265. get planarGizmoEnabled(): boolean;
  49266. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49267. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49268. /**
  49269. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49270. */
  49271. set snapDistance(value: number);
  49272. get snapDistance(): number;
  49273. /**
  49274. * Ratio for the scale of the gizmo (Default: 1)
  49275. */
  49276. set scaleRatio(value: number);
  49277. get scaleRatio(): number;
  49278. /**
  49279. * Disposes of the gizmo
  49280. */
  49281. dispose(): void;
  49282. /**
  49283. * CustomMeshes are not supported by this gizmo
  49284. * @param mesh The mesh to replace the default mesh of the gizmo
  49285. */
  49286. setCustomMesh(mesh: Mesh): void;
  49287. }
  49288. }
  49289. declare module BABYLON {
  49290. /**
  49291. * Single axis drag gizmo
  49292. */
  49293. export class AxisDragGizmo extends Gizmo {
  49294. /**
  49295. * Drag behavior responsible for the gizmos dragging interactions
  49296. */
  49297. dragBehavior: PointerDragBehavior;
  49298. private _pointerObserver;
  49299. /**
  49300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49301. */
  49302. snapDistance: number;
  49303. /**
  49304. * Event that fires each time the gizmo snaps to a new location.
  49305. * * snapDistance is the the change in distance
  49306. */
  49307. onSnapObservable: Observable<{
  49308. snapDistance: number;
  49309. }>;
  49310. private _isEnabled;
  49311. private _parent;
  49312. private _arrow;
  49313. private _coloredMaterial;
  49314. private _hoverMaterial;
  49315. /** @hidden */
  49316. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49317. /** @hidden */
  49318. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49319. /**
  49320. * Creates an AxisDragGizmo
  49321. * @param gizmoLayer The utility layer the gizmo will be added to
  49322. * @param dragAxis The axis which the gizmo will be able to drag on
  49323. * @param color The color of the gizmo
  49324. */
  49325. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49326. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49327. /**
  49328. * If the gizmo is enabled
  49329. */
  49330. set isEnabled(value: boolean);
  49331. get isEnabled(): boolean;
  49332. /**
  49333. * Disposes of the gizmo
  49334. */
  49335. dispose(): void;
  49336. }
  49337. }
  49338. declare module BABYLON.Debug {
  49339. /**
  49340. * The Axes viewer will show 3 axes in a specific point in space
  49341. */
  49342. export class AxesViewer {
  49343. private _xAxis;
  49344. private _yAxis;
  49345. private _zAxis;
  49346. private _scaleLinesFactor;
  49347. private _instanced;
  49348. /**
  49349. * Gets the hosting scene
  49350. */
  49351. scene: Scene;
  49352. /**
  49353. * Gets or sets a number used to scale line length
  49354. */
  49355. scaleLines: number;
  49356. /** Gets the node hierarchy used to render x-axis */
  49357. get xAxis(): TransformNode;
  49358. /** Gets the node hierarchy used to render y-axis */
  49359. get yAxis(): TransformNode;
  49360. /** Gets the node hierarchy used to render z-axis */
  49361. get zAxis(): TransformNode;
  49362. /**
  49363. * Creates a new AxesViewer
  49364. * @param scene defines the hosting scene
  49365. * @param scaleLines defines a number used to scale line length (1 by default)
  49366. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49367. * @param xAxis defines the node hierarchy used to render the x-axis
  49368. * @param yAxis defines the node hierarchy used to render the y-axis
  49369. * @param zAxis defines the node hierarchy used to render the z-axis
  49370. */
  49371. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49372. /**
  49373. * Force the viewer to update
  49374. * @param position defines the position of the viewer
  49375. * @param xaxis defines the x axis of the viewer
  49376. * @param yaxis defines the y axis of the viewer
  49377. * @param zaxis defines the z axis of the viewer
  49378. */
  49379. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49380. /**
  49381. * Creates an instance of this axes viewer.
  49382. * @returns a new axes viewer with instanced meshes
  49383. */
  49384. createInstance(): AxesViewer;
  49385. /** Releases resources */
  49386. dispose(): void;
  49387. private static _SetRenderingGroupId;
  49388. }
  49389. }
  49390. declare module BABYLON.Debug {
  49391. /**
  49392. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49393. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49394. */
  49395. export class BoneAxesViewer extends AxesViewer {
  49396. /**
  49397. * Gets or sets the target mesh where to display the axes viewer
  49398. */
  49399. mesh: Nullable<Mesh>;
  49400. /**
  49401. * Gets or sets the target bone where to display the axes viewer
  49402. */
  49403. bone: Nullable<Bone>;
  49404. /** Gets current position */
  49405. pos: Vector3;
  49406. /** Gets direction of X axis */
  49407. xaxis: Vector3;
  49408. /** Gets direction of Y axis */
  49409. yaxis: Vector3;
  49410. /** Gets direction of Z axis */
  49411. zaxis: Vector3;
  49412. /**
  49413. * Creates a new BoneAxesViewer
  49414. * @param scene defines the hosting scene
  49415. * @param bone defines the target bone
  49416. * @param mesh defines the target mesh
  49417. * @param scaleLines defines a scaling factor for line length (1 by default)
  49418. */
  49419. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49420. /**
  49421. * Force the viewer to update
  49422. */
  49423. update(): void;
  49424. /** Releases resources */
  49425. dispose(): void;
  49426. }
  49427. }
  49428. declare module BABYLON {
  49429. /**
  49430. * Interface used to define scene explorer extensibility option
  49431. */
  49432. export interface IExplorerExtensibilityOption {
  49433. /**
  49434. * Define the option label
  49435. */
  49436. label: string;
  49437. /**
  49438. * Defines the action to execute on click
  49439. */
  49440. action: (entity: any) => void;
  49441. }
  49442. /**
  49443. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49444. */
  49445. export interface IExplorerExtensibilityGroup {
  49446. /**
  49447. * Defines a predicate to test if a given type mut be extended
  49448. */
  49449. predicate: (entity: any) => boolean;
  49450. /**
  49451. * Gets the list of options added to a type
  49452. */
  49453. entries: IExplorerExtensibilityOption[];
  49454. }
  49455. /**
  49456. * Interface used to define the options to use to create the Inspector
  49457. */
  49458. export interface IInspectorOptions {
  49459. /**
  49460. * Display in overlay mode (default: false)
  49461. */
  49462. overlay?: boolean;
  49463. /**
  49464. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49465. */
  49466. globalRoot?: HTMLElement;
  49467. /**
  49468. * Display the Scene explorer
  49469. */
  49470. showExplorer?: boolean;
  49471. /**
  49472. * Display the property inspector
  49473. */
  49474. showInspector?: boolean;
  49475. /**
  49476. * Display in embed mode (both panes on the right)
  49477. */
  49478. embedMode?: boolean;
  49479. /**
  49480. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49481. */
  49482. handleResize?: boolean;
  49483. /**
  49484. * Allow the panes to popup (default: true)
  49485. */
  49486. enablePopup?: boolean;
  49487. /**
  49488. * Allow the panes to be closed by users (default: true)
  49489. */
  49490. enableClose?: boolean;
  49491. /**
  49492. * Optional list of extensibility entries
  49493. */
  49494. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49495. /**
  49496. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49497. */
  49498. inspectorURL?: string;
  49499. /**
  49500. * Optional initial tab (default to DebugLayerTab.Properties)
  49501. */
  49502. initialTab?: DebugLayerTab;
  49503. }
  49504. interface Scene {
  49505. /**
  49506. * @hidden
  49507. * Backing field
  49508. */
  49509. _debugLayer: DebugLayer;
  49510. /**
  49511. * Gets the debug layer (aka Inspector) associated with the scene
  49512. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49513. */
  49514. debugLayer: DebugLayer;
  49515. }
  49516. /**
  49517. * Enum of inspector action tab
  49518. */
  49519. export enum DebugLayerTab {
  49520. /**
  49521. * Properties tag (default)
  49522. */
  49523. Properties = 0,
  49524. /**
  49525. * Debug tab
  49526. */
  49527. Debug = 1,
  49528. /**
  49529. * Statistics tab
  49530. */
  49531. Statistics = 2,
  49532. /**
  49533. * Tools tab
  49534. */
  49535. Tools = 3,
  49536. /**
  49537. * Settings tab
  49538. */
  49539. Settings = 4
  49540. }
  49541. /**
  49542. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49543. * what is happening in your scene
  49544. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49545. */
  49546. export class DebugLayer {
  49547. /**
  49548. * Define the url to get the inspector script from.
  49549. * By default it uses the babylonjs CDN.
  49550. * @ignoreNaming
  49551. */
  49552. static InspectorURL: string;
  49553. private _scene;
  49554. private BJSINSPECTOR;
  49555. private _onPropertyChangedObservable?;
  49556. /**
  49557. * Observable triggered when a property is changed through the inspector.
  49558. */
  49559. get onPropertyChangedObservable(): any;
  49560. /**
  49561. * Instantiates a new debug layer.
  49562. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49563. * what is happening in your scene
  49564. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49565. * @param scene Defines the scene to inspect
  49566. */
  49567. constructor(scene: Scene);
  49568. /** Creates the inspector window. */
  49569. private _createInspector;
  49570. /**
  49571. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49572. * @param entity defines the entity to select
  49573. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49574. */
  49575. select(entity: any, lineContainerTitles?: string | string[]): void;
  49576. /** Get the inspector from bundle or global */
  49577. private _getGlobalInspector;
  49578. /**
  49579. * Get if the inspector is visible or not.
  49580. * @returns true if visible otherwise, false
  49581. */
  49582. isVisible(): boolean;
  49583. /**
  49584. * Hide the inspector and close its window.
  49585. */
  49586. hide(): void;
  49587. /**
  49588. * Update the scene in the inspector
  49589. */
  49590. setAsActiveScene(): void;
  49591. /**
  49592. * Launch the debugLayer.
  49593. * @param config Define the configuration of the inspector
  49594. * @return a promise fulfilled when the debug layer is visible
  49595. */
  49596. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49597. }
  49598. }
  49599. declare module BABYLON {
  49600. /**
  49601. * Class containing static functions to help procedurally build meshes
  49602. */
  49603. export class BoxBuilder {
  49604. /**
  49605. * Creates a box mesh
  49606. * * The parameter `size` sets the size (float) of each box side (default 1)
  49607. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49608. * * 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)
  49609. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49611. * * 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
  49612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49613. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49614. * @param name defines the name of the mesh
  49615. * @param options defines the options used to create the mesh
  49616. * @param scene defines the hosting scene
  49617. * @returns the box mesh
  49618. */
  49619. static CreateBox(name: string, options: {
  49620. size?: number;
  49621. width?: number;
  49622. height?: number;
  49623. depth?: number;
  49624. faceUV?: Vector4[];
  49625. faceColors?: Color4[];
  49626. sideOrientation?: number;
  49627. frontUVs?: Vector4;
  49628. backUVs?: Vector4;
  49629. wrap?: boolean;
  49630. topBaseAt?: number;
  49631. bottomBaseAt?: number;
  49632. updatable?: boolean;
  49633. }, scene?: Nullable<Scene>): Mesh;
  49634. }
  49635. }
  49636. declare module BABYLON.Debug {
  49637. /**
  49638. * Used to show the physics impostor around the specific mesh
  49639. */
  49640. export class PhysicsViewer {
  49641. /** @hidden */
  49642. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49643. /** @hidden */
  49644. protected _meshes: Array<Nullable<AbstractMesh>>;
  49645. /** @hidden */
  49646. protected _scene: Nullable<Scene>;
  49647. /** @hidden */
  49648. protected _numMeshes: number;
  49649. /** @hidden */
  49650. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49651. private _renderFunction;
  49652. private _utilityLayer;
  49653. private _debugBoxMesh;
  49654. private _debugSphereMesh;
  49655. private _debugCylinderMesh;
  49656. private _debugMaterial;
  49657. private _debugMeshMeshes;
  49658. /**
  49659. * Creates a new PhysicsViewer
  49660. * @param scene defines the hosting scene
  49661. */
  49662. constructor(scene: Scene);
  49663. /** @hidden */
  49664. protected _updateDebugMeshes(): void;
  49665. /**
  49666. * Renders a specified physic impostor
  49667. * @param impostor defines the impostor to render
  49668. * @param targetMesh defines the mesh represented by the impostor
  49669. * @returns the new debug mesh used to render the impostor
  49670. */
  49671. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49672. /**
  49673. * Hides a specified physic impostor
  49674. * @param impostor defines the impostor to hide
  49675. */
  49676. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49677. private _getDebugMaterial;
  49678. private _getDebugBoxMesh;
  49679. private _getDebugSphereMesh;
  49680. private _getDebugCylinderMesh;
  49681. private _getDebugMeshMesh;
  49682. private _getDebugMesh;
  49683. /** Releases all resources */
  49684. dispose(): void;
  49685. }
  49686. }
  49687. declare module BABYLON {
  49688. /**
  49689. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49690. * in order to better appreciate the issue one might have.
  49691. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49692. */
  49693. export class RayHelper {
  49694. /**
  49695. * Defines the ray we are currently tryin to visualize.
  49696. */
  49697. ray: Nullable<Ray>;
  49698. private _renderPoints;
  49699. private _renderLine;
  49700. private _renderFunction;
  49701. private _scene;
  49702. private _updateToMeshFunction;
  49703. private _attachedToMesh;
  49704. private _meshSpaceDirection;
  49705. private _meshSpaceOrigin;
  49706. /**
  49707. * Helper function to create a colored helper in a scene in one line.
  49708. * @param ray Defines the ray we are currently tryin to visualize
  49709. * @param scene Defines the scene the ray is used in
  49710. * @param color Defines the color we want to see the ray in
  49711. * @returns The newly created ray helper.
  49712. */
  49713. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49714. /**
  49715. * Instantiate a new ray helper.
  49716. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49717. * in order to better appreciate the issue one might have.
  49718. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49719. * @param ray Defines the ray we are currently tryin to visualize
  49720. */
  49721. constructor(ray: Ray);
  49722. /**
  49723. * Shows the ray we are willing to debug.
  49724. * @param scene Defines the scene the ray needs to be rendered in
  49725. * @param color Defines the color the ray needs to be rendered in
  49726. */
  49727. show(scene: Scene, color?: Color3): void;
  49728. /**
  49729. * Hides the ray we are debugging.
  49730. */
  49731. hide(): void;
  49732. private _render;
  49733. /**
  49734. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49735. * @param mesh Defines the mesh we want the helper attached to
  49736. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49737. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49738. * @param length Defines the length of the ray
  49739. */
  49740. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49741. /**
  49742. * Detach the ray helper from the mesh it has previously been attached to.
  49743. */
  49744. detachFromMesh(): void;
  49745. private _updateToMesh;
  49746. /**
  49747. * Dispose the helper and release its associated resources.
  49748. */
  49749. dispose(): void;
  49750. }
  49751. }
  49752. declare module BABYLON.Debug {
  49753. /**
  49754. * Class used to render a debug view of a given skeleton
  49755. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49756. */
  49757. export class SkeletonViewer {
  49758. /** defines the skeleton to render */
  49759. skeleton: Skeleton;
  49760. /** defines the mesh attached to the skeleton */
  49761. mesh: AbstractMesh;
  49762. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49763. autoUpdateBonesMatrices: boolean;
  49764. /** defines the rendering group id to use with the viewer */
  49765. renderingGroupId: number;
  49766. /** Gets or sets the color used to render the skeleton */
  49767. color: Color3;
  49768. private _scene;
  49769. private _debugLines;
  49770. private _debugMesh;
  49771. private _isEnabled;
  49772. private _renderFunction;
  49773. private _utilityLayer;
  49774. /**
  49775. * Returns the mesh used to render the bones
  49776. */
  49777. get debugMesh(): Nullable<LinesMesh>;
  49778. /**
  49779. * Creates a new SkeletonViewer
  49780. * @param skeleton defines the skeleton to render
  49781. * @param mesh defines the mesh attached to the skeleton
  49782. * @param scene defines the hosting scene
  49783. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49784. * @param renderingGroupId defines the rendering group id to use with the viewer
  49785. */
  49786. constructor(
  49787. /** defines the skeleton to render */
  49788. skeleton: Skeleton,
  49789. /** defines the mesh attached to the skeleton */
  49790. mesh: AbstractMesh, scene: Scene,
  49791. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49792. autoUpdateBonesMatrices?: boolean,
  49793. /** defines the rendering group id to use with the viewer */
  49794. renderingGroupId?: number);
  49795. /** Gets or sets a boolean indicating if the viewer is enabled */
  49796. set isEnabled(value: boolean);
  49797. get isEnabled(): boolean;
  49798. private _getBonePosition;
  49799. private _getLinesForBonesWithLength;
  49800. private _getLinesForBonesNoLength;
  49801. /** Update the viewer to sync with current skeleton state */
  49802. update(): void;
  49803. /** Release associated resources */
  49804. dispose(): void;
  49805. }
  49806. }
  49807. declare module BABYLON {
  49808. /**
  49809. * Enum for Device Types
  49810. */
  49811. export enum DeviceType {
  49812. /** Generic */
  49813. Generic = 0,
  49814. /** Keyboard */
  49815. Keyboard = 1,
  49816. /** Mouse */
  49817. Mouse = 2,
  49818. /** Touch Pointers */
  49819. Touch = 3,
  49820. /** PS4 Dual Shock */
  49821. DualShock = 4,
  49822. /** Xbox */
  49823. Xbox = 5,
  49824. /** Switch Controller */
  49825. Switch = 6
  49826. }
  49827. /**
  49828. * Enum for All Pointers (Touch/Mouse)
  49829. */
  49830. export enum PointerInput {
  49831. /** Horizontal Axis */
  49832. Horizontal = 0,
  49833. /** Vertical Axis */
  49834. Vertical = 1,
  49835. /** Left Click or Touch */
  49836. LeftClick = 2,
  49837. /** Middle Click */
  49838. MiddleClick = 3,
  49839. /** Right Click */
  49840. RightClick = 4,
  49841. /** Browser Back */
  49842. BrowserBack = 5,
  49843. /** Browser Forward */
  49844. BrowserForward = 6
  49845. }
  49846. /**
  49847. * Enum for Dual Shock Gamepad
  49848. */
  49849. export enum DualShockInput {
  49850. /** Cross */
  49851. Cross = 0,
  49852. /** Circle */
  49853. Circle = 1,
  49854. /** Square */
  49855. Square = 2,
  49856. /** Triangle */
  49857. Triangle = 3,
  49858. /** L1 */
  49859. L1 = 4,
  49860. /** R1 */
  49861. R1 = 5,
  49862. /** L2 */
  49863. L2 = 6,
  49864. /** R2 */
  49865. R2 = 7,
  49866. /** Share */
  49867. Share = 8,
  49868. /** Options */
  49869. Options = 9,
  49870. /** L3 */
  49871. L3 = 10,
  49872. /** R3 */
  49873. R3 = 11,
  49874. /** DPadUp */
  49875. DPadUp = 12,
  49876. /** DPadDown */
  49877. DPadDown = 13,
  49878. /** DPadLeft */
  49879. DPadLeft = 14,
  49880. /** DRight */
  49881. DPadRight = 15,
  49882. /** Home */
  49883. Home = 16,
  49884. /** TouchPad */
  49885. TouchPad = 17,
  49886. /** LStickXAxis */
  49887. LStickXAxis = 18,
  49888. /** LStickYAxis */
  49889. LStickYAxis = 19,
  49890. /** RStickXAxis */
  49891. RStickXAxis = 20,
  49892. /** RStickYAxis */
  49893. RStickYAxis = 21
  49894. }
  49895. /**
  49896. * Enum for Xbox Gamepad
  49897. */
  49898. export enum XboxInput {
  49899. /** A */
  49900. A = 0,
  49901. /** B */
  49902. B = 1,
  49903. /** X */
  49904. X = 2,
  49905. /** Y */
  49906. Y = 3,
  49907. /** LB */
  49908. LB = 4,
  49909. /** RB */
  49910. RB = 5,
  49911. /** LT */
  49912. LT = 6,
  49913. /** RT */
  49914. RT = 7,
  49915. /** Back */
  49916. Back = 8,
  49917. /** Start */
  49918. Start = 9,
  49919. /** LS */
  49920. LS = 10,
  49921. /** RS */
  49922. RS = 11,
  49923. /** DPadUp */
  49924. DPadUp = 12,
  49925. /** DPadDown */
  49926. DPadDown = 13,
  49927. /** DPadLeft */
  49928. DPadLeft = 14,
  49929. /** DRight */
  49930. DPadRight = 15,
  49931. /** Home */
  49932. Home = 16,
  49933. /** LStickXAxis */
  49934. LStickXAxis = 17,
  49935. /** LStickYAxis */
  49936. LStickYAxis = 18,
  49937. /** RStickXAxis */
  49938. RStickXAxis = 19,
  49939. /** RStickYAxis */
  49940. RStickYAxis = 20
  49941. }
  49942. /**
  49943. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49944. */
  49945. export enum SwitchInput {
  49946. /** B */
  49947. B = 0,
  49948. /** A */
  49949. A = 1,
  49950. /** Y */
  49951. Y = 2,
  49952. /** X */
  49953. X = 3,
  49954. /** L */
  49955. L = 4,
  49956. /** R */
  49957. R = 5,
  49958. /** ZL */
  49959. ZL = 6,
  49960. /** ZR */
  49961. ZR = 7,
  49962. /** Minus */
  49963. Minus = 8,
  49964. /** Plus */
  49965. Plus = 9,
  49966. /** LS */
  49967. LS = 10,
  49968. /** RS */
  49969. RS = 11,
  49970. /** DPadUp */
  49971. DPadUp = 12,
  49972. /** DPadDown */
  49973. DPadDown = 13,
  49974. /** DPadLeft */
  49975. DPadLeft = 14,
  49976. /** DRight */
  49977. DPadRight = 15,
  49978. /** Home */
  49979. Home = 16,
  49980. /** Capture */
  49981. Capture = 17,
  49982. /** LStickXAxis */
  49983. LStickXAxis = 18,
  49984. /** LStickYAxis */
  49985. LStickYAxis = 19,
  49986. /** RStickXAxis */
  49987. RStickXAxis = 20,
  49988. /** RStickYAxis */
  49989. RStickYAxis = 21
  49990. }
  49991. }
  49992. declare module BABYLON {
  49993. /**
  49994. * This class will take all inputs from Keyboard, Pointer, and
  49995. * any Gamepads and provide a polling system that all devices
  49996. * will use. This class assumes that there will only be one
  49997. * pointer device and one keyboard.
  49998. */
  49999. export class DeviceInputSystem implements IDisposable {
  50000. /**
  50001. * Callback to be triggered when a device is connected
  50002. */
  50003. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50004. /**
  50005. * Callback to be triggered when a device is disconnected
  50006. */
  50007. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50008. /**
  50009. * Callback to be triggered when event driven input is updated
  50010. */
  50011. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50012. private _inputs;
  50013. private _gamepads;
  50014. private _keyboardActive;
  50015. private _pointerActive;
  50016. private _elementToAttachTo;
  50017. private _keyboardDownEvent;
  50018. private _keyboardUpEvent;
  50019. private _pointerMoveEvent;
  50020. private _pointerDownEvent;
  50021. private _pointerUpEvent;
  50022. private _gamepadConnectedEvent;
  50023. private _gamepadDisconnectedEvent;
  50024. private static _MAX_KEYCODES;
  50025. private static _MAX_POINTER_INPUTS;
  50026. private constructor();
  50027. /**
  50028. * Creates a new DeviceInputSystem instance
  50029. * @param engine Engine to pull input element from
  50030. * @returns The new instance
  50031. */
  50032. static Create(engine: Engine): DeviceInputSystem;
  50033. /**
  50034. * Checks for current device input value, given an id and input index
  50035. * @param deviceName Id of connected device
  50036. * @param inputIndex Index of device input
  50037. * @returns Current value of input
  50038. */
  50039. /**
  50040. * Checks for current device input value, given an id and input index
  50041. * @param deviceType Enum specifiying device type
  50042. * @param deviceSlot "Slot" or index that device is referenced in
  50043. * @param inputIndex Id of input to be checked
  50044. * @returns Current value of input
  50045. */
  50046. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50047. /**
  50048. * Dispose of all the eventlisteners
  50049. */
  50050. dispose(): void;
  50051. /**
  50052. * Add device and inputs to device array
  50053. * @param deviceType Enum specifiying device type
  50054. * @param deviceSlot "Slot" or index that device is referenced in
  50055. * @param numberOfInputs Number of input entries to create for given device
  50056. */
  50057. private _registerDevice;
  50058. /**
  50059. * Given a specific device name, remove that device from the device map
  50060. * @param deviceType Enum specifiying device type
  50061. * @param deviceSlot "Slot" or index that device is referenced in
  50062. */
  50063. private _unregisterDevice;
  50064. /**
  50065. * Handle all actions that come from keyboard interaction
  50066. */
  50067. private _handleKeyActions;
  50068. /**
  50069. * Handle all actions that come from pointer interaction
  50070. */
  50071. private _handlePointerActions;
  50072. /**
  50073. * Handle all actions that come from gamepad interaction
  50074. */
  50075. private _handleGamepadActions;
  50076. /**
  50077. * Update all non-event based devices with each frame
  50078. * @param deviceType Enum specifiying device type
  50079. * @param deviceSlot "Slot" or index that device is referenced in
  50080. * @param inputIndex Id of input to be checked
  50081. */
  50082. private _updateDevice;
  50083. /**
  50084. * Gets DeviceType from the device name
  50085. * @param deviceName Name of Device from DeviceInputSystem
  50086. * @returns DeviceType enum value
  50087. */
  50088. private _getGamepadDeviceType;
  50089. }
  50090. }
  50091. declare module BABYLON {
  50092. /**
  50093. * Type to handle enforcement of inputs
  50094. */
  50095. 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;
  50096. }
  50097. declare module BABYLON {
  50098. /**
  50099. * Class that handles all input for a specific device
  50100. */
  50101. export class DeviceSource<T extends DeviceType> {
  50102. /** Type of device */
  50103. readonly deviceType: DeviceType;
  50104. /** "Slot" or index that device is referenced in */
  50105. readonly deviceSlot: number;
  50106. /**
  50107. * Observable to handle device input changes per device
  50108. */
  50109. readonly onInputChangedObservable: Observable<{
  50110. inputIndex: DeviceInput<T>;
  50111. previousState: Nullable<number>;
  50112. currentState: Nullable<number>;
  50113. }>;
  50114. private readonly _deviceInputSystem;
  50115. /**
  50116. * Default Constructor
  50117. * @param deviceInputSystem Reference to DeviceInputSystem
  50118. * @param deviceType Type of device
  50119. * @param deviceSlot "Slot" or index that device is referenced in
  50120. */
  50121. constructor(deviceInputSystem: DeviceInputSystem,
  50122. /** Type of device */
  50123. deviceType: DeviceType,
  50124. /** "Slot" or index that device is referenced in */
  50125. deviceSlot?: number);
  50126. /**
  50127. * Get input for specific input
  50128. * @param inputIndex index of specific input on device
  50129. * @returns Input value from DeviceInputSystem
  50130. */
  50131. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50132. }
  50133. /**
  50134. * Class to keep track of devices
  50135. */
  50136. export class DeviceSourceManager implements IDisposable {
  50137. /**
  50138. * Observable to be triggered when before a device is connected
  50139. */
  50140. readonly onBeforeDeviceConnectedObservable: Observable<{
  50141. deviceType: DeviceType;
  50142. deviceSlot: number;
  50143. }>;
  50144. /**
  50145. * Observable to be triggered when before a device is disconnected
  50146. */
  50147. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50148. deviceType: DeviceType;
  50149. deviceSlot: number;
  50150. }>;
  50151. /**
  50152. * Observable to be triggered when after a device is connected
  50153. */
  50154. readonly onAfterDeviceConnectedObservable: Observable<{
  50155. deviceType: DeviceType;
  50156. deviceSlot: number;
  50157. }>;
  50158. /**
  50159. * Observable to be triggered when after a device is disconnected
  50160. */
  50161. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50162. deviceType: DeviceType;
  50163. deviceSlot: number;
  50164. }>;
  50165. private readonly _devices;
  50166. private readonly _firstDevice;
  50167. private readonly _deviceInputSystem;
  50168. /**
  50169. * Default Constructor
  50170. * @param engine engine to pull input element from
  50171. */
  50172. constructor(engine: Engine);
  50173. /**
  50174. * Gets a DeviceSource, given a type and slot
  50175. * @param deviceType Enum specifying device type
  50176. * @param deviceSlot "Slot" or index that device is referenced in
  50177. * @returns DeviceSource object
  50178. */
  50179. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50180. /**
  50181. * Gets an array of DeviceSource objects for a given device type
  50182. * @param deviceType Enum specifying device type
  50183. * @returns Array of DeviceSource objects
  50184. */
  50185. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50186. /**
  50187. * Dispose of DeviceInputSystem and other parts
  50188. */
  50189. dispose(): void;
  50190. /**
  50191. * Function to add device name to device list
  50192. * @param deviceType Enum specifying device type
  50193. * @param deviceSlot "Slot" or index that device is referenced in
  50194. */
  50195. private _addDevice;
  50196. /**
  50197. * Function to remove device name to device list
  50198. * @param deviceType Enum specifying device type
  50199. * @param deviceSlot "Slot" or index that device is referenced in
  50200. */
  50201. private _removeDevice;
  50202. /**
  50203. * Updates array storing first connected device of each type
  50204. * @param type Type of Device
  50205. */
  50206. private _updateFirstDevices;
  50207. }
  50208. }
  50209. declare module BABYLON {
  50210. /**
  50211. * Options to create the null engine
  50212. */
  50213. export class NullEngineOptions {
  50214. /**
  50215. * Render width (Default: 512)
  50216. */
  50217. renderWidth: number;
  50218. /**
  50219. * Render height (Default: 256)
  50220. */
  50221. renderHeight: number;
  50222. /**
  50223. * Texture size (Default: 512)
  50224. */
  50225. textureSize: number;
  50226. /**
  50227. * If delta time between frames should be constant
  50228. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50229. */
  50230. deterministicLockstep: boolean;
  50231. /**
  50232. * Maximum about of steps between frames (Default: 4)
  50233. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50234. */
  50235. lockstepMaxSteps: number;
  50236. }
  50237. /**
  50238. * The null engine class provides support for headless version of babylon.js.
  50239. * This can be used in server side scenario or for testing purposes
  50240. */
  50241. export class NullEngine extends Engine {
  50242. private _options;
  50243. /**
  50244. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50245. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50246. * @returns true if engine is in deterministic lock step mode
  50247. */
  50248. isDeterministicLockStep(): boolean;
  50249. /**
  50250. * Gets the max steps when engine is running in deterministic lock step
  50251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50252. * @returns the max steps
  50253. */
  50254. getLockstepMaxSteps(): number;
  50255. /**
  50256. * Gets the current hardware scaling level.
  50257. * By default the hardware scaling level is computed from the window device ratio.
  50258. * 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.
  50259. * @returns a number indicating the current hardware scaling level
  50260. */
  50261. getHardwareScalingLevel(): number;
  50262. constructor(options?: NullEngineOptions);
  50263. /**
  50264. * Creates a vertex buffer
  50265. * @param vertices the data for the vertex buffer
  50266. * @returns the new WebGL static buffer
  50267. */
  50268. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50269. /**
  50270. * Creates a new index buffer
  50271. * @param indices defines the content of the index buffer
  50272. * @param updatable defines if the index buffer must be updatable
  50273. * @returns a new webGL buffer
  50274. */
  50275. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50276. /**
  50277. * Clear the current render buffer or the current render target (if any is set up)
  50278. * @param color defines the color to use
  50279. * @param backBuffer defines if the back buffer must be cleared
  50280. * @param depth defines if the depth buffer must be cleared
  50281. * @param stencil defines if the stencil buffer must be cleared
  50282. */
  50283. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50284. /**
  50285. * Gets the current render width
  50286. * @param useScreen defines if screen size must be used (or the current render target if any)
  50287. * @returns a number defining the current render width
  50288. */
  50289. getRenderWidth(useScreen?: boolean): number;
  50290. /**
  50291. * Gets the current render height
  50292. * @param useScreen defines if screen size must be used (or the current render target if any)
  50293. * @returns a number defining the current render height
  50294. */
  50295. getRenderHeight(useScreen?: boolean): number;
  50296. /**
  50297. * Set the WebGL's viewport
  50298. * @param viewport defines the viewport element to be used
  50299. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50300. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50301. */
  50302. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50303. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50304. /**
  50305. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50306. * @param pipelineContext defines the pipeline context to use
  50307. * @param uniformsNames defines the list of uniform names
  50308. * @returns an array of webGL uniform locations
  50309. */
  50310. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50311. /**
  50312. * Gets the lsit of active attributes for a given webGL program
  50313. * @param pipelineContext defines the pipeline context to use
  50314. * @param attributesNames defines the list of attribute names to get
  50315. * @returns an array of indices indicating the offset of each attribute
  50316. */
  50317. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50318. /**
  50319. * Binds an effect to the webGL context
  50320. * @param effect defines the effect to bind
  50321. */
  50322. bindSamplers(effect: Effect): void;
  50323. /**
  50324. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50325. * @param effect defines the effect to activate
  50326. */
  50327. enableEffect(effect: Effect): void;
  50328. /**
  50329. * Set various states to the webGL context
  50330. * @param culling defines backface culling state
  50331. * @param zOffset defines the value to apply to zOffset (0 by default)
  50332. * @param force defines if states must be applied even if cache is up to date
  50333. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50334. */
  50335. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50336. /**
  50337. * Set the value of an uniform to an array of int32
  50338. * @param uniform defines the webGL uniform location where to store the value
  50339. * @param array defines the array of int32 to store
  50340. */
  50341. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50342. /**
  50343. * Set the value of an uniform to an array of int32 (stored as vec2)
  50344. * @param uniform defines the webGL uniform location where to store the value
  50345. * @param array defines the array of int32 to store
  50346. */
  50347. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50348. /**
  50349. * Set the value of an uniform to an array of int32 (stored as vec3)
  50350. * @param uniform defines the webGL uniform location where to store the value
  50351. * @param array defines the array of int32 to store
  50352. */
  50353. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50354. /**
  50355. * Set the value of an uniform to an array of int32 (stored as vec4)
  50356. * @param uniform defines the webGL uniform location where to store the value
  50357. * @param array defines the array of int32 to store
  50358. */
  50359. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50360. /**
  50361. * Set the value of an uniform to an array of float32
  50362. * @param uniform defines the webGL uniform location where to store the value
  50363. * @param array defines the array of float32 to store
  50364. */
  50365. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50366. /**
  50367. * Set the value of an uniform to an array of float32 (stored as vec2)
  50368. * @param uniform defines the webGL uniform location where to store the value
  50369. * @param array defines the array of float32 to store
  50370. */
  50371. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50372. /**
  50373. * Set the value of an uniform to an array of float32 (stored as vec3)
  50374. * @param uniform defines the webGL uniform location where to store the value
  50375. * @param array defines the array of float32 to store
  50376. */
  50377. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50378. /**
  50379. * Set the value of an uniform to an array of float32 (stored as vec4)
  50380. * @param uniform defines the webGL uniform location where to store the value
  50381. * @param array defines the array of float32 to store
  50382. */
  50383. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50384. /**
  50385. * Set the value of an uniform to an array of number
  50386. * @param uniform defines the webGL uniform location where to store the value
  50387. * @param array defines the array of number to store
  50388. */
  50389. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50390. /**
  50391. * Set the value of an uniform to an array of number (stored as vec2)
  50392. * @param uniform defines the webGL uniform location where to store the value
  50393. * @param array defines the array of number to store
  50394. */
  50395. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50396. /**
  50397. * Set the value of an uniform to an array of number (stored as vec3)
  50398. * @param uniform defines the webGL uniform location where to store the value
  50399. * @param array defines the array of number to store
  50400. */
  50401. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50402. /**
  50403. * Set the value of an uniform to an array of number (stored as vec4)
  50404. * @param uniform defines the webGL uniform location where to store the value
  50405. * @param array defines the array of number to store
  50406. */
  50407. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50408. /**
  50409. * Set the value of an uniform to an array of float32 (stored as matrices)
  50410. * @param uniform defines the webGL uniform location where to store the value
  50411. * @param matrices defines the array of float32 to store
  50412. */
  50413. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50414. /**
  50415. * Set the value of an uniform to a matrix (3x3)
  50416. * @param uniform defines the webGL uniform location where to store the value
  50417. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50418. */
  50419. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50420. /**
  50421. * Set the value of an uniform to a matrix (2x2)
  50422. * @param uniform defines the webGL uniform location where to store the value
  50423. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50424. */
  50425. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50426. /**
  50427. * Set the value of an uniform to a number (float)
  50428. * @param uniform defines the webGL uniform location where to store the value
  50429. * @param value defines the float number to store
  50430. */
  50431. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50432. /**
  50433. * Set the value of an uniform to a vec2
  50434. * @param uniform defines the webGL uniform location where to store the value
  50435. * @param x defines the 1st component of the value
  50436. * @param y defines the 2nd component of the value
  50437. */
  50438. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50439. /**
  50440. * Set the value of an uniform to a vec3
  50441. * @param uniform defines the webGL uniform location where to store the value
  50442. * @param x defines the 1st component of the value
  50443. * @param y defines the 2nd component of the value
  50444. * @param z defines the 3rd component of the value
  50445. */
  50446. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50447. /**
  50448. * Set the value of an uniform to a boolean
  50449. * @param uniform defines the webGL uniform location where to store the value
  50450. * @param bool defines the boolean to store
  50451. */
  50452. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50453. /**
  50454. * Set the value of an uniform to a vec4
  50455. * @param uniform defines the webGL uniform location where to store the value
  50456. * @param x defines the 1st component of the value
  50457. * @param y defines the 2nd component of the value
  50458. * @param z defines the 3rd component of the value
  50459. * @param w defines the 4th component of the value
  50460. */
  50461. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50462. /**
  50463. * Sets the current alpha mode
  50464. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50465. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50466. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50467. */
  50468. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50469. /**
  50470. * Bind webGl buffers directly to the webGL context
  50471. * @param vertexBuffers defines the vertex buffer to bind
  50472. * @param indexBuffer defines the index buffer to bind
  50473. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50474. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50475. * @param effect defines the effect associated with the vertex buffer
  50476. */
  50477. bindBuffers(vertexBuffers: {
  50478. [key: string]: VertexBuffer;
  50479. }, indexBuffer: DataBuffer, effect: Effect): void;
  50480. /**
  50481. * Force the entire cache to be cleared
  50482. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50483. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50484. */
  50485. wipeCaches(bruteForce?: boolean): void;
  50486. /**
  50487. * Send a draw order
  50488. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50489. * @param indexStart defines the starting index
  50490. * @param indexCount defines the number of index to draw
  50491. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50492. */
  50493. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50494. /**
  50495. * Draw a list of indexed primitives
  50496. * @param fillMode defines the primitive to use
  50497. * @param indexStart defines the starting index
  50498. * @param indexCount defines the number of index to draw
  50499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50500. */
  50501. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50502. /**
  50503. * Draw a list of unindexed primitives
  50504. * @param fillMode defines the primitive to use
  50505. * @param verticesStart defines the index of first vertex to draw
  50506. * @param verticesCount defines the count of vertices to draw
  50507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50508. */
  50509. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50510. /** @hidden */
  50511. _createTexture(): WebGLTexture;
  50512. /** @hidden */
  50513. _releaseTexture(texture: InternalTexture): void;
  50514. /**
  50515. * Usually called from Texture.ts.
  50516. * Passed information to create a WebGLTexture
  50517. * @param urlArg defines a value which contains one of the following:
  50518. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50519. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50520. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50522. * @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)
  50523. * @param scene needed for loading to the correct scene
  50524. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50525. * @param onLoad optional callback to be called upon successful completion
  50526. * @param onError optional callback to be called upon failure
  50527. * @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
  50528. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50529. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50530. * @param forcedExtension defines the extension to use to pick the right loader
  50531. * @param mimeType defines an optional mime type
  50532. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50533. */
  50534. 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;
  50535. /**
  50536. * Creates a new render target texture
  50537. * @param size defines the size of the texture
  50538. * @param options defines the options used to create the texture
  50539. * @returns a new render target texture stored in an InternalTexture
  50540. */
  50541. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50542. /**
  50543. * Update the sampling mode of a given texture
  50544. * @param samplingMode defines the required sampling mode
  50545. * @param texture defines the texture to update
  50546. */
  50547. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50548. /**
  50549. * Binds the frame buffer to the specified texture.
  50550. * @param texture The texture to render to or null for the default canvas
  50551. * @param faceIndex The face of the texture to render to in case of cube texture
  50552. * @param requiredWidth The width of the target to render to
  50553. * @param requiredHeight The height of the target to render to
  50554. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50555. * @param lodLevel defines le lod level to bind to the frame buffer
  50556. */
  50557. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50558. /**
  50559. * Unbind the current render target texture from the webGL context
  50560. * @param texture defines the render target texture to unbind
  50561. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50562. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50563. */
  50564. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50565. /**
  50566. * Creates a dynamic vertex buffer
  50567. * @param vertices the data for the dynamic vertex buffer
  50568. * @returns the new WebGL dynamic buffer
  50569. */
  50570. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50571. /**
  50572. * Update the content of a dynamic texture
  50573. * @param texture defines the texture to update
  50574. * @param canvas defines the canvas containing the source
  50575. * @param invertY defines if data must be stored with Y axis inverted
  50576. * @param premulAlpha defines if alpha is stored as premultiplied
  50577. * @param format defines the format of the data
  50578. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50579. */
  50580. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50581. /**
  50582. * Gets a boolean indicating if all created effects are ready
  50583. * @returns true if all effects are ready
  50584. */
  50585. areAllEffectsReady(): boolean;
  50586. /**
  50587. * @hidden
  50588. * Get the current error code of the webGL context
  50589. * @returns the error code
  50590. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50591. */
  50592. getError(): number;
  50593. /** @hidden */
  50594. _getUnpackAlignement(): number;
  50595. /** @hidden */
  50596. _unpackFlipY(value: boolean): void;
  50597. /**
  50598. * Update a dynamic index buffer
  50599. * @param indexBuffer defines the target index buffer
  50600. * @param indices defines the data to update
  50601. * @param offset defines the offset in the target index buffer where update should start
  50602. */
  50603. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50604. /**
  50605. * Updates a dynamic vertex buffer.
  50606. * @param vertexBuffer the vertex buffer to update
  50607. * @param vertices the data used to update the vertex buffer
  50608. * @param byteOffset the byte offset of the data (optional)
  50609. * @param byteLength the byte length of the data (optional)
  50610. */
  50611. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50612. /** @hidden */
  50613. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50614. /** @hidden */
  50615. _bindTexture(channel: number, texture: InternalTexture): void;
  50616. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50617. /**
  50618. * 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
  50619. */
  50620. releaseEffects(): void;
  50621. displayLoadingUI(): void;
  50622. hideLoadingUI(): void;
  50623. /** @hidden */
  50624. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50625. /** @hidden */
  50626. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50627. /** @hidden */
  50628. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50629. /** @hidden */
  50630. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50631. }
  50632. }
  50633. declare module BABYLON {
  50634. /**
  50635. * @hidden
  50636. **/
  50637. export class _TimeToken {
  50638. _startTimeQuery: Nullable<WebGLQuery>;
  50639. _endTimeQuery: Nullable<WebGLQuery>;
  50640. _timeElapsedQuery: Nullable<WebGLQuery>;
  50641. _timeElapsedQueryEnded: boolean;
  50642. }
  50643. }
  50644. declare module BABYLON {
  50645. /** @hidden */
  50646. export class _OcclusionDataStorage {
  50647. /** @hidden */
  50648. occlusionInternalRetryCounter: number;
  50649. /** @hidden */
  50650. isOcclusionQueryInProgress: boolean;
  50651. /** @hidden */
  50652. isOccluded: boolean;
  50653. /** @hidden */
  50654. occlusionRetryCount: number;
  50655. /** @hidden */
  50656. occlusionType: number;
  50657. /** @hidden */
  50658. occlusionQueryAlgorithmType: number;
  50659. }
  50660. interface Engine {
  50661. /**
  50662. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50663. * @return the new query
  50664. */
  50665. createQuery(): WebGLQuery;
  50666. /**
  50667. * Delete and release a webGL query
  50668. * @param query defines the query to delete
  50669. * @return the current engine
  50670. */
  50671. deleteQuery(query: WebGLQuery): Engine;
  50672. /**
  50673. * Check if a given query has resolved and got its value
  50674. * @param query defines the query to check
  50675. * @returns true if the query got its value
  50676. */
  50677. isQueryResultAvailable(query: WebGLQuery): boolean;
  50678. /**
  50679. * Gets the value of a given query
  50680. * @param query defines the query to check
  50681. * @returns the value of the query
  50682. */
  50683. getQueryResult(query: WebGLQuery): number;
  50684. /**
  50685. * Initiates an occlusion query
  50686. * @param algorithmType defines the algorithm to use
  50687. * @param query defines the query to use
  50688. * @returns the current engine
  50689. * @see http://doc.babylonjs.com/features/occlusionquery
  50690. */
  50691. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50692. /**
  50693. * Ends an occlusion query
  50694. * @see http://doc.babylonjs.com/features/occlusionquery
  50695. * @param algorithmType defines the algorithm to use
  50696. * @returns the current engine
  50697. */
  50698. endOcclusionQuery(algorithmType: number): Engine;
  50699. /**
  50700. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50701. * Please note that only one query can be issued at a time
  50702. * @returns a time token used to track the time span
  50703. */
  50704. startTimeQuery(): Nullable<_TimeToken>;
  50705. /**
  50706. * Ends a time query
  50707. * @param token defines the token used to measure the time span
  50708. * @returns the time spent (in ns)
  50709. */
  50710. endTimeQuery(token: _TimeToken): int;
  50711. /** @hidden */
  50712. _currentNonTimestampToken: Nullable<_TimeToken>;
  50713. /** @hidden */
  50714. _createTimeQuery(): WebGLQuery;
  50715. /** @hidden */
  50716. _deleteTimeQuery(query: WebGLQuery): void;
  50717. /** @hidden */
  50718. _getGlAlgorithmType(algorithmType: number): number;
  50719. /** @hidden */
  50720. _getTimeQueryResult(query: WebGLQuery): any;
  50721. /** @hidden */
  50722. _getTimeQueryAvailability(query: WebGLQuery): any;
  50723. }
  50724. interface AbstractMesh {
  50725. /**
  50726. * Backing filed
  50727. * @hidden
  50728. */
  50729. __occlusionDataStorage: _OcclusionDataStorage;
  50730. /**
  50731. * Access property
  50732. * @hidden
  50733. */
  50734. _occlusionDataStorage: _OcclusionDataStorage;
  50735. /**
  50736. * 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.
  50737. * The default value is -1 which means don't break the query and wait till the result
  50738. * @see http://doc.babylonjs.com/features/occlusionquery
  50739. */
  50740. occlusionRetryCount: number;
  50741. /**
  50742. * 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:
  50743. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50744. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50745. * * 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.
  50746. * @see http://doc.babylonjs.com/features/occlusionquery
  50747. */
  50748. occlusionType: number;
  50749. /**
  50750. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50751. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50752. * * 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.
  50753. * @see http://doc.babylonjs.com/features/occlusionquery
  50754. */
  50755. occlusionQueryAlgorithmType: number;
  50756. /**
  50757. * 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
  50758. * @see http://doc.babylonjs.com/features/occlusionquery
  50759. */
  50760. isOccluded: boolean;
  50761. /**
  50762. * Flag to check the progress status of the query
  50763. * @see http://doc.babylonjs.com/features/occlusionquery
  50764. */
  50765. isOcclusionQueryInProgress: boolean;
  50766. }
  50767. }
  50768. declare module BABYLON {
  50769. /** @hidden */
  50770. export var _forceTransformFeedbackToBundle: boolean;
  50771. interface Engine {
  50772. /**
  50773. * Creates a webGL transform feedback object
  50774. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50775. * @returns the webGL transform feedback object
  50776. */
  50777. createTransformFeedback(): WebGLTransformFeedback;
  50778. /**
  50779. * Delete a webGL transform feedback object
  50780. * @param value defines the webGL transform feedback object to delete
  50781. */
  50782. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50783. /**
  50784. * Bind a webGL transform feedback object to the webgl context
  50785. * @param value defines the webGL transform feedback object to bind
  50786. */
  50787. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50788. /**
  50789. * Begins a transform feedback operation
  50790. * @param usePoints defines if points or triangles must be used
  50791. */
  50792. beginTransformFeedback(usePoints: boolean): void;
  50793. /**
  50794. * Ends a transform feedback operation
  50795. */
  50796. endTransformFeedback(): void;
  50797. /**
  50798. * Specify the varyings to use with transform feedback
  50799. * @param program defines the associated webGL program
  50800. * @param value defines the list of strings representing the varying names
  50801. */
  50802. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50803. /**
  50804. * Bind a webGL buffer for a transform feedback operation
  50805. * @param value defines the webGL buffer to bind
  50806. */
  50807. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50808. }
  50809. }
  50810. declare module BABYLON {
  50811. /**
  50812. * Creation options of the multi render target texture.
  50813. */
  50814. export interface IMultiRenderTargetOptions {
  50815. /**
  50816. * Define if the texture needs to create mip maps after render.
  50817. */
  50818. generateMipMaps?: boolean;
  50819. /**
  50820. * Define the types of all the draw buffers we want to create
  50821. */
  50822. types?: number[];
  50823. /**
  50824. * Define the sampling modes of all the draw buffers we want to create
  50825. */
  50826. samplingModes?: number[];
  50827. /**
  50828. * Define if a depth buffer is required
  50829. */
  50830. generateDepthBuffer?: boolean;
  50831. /**
  50832. * Define if a stencil buffer is required
  50833. */
  50834. generateStencilBuffer?: boolean;
  50835. /**
  50836. * Define if a depth texture is required instead of a depth buffer
  50837. */
  50838. generateDepthTexture?: boolean;
  50839. /**
  50840. * Define the number of desired draw buffers
  50841. */
  50842. textureCount?: number;
  50843. /**
  50844. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50845. */
  50846. doNotChangeAspectRatio?: boolean;
  50847. /**
  50848. * Define the default type of the buffers we are creating
  50849. */
  50850. defaultType?: number;
  50851. }
  50852. /**
  50853. * A multi render target, like a render target provides the ability to render to a texture.
  50854. * Unlike the render target, it can render to several draw buffers in one draw.
  50855. * This is specially interesting in deferred rendering or for any effects requiring more than
  50856. * just one color from a single pass.
  50857. */
  50858. export class MultiRenderTarget extends RenderTargetTexture {
  50859. private _internalTextures;
  50860. private _textures;
  50861. private _multiRenderTargetOptions;
  50862. /**
  50863. * Get if draw buffers are currently supported by the used hardware and browser.
  50864. */
  50865. get isSupported(): boolean;
  50866. /**
  50867. * Get the list of textures generated by the multi render target.
  50868. */
  50869. get textures(): Texture[];
  50870. /**
  50871. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50872. */
  50873. get depthTexture(): Texture;
  50874. /**
  50875. * Set the wrapping mode on U of all the textures we are rendering to.
  50876. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50877. */
  50878. set wrapU(wrap: number);
  50879. /**
  50880. * Set the wrapping mode on V of all the textures we are rendering to.
  50881. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50882. */
  50883. set wrapV(wrap: number);
  50884. /**
  50885. * Instantiate a new multi render target texture.
  50886. * A multi render target, like a render target provides the ability to render to a texture.
  50887. * Unlike the render target, it can render to several draw buffers in one draw.
  50888. * This is specially interesting in deferred rendering or for any effects requiring more than
  50889. * just one color from a single pass.
  50890. * @param name Define the name of the texture
  50891. * @param size Define the size of the buffers to render to
  50892. * @param count Define the number of target we are rendering into
  50893. * @param scene Define the scene the texture belongs to
  50894. * @param options Define the options used to create the multi render target
  50895. */
  50896. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50897. /** @hidden */
  50898. _rebuild(): void;
  50899. private _createInternalTextures;
  50900. private _createTextures;
  50901. /**
  50902. * Define the number of samples used if MSAA is enabled.
  50903. */
  50904. get samples(): number;
  50905. set samples(value: number);
  50906. /**
  50907. * Resize all the textures in the multi render target.
  50908. * Be carrefull as it will recreate all the data in the new texture.
  50909. * @param size Define the new size
  50910. */
  50911. resize(size: any): void;
  50912. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50913. /**
  50914. * Dispose the render targets and their associated resources
  50915. */
  50916. dispose(): void;
  50917. /**
  50918. * Release all the underlying texture used as draw buffers.
  50919. */
  50920. releaseInternalTextures(): void;
  50921. }
  50922. }
  50923. declare module BABYLON {
  50924. interface ThinEngine {
  50925. /**
  50926. * Unbind a list of render target textures from the webGL context
  50927. * This is used only when drawBuffer extension or webGL2 are active
  50928. * @param textures defines the render target textures to unbind
  50929. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50930. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50931. */
  50932. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50933. /**
  50934. * Create a multi render target texture
  50935. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50936. * @param size defines the size of the texture
  50937. * @param options defines the creation options
  50938. * @returns the cube texture as an InternalTexture
  50939. */
  50940. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50941. /**
  50942. * Update the sample count for a given multiple render target texture
  50943. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50944. * @param textures defines the textures to update
  50945. * @param samples defines the sample count to set
  50946. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50947. */
  50948. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50949. }
  50950. }
  50951. declare module BABYLON {
  50952. /**
  50953. * Class used to define an additional view for the engine
  50954. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50955. */
  50956. export class EngineView {
  50957. /** Defines the canvas where to render the view */
  50958. target: HTMLCanvasElement;
  50959. /** Defines an optional camera used to render the view (will use active camera else) */
  50960. camera?: Camera;
  50961. }
  50962. interface Engine {
  50963. /**
  50964. * Gets or sets the HTML element to use for attaching events
  50965. */
  50966. inputElement: Nullable<HTMLElement>;
  50967. /**
  50968. * Gets the current engine view
  50969. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50970. */
  50971. activeView: Nullable<EngineView>;
  50972. /** Gets or sets the list of views */
  50973. views: EngineView[];
  50974. /**
  50975. * Register a new child canvas
  50976. * @param canvas defines the canvas to register
  50977. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50978. * @returns the associated view
  50979. */
  50980. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50981. /**
  50982. * Remove a registered child canvas
  50983. * @param canvas defines the canvas to remove
  50984. * @returns the current engine
  50985. */
  50986. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50987. }
  50988. }
  50989. declare module BABYLON {
  50990. interface Engine {
  50991. /** @hidden */
  50992. _excludedCompressedTextures: string[];
  50993. /** @hidden */
  50994. _textureFormatInUse: string;
  50995. /**
  50996. * Gets the list of texture formats supported
  50997. */
  50998. readonly texturesSupported: Array<string>;
  50999. /**
  51000. * Gets the texture format in use
  51001. */
  51002. readonly textureFormatInUse: Nullable<string>;
  51003. /**
  51004. * Set the compressed texture extensions or file names to skip.
  51005. *
  51006. * @param skippedFiles defines the list of those texture files you want to skip
  51007. * Example: [".dds", ".env", "myfile.png"]
  51008. */
  51009. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51010. /**
  51011. * Set the compressed texture format to use, based on the formats you have, and the formats
  51012. * supported by the hardware / browser.
  51013. *
  51014. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51015. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51016. * to API arguments needed to compressed textures. This puts the burden on the container
  51017. * generator to house the arcane code for determining these for current & future formats.
  51018. *
  51019. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51020. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51021. *
  51022. * Note: The result of this call is not taken into account when a texture is base64.
  51023. *
  51024. * @param formatsAvailable defines the list of those format families you have created
  51025. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51026. *
  51027. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51028. * @returns The extension selected.
  51029. */
  51030. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51031. }
  51032. }
  51033. declare module BABYLON {
  51034. /**
  51035. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51036. */
  51037. export interface CubeMapInfo {
  51038. /**
  51039. * The pixel array for the front face.
  51040. * This is stored in format, left to right, up to down format.
  51041. */
  51042. front: Nullable<ArrayBufferView>;
  51043. /**
  51044. * The pixel array for the back face.
  51045. * This is stored in format, left to right, up to down format.
  51046. */
  51047. back: Nullable<ArrayBufferView>;
  51048. /**
  51049. * The pixel array for the left face.
  51050. * This is stored in format, left to right, up to down format.
  51051. */
  51052. left: Nullable<ArrayBufferView>;
  51053. /**
  51054. * The pixel array for the right face.
  51055. * This is stored in format, left to right, up to down format.
  51056. */
  51057. right: Nullable<ArrayBufferView>;
  51058. /**
  51059. * The pixel array for the up face.
  51060. * This is stored in format, left to right, up to down format.
  51061. */
  51062. up: Nullable<ArrayBufferView>;
  51063. /**
  51064. * The pixel array for the down face.
  51065. * This is stored in format, left to right, up to down format.
  51066. */
  51067. down: Nullable<ArrayBufferView>;
  51068. /**
  51069. * The size of the cubemap stored.
  51070. *
  51071. * Each faces will be size * size pixels.
  51072. */
  51073. size: number;
  51074. /**
  51075. * The format of the texture.
  51076. *
  51077. * RGBA, RGB.
  51078. */
  51079. format: number;
  51080. /**
  51081. * The type of the texture data.
  51082. *
  51083. * UNSIGNED_INT, FLOAT.
  51084. */
  51085. type: number;
  51086. /**
  51087. * Specifies whether the texture is in gamma space.
  51088. */
  51089. gammaSpace: boolean;
  51090. }
  51091. /**
  51092. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51093. */
  51094. export class PanoramaToCubeMapTools {
  51095. private static FACE_LEFT;
  51096. private static FACE_RIGHT;
  51097. private static FACE_FRONT;
  51098. private static FACE_BACK;
  51099. private static FACE_DOWN;
  51100. private static FACE_UP;
  51101. /**
  51102. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51103. *
  51104. * @param float32Array The source data.
  51105. * @param inputWidth The width of the input panorama.
  51106. * @param inputHeight The height of the input panorama.
  51107. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51108. * @return The cubemap data
  51109. */
  51110. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51111. private static CreateCubemapTexture;
  51112. private static CalcProjectionSpherical;
  51113. }
  51114. }
  51115. declare module BABYLON {
  51116. /**
  51117. * Helper class dealing with the extraction of spherical polynomial dataArray
  51118. * from a cube map.
  51119. */
  51120. export class CubeMapToSphericalPolynomialTools {
  51121. private static FileFaces;
  51122. /**
  51123. * Converts a texture to the according Spherical Polynomial data.
  51124. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51125. *
  51126. * @param texture The texture to extract the information from.
  51127. * @return The Spherical Polynomial data.
  51128. */
  51129. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51130. /**
  51131. * Converts a cubemap to the according Spherical Polynomial data.
  51132. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51133. *
  51134. * @param cubeInfo The Cube map to extract the information from.
  51135. * @return The Spherical Polynomial data.
  51136. */
  51137. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51138. }
  51139. }
  51140. declare module BABYLON {
  51141. interface BaseTexture {
  51142. /**
  51143. * Get the polynomial representation of the texture data.
  51144. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51145. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51146. */
  51147. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51148. }
  51149. }
  51150. declare module BABYLON {
  51151. /** @hidden */
  51152. export var rgbdEncodePixelShader: {
  51153. name: string;
  51154. shader: string;
  51155. };
  51156. }
  51157. declare module BABYLON {
  51158. /** @hidden */
  51159. export var rgbdDecodePixelShader: {
  51160. name: string;
  51161. shader: string;
  51162. };
  51163. }
  51164. declare module BABYLON {
  51165. /**
  51166. * Raw texture data and descriptor sufficient for WebGL texture upload
  51167. */
  51168. export interface EnvironmentTextureInfo {
  51169. /**
  51170. * Version of the environment map
  51171. */
  51172. version: number;
  51173. /**
  51174. * Width of image
  51175. */
  51176. width: number;
  51177. /**
  51178. * Irradiance information stored in the file.
  51179. */
  51180. irradiance: any;
  51181. /**
  51182. * Specular information stored in the file.
  51183. */
  51184. specular: any;
  51185. }
  51186. /**
  51187. * Defines One Image in the file. It requires only the position in the file
  51188. * as well as the length.
  51189. */
  51190. interface BufferImageData {
  51191. /**
  51192. * Length of the image data.
  51193. */
  51194. length: number;
  51195. /**
  51196. * Position of the data from the null terminator delimiting the end of the JSON.
  51197. */
  51198. position: number;
  51199. }
  51200. /**
  51201. * Defines the specular data enclosed in the file.
  51202. * This corresponds to the version 1 of the data.
  51203. */
  51204. export interface EnvironmentTextureSpecularInfoV1 {
  51205. /**
  51206. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51207. */
  51208. specularDataPosition?: number;
  51209. /**
  51210. * This contains all the images data needed to reconstruct the cubemap.
  51211. */
  51212. mipmaps: Array<BufferImageData>;
  51213. /**
  51214. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51215. */
  51216. lodGenerationScale: number;
  51217. }
  51218. /**
  51219. * Sets of helpers addressing the serialization and deserialization of environment texture
  51220. * stored in a BabylonJS env file.
  51221. * Those files are usually stored as .env files.
  51222. */
  51223. export class EnvironmentTextureTools {
  51224. /**
  51225. * Magic number identifying the env file.
  51226. */
  51227. private static _MagicBytes;
  51228. /**
  51229. * Gets the environment info from an env file.
  51230. * @param data The array buffer containing the .env bytes.
  51231. * @returns the environment file info (the json header) if successfully parsed.
  51232. */
  51233. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51234. /**
  51235. * Creates an environment texture from a loaded cube texture.
  51236. * @param texture defines the cube texture to convert in env file
  51237. * @return a promise containing the environment data if succesfull.
  51238. */
  51239. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51240. /**
  51241. * Creates a JSON representation of the spherical data.
  51242. * @param texture defines the texture containing the polynomials
  51243. * @return the JSON representation of the spherical info
  51244. */
  51245. private static _CreateEnvTextureIrradiance;
  51246. /**
  51247. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51248. * @param data the image data
  51249. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51250. * @return the views described by info providing access to the underlying buffer
  51251. */
  51252. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51253. /**
  51254. * Uploads the texture info contained in the env file to the GPU.
  51255. * @param texture defines the internal texture to upload to
  51256. * @param data defines the data to load
  51257. * @param info defines the texture info retrieved through the GetEnvInfo method
  51258. * @returns a promise
  51259. */
  51260. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51261. private static _OnImageReadyAsync;
  51262. /**
  51263. * Uploads the levels of image data to the GPU.
  51264. * @param texture defines the internal texture to upload to
  51265. * @param imageData defines the array buffer views of image data [mipmap][face]
  51266. * @returns a promise
  51267. */
  51268. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51269. /**
  51270. * Uploads spherical polynomials information to the texture.
  51271. * @param texture defines the texture we are trying to upload the information to
  51272. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51273. */
  51274. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51275. /** @hidden */
  51276. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51277. }
  51278. }
  51279. declare module BABYLON {
  51280. /** @hidden */
  51281. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51282. private _genericAttributeLocation;
  51283. private _varyingLocationCount;
  51284. private _varyingLocationMap;
  51285. private _replacements;
  51286. private _textureCount;
  51287. private _uniforms;
  51288. lineProcessor(line: string): string;
  51289. attributeProcessor(attribute: string): string;
  51290. varyingProcessor(varying: string, isFragment: boolean): string;
  51291. uniformProcessor(uniform: string): string;
  51292. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51293. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51294. }
  51295. }
  51296. declare module BABYLON {
  51297. /**
  51298. * Class used to inline functions in shader code
  51299. */
  51300. export class ShaderCodeInliner {
  51301. private static readonly _RegexpFindFunctionNameAndType;
  51302. private _sourceCode;
  51303. private _functionDescr;
  51304. private _numMaxIterations;
  51305. /** Gets or sets the token used to mark the functions to inline */
  51306. inlineToken: string;
  51307. /** Gets or sets the debug mode */
  51308. debug: boolean;
  51309. /** Gets the code after the inlining process */
  51310. get code(): string;
  51311. /**
  51312. * Initializes the inliner
  51313. * @param sourceCode shader code source to inline
  51314. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51315. */
  51316. constructor(sourceCode: string, numMaxIterations?: number);
  51317. /**
  51318. * Start the processing of the shader code
  51319. */
  51320. processCode(): void;
  51321. private _collectFunctions;
  51322. private _processInlining;
  51323. private _extractBetweenMarkers;
  51324. private _skipWhitespaces;
  51325. private _removeComments;
  51326. private _replaceFunctionCallsByCode;
  51327. private _findBackward;
  51328. private _escapeRegExp;
  51329. private _replaceNames;
  51330. }
  51331. }
  51332. declare module BABYLON {
  51333. /**
  51334. * Container for accessors for natively-stored mesh data buffers.
  51335. */
  51336. class NativeDataBuffer extends DataBuffer {
  51337. /**
  51338. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51339. */
  51340. nativeIndexBuffer?: any;
  51341. /**
  51342. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51343. */
  51344. nativeVertexBuffer?: any;
  51345. }
  51346. /** @hidden */
  51347. class NativeTexture extends InternalTexture {
  51348. getInternalTexture(): InternalTexture;
  51349. getViewCount(): number;
  51350. }
  51351. /** @hidden */
  51352. export class NativeEngine extends Engine {
  51353. private readonly _native;
  51354. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51355. private readonly INVALID_HANDLE;
  51356. getHardwareScalingLevel(): number;
  51357. constructor();
  51358. dispose(): void;
  51359. /**
  51360. * Can be used to override the current requestAnimationFrame requester.
  51361. * @hidden
  51362. */
  51363. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51364. /**
  51365. * Override default engine behavior.
  51366. * @param color
  51367. * @param backBuffer
  51368. * @param depth
  51369. * @param stencil
  51370. */
  51371. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51372. /**
  51373. * Gets host document
  51374. * @returns the host document object
  51375. */
  51376. getHostDocument(): Nullable<Document>;
  51377. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51378. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51379. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51380. recordVertexArrayObject(vertexBuffers: {
  51381. [key: string]: VertexBuffer;
  51382. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51383. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51384. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51385. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51386. /**
  51387. * Draw a list of indexed primitives
  51388. * @param fillMode defines the primitive to use
  51389. * @param indexStart defines the starting index
  51390. * @param indexCount defines the number of index to draw
  51391. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51392. */
  51393. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51394. /**
  51395. * Draw a list of unindexed primitives
  51396. * @param fillMode defines the primitive to use
  51397. * @param verticesStart defines the index of first vertex to draw
  51398. * @param verticesCount defines the count of vertices to draw
  51399. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51400. */
  51401. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51402. createPipelineContext(): IPipelineContext;
  51403. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51404. /** @hidden */
  51405. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51406. /** @hidden */
  51407. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51408. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51409. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51410. protected _setProgram(program: WebGLProgram): void;
  51411. _releaseEffect(effect: Effect): void;
  51412. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51413. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51414. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51415. bindSamplers(effect: Effect): void;
  51416. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51417. getRenderWidth(useScreen?: boolean): number;
  51418. getRenderHeight(useScreen?: boolean): number;
  51419. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51420. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51421. /**
  51422. * Set the z offset to apply to current rendering
  51423. * @param value defines the offset to apply
  51424. */
  51425. setZOffset(value: number): void;
  51426. /**
  51427. * Gets the current value of the zOffset
  51428. * @returns the current zOffset state
  51429. */
  51430. getZOffset(): number;
  51431. /**
  51432. * Enable or disable depth buffering
  51433. * @param enable defines the state to set
  51434. */
  51435. setDepthBuffer(enable: boolean): void;
  51436. /**
  51437. * Gets a boolean indicating if depth writing is enabled
  51438. * @returns the current depth writing state
  51439. */
  51440. getDepthWrite(): boolean;
  51441. /**
  51442. * Enable or disable depth writing
  51443. * @param enable defines the state to set
  51444. */
  51445. setDepthWrite(enable: boolean): void;
  51446. /**
  51447. * Enable or disable color writing
  51448. * @param enable defines the state to set
  51449. */
  51450. setColorWrite(enable: boolean): void;
  51451. /**
  51452. * Gets a boolean indicating if color writing is enabled
  51453. * @returns the current color writing state
  51454. */
  51455. getColorWrite(): boolean;
  51456. /**
  51457. * Sets alpha constants used by some alpha blending modes
  51458. * @param r defines the red component
  51459. * @param g defines the green component
  51460. * @param b defines the blue component
  51461. * @param a defines the alpha component
  51462. */
  51463. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51464. /**
  51465. * Sets the current alpha mode
  51466. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51467. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51468. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51469. */
  51470. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51471. /**
  51472. * Gets the current alpha mode
  51473. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51474. * @returns the current alpha mode
  51475. */
  51476. getAlphaMode(): number;
  51477. setInt(uniform: WebGLUniformLocation, int: number): void;
  51478. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51479. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51480. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51481. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51482. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51483. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51484. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51485. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51486. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51487. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51488. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51489. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51490. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51491. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51492. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51493. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51494. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51495. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51496. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51497. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51498. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51499. wipeCaches(bruteForce?: boolean): void;
  51500. _createTexture(): WebGLTexture;
  51501. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51502. /**
  51503. * Usually called from Texture.ts.
  51504. * Passed information to create a WebGLTexture
  51505. * @param url defines a value which contains one of the following:
  51506. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51507. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51508. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51509. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51510. * @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)
  51511. * @param scene needed for loading to the correct scene
  51512. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51513. * @param onLoad optional callback to be called upon successful completion
  51514. * @param onError optional callback to be called upon failure
  51515. * @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
  51516. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51517. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51518. * @param forcedExtension defines the extension to use to pick the right loader
  51519. * @param mimeType defines an optional mime type
  51520. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51521. */
  51522. 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;
  51523. /**
  51524. * Creates a cube texture
  51525. * @param rootUrl defines the url where the files to load is located
  51526. * @param scene defines the current scene
  51527. * @param files defines the list of files to load (1 per face)
  51528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51529. * @param onLoad defines an optional callback raised when the texture is loaded
  51530. * @param onError defines an optional callback raised if there is an issue to load the texture
  51531. * @param format defines the format of the data
  51532. * @param forcedExtension defines the extension to use to pick the right loader
  51533. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51534. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51535. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51536. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51537. * @returns the cube texture as an InternalTexture
  51538. */
  51539. 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;
  51540. private _getSamplingFilter;
  51541. private static _GetNativeTextureFormat;
  51542. createRenderTargetTexture(size: number | {
  51543. width: number;
  51544. height: number;
  51545. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51546. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51547. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51548. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51549. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51550. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51551. /**
  51552. * Updates a dynamic vertex buffer.
  51553. * @param vertexBuffer the vertex buffer to update
  51554. * @param data the data used to update the vertex buffer
  51555. * @param byteOffset the byte offset of the data (optional)
  51556. * @param byteLength the byte length of the data (optional)
  51557. */
  51558. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51559. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51560. private _updateAnisotropicLevel;
  51561. private _getAddressMode;
  51562. /** @hidden */
  51563. _bindTexture(channel: number, texture: InternalTexture): void;
  51564. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51565. releaseEffects(): void;
  51566. /** @hidden */
  51567. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51568. /** @hidden */
  51569. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51570. /** @hidden */
  51571. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51572. /** @hidden */
  51573. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51574. }
  51575. }
  51576. declare module BABYLON {
  51577. /**
  51578. * Gather the list of clipboard event types as constants.
  51579. */
  51580. export class ClipboardEventTypes {
  51581. /**
  51582. * The clipboard event is fired when a copy command is active (pressed).
  51583. */
  51584. static readonly COPY: number;
  51585. /**
  51586. * The clipboard event is fired when a cut command is active (pressed).
  51587. */
  51588. static readonly CUT: number;
  51589. /**
  51590. * The clipboard event is fired when a paste command is active (pressed).
  51591. */
  51592. static readonly PASTE: number;
  51593. }
  51594. /**
  51595. * This class is used to store clipboard related info for the onClipboardObservable event.
  51596. */
  51597. export class ClipboardInfo {
  51598. /**
  51599. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51600. */
  51601. type: number;
  51602. /**
  51603. * Defines the related dom event
  51604. */
  51605. event: ClipboardEvent;
  51606. /**
  51607. *Creates an instance of ClipboardInfo.
  51608. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51609. * @param event Defines the related dom event
  51610. */
  51611. constructor(
  51612. /**
  51613. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51614. */
  51615. type: number,
  51616. /**
  51617. * Defines the related dom event
  51618. */
  51619. event: ClipboardEvent);
  51620. /**
  51621. * Get the clipboard event's type from the keycode.
  51622. * @param keyCode Defines the keyCode for the current keyboard event.
  51623. * @return {number}
  51624. */
  51625. static GetTypeFromCharacter(keyCode: number): number;
  51626. }
  51627. }
  51628. declare module BABYLON {
  51629. /**
  51630. * Google Daydream controller
  51631. */
  51632. export class DaydreamController extends WebVRController {
  51633. /**
  51634. * Base Url for the controller model.
  51635. */
  51636. static MODEL_BASE_URL: string;
  51637. /**
  51638. * File name for the controller model.
  51639. */
  51640. static MODEL_FILENAME: string;
  51641. /**
  51642. * Gamepad Id prefix used to identify Daydream Controller.
  51643. */
  51644. static readonly GAMEPAD_ID_PREFIX: string;
  51645. /**
  51646. * Creates a new DaydreamController from a gamepad
  51647. * @param vrGamepad the gamepad that the controller should be created from
  51648. */
  51649. constructor(vrGamepad: any);
  51650. /**
  51651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51652. * @param scene scene in which to add meshes
  51653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51654. */
  51655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51656. /**
  51657. * Called once for each button that changed state since the last frame
  51658. * @param buttonIdx Which button index changed
  51659. * @param state New state of the button
  51660. * @param changes Which properties on the state changed since last frame
  51661. */
  51662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51663. }
  51664. }
  51665. declare module BABYLON {
  51666. /**
  51667. * Gear VR Controller
  51668. */
  51669. export class GearVRController extends WebVRController {
  51670. /**
  51671. * Base Url for the controller model.
  51672. */
  51673. static MODEL_BASE_URL: string;
  51674. /**
  51675. * File name for the controller model.
  51676. */
  51677. static MODEL_FILENAME: string;
  51678. /**
  51679. * Gamepad Id prefix used to identify this controller.
  51680. */
  51681. static readonly GAMEPAD_ID_PREFIX: string;
  51682. private readonly _buttonIndexToObservableNameMap;
  51683. /**
  51684. * Creates a new GearVRController from a gamepad
  51685. * @param vrGamepad the gamepad that the controller should be created from
  51686. */
  51687. constructor(vrGamepad: any);
  51688. /**
  51689. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51690. * @param scene scene in which to add meshes
  51691. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51692. */
  51693. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51694. /**
  51695. * Called once for each button that changed state since the last frame
  51696. * @param buttonIdx Which button index changed
  51697. * @param state New state of the button
  51698. * @param changes Which properties on the state changed since last frame
  51699. */
  51700. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51701. }
  51702. }
  51703. declare module BABYLON {
  51704. /**
  51705. * Generic Controller
  51706. */
  51707. export class GenericController extends WebVRController {
  51708. /**
  51709. * Base Url for the controller model.
  51710. */
  51711. static readonly MODEL_BASE_URL: string;
  51712. /**
  51713. * File name for the controller model.
  51714. */
  51715. static readonly MODEL_FILENAME: string;
  51716. /**
  51717. * Creates a new GenericController from a gamepad
  51718. * @param vrGamepad the gamepad that the controller should be created from
  51719. */
  51720. constructor(vrGamepad: any);
  51721. /**
  51722. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51723. * @param scene scene in which to add meshes
  51724. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51725. */
  51726. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51727. /**
  51728. * Called once for each button that changed state since the last frame
  51729. * @param buttonIdx Which button index changed
  51730. * @param state New state of the button
  51731. * @param changes Which properties on the state changed since last frame
  51732. */
  51733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51734. }
  51735. }
  51736. declare module BABYLON {
  51737. /**
  51738. * Oculus Touch Controller
  51739. */
  51740. export class OculusTouchController extends WebVRController {
  51741. /**
  51742. * Base Url for the controller model.
  51743. */
  51744. static MODEL_BASE_URL: string;
  51745. /**
  51746. * File name for the left controller model.
  51747. */
  51748. static MODEL_LEFT_FILENAME: string;
  51749. /**
  51750. * File name for the right controller model.
  51751. */
  51752. static MODEL_RIGHT_FILENAME: string;
  51753. /**
  51754. * Base Url for the Quest controller model.
  51755. */
  51756. static QUEST_MODEL_BASE_URL: string;
  51757. /**
  51758. * @hidden
  51759. * If the controllers are running on a device that needs the updated Quest controller models
  51760. */
  51761. static _IsQuest: boolean;
  51762. /**
  51763. * Fired when the secondary trigger on this controller is modified
  51764. */
  51765. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51766. /**
  51767. * Fired when the thumb rest on this controller is modified
  51768. */
  51769. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51770. /**
  51771. * Creates a new OculusTouchController from a gamepad
  51772. * @param vrGamepad the gamepad that the controller should be created from
  51773. */
  51774. constructor(vrGamepad: any);
  51775. /**
  51776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51777. * @param scene scene in which to add meshes
  51778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51779. */
  51780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51781. /**
  51782. * Fired when the A button on this controller is modified
  51783. */
  51784. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51785. /**
  51786. * Fired when the B button on this controller is modified
  51787. */
  51788. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51789. /**
  51790. * Fired when the X button on this controller is modified
  51791. */
  51792. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51793. /**
  51794. * Fired when the Y button on this controller is modified
  51795. */
  51796. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51797. /**
  51798. * Called once for each button that changed state since the last frame
  51799. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51800. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51801. * 2) secondary trigger (same)
  51802. * 3) A (right) X (left), touch, pressed = value
  51803. * 4) B / Y
  51804. * 5) thumb rest
  51805. * @param buttonIdx Which button index changed
  51806. * @param state New state of the button
  51807. * @param changes Which properties on the state changed since last frame
  51808. */
  51809. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51810. }
  51811. }
  51812. declare module BABYLON {
  51813. /**
  51814. * Vive Controller
  51815. */
  51816. export class ViveController extends WebVRController {
  51817. /**
  51818. * Base Url for the controller model.
  51819. */
  51820. static MODEL_BASE_URL: string;
  51821. /**
  51822. * File name for the controller model.
  51823. */
  51824. static MODEL_FILENAME: string;
  51825. /**
  51826. * Creates a new ViveController from a gamepad
  51827. * @param vrGamepad the gamepad that the controller should be created from
  51828. */
  51829. constructor(vrGamepad: any);
  51830. /**
  51831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51832. * @param scene scene in which to add meshes
  51833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51834. */
  51835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51836. /**
  51837. * Fired when the left button on this controller is modified
  51838. */
  51839. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51840. /**
  51841. * Fired when the right button on this controller is modified
  51842. */
  51843. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51844. /**
  51845. * Fired when the menu button on this controller is modified
  51846. */
  51847. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51848. /**
  51849. * Called once for each button that changed state since the last frame
  51850. * Vive mapping:
  51851. * 0: touchpad
  51852. * 1: trigger
  51853. * 2: left AND right buttons
  51854. * 3: menu button
  51855. * @param buttonIdx Which button index changed
  51856. * @param state New state of the button
  51857. * @param changes Which properties on the state changed since last frame
  51858. */
  51859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51860. }
  51861. }
  51862. declare module BABYLON {
  51863. /**
  51864. * Defines the WindowsMotionController object that the state of the windows motion controller
  51865. */
  51866. export class WindowsMotionController extends WebVRController {
  51867. /**
  51868. * The base url used to load the left and right controller models
  51869. */
  51870. static MODEL_BASE_URL: string;
  51871. /**
  51872. * The name of the left controller model file
  51873. */
  51874. static MODEL_LEFT_FILENAME: string;
  51875. /**
  51876. * The name of the right controller model file
  51877. */
  51878. static MODEL_RIGHT_FILENAME: string;
  51879. /**
  51880. * The controller name prefix for this controller type
  51881. */
  51882. static readonly GAMEPAD_ID_PREFIX: string;
  51883. /**
  51884. * The controller id pattern for this controller type
  51885. */
  51886. private static readonly GAMEPAD_ID_PATTERN;
  51887. private _loadedMeshInfo;
  51888. protected readonly _mapping: {
  51889. buttons: string[];
  51890. buttonMeshNames: {
  51891. trigger: string;
  51892. menu: string;
  51893. grip: string;
  51894. thumbstick: string;
  51895. trackpad: string;
  51896. };
  51897. buttonObservableNames: {
  51898. trigger: string;
  51899. menu: string;
  51900. grip: string;
  51901. thumbstick: string;
  51902. trackpad: string;
  51903. };
  51904. axisMeshNames: string[];
  51905. pointingPoseMeshName: string;
  51906. };
  51907. /**
  51908. * Fired when the trackpad on this controller is clicked
  51909. */
  51910. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51911. /**
  51912. * Fired when the trackpad on this controller is modified
  51913. */
  51914. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51915. /**
  51916. * The current x and y values of this controller's trackpad
  51917. */
  51918. trackpad: StickValues;
  51919. /**
  51920. * Creates a new WindowsMotionController from a gamepad
  51921. * @param vrGamepad the gamepad that the controller should be created from
  51922. */
  51923. constructor(vrGamepad: any);
  51924. /**
  51925. * Fired when the trigger on this controller is modified
  51926. */
  51927. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51928. /**
  51929. * Fired when the menu button on this controller is modified
  51930. */
  51931. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51932. /**
  51933. * Fired when the grip button on this controller is modified
  51934. */
  51935. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51936. /**
  51937. * Fired when the thumbstick button on this controller is modified
  51938. */
  51939. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51940. /**
  51941. * Fired when the touchpad button on this controller is modified
  51942. */
  51943. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51944. /**
  51945. * Fired when the touchpad values on this controller are modified
  51946. */
  51947. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51948. protected _updateTrackpad(): void;
  51949. /**
  51950. * Called once per frame by the engine.
  51951. */
  51952. update(): void;
  51953. /**
  51954. * Called once for each button that changed state since the last frame
  51955. * @param buttonIdx Which button index changed
  51956. * @param state New state of the button
  51957. * @param changes Which properties on the state changed since last frame
  51958. */
  51959. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51960. /**
  51961. * Moves the buttons on the controller mesh based on their current state
  51962. * @param buttonName the name of the button to move
  51963. * @param buttonValue the value of the button which determines the buttons new position
  51964. */
  51965. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51966. /**
  51967. * Moves the axis on the controller mesh based on its current state
  51968. * @param axis the index of the axis
  51969. * @param axisValue the value of the axis which determines the meshes new position
  51970. * @hidden
  51971. */
  51972. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51973. /**
  51974. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51975. * @param scene scene in which to add meshes
  51976. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51977. */
  51978. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51979. /**
  51980. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51981. * can be transformed by button presses and axes values, based on this._mapping.
  51982. *
  51983. * @param scene scene in which the meshes exist
  51984. * @param meshes list of meshes that make up the controller model to process
  51985. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51986. */
  51987. private processModel;
  51988. private createMeshInfo;
  51989. /**
  51990. * Gets the ray of the controller in the direction the controller is pointing
  51991. * @param length the length the resulting ray should be
  51992. * @returns a ray in the direction the controller is pointing
  51993. */
  51994. getForwardRay(length?: number): Ray;
  51995. /**
  51996. * Disposes of the controller
  51997. */
  51998. dispose(): void;
  51999. }
  52000. /**
  52001. * This class represents a new windows motion controller in XR.
  52002. */
  52003. export class XRWindowsMotionController extends WindowsMotionController {
  52004. /**
  52005. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52006. */
  52007. protected readonly _mapping: {
  52008. buttons: string[];
  52009. buttonMeshNames: {
  52010. trigger: string;
  52011. menu: string;
  52012. grip: string;
  52013. thumbstick: string;
  52014. trackpad: string;
  52015. };
  52016. buttonObservableNames: {
  52017. trigger: string;
  52018. menu: string;
  52019. grip: string;
  52020. thumbstick: string;
  52021. trackpad: string;
  52022. };
  52023. axisMeshNames: string[];
  52024. pointingPoseMeshName: string;
  52025. };
  52026. /**
  52027. * Construct a new XR-Based windows motion controller
  52028. *
  52029. * @param gamepadInfo the gamepad object from the browser
  52030. */
  52031. constructor(gamepadInfo: any);
  52032. /**
  52033. * holds the thumbstick values (X,Y)
  52034. */
  52035. thumbstickValues: StickValues;
  52036. /**
  52037. * Fired when the thumbstick on this controller is clicked
  52038. */
  52039. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52040. /**
  52041. * Fired when the thumbstick on this controller is modified
  52042. */
  52043. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52044. /**
  52045. * Fired when the touchpad button on this controller is modified
  52046. */
  52047. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52048. /**
  52049. * Fired when the touchpad values on this controller are modified
  52050. */
  52051. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52052. /**
  52053. * Fired when the thumbstick button on this controller is modified
  52054. * here to prevent breaking changes
  52055. */
  52056. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52057. /**
  52058. * updating the thumbstick(!) and not the trackpad.
  52059. * This is named this way due to the difference between WebVR and XR and to avoid
  52060. * changing the parent class.
  52061. */
  52062. protected _updateTrackpad(): void;
  52063. /**
  52064. * Disposes the class with joy
  52065. */
  52066. dispose(): void;
  52067. }
  52068. }
  52069. declare module BABYLON {
  52070. /**
  52071. * Class containing static functions to help procedurally build meshes
  52072. */
  52073. export class PolyhedronBuilder {
  52074. /**
  52075. * Creates a polyhedron mesh
  52076. * * 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
  52077. * * The parameter `size` (positive float, default 1) sets the polygon size
  52078. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52079. * * 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`
  52080. * * 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
  52081. * * 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)`)
  52082. * * 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
  52083. * * 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
  52084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52085. * * 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
  52086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52087. * @param name defines the name of the mesh
  52088. * @param options defines the options used to create the mesh
  52089. * @param scene defines the hosting scene
  52090. * @returns the polyhedron mesh
  52091. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52092. */
  52093. static CreatePolyhedron(name: string, options: {
  52094. type?: number;
  52095. size?: number;
  52096. sizeX?: number;
  52097. sizeY?: number;
  52098. sizeZ?: number;
  52099. custom?: any;
  52100. faceUV?: Vector4[];
  52101. faceColors?: Color4[];
  52102. flat?: boolean;
  52103. updatable?: boolean;
  52104. sideOrientation?: number;
  52105. frontUVs?: Vector4;
  52106. backUVs?: Vector4;
  52107. }, scene?: Nullable<Scene>): Mesh;
  52108. }
  52109. }
  52110. declare module BABYLON {
  52111. /**
  52112. * Gizmo that enables scaling a mesh along 3 axis
  52113. */
  52114. export class ScaleGizmo extends Gizmo {
  52115. /**
  52116. * Internal gizmo used for interactions on the x axis
  52117. */
  52118. xGizmo: AxisScaleGizmo;
  52119. /**
  52120. * Internal gizmo used for interactions on the y axis
  52121. */
  52122. yGizmo: AxisScaleGizmo;
  52123. /**
  52124. * Internal gizmo used for interactions on the z axis
  52125. */
  52126. zGizmo: AxisScaleGizmo;
  52127. /**
  52128. * Internal gizmo used to scale all axis equally
  52129. */
  52130. uniformScaleGizmo: AxisScaleGizmo;
  52131. private _meshAttached;
  52132. private _updateGizmoRotationToMatchAttachedMesh;
  52133. private _snapDistance;
  52134. private _scaleRatio;
  52135. private _uniformScalingMesh;
  52136. private _octahedron;
  52137. private _sensitivity;
  52138. /** Fires an event when any of it's sub gizmos are dragged */
  52139. onDragStartObservable: Observable<unknown>;
  52140. /** Fires an event when any of it's sub gizmos are released from dragging */
  52141. onDragEndObservable: Observable<unknown>;
  52142. get attachedMesh(): Nullable<AbstractMesh>;
  52143. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52144. /**
  52145. * Creates a ScaleGizmo
  52146. * @param gizmoLayer The utility layer the gizmo will be added to
  52147. */
  52148. constructor(gizmoLayer?: UtilityLayerRenderer);
  52149. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52150. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52151. /**
  52152. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52153. */
  52154. set snapDistance(value: number);
  52155. get snapDistance(): number;
  52156. /**
  52157. * Ratio for the scale of the gizmo (Default: 1)
  52158. */
  52159. set scaleRatio(value: number);
  52160. get scaleRatio(): number;
  52161. /**
  52162. * Sensitivity factor for dragging (Default: 1)
  52163. */
  52164. set sensitivity(value: number);
  52165. get sensitivity(): number;
  52166. /**
  52167. * Disposes of the gizmo
  52168. */
  52169. dispose(): void;
  52170. }
  52171. }
  52172. declare module BABYLON {
  52173. /**
  52174. * Single axis scale gizmo
  52175. */
  52176. export class AxisScaleGizmo extends Gizmo {
  52177. /**
  52178. * Drag behavior responsible for the gizmos dragging interactions
  52179. */
  52180. dragBehavior: PointerDragBehavior;
  52181. private _pointerObserver;
  52182. /**
  52183. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52184. */
  52185. snapDistance: number;
  52186. /**
  52187. * Event that fires each time the gizmo snaps to a new location.
  52188. * * snapDistance is the the change in distance
  52189. */
  52190. onSnapObservable: Observable<{
  52191. snapDistance: number;
  52192. }>;
  52193. /**
  52194. * If the scaling operation should be done on all axis (default: false)
  52195. */
  52196. uniformScaling: boolean;
  52197. /**
  52198. * Custom sensitivity value for the drag strength
  52199. */
  52200. sensitivity: number;
  52201. private _isEnabled;
  52202. private _parent;
  52203. private _arrow;
  52204. private _coloredMaterial;
  52205. private _hoverMaterial;
  52206. /**
  52207. * Creates an AxisScaleGizmo
  52208. * @param gizmoLayer The utility layer the gizmo will be added to
  52209. * @param dragAxis The axis which the gizmo will be able to scale on
  52210. * @param color The color of the gizmo
  52211. */
  52212. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52213. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52214. /**
  52215. * If the gizmo is enabled
  52216. */
  52217. set isEnabled(value: boolean);
  52218. get isEnabled(): boolean;
  52219. /**
  52220. * Disposes of the gizmo
  52221. */
  52222. dispose(): void;
  52223. /**
  52224. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52225. * @param mesh The mesh to replace the default mesh of the gizmo
  52226. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52227. */
  52228. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52229. }
  52230. }
  52231. declare module BABYLON {
  52232. /**
  52233. * Bounding box gizmo
  52234. */
  52235. export class BoundingBoxGizmo extends Gizmo {
  52236. private _lineBoundingBox;
  52237. private _rotateSpheresParent;
  52238. private _scaleBoxesParent;
  52239. private _boundingDimensions;
  52240. private _renderObserver;
  52241. private _pointerObserver;
  52242. private _scaleDragSpeed;
  52243. private _tmpQuaternion;
  52244. private _tmpVector;
  52245. private _tmpRotationMatrix;
  52246. /**
  52247. * 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)
  52248. */
  52249. ignoreChildren: boolean;
  52250. /**
  52251. * 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)
  52252. */
  52253. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52254. /**
  52255. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52256. */
  52257. rotationSphereSize: number;
  52258. /**
  52259. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52260. */
  52261. scaleBoxSize: number;
  52262. /**
  52263. * 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)
  52264. */
  52265. fixedDragMeshScreenSize: boolean;
  52266. /**
  52267. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52268. */
  52269. fixedDragMeshScreenSizeDistanceFactor: number;
  52270. /**
  52271. * Fired when a rotation sphere or scale box is dragged
  52272. */
  52273. onDragStartObservable: Observable<{}>;
  52274. /**
  52275. * Fired when a scale box is dragged
  52276. */
  52277. onScaleBoxDragObservable: Observable<{}>;
  52278. /**
  52279. * Fired when a scale box drag is ended
  52280. */
  52281. onScaleBoxDragEndObservable: Observable<{}>;
  52282. /**
  52283. * Fired when a rotation sphere is dragged
  52284. */
  52285. onRotationSphereDragObservable: Observable<{}>;
  52286. /**
  52287. * Fired when a rotation sphere drag is ended
  52288. */
  52289. onRotationSphereDragEndObservable: Observable<{}>;
  52290. /**
  52291. * 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)
  52292. */
  52293. scalePivot: Nullable<Vector3>;
  52294. /**
  52295. * Mesh used as a pivot to rotate the attached mesh
  52296. */
  52297. private _anchorMesh;
  52298. private _existingMeshScale;
  52299. private _dragMesh;
  52300. private pointerDragBehavior;
  52301. private coloredMaterial;
  52302. private hoverColoredMaterial;
  52303. /**
  52304. * Sets the color of the bounding box gizmo
  52305. * @param color the color to set
  52306. */
  52307. setColor(color: Color3): void;
  52308. /**
  52309. * Creates an BoundingBoxGizmo
  52310. * @param gizmoLayer The utility layer the gizmo will be added to
  52311. * @param color The color of the gizmo
  52312. */
  52313. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52315. private _selectNode;
  52316. /**
  52317. * Updates the bounding box information for the Gizmo
  52318. */
  52319. updateBoundingBox(): void;
  52320. private _updateRotationSpheres;
  52321. private _updateScaleBoxes;
  52322. /**
  52323. * Enables rotation on the specified axis and disables rotation on the others
  52324. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52325. */
  52326. setEnabledRotationAxis(axis: string): void;
  52327. /**
  52328. * Enables/disables scaling
  52329. * @param enable if scaling should be enabled
  52330. * @param homogeneousScaling defines if scaling should only be homogeneous
  52331. */
  52332. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52333. private _updateDummy;
  52334. /**
  52335. * Enables a pointer drag behavior on the bounding box of the gizmo
  52336. */
  52337. enableDragBehavior(): void;
  52338. /**
  52339. * Disposes of the gizmo
  52340. */
  52341. dispose(): void;
  52342. /**
  52343. * 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)
  52344. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52345. * @returns the bounding box mesh with the passed in mesh as a child
  52346. */
  52347. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52348. /**
  52349. * CustomMeshes are not supported by this gizmo
  52350. * @param mesh The mesh to replace the default mesh of the gizmo
  52351. */
  52352. setCustomMesh(mesh: Mesh): void;
  52353. }
  52354. }
  52355. declare module BABYLON {
  52356. /**
  52357. * Single plane rotation gizmo
  52358. */
  52359. export class PlaneRotationGizmo extends Gizmo {
  52360. /**
  52361. * Drag behavior responsible for the gizmos dragging interactions
  52362. */
  52363. dragBehavior: PointerDragBehavior;
  52364. private _pointerObserver;
  52365. /**
  52366. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52367. */
  52368. snapDistance: number;
  52369. /**
  52370. * Event that fires each time the gizmo snaps to a new location.
  52371. * * snapDistance is the the change in distance
  52372. */
  52373. onSnapObservable: Observable<{
  52374. snapDistance: number;
  52375. }>;
  52376. private _isEnabled;
  52377. private _parent;
  52378. /**
  52379. * Creates a PlaneRotationGizmo
  52380. * @param gizmoLayer The utility layer the gizmo will be added to
  52381. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52382. * @param color The color of the gizmo
  52383. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52384. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52385. */
  52386. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52387. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52388. /**
  52389. * If the gizmo is enabled
  52390. */
  52391. set isEnabled(value: boolean);
  52392. get isEnabled(): boolean;
  52393. /**
  52394. * Disposes of the gizmo
  52395. */
  52396. dispose(): void;
  52397. }
  52398. }
  52399. declare module BABYLON {
  52400. /**
  52401. * Gizmo that enables rotating a mesh along 3 axis
  52402. */
  52403. export class RotationGizmo extends Gizmo {
  52404. /**
  52405. * Internal gizmo used for interactions on the x axis
  52406. */
  52407. xGizmo: PlaneRotationGizmo;
  52408. /**
  52409. * Internal gizmo used for interactions on the y axis
  52410. */
  52411. yGizmo: PlaneRotationGizmo;
  52412. /**
  52413. * Internal gizmo used for interactions on the z axis
  52414. */
  52415. zGizmo: PlaneRotationGizmo;
  52416. /** Fires an event when any of it's sub gizmos are dragged */
  52417. onDragStartObservable: Observable<unknown>;
  52418. /** Fires an event when any of it's sub gizmos are released from dragging */
  52419. onDragEndObservable: Observable<unknown>;
  52420. private _meshAttached;
  52421. get attachedMesh(): Nullable<AbstractMesh>;
  52422. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52423. /**
  52424. * Creates a RotationGizmo
  52425. * @param gizmoLayer The utility layer the gizmo will be added to
  52426. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52427. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52428. */
  52429. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52430. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52431. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52432. /**
  52433. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52434. */
  52435. set snapDistance(value: number);
  52436. get snapDistance(): number;
  52437. /**
  52438. * Ratio for the scale of the gizmo (Default: 1)
  52439. */
  52440. set scaleRatio(value: number);
  52441. get scaleRatio(): number;
  52442. /**
  52443. * Disposes of the gizmo
  52444. */
  52445. dispose(): void;
  52446. /**
  52447. * CustomMeshes are not supported by this gizmo
  52448. * @param mesh The mesh to replace the default mesh of the gizmo
  52449. */
  52450. setCustomMesh(mesh: Mesh): void;
  52451. }
  52452. }
  52453. declare module BABYLON {
  52454. /**
  52455. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52456. */
  52457. export class GizmoManager implements IDisposable {
  52458. private scene;
  52459. /**
  52460. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52461. */
  52462. gizmos: {
  52463. positionGizmo: Nullable<PositionGizmo>;
  52464. rotationGizmo: Nullable<RotationGizmo>;
  52465. scaleGizmo: Nullable<ScaleGizmo>;
  52466. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52467. };
  52468. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52469. clearGizmoOnEmptyPointerEvent: boolean;
  52470. /** Fires an event when the manager is attached to a mesh */
  52471. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52472. private _gizmosEnabled;
  52473. private _pointerObserver;
  52474. private _attachedMesh;
  52475. private _boundingBoxColor;
  52476. private _defaultUtilityLayer;
  52477. private _defaultKeepDepthUtilityLayer;
  52478. /**
  52479. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52480. */
  52481. boundingBoxDragBehavior: SixDofDragBehavior;
  52482. /**
  52483. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52484. */
  52485. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52486. /**
  52487. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52488. */
  52489. usePointerToAttachGizmos: boolean;
  52490. /**
  52491. * Utility layer that the bounding box gizmo belongs to
  52492. */
  52493. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52494. /**
  52495. * Utility layer that all gizmos besides bounding box belong to
  52496. */
  52497. get utilityLayer(): UtilityLayerRenderer;
  52498. /**
  52499. * Instatiates a gizmo manager
  52500. * @param scene the scene to overlay the gizmos on top of
  52501. */
  52502. constructor(scene: Scene);
  52503. /**
  52504. * Attaches a set of gizmos to the specified mesh
  52505. * @param mesh The mesh the gizmo's should be attached to
  52506. */
  52507. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52508. /**
  52509. * If the position gizmo is enabled
  52510. */
  52511. set positionGizmoEnabled(value: boolean);
  52512. get positionGizmoEnabled(): boolean;
  52513. /**
  52514. * If the rotation gizmo is enabled
  52515. */
  52516. set rotationGizmoEnabled(value: boolean);
  52517. get rotationGizmoEnabled(): boolean;
  52518. /**
  52519. * If the scale gizmo is enabled
  52520. */
  52521. set scaleGizmoEnabled(value: boolean);
  52522. get scaleGizmoEnabled(): boolean;
  52523. /**
  52524. * If the boundingBox gizmo is enabled
  52525. */
  52526. set boundingBoxGizmoEnabled(value: boolean);
  52527. get boundingBoxGizmoEnabled(): boolean;
  52528. /**
  52529. * Disposes of the gizmo manager
  52530. */
  52531. dispose(): void;
  52532. }
  52533. }
  52534. declare module BABYLON {
  52535. /**
  52536. * A directional light is defined by a direction (what a surprise!).
  52537. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52538. * 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.
  52539. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52540. */
  52541. export class DirectionalLight extends ShadowLight {
  52542. private _shadowFrustumSize;
  52543. /**
  52544. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52545. */
  52546. get shadowFrustumSize(): number;
  52547. /**
  52548. * Specifies a fix frustum size for the shadow generation.
  52549. */
  52550. set shadowFrustumSize(value: number);
  52551. private _shadowOrthoScale;
  52552. /**
  52553. * Gets the shadow projection scale against the optimal computed one.
  52554. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52555. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52556. */
  52557. get shadowOrthoScale(): number;
  52558. /**
  52559. * Sets the shadow projection scale against the optimal computed one.
  52560. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52561. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52562. */
  52563. set shadowOrthoScale(value: number);
  52564. /**
  52565. * Automatically compute the projection matrix to best fit (including all the casters)
  52566. * on each frame.
  52567. */
  52568. autoUpdateExtends: boolean;
  52569. /**
  52570. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52571. * on each frame. autoUpdateExtends must be set to true for this to work
  52572. */
  52573. autoCalcShadowZBounds: boolean;
  52574. private _orthoLeft;
  52575. private _orthoRight;
  52576. private _orthoTop;
  52577. private _orthoBottom;
  52578. /**
  52579. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52580. * The directional light is emitted from everywhere in the given direction.
  52581. * It can cast shadows.
  52582. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52583. * @param name The friendly name of the light
  52584. * @param direction The direction of the light
  52585. * @param scene The scene the light belongs to
  52586. */
  52587. constructor(name: string, direction: Vector3, scene: Scene);
  52588. /**
  52589. * Returns the string "DirectionalLight".
  52590. * @return The class name
  52591. */
  52592. getClassName(): string;
  52593. /**
  52594. * Returns the integer 1.
  52595. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52596. */
  52597. getTypeID(): number;
  52598. /**
  52599. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52600. * Returns the DirectionalLight Shadow projection matrix.
  52601. */
  52602. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52603. /**
  52604. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52605. * Returns the DirectionalLight Shadow projection matrix.
  52606. */
  52607. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52608. /**
  52609. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52610. * Returns the DirectionalLight Shadow projection matrix.
  52611. */
  52612. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52613. protected _buildUniformLayout(): void;
  52614. /**
  52615. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52616. * @param effect The effect to update
  52617. * @param lightIndex The index of the light in the effect to update
  52618. * @returns The directional light
  52619. */
  52620. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52621. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52622. /**
  52623. * Gets the minZ used for shadow according to both the scene and the light.
  52624. *
  52625. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52626. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52627. * @param activeCamera The camera we are returning the min for
  52628. * @returns the depth min z
  52629. */
  52630. getDepthMinZ(activeCamera: Camera): number;
  52631. /**
  52632. * Gets the maxZ used for shadow according to both the scene and the light.
  52633. *
  52634. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52635. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52636. * @param activeCamera The camera we are returning the max for
  52637. * @returns the depth max z
  52638. */
  52639. getDepthMaxZ(activeCamera: Camera): number;
  52640. /**
  52641. * Prepares the list of defines specific to the light type.
  52642. * @param defines the list of defines
  52643. * @param lightIndex defines the index of the light for the effect
  52644. */
  52645. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52646. }
  52647. }
  52648. declare module BABYLON {
  52649. /**
  52650. * Class containing static functions to help procedurally build meshes
  52651. */
  52652. export class HemisphereBuilder {
  52653. /**
  52654. * Creates a hemisphere mesh
  52655. * @param name defines the name of the mesh
  52656. * @param options defines the options used to create the mesh
  52657. * @param scene defines the hosting scene
  52658. * @returns the hemisphere mesh
  52659. */
  52660. static CreateHemisphere(name: string, options: {
  52661. segments?: number;
  52662. diameter?: number;
  52663. sideOrientation?: number;
  52664. }, scene: any): Mesh;
  52665. }
  52666. }
  52667. declare module BABYLON {
  52668. /**
  52669. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52670. * These values define a cone of light starting from the position, emitting toward the direction.
  52671. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52672. * and the exponent defines the speed of the decay of the light with distance (reach).
  52673. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52674. */
  52675. export class SpotLight extends ShadowLight {
  52676. private _angle;
  52677. private _innerAngle;
  52678. private _cosHalfAngle;
  52679. private _lightAngleScale;
  52680. private _lightAngleOffset;
  52681. /**
  52682. * Gets the cone angle of the spot light in Radians.
  52683. */
  52684. get angle(): number;
  52685. /**
  52686. * Sets the cone angle of the spot light in Radians.
  52687. */
  52688. set angle(value: number);
  52689. /**
  52690. * Only used in gltf falloff mode, this defines the angle where
  52691. * the directional falloff will start before cutting at angle which could be seen
  52692. * as outer angle.
  52693. */
  52694. get innerAngle(): number;
  52695. /**
  52696. * Only used in gltf falloff mode, this defines the angle where
  52697. * the directional falloff will start before cutting at angle which could be seen
  52698. * as outer angle.
  52699. */
  52700. set innerAngle(value: number);
  52701. private _shadowAngleScale;
  52702. /**
  52703. * Allows scaling the angle of the light for shadow generation only.
  52704. */
  52705. get shadowAngleScale(): number;
  52706. /**
  52707. * Allows scaling the angle of the light for shadow generation only.
  52708. */
  52709. set shadowAngleScale(value: number);
  52710. /**
  52711. * The light decay speed with the distance from the emission spot.
  52712. */
  52713. exponent: number;
  52714. private _projectionTextureMatrix;
  52715. /**
  52716. * Allows reading the projecton texture
  52717. */
  52718. get projectionTextureMatrix(): Matrix;
  52719. protected _projectionTextureLightNear: number;
  52720. /**
  52721. * Gets the near clip of the Spotlight for texture projection.
  52722. */
  52723. get projectionTextureLightNear(): number;
  52724. /**
  52725. * Sets the near clip of the Spotlight for texture projection.
  52726. */
  52727. set projectionTextureLightNear(value: number);
  52728. protected _projectionTextureLightFar: number;
  52729. /**
  52730. * Gets the far clip of the Spotlight for texture projection.
  52731. */
  52732. get projectionTextureLightFar(): number;
  52733. /**
  52734. * Sets the far clip of the Spotlight for texture projection.
  52735. */
  52736. set projectionTextureLightFar(value: number);
  52737. protected _projectionTextureUpDirection: Vector3;
  52738. /**
  52739. * Gets the Up vector of the Spotlight for texture projection.
  52740. */
  52741. get projectionTextureUpDirection(): Vector3;
  52742. /**
  52743. * Sets the Up vector of the Spotlight for texture projection.
  52744. */
  52745. set projectionTextureUpDirection(value: Vector3);
  52746. private _projectionTexture;
  52747. /**
  52748. * Gets the projection texture of the light.
  52749. */
  52750. get projectionTexture(): Nullable<BaseTexture>;
  52751. /**
  52752. * Sets the projection texture of the light.
  52753. */
  52754. set projectionTexture(value: Nullable<BaseTexture>);
  52755. private _projectionTextureViewLightDirty;
  52756. private _projectionTextureProjectionLightDirty;
  52757. private _projectionTextureDirty;
  52758. private _projectionTextureViewTargetVector;
  52759. private _projectionTextureViewLightMatrix;
  52760. private _projectionTextureProjectionLightMatrix;
  52761. private _projectionTextureScalingMatrix;
  52762. /**
  52763. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52764. * It can cast shadows.
  52765. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52766. * @param name The light friendly name
  52767. * @param position The position of the spot light in the scene
  52768. * @param direction The direction of the light in the scene
  52769. * @param angle The cone angle of the light in Radians
  52770. * @param exponent The light decay speed with the distance from the emission spot
  52771. * @param scene The scene the lights belongs to
  52772. */
  52773. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52774. /**
  52775. * Returns the string "SpotLight".
  52776. * @returns the class name
  52777. */
  52778. getClassName(): string;
  52779. /**
  52780. * Returns the integer 2.
  52781. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52782. */
  52783. getTypeID(): number;
  52784. /**
  52785. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52786. */
  52787. protected _setDirection(value: Vector3): void;
  52788. /**
  52789. * Overrides the position setter to recompute the projection texture view light Matrix.
  52790. */
  52791. protected _setPosition(value: Vector3): void;
  52792. /**
  52793. * 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.
  52794. * Returns the SpotLight.
  52795. */
  52796. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52797. protected _computeProjectionTextureViewLightMatrix(): void;
  52798. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52799. /**
  52800. * Main function for light texture projection matrix computing.
  52801. */
  52802. protected _computeProjectionTextureMatrix(): void;
  52803. protected _buildUniformLayout(): void;
  52804. private _computeAngleValues;
  52805. /**
  52806. * Sets the passed Effect "effect" with the Light textures.
  52807. * @param effect The effect to update
  52808. * @param lightIndex The index of the light in the effect to update
  52809. * @returns The light
  52810. */
  52811. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52812. /**
  52813. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52814. * @param effect The effect to update
  52815. * @param lightIndex The index of the light in the effect to update
  52816. * @returns The spot light
  52817. */
  52818. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52819. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52820. /**
  52821. * Disposes the light and the associated resources.
  52822. */
  52823. dispose(): void;
  52824. /**
  52825. * Prepares the list of defines specific to the light type.
  52826. * @param defines the list of defines
  52827. * @param lightIndex defines the index of the light for the effect
  52828. */
  52829. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52830. }
  52831. }
  52832. declare module BABYLON {
  52833. /**
  52834. * Gizmo that enables viewing a light
  52835. */
  52836. export class LightGizmo extends Gizmo {
  52837. private _lightMesh;
  52838. private _material;
  52839. private _cachedPosition;
  52840. private _cachedForward;
  52841. private _attachedMeshParent;
  52842. /**
  52843. * Creates a LightGizmo
  52844. * @param gizmoLayer The utility layer the gizmo will be added to
  52845. */
  52846. constructor(gizmoLayer?: UtilityLayerRenderer);
  52847. private _light;
  52848. /**
  52849. * The light that the gizmo is attached to
  52850. */
  52851. set light(light: Nullable<Light>);
  52852. get light(): Nullable<Light>;
  52853. /**
  52854. * Gets the material used to render the light gizmo
  52855. */
  52856. get material(): StandardMaterial;
  52857. /**
  52858. * @hidden
  52859. * Updates the gizmo to match the attached mesh's position/rotation
  52860. */
  52861. protected _update(): void;
  52862. private static _Scale;
  52863. /**
  52864. * Creates the lines for a light mesh
  52865. */
  52866. private static _CreateLightLines;
  52867. /**
  52868. * Disposes of the light gizmo
  52869. */
  52870. dispose(): void;
  52871. private static _CreateHemisphericLightMesh;
  52872. private static _CreatePointLightMesh;
  52873. private static _CreateSpotLightMesh;
  52874. private static _CreateDirectionalLightMesh;
  52875. }
  52876. }
  52877. declare module BABYLON {
  52878. /** @hidden */
  52879. export var backgroundFragmentDeclaration: {
  52880. name: string;
  52881. shader: string;
  52882. };
  52883. }
  52884. declare module BABYLON {
  52885. /** @hidden */
  52886. export var backgroundUboDeclaration: {
  52887. name: string;
  52888. shader: string;
  52889. };
  52890. }
  52891. declare module BABYLON {
  52892. /** @hidden */
  52893. export var backgroundPixelShader: {
  52894. name: string;
  52895. shader: string;
  52896. };
  52897. }
  52898. declare module BABYLON {
  52899. /** @hidden */
  52900. export var backgroundVertexDeclaration: {
  52901. name: string;
  52902. shader: string;
  52903. };
  52904. }
  52905. declare module BABYLON {
  52906. /** @hidden */
  52907. export var backgroundVertexShader: {
  52908. name: string;
  52909. shader: string;
  52910. };
  52911. }
  52912. declare module BABYLON {
  52913. /**
  52914. * Background material used to create an efficient environement around your scene.
  52915. */
  52916. export class BackgroundMaterial extends PushMaterial {
  52917. /**
  52918. * Standard reflectance value at parallel view angle.
  52919. */
  52920. static StandardReflectance0: number;
  52921. /**
  52922. * Standard reflectance value at grazing angle.
  52923. */
  52924. static StandardReflectance90: number;
  52925. protected _primaryColor: Color3;
  52926. /**
  52927. * Key light Color (multiply against the environement texture)
  52928. */
  52929. primaryColor: Color3;
  52930. protected __perceptualColor: Nullable<Color3>;
  52931. /**
  52932. * Experimental Internal Use Only.
  52933. *
  52934. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52935. * This acts as a helper to set the primary color to a more "human friendly" value.
  52936. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52937. * output color as close as possible from the chosen value.
  52938. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52939. * part of lighting setup.)
  52940. */
  52941. get _perceptualColor(): Nullable<Color3>;
  52942. set _perceptualColor(value: Nullable<Color3>);
  52943. protected _primaryColorShadowLevel: float;
  52944. /**
  52945. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52946. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52947. */
  52948. get primaryColorShadowLevel(): float;
  52949. set primaryColorShadowLevel(value: float);
  52950. protected _primaryColorHighlightLevel: float;
  52951. /**
  52952. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52953. * The primary color is used at the level chosen to define what the white area would look.
  52954. */
  52955. get primaryColorHighlightLevel(): float;
  52956. set primaryColorHighlightLevel(value: float);
  52957. protected _reflectionTexture: Nullable<BaseTexture>;
  52958. /**
  52959. * Reflection Texture used in the material.
  52960. * Should be author in a specific way for the best result (refer to the documentation).
  52961. */
  52962. reflectionTexture: Nullable<BaseTexture>;
  52963. protected _reflectionBlur: float;
  52964. /**
  52965. * Reflection Texture level of blur.
  52966. *
  52967. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52968. * texture twice.
  52969. */
  52970. reflectionBlur: float;
  52971. protected _diffuseTexture: Nullable<BaseTexture>;
  52972. /**
  52973. * Diffuse Texture used in the material.
  52974. * Should be author in a specific way for the best result (refer to the documentation).
  52975. */
  52976. diffuseTexture: Nullable<BaseTexture>;
  52977. protected _shadowLights: Nullable<IShadowLight[]>;
  52978. /**
  52979. * Specify the list of lights casting shadow on the material.
  52980. * All scene shadow lights will be included if null.
  52981. */
  52982. shadowLights: Nullable<IShadowLight[]>;
  52983. protected _shadowLevel: float;
  52984. /**
  52985. * Helps adjusting the shadow to a softer level if required.
  52986. * 0 means black shadows and 1 means no shadows.
  52987. */
  52988. shadowLevel: float;
  52989. protected _sceneCenter: Vector3;
  52990. /**
  52991. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52992. * It is usually zero but might be interesting to modify according to your setup.
  52993. */
  52994. sceneCenter: Vector3;
  52995. protected _opacityFresnel: boolean;
  52996. /**
  52997. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52998. * This helps ensuring a nice transition when the camera goes under the ground.
  52999. */
  53000. opacityFresnel: boolean;
  53001. protected _reflectionFresnel: boolean;
  53002. /**
  53003. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53004. * This helps adding a mirror texture on the ground.
  53005. */
  53006. reflectionFresnel: boolean;
  53007. protected _reflectionFalloffDistance: number;
  53008. /**
  53009. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53010. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53011. */
  53012. reflectionFalloffDistance: number;
  53013. protected _reflectionAmount: number;
  53014. /**
  53015. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53016. */
  53017. reflectionAmount: number;
  53018. protected _reflectionReflectance0: number;
  53019. /**
  53020. * This specifies the weight of the reflection at grazing angle.
  53021. */
  53022. reflectionReflectance0: number;
  53023. protected _reflectionReflectance90: number;
  53024. /**
  53025. * This specifies the weight of the reflection at a perpendicular point of view.
  53026. */
  53027. reflectionReflectance90: number;
  53028. /**
  53029. * Sets the reflection reflectance fresnel values according to the default standard
  53030. * empirically know to work well :-)
  53031. */
  53032. set reflectionStandardFresnelWeight(value: number);
  53033. protected _useRGBColor: boolean;
  53034. /**
  53035. * Helps to directly use the maps channels instead of their level.
  53036. */
  53037. useRGBColor: boolean;
  53038. protected _enableNoise: boolean;
  53039. /**
  53040. * This helps reducing the banding effect that could occur on the background.
  53041. */
  53042. enableNoise: boolean;
  53043. /**
  53044. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53045. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53046. * Recommended to be keep at 1.0 except for special cases.
  53047. */
  53048. get fovMultiplier(): number;
  53049. set fovMultiplier(value: number);
  53050. private _fovMultiplier;
  53051. /**
  53052. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53053. */
  53054. useEquirectangularFOV: boolean;
  53055. private _maxSimultaneousLights;
  53056. /**
  53057. * Number of Simultaneous lights allowed on the material.
  53058. */
  53059. maxSimultaneousLights: int;
  53060. /**
  53061. * Default configuration related to image processing available in the Background Material.
  53062. */
  53063. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53064. /**
  53065. * Keep track of the image processing observer to allow dispose and replace.
  53066. */
  53067. private _imageProcessingObserver;
  53068. /**
  53069. * Attaches a new image processing configuration to the PBR Material.
  53070. * @param configuration (if null the scene configuration will be use)
  53071. */
  53072. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53073. /**
  53074. * Gets the image processing configuration used either in this material.
  53075. */
  53076. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53077. /**
  53078. * Sets the Default image processing configuration used either in the this material.
  53079. *
  53080. * If sets to null, the scene one is in use.
  53081. */
  53082. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53083. /**
  53084. * Gets wether the color curves effect is enabled.
  53085. */
  53086. get cameraColorCurvesEnabled(): boolean;
  53087. /**
  53088. * Sets wether the color curves effect is enabled.
  53089. */
  53090. set cameraColorCurvesEnabled(value: boolean);
  53091. /**
  53092. * Gets wether the color grading effect is enabled.
  53093. */
  53094. get cameraColorGradingEnabled(): boolean;
  53095. /**
  53096. * Gets wether the color grading effect is enabled.
  53097. */
  53098. set cameraColorGradingEnabled(value: boolean);
  53099. /**
  53100. * Gets wether tonemapping is enabled or not.
  53101. */
  53102. get cameraToneMappingEnabled(): boolean;
  53103. /**
  53104. * Sets wether tonemapping is enabled or not
  53105. */
  53106. set cameraToneMappingEnabled(value: boolean);
  53107. /**
  53108. * The camera exposure used on this material.
  53109. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53110. * This corresponds to a photographic exposure.
  53111. */
  53112. get cameraExposure(): float;
  53113. /**
  53114. * The camera exposure used on this material.
  53115. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53116. * This corresponds to a photographic exposure.
  53117. */
  53118. set cameraExposure(value: float);
  53119. /**
  53120. * Gets The camera contrast used on this material.
  53121. */
  53122. get cameraContrast(): float;
  53123. /**
  53124. * Sets The camera contrast used on this material.
  53125. */
  53126. set cameraContrast(value: float);
  53127. /**
  53128. * Gets the Color Grading 2D Lookup Texture.
  53129. */
  53130. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53131. /**
  53132. * Sets the Color Grading 2D Lookup Texture.
  53133. */
  53134. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53135. /**
  53136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53138. * 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;
  53139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53140. */
  53141. get cameraColorCurves(): Nullable<ColorCurves>;
  53142. /**
  53143. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53144. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53145. * 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;
  53146. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53147. */
  53148. set cameraColorCurves(value: Nullable<ColorCurves>);
  53149. /**
  53150. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53151. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53152. */
  53153. switchToBGR: boolean;
  53154. private _renderTargets;
  53155. private _reflectionControls;
  53156. private _white;
  53157. private _primaryShadowColor;
  53158. private _primaryHighlightColor;
  53159. /**
  53160. * Instantiates a Background Material in the given scene
  53161. * @param name The friendly name of the material
  53162. * @param scene The scene to add the material to
  53163. */
  53164. constructor(name: string, scene: Scene);
  53165. /**
  53166. * Gets a boolean indicating that current material needs to register RTT
  53167. */
  53168. get hasRenderTargetTextures(): boolean;
  53169. /**
  53170. * The entire material has been created in order to prevent overdraw.
  53171. * @returns false
  53172. */
  53173. needAlphaTesting(): boolean;
  53174. /**
  53175. * The entire material has been created in order to prevent overdraw.
  53176. * @returns true if blending is enable
  53177. */
  53178. needAlphaBlending(): boolean;
  53179. /**
  53180. * Checks wether the material is ready to be rendered for a given mesh.
  53181. * @param mesh The mesh to render
  53182. * @param subMesh The submesh to check against
  53183. * @param useInstances Specify wether or not the material is used with instances
  53184. * @returns true if all the dependencies are ready (Textures, Effects...)
  53185. */
  53186. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53187. /**
  53188. * Compute the primary color according to the chosen perceptual color.
  53189. */
  53190. private _computePrimaryColorFromPerceptualColor;
  53191. /**
  53192. * Compute the highlights and shadow colors according to their chosen levels.
  53193. */
  53194. private _computePrimaryColors;
  53195. /**
  53196. * Build the uniform buffer used in the material.
  53197. */
  53198. buildUniformLayout(): void;
  53199. /**
  53200. * Unbind the material.
  53201. */
  53202. unbind(): void;
  53203. /**
  53204. * Bind only the world matrix to the material.
  53205. * @param world The world matrix to bind.
  53206. */
  53207. bindOnlyWorldMatrix(world: Matrix): void;
  53208. /**
  53209. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53210. * @param world The world matrix to bind.
  53211. * @param subMesh The submesh to bind for.
  53212. */
  53213. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53214. /**
  53215. * Checks to see if a texture is used in the material.
  53216. * @param texture - Base texture to use.
  53217. * @returns - Boolean specifying if a texture is used in the material.
  53218. */
  53219. hasTexture(texture: BaseTexture): boolean;
  53220. /**
  53221. * Dispose the material.
  53222. * @param forceDisposeEffect Force disposal of the associated effect.
  53223. * @param forceDisposeTextures Force disposal of the associated textures.
  53224. */
  53225. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53226. /**
  53227. * Clones the material.
  53228. * @param name The cloned name.
  53229. * @returns The cloned material.
  53230. */
  53231. clone(name: string): BackgroundMaterial;
  53232. /**
  53233. * Serializes the current material to its JSON representation.
  53234. * @returns The JSON representation.
  53235. */
  53236. serialize(): any;
  53237. /**
  53238. * Gets the class name of the material
  53239. * @returns "BackgroundMaterial"
  53240. */
  53241. getClassName(): string;
  53242. /**
  53243. * Parse a JSON input to create back a background material.
  53244. * @param source The JSON data to parse
  53245. * @param scene The scene to create the parsed material in
  53246. * @param rootUrl The root url of the assets the material depends upon
  53247. * @returns the instantiated BackgroundMaterial.
  53248. */
  53249. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53250. }
  53251. }
  53252. declare module BABYLON {
  53253. /**
  53254. * Represents the different options available during the creation of
  53255. * a Environment helper.
  53256. *
  53257. * This can control the default ground, skybox and image processing setup of your scene.
  53258. */
  53259. export interface IEnvironmentHelperOptions {
  53260. /**
  53261. * Specifies whether or not to create a ground.
  53262. * True by default.
  53263. */
  53264. createGround: boolean;
  53265. /**
  53266. * Specifies the ground size.
  53267. * 15 by default.
  53268. */
  53269. groundSize: number;
  53270. /**
  53271. * The texture used on the ground for the main color.
  53272. * Comes from the BabylonJS CDN by default.
  53273. *
  53274. * Remarks: Can be either a texture or a url.
  53275. */
  53276. groundTexture: string | BaseTexture;
  53277. /**
  53278. * The color mixed in the ground texture by default.
  53279. * BabylonJS clearColor by default.
  53280. */
  53281. groundColor: Color3;
  53282. /**
  53283. * Specifies the ground opacity.
  53284. * 1 by default.
  53285. */
  53286. groundOpacity: number;
  53287. /**
  53288. * Enables the ground to receive shadows.
  53289. * True by default.
  53290. */
  53291. enableGroundShadow: boolean;
  53292. /**
  53293. * Helps preventing the shadow to be fully black on the ground.
  53294. * 0.5 by default.
  53295. */
  53296. groundShadowLevel: number;
  53297. /**
  53298. * Creates a mirror texture attach to the ground.
  53299. * false by default.
  53300. */
  53301. enableGroundMirror: boolean;
  53302. /**
  53303. * Specifies the ground mirror size ratio.
  53304. * 0.3 by default as the default kernel is 64.
  53305. */
  53306. groundMirrorSizeRatio: number;
  53307. /**
  53308. * Specifies the ground mirror blur kernel size.
  53309. * 64 by default.
  53310. */
  53311. groundMirrorBlurKernel: number;
  53312. /**
  53313. * Specifies the ground mirror visibility amount.
  53314. * 1 by default
  53315. */
  53316. groundMirrorAmount: number;
  53317. /**
  53318. * Specifies the ground mirror reflectance weight.
  53319. * This uses the standard weight of the background material to setup the fresnel effect
  53320. * of the mirror.
  53321. * 1 by default.
  53322. */
  53323. groundMirrorFresnelWeight: number;
  53324. /**
  53325. * Specifies the ground mirror Falloff distance.
  53326. * This can helps reducing the size of the reflection.
  53327. * 0 by Default.
  53328. */
  53329. groundMirrorFallOffDistance: number;
  53330. /**
  53331. * Specifies the ground mirror texture type.
  53332. * Unsigned Int by Default.
  53333. */
  53334. groundMirrorTextureType: number;
  53335. /**
  53336. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53337. * the shown objects.
  53338. */
  53339. groundYBias: number;
  53340. /**
  53341. * Specifies whether or not to create a skybox.
  53342. * True by default.
  53343. */
  53344. createSkybox: boolean;
  53345. /**
  53346. * Specifies the skybox size.
  53347. * 20 by default.
  53348. */
  53349. skyboxSize: number;
  53350. /**
  53351. * The texture used on the skybox for the main color.
  53352. * Comes from the BabylonJS CDN by default.
  53353. *
  53354. * Remarks: Can be either a texture or a url.
  53355. */
  53356. skyboxTexture: string | BaseTexture;
  53357. /**
  53358. * The color mixed in the skybox texture by default.
  53359. * BabylonJS clearColor by default.
  53360. */
  53361. skyboxColor: Color3;
  53362. /**
  53363. * The background rotation around the Y axis of the scene.
  53364. * This helps aligning the key lights of your scene with the background.
  53365. * 0 by default.
  53366. */
  53367. backgroundYRotation: number;
  53368. /**
  53369. * Compute automatically the size of the elements to best fit with the scene.
  53370. */
  53371. sizeAuto: boolean;
  53372. /**
  53373. * Default position of the rootMesh if autoSize is not true.
  53374. */
  53375. rootPosition: Vector3;
  53376. /**
  53377. * Sets up the image processing in the scene.
  53378. * true by default.
  53379. */
  53380. setupImageProcessing: boolean;
  53381. /**
  53382. * The texture used as your environment texture in the scene.
  53383. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53384. *
  53385. * Remarks: Can be either a texture or a url.
  53386. */
  53387. environmentTexture: string | BaseTexture;
  53388. /**
  53389. * The value of the exposure to apply to the scene.
  53390. * 0.6 by default if setupImageProcessing is true.
  53391. */
  53392. cameraExposure: number;
  53393. /**
  53394. * The value of the contrast to apply to the scene.
  53395. * 1.6 by default if setupImageProcessing is true.
  53396. */
  53397. cameraContrast: number;
  53398. /**
  53399. * Specifies whether or not tonemapping should be enabled in the scene.
  53400. * true by default if setupImageProcessing is true.
  53401. */
  53402. toneMappingEnabled: boolean;
  53403. }
  53404. /**
  53405. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53406. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53407. * It also helps with the default setup of your imageProcessing configuration.
  53408. */
  53409. export class EnvironmentHelper {
  53410. /**
  53411. * Default ground texture URL.
  53412. */
  53413. private static _groundTextureCDNUrl;
  53414. /**
  53415. * Default skybox texture URL.
  53416. */
  53417. private static _skyboxTextureCDNUrl;
  53418. /**
  53419. * Default environment texture URL.
  53420. */
  53421. private static _environmentTextureCDNUrl;
  53422. /**
  53423. * Creates the default options for the helper.
  53424. */
  53425. private static _getDefaultOptions;
  53426. private _rootMesh;
  53427. /**
  53428. * Gets the root mesh created by the helper.
  53429. */
  53430. get rootMesh(): Mesh;
  53431. private _skybox;
  53432. /**
  53433. * Gets the skybox created by the helper.
  53434. */
  53435. get skybox(): Nullable<Mesh>;
  53436. private _skyboxTexture;
  53437. /**
  53438. * Gets the skybox texture created by the helper.
  53439. */
  53440. get skyboxTexture(): Nullable<BaseTexture>;
  53441. private _skyboxMaterial;
  53442. /**
  53443. * Gets the skybox material created by the helper.
  53444. */
  53445. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53446. private _ground;
  53447. /**
  53448. * Gets the ground mesh created by the helper.
  53449. */
  53450. get ground(): Nullable<Mesh>;
  53451. private _groundTexture;
  53452. /**
  53453. * Gets the ground texture created by the helper.
  53454. */
  53455. get groundTexture(): Nullable<BaseTexture>;
  53456. private _groundMirror;
  53457. /**
  53458. * Gets the ground mirror created by the helper.
  53459. */
  53460. get groundMirror(): Nullable<MirrorTexture>;
  53461. /**
  53462. * Gets the ground mirror render list to helps pushing the meshes
  53463. * you wish in the ground reflection.
  53464. */
  53465. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53466. private _groundMaterial;
  53467. /**
  53468. * Gets the ground material created by the helper.
  53469. */
  53470. get groundMaterial(): Nullable<BackgroundMaterial>;
  53471. /**
  53472. * Stores the creation options.
  53473. */
  53474. private readonly _scene;
  53475. private _options;
  53476. /**
  53477. * This observable will be notified with any error during the creation of the environment,
  53478. * mainly texture creation errors.
  53479. */
  53480. onErrorObservable: Observable<{
  53481. message?: string;
  53482. exception?: any;
  53483. }>;
  53484. /**
  53485. * constructor
  53486. * @param options Defines the options we want to customize the helper
  53487. * @param scene The scene to add the material to
  53488. */
  53489. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53490. /**
  53491. * Updates the background according to the new options
  53492. * @param options
  53493. */
  53494. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53495. /**
  53496. * Sets the primary color of all the available elements.
  53497. * @param color the main color to affect to the ground and the background
  53498. */
  53499. setMainColor(color: Color3): void;
  53500. /**
  53501. * Setup the image processing according to the specified options.
  53502. */
  53503. private _setupImageProcessing;
  53504. /**
  53505. * Setup the environment texture according to the specified options.
  53506. */
  53507. private _setupEnvironmentTexture;
  53508. /**
  53509. * Setup the background according to the specified options.
  53510. */
  53511. private _setupBackground;
  53512. /**
  53513. * Get the scene sizes according to the setup.
  53514. */
  53515. private _getSceneSize;
  53516. /**
  53517. * Setup the ground according to the specified options.
  53518. */
  53519. private _setupGround;
  53520. /**
  53521. * Setup the ground material according to the specified options.
  53522. */
  53523. private _setupGroundMaterial;
  53524. /**
  53525. * Setup the ground diffuse texture according to the specified options.
  53526. */
  53527. private _setupGroundDiffuseTexture;
  53528. /**
  53529. * Setup the ground mirror texture according to the specified options.
  53530. */
  53531. private _setupGroundMirrorTexture;
  53532. /**
  53533. * Setup the ground to receive the mirror texture.
  53534. */
  53535. private _setupMirrorInGroundMaterial;
  53536. /**
  53537. * Setup the skybox according to the specified options.
  53538. */
  53539. private _setupSkybox;
  53540. /**
  53541. * Setup the skybox material according to the specified options.
  53542. */
  53543. private _setupSkyboxMaterial;
  53544. /**
  53545. * Setup the skybox reflection texture according to the specified options.
  53546. */
  53547. private _setupSkyboxReflectionTexture;
  53548. private _errorHandler;
  53549. /**
  53550. * Dispose all the elements created by the Helper.
  53551. */
  53552. dispose(): void;
  53553. }
  53554. }
  53555. declare module BABYLON {
  53556. /**
  53557. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53558. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53559. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53560. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53561. */
  53562. export class PhotoDome extends TransformNode {
  53563. /**
  53564. * Define the image as a Monoscopic panoramic 360 image.
  53565. */
  53566. static readonly MODE_MONOSCOPIC: number;
  53567. /**
  53568. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53569. */
  53570. static readonly MODE_TOPBOTTOM: number;
  53571. /**
  53572. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53573. */
  53574. static readonly MODE_SIDEBYSIDE: number;
  53575. private _useDirectMapping;
  53576. /**
  53577. * The texture being displayed on the sphere
  53578. */
  53579. protected _photoTexture: Texture;
  53580. /**
  53581. * Gets or sets the texture being displayed on the sphere
  53582. */
  53583. get photoTexture(): Texture;
  53584. set photoTexture(value: Texture);
  53585. /**
  53586. * Observable raised when an error occured while loading the 360 image
  53587. */
  53588. onLoadErrorObservable: Observable<string>;
  53589. /**
  53590. * The skybox material
  53591. */
  53592. protected _material: BackgroundMaterial;
  53593. /**
  53594. * The surface used for the skybox
  53595. */
  53596. protected _mesh: Mesh;
  53597. /**
  53598. * Gets the mesh used for the skybox.
  53599. */
  53600. get mesh(): Mesh;
  53601. /**
  53602. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53603. * Also see the options.resolution property.
  53604. */
  53605. get fovMultiplier(): number;
  53606. set fovMultiplier(value: number);
  53607. private _imageMode;
  53608. /**
  53609. * Gets or set the current video mode for the video. It can be:
  53610. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53611. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53612. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53613. */
  53614. get imageMode(): number;
  53615. set imageMode(value: number);
  53616. /**
  53617. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53618. * @param name Element's name, child elements will append suffixes for their own names.
  53619. * @param urlsOfPhoto defines the url of the photo to display
  53620. * @param options defines an object containing optional or exposed sub element properties
  53621. * @param onError defines a callback called when an error occured while loading the texture
  53622. */
  53623. constructor(name: string, urlOfPhoto: string, options: {
  53624. resolution?: number;
  53625. size?: number;
  53626. useDirectMapping?: boolean;
  53627. faceForward?: boolean;
  53628. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53629. private _onBeforeCameraRenderObserver;
  53630. private _changeImageMode;
  53631. /**
  53632. * Releases resources associated with this node.
  53633. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53634. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53635. */
  53636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53637. }
  53638. }
  53639. declare module BABYLON {
  53640. /**
  53641. * Class used to host RGBD texture specific utilities
  53642. */
  53643. export class RGBDTextureTools {
  53644. /**
  53645. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53646. * @param texture the texture to expand.
  53647. */
  53648. static ExpandRGBDTexture(texture: Texture): void;
  53649. }
  53650. }
  53651. declare module BABYLON {
  53652. /**
  53653. * Class used to host texture specific utilities
  53654. */
  53655. export class BRDFTextureTools {
  53656. /**
  53657. * Prevents texture cache collision
  53658. */
  53659. private static _instanceNumber;
  53660. /**
  53661. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53662. * @param scene defines the hosting scene
  53663. * @returns the environment BRDF texture
  53664. */
  53665. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53666. private static _environmentBRDFBase64Texture;
  53667. }
  53668. }
  53669. declare module BABYLON {
  53670. /**
  53671. * @hidden
  53672. */
  53673. export interface IMaterialClearCoatDefines {
  53674. CLEARCOAT: boolean;
  53675. CLEARCOAT_DEFAULTIOR: boolean;
  53676. CLEARCOAT_TEXTURE: boolean;
  53677. CLEARCOAT_TEXTUREDIRECTUV: number;
  53678. CLEARCOAT_BUMP: boolean;
  53679. CLEARCOAT_BUMPDIRECTUV: number;
  53680. CLEARCOAT_TINT: boolean;
  53681. CLEARCOAT_TINT_TEXTURE: boolean;
  53682. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53683. /** @hidden */
  53684. _areTexturesDirty: boolean;
  53685. }
  53686. /**
  53687. * Define the code related to the clear coat parameters of the pbr material.
  53688. */
  53689. export class PBRClearCoatConfiguration {
  53690. /**
  53691. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53692. * The default fits with a polyurethane material.
  53693. */
  53694. private static readonly _DefaultIndexOfRefraction;
  53695. private _isEnabled;
  53696. /**
  53697. * Defines if the clear coat is enabled in the material.
  53698. */
  53699. isEnabled: boolean;
  53700. /**
  53701. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53702. */
  53703. intensity: number;
  53704. /**
  53705. * Defines the clear coat layer roughness.
  53706. */
  53707. roughness: number;
  53708. private _indexOfRefraction;
  53709. /**
  53710. * Defines the index of refraction of the clear coat.
  53711. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53712. * The default fits with a polyurethane material.
  53713. * Changing the default value is more performance intensive.
  53714. */
  53715. indexOfRefraction: number;
  53716. private _texture;
  53717. /**
  53718. * Stores the clear coat values in a texture.
  53719. */
  53720. texture: Nullable<BaseTexture>;
  53721. private _bumpTexture;
  53722. /**
  53723. * Define the clear coat specific bump texture.
  53724. */
  53725. bumpTexture: Nullable<BaseTexture>;
  53726. private _isTintEnabled;
  53727. /**
  53728. * Defines if the clear coat tint is enabled in the material.
  53729. */
  53730. isTintEnabled: boolean;
  53731. /**
  53732. * Defines the clear coat tint of the material.
  53733. * This is only use if tint is enabled
  53734. */
  53735. tintColor: Color3;
  53736. /**
  53737. * Defines the distance at which the tint color should be found in the
  53738. * clear coat media.
  53739. * This is only use if tint is enabled
  53740. */
  53741. tintColorAtDistance: number;
  53742. /**
  53743. * Defines the clear coat layer thickness.
  53744. * This is only use if tint is enabled
  53745. */
  53746. tintThickness: number;
  53747. private _tintTexture;
  53748. /**
  53749. * Stores the clear tint values in a texture.
  53750. * rgb is tint
  53751. * a is a thickness factor
  53752. */
  53753. tintTexture: Nullable<BaseTexture>;
  53754. /** @hidden */
  53755. private _internalMarkAllSubMeshesAsTexturesDirty;
  53756. /** @hidden */
  53757. _markAllSubMeshesAsTexturesDirty(): void;
  53758. /**
  53759. * Instantiate a new istance of clear coat configuration.
  53760. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53761. */
  53762. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53763. /**
  53764. * Gets wehter the submesh is ready to be used or not.
  53765. * @param defines the list of "defines" to update.
  53766. * @param scene defines the scene the material belongs to.
  53767. * @param engine defines the engine the material belongs to.
  53768. * @param disableBumpMap defines wether the material disables bump or not.
  53769. * @returns - boolean indicating that the submesh is ready or not.
  53770. */
  53771. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53772. /**
  53773. * Checks to see if a texture is used in the material.
  53774. * @param defines the list of "defines" to update.
  53775. * @param scene defines the scene to the material belongs to.
  53776. */
  53777. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53778. /**
  53779. * Binds the material data.
  53780. * @param uniformBuffer defines the Uniform buffer to fill in.
  53781. * @param scene defines the scene the material belongs to.
  53782. * @param engine defines the engine the material belongs to.
  53783. * @param disableBumpMap defines wether the material disables bump or not.
  53784. * @param isFrozen defines wether the material is frozen or not.
  53785. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53786. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53787. */
  53788. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53789. /**
  53790. * Checks to see if a texture is used in the material.
  53791. * @param texture - Base texture to use.
  53792. * @returns - Boolean specifying if a texture is used in the material.
  53793. */
  53794. hasTexture(texture: BaseTexture): boolean;
  53795. /**
  53796. * Returns an array of the actively used textures.
  53797. * @param activeTextures Array of BaseTextures
  53798. */
  53799. getActiveTextures(activeTextures: BaseTexture[]): void;
  53800. /**
  53801. * Returns the animatable textures.
  53802. * @param animatables Array of animatable textures.
  53803. */
  53804. getAnimatables(animatables: IAnimatable[]): void;
  53805. /**
  53806. * Disposes the resources of the material.
  53807. * @param forceDisposeTextures - Forces the disposal of all textures.
  53808. */
  53809. dispose(forceDisposeTextures?: boolean): void;
  53810. /**
  53811. * Get the current class name of the texture useful for serialization or dynamic coding.
  53812. * @returns "PBRClearCoatConfiguration"
  53813. */
  53814. getClassName(): string;
  53815. /**
  53816. * Add fallbacks to the effect fallbacks list.
  53817. * @param defines defines the Base texture to use.
  53818. * @param fallbacks defines the current fallback list.
  53819. * @param currentRank defines the current fallback rank.
  53820. * @returns the new fallback rank.
  53821. */
  53822. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53823. /**
  53824. * Add the required uniforms to the current list.
  53825. * @param uniforms defines the current uniform list.
  53826. */
  53827. static AddUniforms(uniforms: string[]): void;
  53828. /**
  53829. * Add the required samplers to the current list.
  53830. * @param samplers defines the current sampler list.
  53831. */
  53832. static AddSamplers(samplers: string[]): void;
  53833. /**
  53834. * Add the required uniforms to the current buffer.
  53835. * @param uniformBuffer defines the current uniform buffer.
  53836. */
  53837. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53838. /**
  53839. * Makes a duplicate of the current configuration into another one.
  53840. * @param clearCoatConfiguration define the config where to copy the info
  53841. */
  53842. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53843. /**
  53844. * Serializes this clear coat configuration.
  53845. * @returns - An object with the serialized config.
  53846. */
  53847. serialize(): any;
  53848. /**
  53849. * Parses a anisotropy Configuration from a serialized object.
  53850. * @param source - Serialized object.
  53851. * @param scene Defines the scene we are parsing for
  53852. * @param rootUrl Defines the rootUrl to load from
  53853. */
  53854. parse(source: any, scene: Scene, rootUrl: string): void;
  53855. }
  53856. }
  53857. declare module BABYLON {
  53858. /**
  53859. * @hidden
  53860. */
  53861. export interface IMaterialAnisotropicDefines {
  53862. ANISOTROPIC: boolean;
  53863. ANISOTROPIC_TEXTURE: boolean;
  53864. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53865. MAINUV1: boolean;
  53866. _areTexturesDirty: boolean;
  53867. _needUVs: boolean;
  53868. }
  53869. /**
  53870. * Define the code related to the anisotropic parameters of the pbr material.
  53871. */
  53872. export class PBRAnisotropicConfiguration {
  53873. private _isEnabled;
  53874. /**
  53875. * Defines if the anisotropy is enabled in the material.
  53876. */
  53877. isEnabled: boolean;
  53878. /**
  53879. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53880. */
  53881. intensity: number;
  53882. /**
  53883. * Defines if the effect is along the tangents, bitangents or in between.
  53884. * By default, the effect is "strectching" the highlights along the tangents.
  53885. */
  53886. direction: Vector2;
  53887. private _texture;
  53888. /**
  53889. * Stores the anisotropy values in a texture.
  53890. * rg is direction (like normal from -1 to 1)
  53891. * b is a intensity
  53892. */
  53893. texture: Nullable<BaseTexture>;
  53894. /** @hidden */
  53895. private _internalMarkAllSubMeshesAsTexturesDirty;
  53896. /** @hidden */
  53897. _markAllSubMeshesAsTexturesDirty(): void;
  53898. /**
  53899. * Instantiate a new istance of anisotropy configuration.
  53900. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53901. */
  53902. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53903. /**
  53904. * Specifies that the submesh is ready to be used.
  53905. * @param defines the list of "defines" to update.
  53906. * @param scene defines the scene the material belongs to.
  53907. * @returns - boolean indicating that the submesh is ready or not.
  53908. */
  53909. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53910. /**
  53911. * Checks to see if a texture is used in the material.
  53912. * @param defines the list of "defines" to update.
  53913. * @param mesh the mesh we are preparing the defines for.
  53914. * @param scene defines the scene the material belongs to.
  53915. */
  53916. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53917. /**
  53918. * Binds the material data.
  53919. * @param uniformBuffer defines the Uniform buffer to fill in.
  53920. * @param scene defines the scene the material belongs to.
  53921. * @param isFrozen defines wether the material is frozen or not.
  53922. */
  53923. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53924. /**
  53925. * Checks to see if a texture is used in the material.
  53926. * @param texture - Base texture to use.
  53927. * @returns - Boolean specifying if a texture is used in the material.
  53928. */
  53929. hasTexture(texture: BaseTexture): boolean;
  53930. /**
  53931. * Returns an array of the actively used textures.
  53932. * @param activeTextures Array of BaseTextures
  53933. */
  53934. getActiveTextures(activeTextures: BaseTexture[]): void;
  53935. /**
  53936. * Returns the animatable textures.
  53937. * @param animatables Array of animatable textures.
  53938. */
  53939. getAnimatables(animatables: IAnimatable[]): void;
  53940. /**
  53941. * Disposes the resources of the material.
  53942. * @param forceDisposeTextures - Forces the disposal of all textures.
  53943. */
  53944. dispose(forceDisposeTextures?: boolean): void;
  53945. /**
  53946. * Get the current class name of the texture useful for serialization or dynamic coding.
  53947. * @returns "PBRAnisotropicConfiguration"
  53948. */
  53949. getClassName(): string;
  53950. /**
  53951. * Add fallbacks to the effect fallbacks list.
  53952. * @param defines defines the Base texture to use.
  53953. * @param fallbacks defines the current fallback list.
  53954. * @param currentRank defines the current fallback rank.
  53955. * @returns the new fallback rank.
  53956. */
  53957. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53958. /**
  53959. * Add the required uniforms to the current list.
  53960. * @param uniforms defines the current uniform list.
  53961. */
  53962. static AddUniforms(uniforms: string[]): void;
  53963. /**
  53964. * Add the required uniforms to the current buffer.
  53965. * @param uniformBuffer defines the current uniform buffer.
  53966. */
  53967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53968. /**
  53969. * Add the required samplers to the current list.
  53970. * @param samplers defines the current sampler list.
  53971. */
  53972. static AddSamplers(samplers: string[]): void;
  53973. /**
  53974. * Makes a duplicate of the current configuration into another one.
  53975. * @param anisotropicConfiguration define the config where to copy the info
  53976. */
  53977. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53978. /**
  53979. * Serializes this anisotropy configuration.
  53980. * @returns - An object with the serialized config.
  53981. */
  53982. serialize(): any;
  53983. /**
  53984. * Parses a anisotropy Configuration from a serialized object.
  53985. * @param source - Serialized object.
  53986. * @param scene Defines the scene we are parsing for
  53987. * @param rootUrl Defines the rootUrl to load from
  53988. */
  53989. parse(source: any, scene: Scene, rootUrl: string): void;
  53990. }
  53991. }
  53992. declare module BABYLON {
  53993. /**
  53994. * @hidden
  53995. */
  53996. export interface IMaterialBRDFDefines {
  53997. BRDF_V_HEIGHT_CORRELATED: boolean;
  53998. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53999. SPHERICAL_HARMONICS: boolean;
  54000. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54001. /** @hidden */
  54002. _areMiscDirty: boolean;
  54003. }
  54004. /**
  54005. * Define the code related to the BRDF parameters of the pbr material.
  54006. */
  54007. export class PBRBRDFConfiguration {
  54008. /**
  54009. * Default value used for the energy conservation.
  54010. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54011. */
  54012. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54013. /**
  54014. * Default value used for the Smith Visibility Height Correlated mode.
  54015. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54016. */
  54017. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54018. /**
  54019. * Default value used for the IBL diffuse part.
  54020. * This can help switching back to the polynomials mode globally which is a tiny bit
  54021. * less GPU intensive at the drawback of a lower quality.
  54022. */
  54023. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54024. /**
  54025. * Default value used for activating energy conservation for the specular workflow.
  54026. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54027. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54028. */
  54029. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54030. private _useEnergyConservation;
  54031. /**
  54032. * Defines if the material uses energy conservation.
  54033. */
  54034. useEnergyConservation: boolean;
  54035. private _useSmithVisibilityHeightCorrelated;
  54036. /**
  54037. * LEGACY Mode set to false
  54038. * Defines if the material uses height smith correlated visibility term.
  54039. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54040. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54041. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54042. * Not relying on height correlated will also disable energy conservation.
  54043. */
  54044. useSmithVisibilityHeightCorrelated: boolean;
  54045. private _useSphericalHarmonics;
  54046. /**
  54047. * LEGACY Mode set to false
  54048. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54049. * diffuse part of the IBL.
  54050. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54051. * to the ground truth.
  54052. */
  54053. useSphericalHarmonics: boolean;
  54054. private _useSpecularGlossinessInputEnergyConservation;
  54055. /**
  54056. * Defines if the material uses energy conservation, when the specular workflow is active.
  54057. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54058. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54059. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54060. */
  54061. useSpecularGlossinessInputEnergyConservation: boolean;
  54062. /** @hidden */
  54063. private _internalMarkAllSubMeshesAsMiscDirty;
  54064. /** @hidden */
  54065. _markAllSubMeshesAsMiscDirty(): void;
  54066. /**
  54067. * Instantiate a new istance of clear coat configuration.
  54068. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54069. */
  54070. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54071. /**
  54072. * Checks to see if a texture is used in the material.
  54073. * @param defines the list of "defines" to update.
  54074. */
  54075. prepareDefines(defines: IMaterialBRDFDefines): void;
  54076. /**
  54077. * Get the current class name of the texture useful for serialization or dynamic coding.
  54078. * @returns "PBRClearCoatConfiguration"
  54079. */
  54080. getClassName(): string;
  54081. /**
  54082. * Makes a duplicate of the current configuration into another one.
  54083. * @param brdfConfiguration define the config where to copy the info
  54084. */
  54085. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54086. /**
  54087. * Serializes this BRDF configuration.
  54088. * @returns - An object with the serialized config.
  54089. */
  54090. serialize(): any;
  54091. /**
  54092. * Parses a anisotropy Configuration from a serialized object.
  54093. * @param source - Serialized object.
  54094. * @param scene Defines the scene we are parsing for
  54095. * @param rootUrl Defines the rootUrl to load from
  54096. */
  54097. parse(source: any, scene: Scene, rootUrl: string): void;
  54098. }
  54099. }
  54100. declare module BABYLON {
  54101. /**
  54102. * @hidden
  54103. */
  54104. export interface IMaterialSheenDefines {
  54105. SHEEN: boolean;
  54106. SHEEN_TEXTURE: boolean;
  54107. SHEEN_TEXTUREDIRECTUV: number;
  54108. SHEEN_LINKWITHALBEDO: boolean;
  54109. SHEEN_ROUGHNESS: boolean;
  54110. SHEEN_ALBEDOSCALING: boolean;
  54111. /** @hidden */
  54112. _areTexturesDirty: boolean;
  54113. }
  54114. /**
  54115. * Define the code related to the Sheen parameters of the pbr material.
  54116. */
  54117. export class PBRSheenConfiguration {
  54118. private _isEnabled;
  54119. /**
  54120. * Defines if the material uses sheen.
  54121. */
  54122. isEnabled: boolean;
  54123. private _linkSheenWithAlbedo;
  54124. /**
  54125. * Defines if the sheen is linked to the sheen color.
  54126. */
  54127. linkSheenWithAlbedo: boolean;
  54128. /**
  54129. * Defines the sheen intensity.
  54130. */
  54131. intensity: number;
  54132. /**
  54133. * Defines the sheen color.
  54134. */
  54135. color: Color3;
  54136. private _texture;
  54137. /**
  54138. * Stores the sheen tint values in a texture.
  54139. * rgb is tint
  54140. * a is a intensity
  54141. */
  54142. texture: Nullable<BaseTexture>;
  54143. private _roughness;
  54144. /**
  54145. * Defines the sheen roughness.
  54146. * It is not taken into account if linkSheenWithAlbedo is true.
  54147. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54148. */
  54149. roughness: Nullable<number>;
  54150. private _albedoScaling;
  54151. /**
  54152. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54153. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54154. * making it easier to setup and tweak the effect
  54155. */
  54156. albedoScaling: boolean;
  54157. /** @hidden */
  54158. private _internalMarkAllSubMeshesAsTexturesDirty;
  54159. /** @hidden */
  54160. _markAllSubMeshesAsTexturesDirty(): void;
  54161. /**
  54162. * Instantiate a new istance of clear coat configuration.
  54163. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54164. */
  54165. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54166. /**
  54167. * Specifies that the submesh is ready to be used.
  54168. * @param defines the list of "defines" to update.
  54169. * @param scene defines the scene the material belongs to.
  54170. * @returns - boolean indicating that the submesh is ready or not.
  54171. */
  54172. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54173. /**
  54174. * Checks to see if a texture is used in the material.
  54175. * @param defines the list of "defines" to update.
  54176. * @param scene defines the scene the material belongs to.
  54177. */
  54178. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54179. /**
  54180. * Binds the material data.
  54181. * @param uniformBuffer defines the Uniform buffer to fill in.
  54182. * @param scene defines the scene the material belongs to.
  54183. * @param isFrozen defines wether the material is frozen or not.
  54184. */
  54185. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54186. /**
  54187. * Checks to see if a texture is used in the material.
  54188. * @param texture - Base texture to use.
  54189. * @returns - Boolean specifying if a texture is used in the material.
  54190. */
  54191. hasTexture(texture: BaseTexture): boolean;
  54192. /**
  54193. * Returns an array of the actively used textures.
  54194. * @param activeTextures Array of BaseTextures
  54195. */
  54196. getActiveTextures(activeTextures: BaseTexture[]): void;
  54197. /**
  54198. * Returns the animatable textures.
  54199. * @param animatables Array of animatable textures.
  54200. */
  54201. getAnimatables(animatables: IAnimatable[]): void;
  54202. /**
  54203. * Disposes the resources of the material.
  54204. * @param forceDisposeTextures - Forces the disposal of all textures.
  54205. */
  54206. dispose(forceDisposeTextures?: boolean): void;
  54207. /**
  54208. * Get the current class name of the texture useful for serialization or dynamic coding.
  54209. * @returns "PBRSheenConfiguration"
  54210. */
  54211. getClassName(): string;
  54212. /**
  54213. * Add fallbacks to the effect fallbacks list.
  54214. * @param defines defines the Base texture to use.
  54215. * @param fallbacks defines the current fallback list.
  54216. * @param currentRank defines the current fallback rank.
  54217. * @returns the new fallback rank.
  54218. */
  54219. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54220. /**
  54221. * Add the required uniforms to the current list.
  54222. * @param uniforms defines the current uniform list.
  54223. */
  54224. static AddUniforms(uniforms: string[]): void;
  54225. /**
  54226. * Add the required uniforms to the current buffer.
  54227. * @param uniformBuffer defines the current uniform buffer.
  54228. */
  54229. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54230. /**
  54231. * Add the required samplers to the current list.
  54232. * @param samplers defines the current sampler list.
  54233. */
  54234. static AddSamplers(samplers: string[]): void;
  54235. /**
  54236. * Makes a duplicate of the current configuration into another one.
  54237. * @param sheenConfiguration define the config where to copy the info
  54238. */
  54239. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54240. /**
  54241. * Serializes this BRDF configuration.
  54242. * @returns - An object with the serialized config.
  54243. */
  54244. serialize(): any;
  54245. /**
  54246. * Parses a anisotropy Configuration from a serialized object.
  54247. * @param source - Serialized object.
  54248. * @param scene Defines the scene we are parsing for
  54249. * @param rootUrl Defines the rootUrl to load from
  54250. */
  54251. parse(source: any, scene: Scene, rootUrl: string): void;
  54252. }
  54253. }
  54254. declare module BABYLON {
  54255. /**
  54256. * @hidden
  54257. */
  54258. export interface IMaterialSubSurfaceDefines {
  54259. SUBSURFACE: boolean;
  54260. SS_REFRACTION: boolean;
  54261. SS_TRANSLUCENCY: boolean;
  54262. SS_SCATTERING: boolean;
  54263. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54264. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54265. SS_REFRACTIONMAP_3D: boolean;
  54266. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54267. SS_LODINREFRACTIONALPHA: boolean;
  54268. SS_GAMMAREFRACTION: boolean;
  54269. SS_RGBDREFRACTION: boolean;
  54270. SS_LINEARSPECULARREFRACTION: boolean;
  54271. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54272. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54273. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54274. /** @hidden */
  54275. _areTexturesDirty: boolean;
  54276. }
  54277. /**
  54278. * Define the code related to the sub surface parameters of the pbr material.
  54279. */
  54280. export class PBRSubSurfaceConfiguration {
  54281. private _isRefractionEnabled;
  54282. /**
  54283. * Defines if the refraction is enabled in the material.
  54284. */
  54285. isRefractionEnabled: boolean;
  54286. private _isTranslucencyEnabled;
  54287. /**
  54288. * Defines if the translucency is enabled in the material.
  54289. */
  54290. isTranslucencyEnabled: boolean;
  54291. private _isScatteringEnabled;
  54292. /**
  54293. * Defines the refraction intensity of the material.
  54294. * The refraction when enabled replaces the Diffuse part of the material.
  54295. * The intensity helps transitionning between diffuse and refraction.
  54296. */
  54297. refractionIntensity: number;
  54298. /**
  54299. * Defines the translucency intensity of the material.
  54300. * When translucency has been enabled, this defines how much of the "translucency"
  54301. * is addded to the diffuse part of the material.
  54302. */
  54303. translucencyIntensity: number;
  54304. /**
  54305. * Defines the scattering intensity of the material.
  54306. * When scattering has been enabled, this defines how much of the "scattered light"
  54307. * is addded to the diffuse part of the material.
  54308. */
  54309. scatteringIntensity: number;
  54310. /**
  54311. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54312. */
  54313. useAlbedoToTintRefraction: boolean;
  54314. private _thicknessTexture;
  54315. /**
  54316. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54317. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54318. * 0 would mean minimumThickness
  54319. * 1 would mean maximumThickness
  54320. * The other channels might be use as a mask to vary the different effects intensity.
  54321. */
  54322. thicknessTexture: Nullable<BaseTexture>;
  54323. private _refractionTexture;
  54324. /**
  54325. * Defines the texture to use for refraction.
  54326. */
  54327. refractionTexture: Nullable<BaseTexture>;
  54328. private _indexOfRefraction;
  54329. /**
  54330. * Index of refraction of the material base layer.
  54331. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54332. *
  54333. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54334. *
  54335. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54336. */
  54337. indexOfRefraction: number;
  54338. private _volumeIndexOfRefraction;
  54339. /**
  54340. * Index of refraction of the material's volume.
  54341. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54342. *
  54343. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54344. * the volume will use the same IOR as the surface.
  54345. */
  54346. get volumeIndexOfRefraction(): number;
  54347. set volumeIndexOfRefraction(value: number);
  54348. private _invertRefractionY;
  54349. /**
  54350. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54351. */
  54352. invertRefractionY: boolean;
  54353. private _linkRefractionWithTransparency;
  54354. /**
  54355. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54356. * Materials half opaque for instance using refraction could benefit from this control.
  54357. */
  54358. linkRefractionWithTransparency: boolean;
  54359. /**
  54360. * Defines the minimum thickness stored in the thickness map.
  54361. * If no thickness map is defined, this value will be used to simulate thickness.
  54362. */
  54363. minimumThickness: number;
  54364. /**
  54365. * Defines the maximum thickness stored in the thickness map.
  54366. */
  54367. maximumThickness: number;
  54368. /**
  54369. * Defines the volume tint of the material.
  54370. * This is used for both translucency and scattering.
  54371. */
  54372. tintColor: Color3;
  54373. /**
  54374. * Defines the distance at which the tint color should be found in the media.
  54375. * This is used for refraction only.
  54376. */
  54377. tintColorAtDistance: number;
  54378. /**
  54379. * Defines how far each channel transmit through the media.
  54380. * It is defined as a color to simplify it selection.
  54381. */
  54382. diffusionDistance: Color3;
  54383. private _useMaskFromThicknessTexture;
  54384. /**
  54385. * Stores the intensity of the different subsurface effects in the thickness texture.
  54386. * * the green channel is the translucency intensity.
  54387. * * the blue channel is the scattering intensity.
  54388. * * the alpha channel is the refraction intensity.
  54389. */
  54390. useMaskFromThicknessTexture: boolean;
  54391. /** @hidden */
  54392. private _internalMarkAllSubMeshesAsTexturesDirty;
  54393. /** @hidden */
  54394. _markAllSubMeshesAsTexturesDirty(): void;
  54395. /**
  54396. * Instantiate a new istance of sub surface configuration.
  54397. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54398. */
  54399. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54400. /**
  54401. * Gets wehter the submesh is ready to be used or not.
  54402. * @param defines the list of "defines" to update.
  54403. * @param scene defines the scene the material belongs to.
  54404. * @returns - boolean indicating that the submesh is ready or not.
  54405. */
  54406. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54407. /**
  54408. * Checks to see if a texture is used in the material.
  54409. * @param defines the list of "defines" to update.
  54410. * @param scene defines the scene to the material belongs to.
  54411. */
  54412. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54413. /**
  54414. * Binds the material data.
  54415. * @param uniformBuffer defines the Uniform buffer to fill in.
  54416. * @param scene defines the scene the material belongs to.
  54417. * @param engine defines the engine the material belongs to.
  54418. * @param isFrozen defines whether the material is frozen or not.
  54419. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54420. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54421. */
  54422. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54423. /**
  54424. * Unbinds the material from the mesh.
  54425. * @param activeEffect defines the effect that should be unbound from.
  54426. * @returns true if unbound, otherwise false
  54427. */
  54428. unbind(activeEffect: Effect): boolean;
  54429. /**
  54430. * Returns the texture used for refraction or null if none is used.
  54431. * @param scene defines the scene the material belongs to.
  54432. * @returns - Refraction texture if present. If no refraction texture and refraction
  54433. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54434. */
  54435. private _getRefractionTexture;
  54436. /**
  54437. * Returns true if alpha blending should be disabled.
  54438. */
  54439. get disableAlphaBlending(): boolean;
  54440. /**
  54441. * Fills the list of render target textures.
  54442. * @param renderTargets the list of render targets to update
  54443. */
  54444. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54445. /**
  54446. * Checks to see if a texture is used in the material.
  54447. * @param texture - Base texture to use.
  54448. * @returns - Boolean specifying if a texture is used in the material.
  54449. */
  54450. hasTexture(texture: BaseTexture): boolean;
  54451. /**
  54452. * Gets a boolean indicating that current material needs to register RTT
  54453. * @returns true if this uses a render target otherwise false.
  54454. */
  54455. hasRenderTargetTextures(): boolean;
  54456. /**
  54457. * Returns an array of the actively used textures.
  54458. * @param activeTextures Array of BaseTextures
  54459. */
  54460. getActiveTextures(activeTextures: BaseTexture[]): void;
  54461. /**
  54462. * Returns the animatable textures.
  54463. * @param animatables Array of animatable textures.
  54464. */
  54465. getAnimatables(animatables: IAnimatable[]): void;
  54466. /**
  54467. * Disposes the resources of the material.
  54468. * @param forceDisposeTextures - Forces the disposal of all textures.
  54469. */
  54470. dispose(forceDisposeTextures?: boolean): void;
  54471. /**
  54472. * Get the current class name of the texture useful for serialization or dynamic coding.
  54473. * @returns "PBRSubSurfaceConfiguration"
  54474. */
  54475. getClassName(): string;
  54476. /**
  54477. * Add fallbacks to the effect fallbacks list.
  54478. * @param defines defines the Base texture to use.
  54479. * @param fallbacks defines the current fallback list.
  54480. * @param currentRank defines the current fallback rank.
  54481. * @returns the new fallback rank.
  54482. */
  54483. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54484. /**
  54485. * Add the required uniforms to the current list.
  54486. * @param uniforms defines the current uniform list.
  54487. */
  54488. static AddUniforms(uniforms: string[]): void;
  54489. /**
  54490. * Add the required samplers to the current list.
  54491. * @param samplers defines the current sampler list.
  54492. */
  54493. static AddSamplers(samplers: string[]): void;
  54494. /**
  54495. * Add the required uniforms to the current buffer.
  54496. * @param uniformBuffer defines the current uniform buffer.
  54497. */
  54498. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54499. /**
  54500. * Makes a duplicate of the current configuration into another one.
  54501. * @param configuration define the config where to copy the info
  54502. */
  54503. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54504. /**
  54505. * Serializes this Sub Surface configuration.
  54506. * @returns - An object with the serialized config.
  54507. */
  54508. serialize(): any;
  54509. /**
  54510. * Parses a anisotropy Configuration from a serialized object.
  54511. * @param source - Serialized object.
  54512. * @param scene Defines the scene we are parsing for
  54513. * @param rootUrl Defines the rootUrl to load from
  54514. */
  54515. parse(source: any, scene: Scene, rootUrl: string): void;
  54516. }
  54517. }
  54518. declare module BABYLON {
  54519. /** @hidden */
  54520. export var pbrFragmentDeclaration: {
  54521. name: string;
  54522. shader: string;
  54523. };
  54524. }
  54525. declare module BABYLON {
  54526. /** @hidden */
  54527. export var pbrUboDeclaration: {
  54528. name: string;
  54529. shader: string;
  54530. };
  54531. }
  54532. declare module BABYLON {
  54533. /** @hidden */
  54534. export var pbrFragmentExtraDeclaration: {
  54535. name: string;
  54536. shader: string;
  54537. };
  54538. }
  54539. declare module BABYLON {
  54540. /** @hidden */
  54541. export var pbrFragmentSamplersDeclaration: {
  54542. name: string;
  54543. shader: string;
  54544. };
  54545. }
  54546. declare module BABYLON {
  54547. /** @hidden */
  54548. export var importanceSampling: {
  54549. name: string;
  54550. shader: string;
  54551. };
  54552. }
  54553. declare module BABYLON {
  54554. /** @hidden */
  54555. export var pbrHelperFunctions: {
  54556. name: string;
  54557. shader: string;
  54558. };
  54559. }
  54560. declare module BABYLON {
  54561. /** @hidden */
  54562. export var harmonicsFunctions: {
  54563. name: string;
  54564. shader: string;
  54565. };
  54566. }
  54567. declare module BABYLON {
  54568. /** @hidden */
  54569. export var pbrDirectLightingSetupFunctions: {
  54570. name: string;
  54571. shader: string;
  54572. };
  54573. }
  54574. declare module BABYLON {
  54575. /** @hidden */
  54576. export var pbrDirectLightingFalloffFunctions: {
  54577. name: string;
  54578. shader: string;
  54579. };
  54580. }
  54581. declare module BABYLON {
  54582. /** @hidden */
  54583. export var pbrBRDFFunctions: {
  54584. name: string;
  54585. shader: string;
  54586. };
  54587. }
  54588. declare module BABYLON {
  54589. /** @hidden */
  54590. export var hdrFilteringFunctions: {
  54591. name: string;
  54592. shader: string;
  54593. };
  54594. }
  54595. declare module BABYLON {
  54596. /** @hidden */
  54597. export var pbrDirectLightingFunctions: {
  54598. name: string;
  54599. shader: string;
  54600. };
  54601. }
  54602. declare module BABYLON {
  54603. /** @hidden */
  54604. export var pbrIBLFunctions: {
  54605. name: string;
  54606. shader: string;
  54607. };
  54608. }
  54609. declare module BABYLON {
  54610. /** @hidden */
  54611. export var pbrBlockAlbedoOpacity: {
  54612. name: string;
  54613. shader: string;
  54614. };
  54615. }
  54616. declare module BABYLON {
  54617. /** @hidden */
  54618. export var pbrBlockReflectivity: {
  54619. name: string;
  54620. shader: string;
  54621. };
  54622. }
  54623. declare module BABYLON {
  54624. /** @hidden */
  54625. export var pbrBlockAmbientOcclusion: {
  54626. name: string;
  54627. shader: string;
  54628. };
  54629. }
  54630. declare module BABYLON {
  54631. /** @hidden */
  54632. export var pbrBlockAlphaFresnel: {
  54633. name: string;
  54634. shader: string;
  54635. };
  54636. }
  54637. declare module BABYLON {
  54638. /** @hidden */
  54639. export var pbrBlockAnisotropic: {
  54640. name: string;
  54641. shader: string;
  54642. };
  54643. }
  54644. declare module BABYLON {
  54645. /** @hidden */
  54646. export var pbrBlockReflection: {
  54647. name: string;
  54648. shader: string;
  54649. };
  54650. }
  54651. declare module BABYLON {
  54652. /** @hidden */
  54653. export var pbrBlockSheen: {
  54654. name: string;
  54655. shader: string;
  54656. };
  54657. }
  54658. declare module BABYLON {
  54659. /** @hidden */
  54660. export var pbrBlockClearcoat: {
  54661. name: string;
  54662. shader: string;
  54663. };
  54664. }
  54665. declare module BABYLON {
  54666. /** @hidden */
  54667. export var pbrBlockSubSurface: {
  54668. name: string;
  54669. shader: string;
  54670. };
  54671. }
  54672. declare module BABYLON {
  54673. /** @hidden */
  54674. export var pbrBlockNormalGeometric: {
  54675. name: string;
  54676. shader: string;
  54677. };
  54678. }
  54679. declare module BABYLON {
  54680. /** @hidden */
  54681. export var pbrBlockNormalFinal: {
  54682. name: string;
  54683. shader: string;
  54684. };
  54685. }
  54686. declare module BABYLON {
  54687. /** @hidden */
  54688. export var pbrBlockGeometryInfo: {
  54689. name: string;
  54690. shader: string;
  54691. };
  54692. }
  54693. declare module BABYLON {
  54694. /** @hidden */
  54695. export var pbrBlockReflectance0: {
  54696. name: string;
  54697. shader: string;
  54698. };
  54699. }
  54700. declare module BABYLON {
  54701. /** @hidden */
  54702. export var pbrBlockReflectance: {
  54703. name: string;
  54704. shader: string;
  54705. };
  54706. }
  54707. declare module BABYLON {
  54708. /** @hidden */
  54709. export var pbrBlockDirectLighting: {
  54710. name: string;
  54711. shader: string;
  54712. };
  54713. }
  54714. declare module BABYLON {
  54715. /** @hidden */
  54716. export var pbrBlockFinalLitComponents: {
  54717. name: string;
  54718. shader: string;
  54719. };
  54720. }
  54721. declare module BABYLON {
  54722. /** @hidden */
  54723. export var pbrBlockFinalUnlitComponents: {
  54724. name: string;
  54725. shader: string;
  54726. };
  54727. }
  54728. declare module BABYLON {
  54729. /** @hidden */
  54730. export var pbrBlockFinalColorComposition: {
  54731. name: string;
  54732. shader: string;
  54733. };
  54734. }
  54735. declare module BABYLON {
  54736. /** @hidden */
  54737. export var pbrBlockImageProcessing: {
  54738. name: string;
  54739. shader: string;
  54740. };
  54741. }
  54742. declare module BABYLON {
  54743. /** @hidden */
  54744. export var pbrDebug: {
  54745. name: string;
  54746. shader: string;
  54747. };
  54748. }
  54749. declare module BABYLON {
  54750. /** @hidden */
  54751. export var pbrPixelShader: {
  54752. name: string;
  54753. shader: string;
  54754. };
  54755. }
  54756. declare module BABYLON {
  54757. /** @hidden */
  54758. export var pbrVertexDeclaration: {
  54759. name: string;
  54760. shader: string;
  54761. };
  54762. }
  54763. declare module BABYLON {
  54764. /** @hidden */
  54765. export var pbrVertexShader: {
  54766. name: string;
  54767. shader: string;
  54768. };
  54769. }
  54770. declare module BABYLON {
  54771. /**
  54772. * Manages the defines for the PBR Material.
  54773. * @hidden
  54774. */
  54775. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54776. PBR: boolean;
  54777. NUM_SAMPLES: string;
  54778. REALTIME_FILTERING: boolean;
  54779. MAINUV1: boolean;
  54780. MAINUV2: boolean;
  54781. UV1: boolean;
  54782. UV2: boolean;
  54783. ALBEDO: boolean;
  54784. GAMMAALBEDO: boolean;
  54785. ALBEDODIRECTUV: number;
  54786. VERTEXCOLOR: boolean;
  54787. AMBIENT: boolean;
  54788. AMBIENTDIRECTUV: number;
  54789. AMBIENTINGRAYSCALE: boolean;
  54790. OPACITY: boolean;
  54791. VERTEXALPHA: boolean;
  54792. OPACITYDIRECTUV: number;
  54793. OPACITYRGB: boolean;
  54794. ALPHATEST: boolean;
  54795. DEPTHPREPASS: boolean;
  54796. ALPHABLEND: boolean;
  54797. ALPHAFROMALBEDO: boolean;
  54798. ALPHATESTVALUE: string;
  54799. SPECULAROVERALPHA: boolean;
  54800. RADIANCEOVERALPHA: boolean;
  54801. ALPHAFRESNEL: boolean;
  54802. LINEARALPHAFRESNEL: boolean;
  54803. PREMULTIPLYALPHA: boolean;
  54804. EMISSIVE: boolean;
  54805. EMISSIVEDIRECTUV: number;
  54806. REFLECTIVITY: boolean;
  54807. REFLECTIVITYDIRECTUV: number;
  54808. SPECULARTERM: boolean;
  54809. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54810. MICROSURFACEAUTOMATIC: boolean;
  54811. LODBASEDMICROSFURACE: boolean;
  54812. MICROSURFACEMAP: boolean;
  54813. MICROSURFACEMAPDIRECTUV: number;
  54814. METALLICWORKFLOW: boolean;
  54815. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54816. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54817. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54818. AOSTOREINMETALMAPRED: boolean;
  54819. METALLIC_REFLECTANCE: boolean;
  54820. METALLIC_REFLECTANCEDIRECTUV: number;
  54821. ENVIRONMENTBRDF: boolean;
  54822. ENVIRONMENTBRDF_RGBD: boolean;
  54823. NORMAL: boolean;
  54824. TANGENT: boolean;
  54825. BUMP: boolean;
  54826. BUMPDIRECTUV: number;
  54827. OBJECTSPACE_NORMALMAP: boolean;
  54828. PARALLAX: boolean;
  54829. PARALLAXOCCLUSION: boolean;
  54830. NORMALXYSCALE: boolean;
  54831. LIGHTMAP: boolean;
  54832. LIGHTMAPDIRECTUV: number;
  54833. USELIGHTMAPASSHADOWMAP: boolean;
  54834. GAMMALIGHTMAP: boolean;
  54835. RGBDLIGHTMAP: boolean;
  54836. REFLECTION: boolean;
  54837. REFLECTIONMAP_3D: boolean;
  54838. REFLECTIONMAP_SPHERICAL: boolean;
  54839. REFLECTIONMAP_PLANAR: boolean;
  54840. REFLECTIONMAP_CUBIC: boolean;
  54841. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54842. REFLECTIONMAP_PROJECTION: boolean;
  54843. REFLECTIONMAP_SKYBOX: boolean;
  54844. REFLECTIONMAP_EXPLICIT: boolean;
  54845. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54846. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54847. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54848. INVERTCUBICMAP: boolean;
  54849. USESPHERICALFROMREFLECTIONMAP: boolean;
  54850. USEIRRADIANCEMAP: boolean;
  54851. SPHERICAL_HARMONICS: boolean;
  54852. USESPHERICALINVERTEX: boolean;
  54853. REFLECTIONMAP_OPPOSITEZ: boolean;
  54854. LODINREFLECTIONALPHA: boolean;
  54855. GAMMAREFLECTION: boolean;
  54856. RGBDREFLECTION: boolean;
  54857. LINEARSPECULARREFLECTION: boolean;
  54858. RADIANCEOCCLUSION: boolean;
  54859. HORIZONOCCLUSION: boolean;
  54860. INSTANCES: boolean;
  54861. THIN_INSTANCES: boolean;
  54862. NUM_BONE_INFLUENCERS: number;
  54863. BonesPerMesh: number;
  54864. BONETEXTURE: boolean;
  54865. NONUNIFORMSCALING: boolean;
  54866. MORPHTARGETS: boolean;
  54867. MORPHTARGETS_NORMAL: boolean;
  54868. MORPHTARGETS_TANGENT: boolean;
  54869. MORPHTARGETS_UV: boolean;
  54870. NUM_MORPH_INFLUENCERS: number;
  54871. IMAGEPROCESSING: boolean;
  54872. VIGNETTE: boolean;
  54873. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54874. VIGNETTEBLENDMODEOPAQUE: boolean;
  54875. TONEMAPPING: boolean;
  54876. TONEMAPPING_ACES: boolean;
  54877. CONTRAST: boolean;
  54878. COLORCURVES: boolean;
  54879. COLORGRADING: boolean;
  54880. COLORGRADING3D: boolean;
  54881. SAMPLER3DGREENDEPTH: boolean;
  54882. SAMPLER3DBGRMAP: boolean;
  54883. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54884. EXPOSURE: boolean;
  54885. MULTIVIEW: boolean;
  54886. USEPHYSICALLIGHTFALLOFF: boolean;
  54887. USEGLTFLIGHTFALLOFF: boolean;
  54888. TWOSIDEDLIGHTING: boolean;
  54889. SHADOWFLOAT: boolean;
  54890. CLIPPLANE: boolean;
  54891. CLIPPLANE2: boolean;
  54892. CLIPPLANE3: boolean;
  54893. CLIPPLANE4: boolean;
  54894. CLIPPLANE5: boolean;
  54895. CLIPPLANE6: boolean;
  54896. POINTSIZE: boolean;
  54897. FOG: boolean;
  54898. LOGARITHMICDEPTH: boolean;
  54899. FORCENORMALFORWARD: boolean;
  54900. SPECULARAA: boolean;
  54901. CLEARCOAT: boolean;
  54902. CLEARCOAT_DEFAULTIOR: boolean;
  54903. CLEARCOAT_TEXTURE: boolean;
  54904. CLEARCOAT_TEXTUREDIRECTUV: number;
  54905. CLEARCOAT_BUMP: boolean;
  54906. CLEARCOAT_BUMPDIRECTUV: number;
  54907. CLEARCOAT_TINT: boolean;
  54908. CLEARCOAT_TINT_TEXTURE: boolean;
  54909. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54910. ANISOTROPIC: boolean;
  54911. ANISOTROPIC_TEXTURE: boolean;
  54912. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54913. BRDF_V_HEIGHT_CORRELATED: boolean;
  54914. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54915. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54916. SHEEN: boolean;
  54917. SHEEN_TEXTURE: boolean;
  54918. SHEEN_TEXTUREDIRECTUV: number;
  54919. SHEEN_LINKWITHALBEDO: boolean;
  54920. SHEEN_ROUGHNESS: boolean;
  54921. SHEEN_ALBEDOSCALING: boolean;
  54922. SUBSURFACE: boolean;
  54923. SS_REFRACTION: boolean;
  54924. SS_TRANSLUCENCY: boolean;
  54925. SS_SCATTERING: boolean;
  54926. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54927. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54928. SS_REFRACTIONMAP_3D: boolean;
  54929. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54930. SS_LODINREFRACTIONALPHA: boolean;
  54931. SS_GAMMAREFRACTION: boolean;
  54932. SS_RGBDREFRACTION: boolean;
  54933. SS_LINEARSPECULARREFRACTION: boolean;
  54934. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54935. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54936. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54937. UNLIT: boolean;
  54938. DEBUGMODE: number;
  54939. /**
  54940. * Initializes the PBR Material defines.
  54941. */
  54942. constructor();
  54943. /**
  54944. * Resets the PBR Material defines.
  54945. */
  54946. reset(): void;
  54947. }
  54948. /**
  54949. * The Physically based material base class of BJS.
  54950. *
  54951. * This offers the main features of a standard PBR material.
  54952. * For more information, please refer to the documentation :
  54953. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54954. */
  54955. export abstract class PBRBaseMaterial extends PushMaterial {
  54956. /**
  54957. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54958. */
  54959. static readonly PBRMATERIAL_OPAQUE: number;
  54960. /**
  54961. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54962. */
  54963. static readonly PBRMATERIAL_ALPHATEST: number;
  54964. /**
  54965. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54966. */
  54967. static readonly PBRMATERIAL_ALPHABLEND: number;
  54968. /**
  54969. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54970. * They are also discarded below the alpha cutoff threshold to improve performances.
  54971. */
  54972. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54973. /**
  54974. * Defines the default value of how much AO map is occluding the analytical lights
  54975. * (point spot...).
  54976. */
  54977. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54978. /**
  54979. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54980. */
  54981. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54982. /**
  54983. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54984. * to enhance interoperability with other engines.
  54985. */
  54986. static readonly LIGHTFALLOFF_GLTF: number;
  54987. /**
  54988. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54989. * to enhance interoperability with other materials.
  54990. */
  54991. static readonly LIGHTFALLOFF_STANDARD: number;
  54992. /**
  54993. * Intensity of the direct lights e.g. the four lights available in your scene.
  54994. * This impacts both the direct diffuse and specular highlights.
  54995. */
  54996. protected _directIntensity: number;
  54997. /**
  54998. * Intensity of the emissive part of the material.
  54999. * This helps controlling the emissive effect without modifying the emissive color.
  55000. */
  55001. protected _emissiveIntensity: number;
  55002. /**
  55003. * Intensity of the environment e.g. how much the environment will light the object
  55004. * either through harmonics for rough material or through the refelction for shiny ones.
  55005. */
  55006. protected _environmentIntensity: number;
  55007. /**
  55008. * This is a special control allowing the reduction of the specular highlights coming from the
  55009. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55010. */
  55011. protected _specularIntensity: number;
  55012. /**
  55013. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55014. */
  55015. private _lightingInfos;
  55016. /**
  55017. * Debug Control allowing disabling the bump map on this material.
  55018. */
  55019. protected _disableBumpMap: boolean;
  55020. /**
  55021. * AKA Diffuse Texture in standard nomenclature.
  55022. */
  55023. protected _albedoTexture: Nullable<BaseTexture>;
  55024. /**
  55025. * AKA Occlusion Texture in other nomenclature.
  55026. */
  55027. protected _ambientTexture: Nullable<BaseTexture>;
  55028. /**
  55029. * AKA Occlusion Texture Intensity in other nomenclature.
  55030. */
  55031. protected _ambientTextureStrength: number;
  55032. /**
  55033. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55034. * 1 means it completely occludes it
  55035. * 0 mean it has no impact
  55036. */
  55037. protected _ambientTextureImpactOnAnalyticalLights: number;
  55038. /**
  55039. * Stores the alpha values in a texture.
  55040. */
  55041. protected _opacityTexture: Nullable<BaseTexture>;
  55042. /**
  55043. * Stores the reflection values in a texture.
  55044. */
  55045. protected _reflectionTexture: Nullable<BaseTexture>;
  55046. /**
  55047. * Stores the emissive values in a texture.
  55048. */
  55049. protected _emissiveTexture: Nullable<BaseTexture>;
  55050. /**
  55051. * AKA Specular texture in other nomenclature.
  55052. */
  55053. protected _reflectivityTexture: Nullable<BaseTexture>;
  55054. /**
  55055. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55056. */
  55057. protected _metallicTexture: Nullable<BaseTexture>;
  55058. /**
  55059. * Specifies the metallic scalar of the metallic/roughness workflow.
  55060. * Can also be used to scale the metalness values of the metallic texture.
  55061. */
  55062. protected _metallic: Nullable<number>;
  55063. /**
  55064. * Specifies the roughness scalar of the metallic/roughness workflow.
  55065. * Can also be used to scale the roughness values of the metallic texture.
  55066. */
  55067. protected _roughness: Nullable<number>;
  55068. /**
  55069. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55070. * By default the indexOfrefraction is used to compute F0;
  55071. *
  55072. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55073. *
  55074. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55075. * F90 = metallicReflectanceColor;
  55076. */
  55077. protected _metallicF0Factor: number;
  55078. /**
  55079. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55080. * By default the F90 is always 1;
  55081. *
  55082. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55083. *
  55084. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55085. * F90 = metallicReflectanceColor;
  55086. */
  55087. protected _metallicReflectanceColor: Color3;
  55088. /**
  55089. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55090. * This is multiply against the scalar values defined in the material.
  55091. */
  55092. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55093. /**
  55094. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55095. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55096. */
  55097. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55098. /**
  55099. * Stores surface normal data used to displace a mesh in a texture.
  55100. */
  55101. protected _bumpTexture: Nullable<BaseTexture>;
  55102. /**
  55103. * Stores the pre-calculated light information of a mesh in a texture.
  55104. */
  55105. protected _lightmapTexture: Nullable<BaseTexture>;
  55106. /**
  55107. * The color of a material in ambient lighting.
  55108. */
  55109. protected _ambientColor: Color3;
  55110. /**
  55111. * AKA Diffuse Color in other nomenclature.
  55112. */
  55113. protected _albedoColor: Color3;
  55114. /**
  55115. * AKA Specular Color in other nomenclature.
  55116. */
  55117. protected _reflectivityColor: Color3;
  55118. /**
  55119. * The color applied when light is reflected from a material.
  55120. */
  55121. protected _reflectionColor: Color3;
  55122. /**
  55123. * The color applied when light is emitted from a material.
  55124. */
  55125. protected _emissiveColor: Color3;
  55126. /**
  55127. * AKA Glossiness in other nomenclature.
  55128. */
  55129. protected _microSurface: number;
  55130. /**
  55131. * Specifies that the material will use the light map as a show map.
  55132. */
  55133. protected _useLightmapAsShadowmap: boolean;
  55134. /**
  55135. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55136. * makes the reflect vector face the model (under horizon).
  55137. */
  55138. protected _useHorizonOcclusion: boolean;
  55139. /**
  55140. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55141. * too much the area relying on ambient texture to define their ambient occlusion.
  55142. */
  55143. protected _useRadianceOcclusion: boolean;
  55144. /**
  55145. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55146. */
  55147. protected _useAlphaFromAlbedoTexture: boolean;
  55148. /**
  55149. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55150. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55151. */
  55152. protected _useSpecularOverAlpha: boolean;
  55153. /**
  55154. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55155. */
  55156. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55157. /**
  55158. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55159. */
  55160. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55161. /**
  55162. * Specifies if the metallic texture contains the roughness information in its green channel.
  55163. */
  55164. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55165. /**
  55166. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55167. */
  55168. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55169. /**
  55170. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55171. */
  55172. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55173. /**
  55174. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55175. */
  55176. protected _useAmbientInGrayScale: boolean;
  55177. /**
  55178. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55179. * The material will try to infer what glossiness each pixel should be.
  55180. */
  55181. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55182. /**
  55183. * Defines the falloff type used in this material.
  55184. * It by default is Physical.
  55185. */
  55186. protected _lightFalloff: number;
  55187. /**
  55188. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55189. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55190. */
  55191. protected _useRadianceOverAlpha: boolean;
  55192. /**
  55193. * Allows using an object space normal map (instead of tangent space).
  55194. */
  55195. protected _useObjectSpaceNormalMap: boolean;
  55196. /**
  55197. * Allows using the bump map in parallax mode.
  55198. */
  55199. protected _useParallax: boolean;
  55200. /**
  55201. * Allows using the bump map in parallax occlusion mode.
  55202. */
  55203. protected _useParallaxOcclusion: boolean;
  55204. /**
  55205. * Controls the scale bias of the parallax mode.
  55206. */
  55207. protected _parallaxScaleBias: number;
  55208. /**
  55209. * If sets to true, disables all the lights affecting the material.
  55210. */
  55211. protected _disableLighting: boolean;
  55212. /**
  55213. * Number of Simultaneous lights allowed on the material.
  55214. */
  55215. protected _maxSimultaneousLights: number;
  55216. /**
  55217. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55218. */
  55219. protected _invertNormalMapX: boolean;
  55220. /**
  55221. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55222. */
  55223. protected _invertNormalMapY: boolean;
  55224. /**
  55225. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55226. */
  55227. protected _twoSidedLighting: boolean;
  55228. /**
  55229. * Defines the alpha limits in alpha test mode.
  55230. */
  55231. protected _alphaCutOff: number;
  55232. /**
  55233. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55234. */
  55235. protected _forceAlphaTest: boolean;
  55236. /**
  55237. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55238. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55239. */
  55240. protected _useAlphaFresnel: boolean;
  55241. /**
  55242. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55243. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55244. */
  55245. protected _useLinearAlphaFresnel: boolean;
  55246. /**
  55247. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55248. * from cos thetav and roughness:
  55249. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55250. */
  55251. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55252. /**
  55253. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55254. */
  55255. protected _forceIrradianceInFragment: boolean;
  55256. private _realTimeFiltering;
  55257. /**
  55258. * Enables realtime filtering on the texture.
  55259. */
  55260. get realTimeFiltering(): boolean;
  55261. set realTimeFiltering(b: boolean);
  55262. private _realTimeFilteringQuality;
  55263. /**
  55264. * Quality switch for realtime filtering
  55265. */
  55266. get realTimeFilteringQuality(): number;
  55267. set realTimeFilteringQuality(n: number);
  55268. /**
  55269. * Force normal to face away from face.
  55270. */
  55271. protected _forceNormalForward: boolean;
  55272. /**
  55273. * Enables specular anti aliasing in the PBR shader.
  55274. * It will both interacts on the Geometry for analytical and IBL lighting.
  55275. * It also prefilter the roughness map based on the bump values.
  55276. */
  55277. protected _enableSpecularAntiAliasing: boolean;
  55278. /**
  55279. * Default configuration related to image processing available in the PBR Material.
  55280. */
  55281. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55282. /**
  55283. * Keep track of the image processing observer to allow dispose and replace.
  55284. */
  55285. private _imageProcessingObserver;
  55286. /**
  55287. * Attaches a new image processing configuration to the PBR Material.
  55288. * @param configuration
  55289. */
  55290. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55291. /**
  55292. * Stores the available render targets.
  55293. */
  55294. private _renderTargets;
  55295. /**
  55296. * Sets the global ambient color for the material used in lighting calculations.
  55297. */
  55298. private _globalAmbientColor;
  55299. /**
  55300. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55301. */
  55302. private _useLogarithmicDepth;
  55303. /**
  55304. * If set to true, no lighting calculations will be applied.
  55305. */
  55306. private _unlit;
  55307. private _debugMode;
  55308. /**
  55309. * @hidden
  55310. * This is reserved for the inspector.
  55311. * Defines the material debug mode.
  55312. * It helps seeing only some components of the material while troubleshooting.
  55313. */
  55314. debugMode: number;
  55315. /**
  55316. * @hidden
  55317. * This is reserved for the inspector.
  55318. * Specify from where on screen the debug mode should start.
  55319. * The value goes from -1 (full screen) to 1 (not visible)
  55320. * It helps with side by side comparison against the final render
  55321. * This defaults to -1
  55322. */
  55323. private debugLimit;
  55324. /**
  55325. * @hidden
  55326. * This is reserved for the inspector.
  55327. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55328. * You can use the factor to better multiply the final value.
  55329. */
  55330. private debugFactor;
  55331. /**
  55332. * Defines the clear coat layer parameters for the material.
  55333. */
  55334. readonly clearCoat: PBRClearCoatConfiguration;
  55335. /**
  55336. * Defines the anisotropic parameters for the material.
  55337. */
  55338. readonly anisotropy: PBRAnisotropicConfiguration;
  55339. /**
  55340. * Defines the BRDF parameters for the material.
  55341. */
  55342. readonly brdf: PBRBRDFConfiguration;
  55343. /**
  55344. * Defines the Sheen parameters for the material.
  55345. */
  55346. readonly sheen: PBRSheenConfiguration;
  55347. /**
  55348. * Defines the SubSurface parameters for the material.
  55349. */
  55350. readonly subSurface: PBRSubSurfaceConfiguration;
  55351. protected _rebuildInParallel: boolean;
  55352. /**
  55353. * Instantiates a new PBRMaterial instance.
  55354. *
  55355. * @param name The material name
  55356. * @param scene The scene the material will be use in.
  55357. */
  55358. constructor(name: string, scene: Scene);
  55359. /**
  55360. * Gets a boolean indicating that current material needs to register RTT
  55361. */
  55362. get hasRenderTargetTextures(): boolean;
  55363. /**
  55364. * Gets the name of the material class.
  55365. */
  55366. getClassName(): string;
  55367. /**
  55368. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55369. */
  55370. get useLogarithmicDepth(): boolean;
  55371. /**
  55372. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55373. */
  55374. set useLogarithmicDepth(value: boolean);
  55375. /**
  55376. * Returns true if alpha blending should be disabled.
  55377. */
  55378. protected get _disableAlphaBlending(): boolean;
  55379. /**
  55380. * Specifies whether or not this material should be rendered in alpha blend mode.
  55381. */
  55382. needAlphaBlending(): boolean;
  55383. /**
  55384. * Specifies whether or not this material should be rendered in alpha test mode.
  55385. */
  55386. needAlphaTesting(): boolean;
  55387. /**
  55388. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55389. */
  55390. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55391. /**
  55392. * Gets the texture used for the alpha test.
  55393. */
  55394. getAlphaTestTexture(): Nullable<BaseTexture>;
  55395. /**
  55396. * Specifies that the submesh is ready to be used.
  55397. * @param mesh - BJS mesh.
  55398. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55399. * @param useInstances - Specifies that instances should be used.
  55400. * @returns - boolean indicating that the submesh is ready or not.
  55401. */
  55402. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55403. /**
  55404. * Specifies if the material uses metallic roughness workflow.
  55405. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55406. */
  55407. isMetallicWorkflow(): boolean;
  55408. private _prepareEffect;
  55409. private _prepareDefines;
  55410. /**
  55411. * Force shader compilation
  55412. */
  55413. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55414. /**
  55415. * Initializes the uniform buffer layout for the shader.
  55416. */
  55417. buildUniformLayout(): void;
  55418. /**
  55419. * Unbinds the material from the mesh
  55420. */
  55421. unbind(): void;
  55422. /**
  55423. * Binds the submesh data.
  55424. * @param world - The world matrix.
  55425. * @param mesh - The BJS mesh.
  55426. * @param subMesh - A submesh of the BJS mesh.
  55427. */
  55428. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55429. /**
  55430. * Returns the animatable textures.
  55431. * @returns - Array of animatable textures.
  55432. */
  55433. getAnimatables(): IAnimatable[];
  55434. /**
  55435. * Returns the texture used for reflections.
  55436. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55437. */
  55438. private _getReflectionTexture;
  55439. /**
  55440. * Returns an array of the actively used textures.
  55441. * @returns - Array of BaseTextures
  55442. */
  55443. getActiveTextures(): BaseTexture[];
  55444. /**
  55445. * Checks to see if a texture is used in the material.
  55446. * @param texture - Base texture to use.
  55447. * @returns - Boolean specifying if a texture is used in the material.
  55448. */
  55449. hasTexture(texture: BaseTexture): boolean;
  55450. /**
  55451. * Disposes the resources of the material.
  55452. * @param forceDisposeEffect - Forces the disposal of effects.
  55453. * @param forceDisposeTextures - Forces the disposal of all textures.
  55454. */
  55455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55456. }
  55457. }
  55458. declare module BABYLON {
  55459. /**
  55460. * The Physically based material of BJS.
  55461. *
  55462. * This offers the main features of a standard PBR material.
  55463. * For more information, please refer to the documentation :
  55464. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55465. */
  55466. export class PBRMaterial extends PBRBaseMaterial {
  55467. /**
  55468. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55469. */
  55470. static readonly PBRMATERIAL_OPAQUE: number;
  55471. /**
  55472. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55473. */
  55474. static readonly PBRMATERIAL_ALPHATEST: number;
  55475. /**
  55476. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55477. */
  55478. static readonly PBRMATERIAL_ALPHABLEND: number;
  55479. /**
  55480. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55481. * They are also discarded below the alpha cutoff threshold to improve performances.
  55482. */
  55483. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55484. /**
  55485. * Defines the default value of how much AO map is occluding the analytical lights
  55486. * (point spot...).
  55487. */
  55488. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55489. /**
  55490. * Intensity of the direct lights e.g. the four lights available in your scene.
  55491. * This impacts both the direct diffuse and specular highlights.
  55492. */
  55493. directIntensity: number;
  55494. /**
  55495. * Intensity of the emissive part of the material.
  55496. * This helps controlling the emissive effect without modifying the emissive color.
  55497. */
  55498. emissiveIntensity: number;
  55499. /**
  55500. * Intensity of the environment e.g. how much the environment will light the object
  55501. * either through harmonics for rough material or through the refelction for shiny ones.
  55502. */
  55503. environmentIntensity: number;
  55504. /**
  55505. * This is a special control allowing the reduction of the specular highlights coming from the
  55506. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55507. */
  55508. specularIntensity: number;
  55509. /**
  55510. * Debug Control allowing disabling the bump map on this material.
  55511. */
  55512. disableBumpMap: boolean;
  55513. /**
  55514. * AKA Diffuse Texture in standard nomenclature.
  55515. */
  55516. albedoTexture: BaseTexture;
  55517. /**
  55518. * AKA Occlusion Texture in other nomenclature.
  55519. */
  55520. ambientTexture: BaseTexture;
  55521. /**
  55522. * AKA Occlusion Texture Intensity in other nomenclature.
  55523. */
  55524. ambientTextureStrength: number;
  55525. /**
  55526. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55527. * 1 means it completely occludes it
  55528. * 0 mean it has no impact
  55529. */
  55530. ambientTextureImpactOnAnalyticalLights: number;
  55531. /**
  55532. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55533. */
  55534. opacityTexture: BaseTexture;
  55535. /**
  55536. * Stores the reflection values in a texture.
  55537. */
  55538. reflectionTexture: Nullable<BaseTexture>;
  55539. /**
  55540. * Stores the emissive values in a texture.
  55541. */
  55542. emissiveTexture: BaseTexture;
  55543. /**
  55544. * AKA Specular texture in other nomenclature.
  55545. */
  55546. reflectivityTexture: BaseTexture;
  55547. /**
  55548. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55549. */
  55550. metallicTexture: BaseTexture;
  55551. /**
  55552. * Specifies the metallic scalar of the metallic/roughness workflow.
  55553. * Can also be used to scale the metalness values of the metallic texture.
  55554. */
  55555. metallic: Nullable<number>;
  55556. /**
  55557. * Specifies the roughness scalar of the metallic/roughness workflow.
  55558. * Can also be used to scale the roughness values of the metallic texture.
  55559. */
  55560. roughness: Nullable<number>;
  55561. /**
  55562. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55563. * By default the indexOfrefraction is used to compute F0;
  55564. *
  55565. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55566. *
  55567. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55568. * F90 = metallicReflectanceColor;
  55569. */
  55570. metallicF0Factor: number;
  55571. /**
  55572. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55573. * By default the F90 is always 1;
  55574. *
  55575. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55576. *
  55577. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55578. * F90 = metallicReflectanceColor;
  55579. */
  55580. metallicReflectanceColor: Color3;
  55581. /**
  55582. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55583. * This is multiply against the scalar values defined in the material.
  55584. */
  55585. metallicReflectanceTexture: Nullable<BaseTexture>;
  55586. /**
  55587. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55588. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55589. */
  55590. microSurfaceTexture: BaseTexture;
  55591. /**
  55592. * Stores surface normal data used to displace a mesh in a texture.
  55593. */
  55594. bumpTexture: BaseTexture;
  55595. /**
  55596. * Stores the pre-calculated light information of a mesh in a texture.
  55597. */
  55598. lightmapTexture: BaseTexture;
  55599. /**
  55600. * Stores the refracted light information in a texture.
  55601. */
  55602. get refractionTexture(): Nullable<BaseTexture>;
  55603. set refractionTexture(value: Nullable<BaseTexture>);
  55604. /**
  55605. * The color of a material in ambient lighting.
  55606. */
  55607. ambientColor: Color3;
  55608. /**
  55609. * AKA Diffuse Color in other nomenclature.
  55610. */
  55611. albedoColor: Color3;
  55612. /**
  55613. * AKA Specular Color in other nomenclature.
  55614. */
  55615. reflectivityColor: Color3;
  55616. /**
  55617. * The color reflected from the material.
  55618. */
  55619. reflectionColor: Color3;
  55620. /**
  55621. * The color emitted from the material.
  55622. */
  55623. emissiveColor: Color3;
  55624. /**
  55625. * AKA Glossiness in other nomenclature.
  55626. */
  55627. microSurface: number;
  55628. /**
  55629. * Index of refraction of the material base layer.
  55630. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55631. *
  55632. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55633. *
  55634. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55635. */
  55636. get indexOfRefraction(): number;
  55637. set indexOfRefraction(value: number);
  55638. /**
  55639. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55640. */
  55641. get invertRefractionY(): boolean;
  55642. set invertRefractionY(value: boolean);
  55643. /**
  55644. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55645. * Materials half opaque for instance using refraction could benefit from this control.
  55646. */
  55647. get linkRefractionWithTransparency(): boolean;
  55648. set linkRefractionWithTransparency(value: boolean);
  55649. /**
  55650. * If true, the light map contains occlusion information instead of lighting info.
  55651. */
  55652. useLightmapAsShadowmap: boolean;
  55653. /**
  55654. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55655. */
  55656. useAlphaFromAlbedoTexture: boolean;
  55657. /**
  55658. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55659. */
  55660. forceAlphaTest: boolean;
  55661. /**
  55662. * Defines the alpha limits in alpha test mode.
  55663. */
  55664. alphaCutOff: number;
  55665. /**
  55666. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55667. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55668. */
  55669. useSpecularOverAlpha: boolean;
  55670. /**
  55671. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55672. */
  55673. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55674. /**
  55675. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55676. */
  55677. useRoughnessFromMetallicTextureAlpha: boolean;
  55678. /**
  55679. * Specifies if the metallic texture contains the roughness information in its green channel.
  55680. */
  55681. useRoughnessFromMetallicTextureGreen: boolean;
  55682. /**
  55683. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55684. */
  55685. useMetallnessFromMetallicTextureBlue: boolean;
  55686. /**
  55687. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55688. */
  55689. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55690. /**
  55691. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55692. */
  55693. useAmbientInGrayScale: boolean;
  55694. /**
  55695. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55696. * The material will try to infer what glossiness each pixel should be.
  55697. */
  55698. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55699. /**
  55700. * BJS is using an harcoded light falloff based on a manually sets up range.
  55701. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55702. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55703. */
  55704. get usePhysicalLightFalloff(): boolean;
  55705. /**
  55706. * BJS is using an harcoded light falloff based on a manually sets up range.
  55707. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55708. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55709. */
  55710. set usePhysicalLightFalloff(value: boolean);
  55711. /**
  55712. * In order to support the falloff compatibility with gltf, a special mode has been added
  55713. * to reproduce the gltf light falloff.
  55714. */
  55715. get useGLTFLightFalloff(): boolean;
  55716. /**
  55717. * In order to support the falloff compatibility with gltf, a special mode has been added
  55718. * to reproduce the gltf light falloff.
  55719. */
  55720. set useGLTFLightFalloff(value: boolean);
  55721. /**
  55722. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55723. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55724. */
  55725. useRadianceOverAlpha: boolean;
  55726. /**
  55727. * Allows using an object space normal map (instead of tangent space).
  55728. */
  55729. useObjectSpaceNormalMap: boolean;
  55730. /**
  55731. * Allows using the bump map in parallax mode.
  55732. */
  55733. useParallax: boolean;
  55734. /**
  55735. * Allows using the bump map in parallax occlusion mode.
  55736. */
  55737. useParallaxOcclusion: boolean;
  55738. /**
  55739. * Controls the scale bias of the parallax mode.
  55740. */
  55741. parallaxScaleBias: number;
  55742. /**
  55743. * If sets to true, disables all the lights affecting the material.
  55744. */
  55745. disableLighting: boolean;
  55746. /**
  55747. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55748. */
  55749. forceIrradianceInFragment: boolean;
  55750. /**
  55751. * Number of Simultaneous lights allowed on the material.
  55752. */
  55753. maxSimultaneousLights: number;
  55754. /**
  55755. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55756. */
  55757. invertNormalMapX: boolean;
  55758. /**
  55759. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55760. */
  55761. invertNormalMapY: boolean;
  55762. /**
  55763. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55764. */
  55765. twoSidedLighting: boolean;
  55766. /**
  55767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55768. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55769. */
  55770. useAlphaFresnel: boolean;
  55771. /**
  55772. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55773. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55774. */
  55775. useLinearAlphaFresnel: boolean;
  55776. /**
  55777. * Let user defines the brdf lookup texture used for IBL.
  55778. * A default 8bit version is embedded but you could point at :
  55779. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55780. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55781. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55782. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55783. */
  55784. environmentBRDFTexture: Nullable<BaseTexture>;
  55785. /**
  55786. * Force normal to face away from face.
  55787. */
  55788. forceNormalForward: boolean;
  55789. /**
  55790. * Enables specular anti aliasing in the PBR shader.
  55791. * It will both interacts on the Geometry for analytical and IBL lighting.
  55792. * It also prefilter the roughness map based on the bump values.
  55793. */
  55794. enableSpecularAntiAliasing: boolean;
  55795. /**
  55796. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55797. * makes the reflect vector face the model (under horizon).
  55798. */
  55799. useHorizonOcclusion: boolean;
  55800. /**
  55801. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55802. * too much the area relying on ambient texture to define their ambient occlusion.
  55803. */
  55804. useRadianceOcclusion: boolean;
  55805. /**
  55806. * If set to true, no lighting calculations will be applied.
  55807. */
  55808. unlit: boolean;
  55809. /**
  55810. * Gets the image processing configuration used either in this material.
  55811. */
  55812. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55813. /**
  55814. * Sets the Default image processing configuration used either in the this material.
  55815. *
  55816. * If sets to null, the scene one is in use.
  55817. */
  55818. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55819. /**
  55820. * Gets wether the color curves effect is enabled.
  55821. */
  55822. get cameraColorCurvesEnabled(): boolean;
  55823. /**
  55824. * Sets wether the color curves effect is enabled.
  55825. */
  55826. set cameraColorCurvesEnabled(value: boolean);
  55827. /**
  55828. * Gets wether the color grading effect is enabled.
  55829. */
  55830. get cameraColorGradingEnabled(): boolean;
  55831. /**
  55832. * Gets wether the color grading effect is enabled.
  55833. */
  55834. set cameraColorGradingEnabled(value: boolean);
  55835. /**
  55836. * Gets wether tonemapping is enabled or not.
  55837. */
  55838. get cameraToneMappingEnabled(): boolean;
  55839. /**
  55840. * Sets wether tonemapping is enabled or not
  55841. */
  55842. set cameraToneMappingEnabled(value: boolean);
  55843. /**
  55844. * The camera exposure used on this material.
  55845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55846. * This corresponds to a photographic exposure.
  55847. */
  55848. get cameraExposure(): number;
  55849. /**
  55850. * The camera exposure used on this material.
  55851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55852. * This corresponds to a photographic exposure.
  55853. */
  55854. set cameraExposure(value: number);
  55855. /**
  55856. * Gets The camera contrast used on this material.
  55857. */
  55858. get cameraContrast(): number;
  55859. /**
  55860. * Sets The camera contrast used on this material.
  55861. */
  55862. set cameraContrast(value: number);
  55863. /**
  55864. * Gets the Color Grading 2D Lookup Texture.
  55865. */
  55866. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55867. /**
  55868. * Sets the Color Grading 2D Lookup Texture.
  55869. */
  55870. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55871. /**
  55872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55874. * 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;
  55875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55876. */
  55877. get cameraColorCurves(): Nullable<ColorCurves>;
  55878. /**
  55879. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55881. * 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;
  55882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55883. */
  55884. set cameraColorCurves(value: Nullable<ColorCurves>);
  55885. /**
  55886. * Instantiates a new PBRMaterial instance.
  55887. *
  55888. * @param name The material name
  55889. * @param scene The scene the material will be use in.
  55890. */
  55891. constructor(name: string, scene: Scene);
  55892. /**
  55893. * Returns the name of this material class.
  55894. */
  55895. getClassName(): string;
  55896. /**
  55897. * Makes a duplicate of the current material.
  55898. * @param name - name to use for the new material.
  55899. */
  55900. clone(name: string): PBRMaterial;
  55901. /**
  55902. * Serializes this PBR Material.
  55903. * @returns - An object with the serialized material.
  55904. */
  55905. serialize(): any;
  55906. /**
  55907. * Parses a PBR Material from a serialized object.
  55908. * @param source - Serialized object.
  55909. * @param scene - BJS scene instance.
  55910. * @param rootUrl - url for the scene object
  55911. * @returns - PBRMaterial
  55912. */
  55913. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55914. }
  55915. }
  55916. declare module BABYLON {
  55917. /**
  55918. * Direct draw surface info
  55919. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55920. */
  55921. export interface DDSInfo {
  55922. /**
  55923. * Width of the texture
  55924. */
  55925. width: number;
  55926. /**
  55927. * Width of the texture
  55928. */
  55929. height: number;
  55930. /**
  55931. * Number of Mipmaps for the texture
  55932. * @see https://en.wikipedia.org/wiki/Mipmap
  55933. */
  55934. mipmapCount: number;
  55935. /**
  55936. * If the textures format is a known fourCC format
  55937. * @see https://www.fourcc.org/
  55938. */
  55939. isFourCC: boolean;
  55940. /**
  55941. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55942. */
  55943. isRGB: boolean;
  55944. /**
  55945. * If the texture is a lumincance format
  55946. */
  55947. isLuminance: boolean;
  55948. /**
  55949. * If this is a cube texture
  55950. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55951. */
  55952. isCube: boolean;
  55953. /**
  55954. * If the texture is a compressed format eg. FOURCC_DXT1
  55955. */
  55956. isCompressed: boolean;
  55957. /**
  55958. * The dxgiFormat of the texture
  55959. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55960. */
  55961. dxgiFormat: number;
  55962. /**
  55963. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55964. */
  55965. textureType: number;
  55966. /**
  55967. * Sphericle polynomial created for the dds texture
  55968. */
  55969. sphericalPolynomial?: SphericalPolynomial;
  55970. }
  55971. /**
  55972. * Class used to provide DDS decompression tools
  55973. */
  55974. export class DDSTools {
  55975. /**
  55976. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55977. */
  55978. static StoreLODInAlphaChannel: boolean;
  55979. /**
  55980. * Gets DDS information from an array buffer
  55981. * @param data defines the array buffer view to read data from
  55982. * @returns the DDS information
  55983. */
  55984. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55985. private static _FloatView;
  55986. private static _Int32View;
  55987. private static _ToHalfFloat;
  55988. private static _FromHalfFloat;
  55989. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55990. private static _GetHalfFloatRGBAArrayBuffer;
  55991. private static _GetFloatRGBAArrayBuffer;
  55992. private static _GetFloatAsUIntRGBAArrayBuffer;
  55993. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55994. private static _GetRGBAArrayBuffer;
  55995. private static _ExtractLongWordOrder;
  55996. private static _GetRGBArrayBuffer;
  55997. private static _GetLuminanceArrayBuffer;
  55998. /**
  55999. * Uploads DDS Levels to a Babylon Texture
  56000. * @hidden
  56001. */
  56002. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56003. }
  56004. interface ThinEngine {
  56005. /**
  56006. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56007. * @param rootUrl defines the url where the file to load is located
  56008. * @param scene defines the current scene
  56009. * @param lodScale defines scale to apply to the mip map selection
  56010. * @param lodOffset defines offset to apply to the mip map selection
  56011. * @param onLoad defines an optional callback raised when the texture is loaded
  56012. * @param onError defines an optional callback raised if there is an issue to load the texture
  56013. * @param format defines the format of the data
  56014. * @param forcedExtension defines the extension to use to pick the right loader
  56015. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56016. * @returns the cube texture as an InternalTexture
  56017. */
  56018. 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;
  56019. }
  56020. }
  56021. declare module BABYLON {
  56022. /**
  56023. * Implementation of the DDS Texture Loader.
  56024. * @hidden
  56025. */
  56026. export class _DDSTextureLoader implements IInternalTextureLoader {
  56027. /**
  56028. * Defines wether the loader supports cascade loading the different faces.
  56029. */
  56030. readonly supportCascades: boolean;
  56031. /**
  56032. * This returns if the loader support the current file information.
  56033. * @param extension defines the file extension of the file being loaded
  56034. * @returns true if the loader can load the specified file
  56035. */
  56036. canLoad(extension: string): boolean;
  56037. /**
  56038. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56039. * @param data contains the texture data
  56040. * @param texture defines the BabylonJS internal texture
  56041. * @param createPolynomials will be true if polynomials have been requested
  56042. * @param onLoad defines the callback to trigger once the texture is ready
  56043. * @param onError defines the callback to trigger in case of error
  56044. */
  56045. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56046. /**
  56047. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56048. * @param data contains the texture data
  56049. * @param texture defines the BabylonJS internal texture
  56050. * @param callback defines the method to call once ready to upload
  56051. */
  56052. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * Implementation of the ENV Texture Loader.
  56058. * @hidden
  56059. */
  56060. export class _ENVTextureLoader implements IInternalTextureLoader {
  56061. /**
  56062. * Defines wether the loader supports cascade loading the different faces.
  56063. */
  56064. readonly supportCascades: boolean;
  56065. /**
  56066. * This returns if the loader support the current file information.
  56067. * @param extension defines the file extension of the file being loaded
  56068. * @returns true if the loader can load the specified file
  56069. */
  56070. canLoad(extension: string): boolean;
  56071. /**
  56072. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56073. * @param data contains the texture data
  56074. * @param texture defines the BabylonJS internal texture
  56075. * @param createPolynomials will be true if polynomials have been requested
  56076. * @param onLoad defines the callback to trigger once the texture is ready
  56077. * @param onError defines the callback to trigger in case of error
  56078. */
  56079. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56080. /**
  56081. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56082. * @param data contains the texture data
  56083. * @param texture defines the BabylonJS internal texture
  56084. * @param callback defines the method to call once ready to upload
  56085. */
  56086. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56092. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56093. */
  56094. export class KhronosTextureContainer {
  56095. /** contents of the KTX container file */
  56096. data: ArrayBufferView;
  56097. private static HEADER_LEN;
  56098. private static COMPRESSED_2D;
  56099. private static COMPRESSED_3D;
  56100. private static TEX_2D;
  56101. private static TEX_3D;
  56102. /**
  56103. * Gets the openGL type
  56104. */
  56105. glType: number;
  56106. /**
  56107. * Gets the openGL type size
  56108. */
  56109. glTypeSize: number;
  56110. /**
  56111. * Gets the openGL format
  56112. */
  56113. glFormat: number;
  56114. /**
  56115. * Gets the openGL internal format
  56116. */
  56117. glInternalFormat: number;
  56118. /**
  56119. * Gets the base internal format
  56120. */
  56121. glBaseInternalFormat: number;
  56122. /**
  56123. * Gets image width in pixel
  56124. */
  56125. pixelWidth: number;
  56126. /**
  56127. * Gets image height in pixel
  56128. */
  56129. pixelHeight: number;
  56130. /**
  56131. * Gets image depth in pixels
  56132. */
  56133. pixelDepth: number;
  56134. /**
  56135. * Gets the number of array elements
  56136. */
  56137. numberOfArrayElements: number;
  56138. /**
  56139. * Gets the number of faces
  56140. */
  56141. numberOfFaces: number;
  56142. /**
  56143. * Gets the number of mipmap levels
  56144. */
  56145. numberOfMipmapLevels: number;
  56146. /**
  56147. * Gets the bytes of key value data
  56148. */
  56149. bytesOfKeyValueData: number;
  56150. /**
  56151. * Gets the load type
  56152. */
  56153. loadType: number;
  56154. /**
  56155. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56156. */
  56157. isInvalid: boolean;
  56158. /**
  56159. * Creates a new KhronosTextureContainer
  56160. * @param data contents of the KTX container file
  56161. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56162. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56163. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56164. */
  56165. constructor(
  56166. /** contents of the KTX container file */
  56167. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56168. /**
  56169. * Uploads KTX content to a Babylon Texture.
  56170. * It is assumed that the texture has already been created & is currently bound
  56171. * @hidden
  56172. */
  56173. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56174. private _upload2DCompressedLevels;
  56175. /**
  56176. * Checks if the given data starts with a KTX file identifier.
  56177. * @param data the data to check
  56178. * @returns true if the data is a KTX file or false otherwise
  56179. */
  56180. static IsValid(data: ArrayBufferView): boolean;
  56181. }
  56182. }
  56183. declare module BABYLON {
  56184. /**
  56185. * Class for loading KTX2 files
  56186. * !!! Experimental Extension Subject to Changes !!!
  56187. * @hidden
  56188. */
  56189. export class KhronosTextureContainer2 {
  56190. private static _ModulePromise;
  56191. private static _TranscodeFormat;
  56192. constructor(engine: ThinEngine);
  56193. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56194. private _determineTranscodeFormat;
  56195. /**
  56196. * Checks if the given data starts with a KTX2 file identifier.
  56197. * @param data the data to check
  56198. * @returns true if the data is a KTX2 file or false otherwise
  56199. */
  56200. static IsValid(data: ArrayBufferView): boolean;
  56201. }
  56202. }
  56203. declare module BABYLON {
  56204. /**
  56205. * Implementation of the KTX Texture Loader.
  56206. * @hidden
  56207. */
  56208. export class _KTXTextureLoader implements IInternalTextureLoader {
  56209. /**
  56210. * Defines wether the loader supports cascade loading the different faces.
  56211. */
  56212. readonly supportCascades: boolean;
  56213. /**
  56214. * This returns if the loader support the current file information.
  56215. * @param extension defines the file extension of the file being loaded
  56216. * @returns true if the loader can load the specified file
  56217. */
  56218. canLoad(extension: string): boolean;
  56219. /**
  56220. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56221. * @param data contains the texture data
  56222. * @param texture defines the BabylonJS internal texture
  56223. * @param createPolynomials will be true if polynomials have been requested
  56224. * @param onLoad defines the callback to trigger once the texture is ready
  56225. * @param onError defines the callback to trigger in case of error
  56226. */
  56227. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56228. /**
  56229. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56230. * @param data contains the texture data
  56231. * @param texture defines the BabylonJS internal texture
  56232. * @param callback defines the method to call once ready to upload
  56233. */
  56234. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56235. }
  56236. }
  56237. declare module BABYLON {
  56238. /** @hidden */
  56239. export var _forceSceneHelpersToBundle: boolean;
  56240. interface Scene {
  56241. /**
  56242. * Creates a default light for the scene.
  56243. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56244. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56245. */
  56246. createDefaultLight(replace?: boolean): void;
  56247. /**
  56248. * Creates a default camera for the scene.
  56249. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56250. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56251. * @param replace has default false, when true replaces the active camera in the scene
  56252. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56253. */
  56254. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56255. /**
  56256. * Creates a default camera and a default light.
  56257. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56258. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56259. * @param replace has the default false, when true replaces the active camera/light in the scene
  56260. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56261. */
  56262. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56263. /**
  56264. * Creates a new sky box
  56265. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56266. * @param environmentTexture defines the texture to use as environment texture
  56267. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56268. * @param scale defines the overall scale of the skybox
  56269. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56270. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56271. * @returns a new mesh holding the sky box
  56272. */
  56273. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56274. /**
  56275. * Creates a new environment
  56276. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56277. * @param options defines the options you can use to configure the environment
  56278. * @returns the new EnvironmentHelper
  56279. */
  56280. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56281. /**
  56282. * Creates a new VREXperienceHelper
  56283. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56284. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56285. * @returns a new VREXperienceHelper
  56286. */
  56287. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56288. /**
  56289. * Creates a new WebXRDefaultExperience
  56290. * @see http://doc.babylonjs.com/how_to/webxr
  56291. * @param options experience options
  56292. * @returns a promise for a new WebXRDefaultExperience
  56293. */
  56294. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56295. }
  56296. }
  56297. declare module BABYLON {
  56298. /**
  56299. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56300. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56301. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56302. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56303. */
  56304. export class VideoDome extends TransformNode {
  56305. /**
  56306. * Define the video source as a Monoscopic panoramic 360 video.
  56307. */
  56308. static readonly MODE_MONOSCOPIC: number;
  56309. /**
  56310. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56311. */
  56312. static readonly MODE_TOPBOTTOM: number;
  56313. /**
  56314. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56315. */
  56316. static readonly MODE_SIDEBYSIDE: number;
  56317. private _halfDome;
  56318. private _useDirectMapping;
  56319. /**
  56320. * The video texture being displayed on the sphere
  56321. */
  56322. protected _videoTexture: VideoTexture;
  56323. /**
  56324. * Gets the video texture being displayed on the sphere
  56325. */
  56326. get videoTexture(): VideoTexture;
  56327. /**
  56328. * The skybox material
  56329. */
  56330. protected _material: BackgroundMaterial;
  56331. /**
  56332. * The surface used for the skybox
  56333. */
  56334. protected _mesh: Mesh;
  56335. /**
  56336. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56337. */
  56338. private _halfDomeMask;
  56339. /**
  56340. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56341. * Also see the options.resolution property.
  56342. */
  56343. get fovMultiplier(): number;
  56344. set fovMultiplier(value: number);
  56345. private _videoMode;
  56346. /**
  56347. * Gets or set the current video mode for the video. It can be:
  56348. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56349. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56350. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56351. */
  56352. get videoMode(): number;
  56353. set videoMode(value: number);
  56354. /**
  56355. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56356. *
  56357. */
  56358. get halfDome(): boolean;
  56359. /**
  56360. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56361. */
  56362. set halfDome(enabled: boolean);
  56363. /**
  56364. * Oberserver used in Stereoscopic VR Mode.
  56365. */
  56366. private _onBeforeCameraRenderObserver;
  56367. /**
  56368. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56369. * @param name Element's name, child elements will append suffixes for their own names.
  56370. * @param urlsOrVideo defines the url(s) or the video element to use
  56371. * @param options An object containing optional or exposed sub element properties
  56372. */
  56373. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56374. resolution?: number;
  56375. clickToPlay?: boolean;
  56376. autoPlay?: boolean;
  56377. loop?: boolean;
  56378. size?: number;
  56379. poster?: string;
  56380. faceForward?: boolean;
  56381. useDirectMapping?: boolean;
  56382. halfDomeMode?: boolean;
  56383. }, scene: Scene);
  56384. private _changeVideoMode;
  56385. /**
  56386. * Releases resources associated with this node.
  56387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56389. */
  56390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56391. }
  56392. }
  56393. declare module BABYLON {
  56394. /**
  56395. * This class can be used to get instrumentation data from a Babylon engine
  56396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56397. */
  56398. export class EngineInstrumentation implements IDisposable {
  56399. /**
  56400. * Define the instrumented engine.
  56401. */
  56402. engine: Engine;
  56403. private _captureGPUFrameTime;
  56404. private _gpuFrameTimeToken;
  56405. private _gpuFrameTime;
  56406. private _captureShaderCompilationTime;
  56407. private _shaderCompilationTime;
  56408. private _onBeginFrameObserver;
  56409. private _onEndFrameObserver;
  56410. private _onBeforeShaderCompilationObserver;
  56411. private _onAfterShaderCompilationObserver;
  56412. /**
  56413. * Gets the perf counter used for GPU frame time
  56414. */
  56415. get gpuFrameTimeCounter(): PerfCounter;
  56416. /**
  56417. * Gets the GPU frame time capture status
  56418. */
  56419. get captureGPUFrameTime(): boolean;
  56420. /**
  56421. * Enable or disable the GPU frame time capture
  56422. */
  56423. set captureGPUFrameTime(value: boolean);
  56424. /**
  56425. * Gets the perf counter used for shader compilation time
  56426. */
  56427. get shaderCompilationTimeCounter(): PerfCounter;
  56428. /**
  56429. * Gets the shader compilation time capture status
  56430. */
  56431. get captureShaderCompilationTime(): boolean;
  56432. /**
  56433. * Enable or disable the shader compilation time capture
  56434. */
  56435. set captureShaderCompilationTime(value: boolean);
  56436. /**
  56437. * Instantiates a new engine instrumentation.
  56438. * This class can be used to get instrumentation data from a Babylon engine
  56439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56440. * @param engine Defines the engine to instrument
  56441. */
  56442. constructor(
  56443. /**
  56444. * Define the instrumented engine.
  56445. */
  56446. engine: Engine);
  56447. /**
  56448. * Dispose and release associated resources.
  56449. */
  56450. dispose(): void;
  56451. }
  56452. }
  56453. declare module BABYLON {
  56454. /**
  56455. * This class can be used to get instrumentation data from a Babylon engine
  56456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56457. */
  56458. export class SceneInstrumentation implements IDisposable {
  56459. /**
  56460. * Defines the scene to instrument
  56461. */
  56462. scene: Scene;
  56463. private _captureActiveMeshesEvaluationTime;
  56464. private _activeMeshesEvaluationTime;
  56465. private _captureRenderTargetsRenderTime;
  56466. private _renderTargetsRenderTime;
  56467. private _captureFrameTime;
  56468. private _frameTime;
  56469. private _captureRenderTime;
  56470. private _renderTime;
  56471. private _captureInterFrameTime;
  56472. private _interFrameTime;
  56473. private _captureParticlesRenderTime;
  56474. private _particlesRenderTime;
  56475. private _captureSpritesRenderTime;
  56476. private _spritesRenderTime;
  56477. private _capturePhysicsTime;
  56478. private _physicsTime;
  56479. private _captureAnimationsTime;
  56480. private _animationsTime;
  56481. private _captureCameraRenderTime;
  56482. private _cameraRenderTime;
  56483. private _onBeforeActiveMeshesEvaluationObserver;
  56484. private _onAfterActiveMeshesEvaluationObserver;
  56485. private _onBeforeRenderTargetsRenderObserver;
  56486. private _onAfterRenderTargetsRenderObserver;
  56487. private _onAfterRenderObserver;
  56488. private _onBeforeDrawPhaseObserver;
  56489. private _onAfterDrawPhaseObserver;
  56490. private _onBeforeAnimationsObserver;
  56491. private _onBeforeParticlesRenderingObserver;
  56492. private _onAfterParticlesRenderingObserver;
  56493. private _onBeforeSpritesRenderingObserver;
  56494. private _onAfterSpritesRenderingObserver;
  56495. private _onBeforePhysicsObserver;
  56496. private _onAfterPhysicsObserver;
  56497. private _onAfterAnimationsObserver;
  56498. private _onBeforeCameraRenderObserver;
  56499. private _onAfterCameraRenderObserver;
  56500. /**
  56501. * Gets the perf counter used for active meshes evaluation time
  56502. */
  56503. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56504. /**
  56505. * Gets the active meshes evaluation time capture status
  56506. */
  56507. get captureActiveMeshesEvaluationTime(): boolean;
  56508. /**
  56509. * Enable or disable the active meshes evaluation time capture
  56510. */
  56511. set captureActiveMeshesEvaluationTime(value: boolean);
  56512. /**
  56513. * Gets the perf counter used for render targets render time
  56514. */
  56515. get renderTargetsRenderTimeCounter(): PerfCounter;
  56516. /**
  56517. * Gets the render targets render time capture status
  56518. */
  56519. get captureRenderTargetsRenderTime(): boolean;
  56520. /**
  56521. * Enable or disable the render targets render time capture
  56522. */
  56523. set captureRenderTargetsRenderTime(value: boolean);
  56524. /**
  56525. * Gets the perf counter used for particles render time
  56526. */
  56527. get particlesRenderTimeCounter(): PerfCounter;
  56528. /**
  56529. * Gets the particles render time capture status
  56530. */
  56531. get captureParticlesRenderTime(): boolean;
  56532. /**
  56533. * Enable or disable the particles render time capture
  56534. */
  56535. set captureParticlesRenderTime(value: boolean);
  56536. /**
  56537. * Gets the perf counter used for sprites render time
  56538. */
  56539. get spritesRenderTimeCounter(): PerfCounter;
  56540. /**
  56541. * Gets the sprites render time capture status
  56542. */
  56543. get captureSpritesRenderTime(): boolean;
  56544. /**
  56545. * Enable or disable the sprites render time capture
  56546. */
  56547. set captureSpritesRenderTime(value: boolean);
  56548. /**
  56549. * Gets the perf counter used for physics time
  56550. */
  56551. get physicsTimeCounter(): PerfCounter;
  56552. /**
  56553. * Gets the physics time capture status
  56554. */
  56555. get capturePhysicsTime(): boolean;
  56556. /**
  56557. * Enable or disable the physics time capture
  56558. */
  56559. set capturePhysicsTime(value: boolean);
  56560. /**
  56561. * Gets the perf counter used for animations time
  56562. */
  56563. get animationsTimeCounter(): PerfCounter;
  56564. /**
  56565. * Gets the animations time capture status
  56566. */
  56567. get captureAnimationsTime(): boolean;
  56568. /**
  56569. * Enable or disable the animations time capture
  56570. */
  56571. set captureAnimationsTime(value: boolean);
  56572. /**
  56573. * Gets the perf counter used for frame time capture
  56574. */
  56575. get frameTimeCounter(): PerfCounter;
  56576. /**
  56577. * Gets the frame time capture status
  56578. */
  56579. get captureFrameTime(): boolean;
  56580. /**
  56581. * Enable or disable the frame time capture
  56582. */
  56583. set captureFrameTime(value: boolean);
  56584. /**
  56585. * Gets the perf counter used for inter-frames time capture
  56586. */
  56587. get interFrameTimeCounter(): PerfCounter;
  56588. /**
  56589. * Gets the inter-frames time capture status
  56590. */
  56591. get captureInterFrameTime(): boolean;
  56592. /**
  56593. * Enable or disable the inter-frames time capture
  56594. */
  56595. set captureInterFrameTime(value: boolean);
  56596. /**
  56597. * Gets the perf counter used for render time capture
  56598. */
  56599. get renderTimeCounter(): PerfCounter;
  56600. /**
  56601. * Gets the render time capture status
  56602. */
  56603. get captureRenderTime(): boolean;
  56604. /**
  56605. * Enable or disable the render time capture
  56606. */
  56607. set captureRenderTime(value: boolean);
  56608. /**
  56609. * Gets the perf counter used for camera render time capture
  56610. */
  56611. get cameraRenderTimeCounter(): PerfCounter;
  56612. /**
  56613. * Gets the camera render time capture status
  56614. */
  56615. get captureCameraRenderTime(): boolean;
  56616. /**
  56617. * Enable or disable the camera render time capture
  56618. */
  56619. set captureCameraRenderTime(value: boolean);
  56620. /**
  56621. * Gets the perf counter used for draw calls
  56622. */
  56623. get drawCallsCounter(): PerfCounter;
  56624. /**
  56625. * Instantiates a new scene instrumentation.
  56626. * This class can be used to get instrumentation data from a Babylon engine
  56627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56628. * @param scene Defines the scene to instrument
  56629. */
  56630. constructor(
  56631. /**
  56632. * Defines the scene to instrument
  56633. */
  56634. scene: Scene);
  56635. /**
  56636. * Dispose and release associated resources.
  56637. */
  56638. dispose(): void;
  56639. }
  56640. }
  56641. declare module BABYLON {
  56642. /** @hidden */
  56643. export var glowMapGenerationPixelShader: {
  56644. name: string;
  56645. shader: string;
  56646. };
  56647. }
  56648. declare module BABYLON {
  56649. /** @hidden */
  56650. export var glowMapGenerationVertexShader: {
  56651. name: string;
  56652. shader: string;
  56653. };
  56654. }
  56655. declare module BABYLON {
  56656. /**
  56657. * Effect layer options. This helps customizing the behaviour
  56658. * of the effect layer.
  56659. */
  56660. export interface IEffectLayerOptions {
  56661. /**
  56662. * Multiplication factor apply to the canvas size to compute the render target size
  56663. * used to generated the objects (the smaller the faster).
  56664. */
  56665. mainTextureRatio: number;
  56666. /**
  56667. * Enforces a fixed size texture to ensure effect stability across devices.
  56668. */
  56669. mainTextureFixedSize?: number;
  56670. /**
  56671. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56672. */
  56673. alphaBlendingMode: number;
  56674. /**
  56675. * The camera attached to the layer.
  56676. */
  56677. camera: Nullable<Camera>;
  56678. /**
  56679. * The rendering group to draw the layer in.
  56680. */
  56681. renderingGroupId: number;
  56682. }
  56683. /**
  56684. * The effect layer Helps adding post process effect blended with the main pass.
  56685. *
  56686. * This can be for instance use to generate glow or higlight effects on the scene.
  56687. *
  56688. * The effect layer class can not be used directly and is intented to inherited from to be
  56689. * customized per effects.
  56690. */
  56691. export abstract class EffectLayer {
  56692. private _vertexBuffers;
  56693. private _indexBuffer;
  56694. private _cachedDefines;
  56695. private _effectLayerMapGenerationEffect;
  56696. private _effectLayerOptions;
  56697. private _mergeEffect;
  56698. protected _scene: Scene;
  56699. protected _engine: Engine;
  56700. protected _maxSize: number;
  56701. protected _mainTextureDesiredSize: ISize;
  56702. protected _mainTexture: RenderTargetTexture;
  56703. protected _shouldRender: boolean;
  56704. protected _postProcesses: PostProcess[];
  56705. protected _textures: BaseTexture[];
  56706. protected _emissiveTextureAndColor: {
  56707. texture: Nullable<BaseTexture>;
  56708. color: Color4;
  56709. };
  56710. /**
  56711. * The name of the layer
  56712. */
  56713. name: string;
  56714. /**
  56715. * The clear color of the texture used to generate the glow map.
  56716. */
  56717. neutralColor: Color4;
  56718. /**
  56719. * Specifies whether the highlight layer is enabled or not.
  56720. */
  56721. isEnabled: boolean;
  56722. /**
  56723. * Gets the camera attached to the layer.
  56724. */
  56725. get camera(): Nullable<Camera>;
  56726. /**
  56727. * Gets the rendering group id the layer should render in.
  56728. */
  56729. get renderingGroupId(): number;
  56730. set renderingGroupId(renderingGroupId: number);
  56731. /**
  56732. * An event triggered when the effect layer has been disposed.
  56733. */
  56734. onDisposeObservable: Observable<EffectLayer>;
  56735. /**
  56736. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56737. */
  56738. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56739. /**
  56740. * An event triggered when the generated texture is being merged in the scene.
  56741. */
  56742. onBeforeComposeObservable: Observable<EffectLayer>;
  56743. /**
  56744. * An event triggered when the mesh is rendered into the effect render target.
  56745. */
  56746. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56747. /**
  56748. * An event triggered after the mesh has been rendered into the effect render target.
  56749. */
  56750. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56751. /**
  56752. * An event triggered when the generated texture has been merged in the scene.
  56753. */
  56754. onAfterComposeObservable: Observable<EffectLayer>;
  56755. /**
  56756. * An event triggered when the efffect layer changes its size.
  56757. */
  56758. onSizeChangedObservable: Observable<EffectLayer>;
  56759. /** @hidden */
  56760. static _SceneComponentInitialization: (scene: Scene) => void;
  56761. /**
  56762. * Instantiates a new effect Layer and references it in the scene.
  56763. * @param name The name of the layer
  56764. * @param scene The scene to use the layer in
  56765. */
  56766. constructor(
  56767. /** The Friendly of the effect in the scene */
  56768. name: string, scene: Scene);
  56769. /**
  56770. * Get the effect name of the layer.
  56771. * @return The effect name
  56772. */
  56773. abstract getEffectName(): string;
  56774. /**
  56775. * Checks for the readiness of the element composing the layer.
  56776. * @param subMesh the mesh to check for
  56777. * @param useInstances specify whether or not to use instances to render the mesh
  56778. * @return true if ready otherwise, false
  56779. */
  56780. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56781. /**
  56782. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56783. * @returns true if the effect requires stencil during the main canvas render pass.
  56784. */
  56785. abstract needStencil(): boolean;
  56786. /**
  56787. * Create the merge effect. This is the shader use to blit the information back
  56788. * to the main canvas at the end of the scene rendering.
  56789. * @returns The effect containing the shader used to merge the effect on the main canvas
  56790. */
  56791. protected abstract _createMergeEffect(): Effect;
  56792. /**
  56793. * Creates the render target textures and post processes used in the effect layer.
  56794. */
  56795. protected abstract _createTextureAndPostProcesses(): void;
  56796. /**
  56797. * Implementation specific of rendering the generating effect on the main canvas.
  56798. * @param effect The effect used to render through
  56799. */
  56800. protected abstract _internalRender(effect: Effect): void;
  56801. /**
  56802. * Sets the required values for both the emissive texture and and the main color.
  56803. */
  56804. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56805. /**
  56806. * Free any resources and references associated to a mesh.
  56807. * Internal use
  56808. * @param mesh The mesh to free.
  56809. */
  56810. abstract _disposeMesh(mesh: Mesh): void;
  56811. /**
  56812. * Serializes this layer (Glow or Highlight for example)
  56813. * @returns a serialized layer object
  56814. */
  56815. abstract serialize?(): any;
  56816. /**
  56817. * Initializes the effect layer with the required options.
  56818. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56819. */
  56820. protected _init(options: Partial<IEffectLayerOptions>): void;
  56821. /**
  56822. * Generates the index buffer of the full screen quad blending to the main canvas.
  56823. */
  56824. private _generateIndexBuffer;
  56825. /**
  56826. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56827. */
  56828. private _generateVertexBuffer;
  56829. /**
  56830. * Sets the main texture desired size which is the closest power of two
  56831. * of the engine canvas size.
  56832. */
  56833. private _setMainTextureSize;
  56834. /**
  56835. * Creates the main texture for the effect layer.
  56836. */
  56837. protected _createMainTexture(): void;
  56838. /**
  56839. * Adds specific effects defines.
  56840. * @param defines The defines to add specifics to.
  56841. */
  56842. protected _addCustomEffectDefines(defines: string[]): void;
  56843. /**
  56844. * Checks for the readiness of the element composing the layer.
  56845. * @param subMesh the mesh to check for
  56846. * @param useInstances specify whether or not to use instances to render the mesh
  56847. * @param emissiveTexture the associated emissive texture used to generate the glow
  56848. * @return true if ready otherwise, false
  56849. */
  56850. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56851. /**
  56852. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56853. */
  56854. render(): void;
  56855. /**
  56856. * Determine if a given mesh will be used in the current effect.
  56857. * @param mesh mesh to test
  56858. * @returns true if the mesh will be used
  56859. */
  56860. hasMesh(mesh: AbstractMesh): boolean;
  56861. /**
  56862. * Returns true if the layer contains information to display, otherwise false.
  56863. * @returns true if the glow layer should be rendered
  56864. */
  56865. shouldRender(): boolean;
  56866. /**
  56867. * Returns true if the mesh should render, otherwise false.
  56868. * @param mesh The mesh to render
  56869. * @returns true if it should render otherwise false
  56870. */
  56871. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56872. /**
  56873. * Returns true if the mesh can be rendered, otherwise false.
  56874. * @param mesh The mesh to render
  56875. * @param material The material used on the mesh
  56876. * @returns true if it can be rendered otherwise false
  56877. */
  56878. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56879. /**
  56880. * Returns true if the mesh should render, otherwise false.
  56881. * @param mesh The mesh to render
  56882. * @returns true if it should render otherwise false
  56883. */
  56884. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56885. /**
  56886. * Renders the submesh passed in parameter to the generation map.
  56887. */
  56888. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56889. /**
  56890. * Defines whether the current material of the mesh should be use to render the effect.
  56891. * @param mesh defines the current mesh to render
  56892. */
  56893. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56894. /**
  56895. * Rebuild the required buffers.
  56896. * @hidden Internal use only.
  56897. */
  56898. _rebuild(): void;
  56899. /**
  56900. * Dispose only the render target textures and post process.
  56901. */
  56902. private _disposeTextureAndPostProcesses;
  56903. /**
  56904. * Dispose the highlight layer and free resources.
  56905. */
  56906. dispose(): void;
  56907. /**
  56908. * Gets the class name of the effect layer
  56909. * @returns the string with the class name of the effect layer
  56910. */
  56911. getClassName(): string;
  56912. /**
  56913. * Creates an effect layer from parsed effect layer data
  56914. * @param parsedEffectLayer defines effect layer data
  56915. * @param scene defines the current scene
  56916. * @param rootUrl defines the root URL containing the effect layer information
  56917. * @returns a parsed effect Layer
  56918. */
  56919. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56920. }
  56921. }
  56922. declare module BABYLON {
  56923. interface AbstractScene {
  56924. /**
  56925. * The list of effect layers (highlights/glow) added to the scene
  56926. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56927. * @see http://doc.babylonjs.com/how_to/glow_layer
  56928. */
  56929. effectLayers: Array<EffectLayer>;
  56930. /**
  56931. * Removes the given effect layer from this scene.
  56932. * @param toRemove defines the effect layer to remove
  56933. * @returns the index of the removed effect layer
  56934. */
  56935. removeEffectLayer(toRemove: EffectLayer): number;
  56936. /**
  56937. * Adds the given effect layer to this scene
  56938. * @param newEffectLayer defines the effect layer to add
  56939. */
  56940. addEffectLayer(newEffectLayer: EffectLayer): void;
  56941. }
  56942. /**
  56943. * Defines the layer scene component responsible to manage any effect layers
  56944. * in a given scene.
  56945. */
  56946. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56947. /**
  56948. * The component name helpfull to identify the component in the list of scene components.
  56949. */
  56950. readonly name: string;
  56951. /**
  56952. * The scene the component belongs to.
  56953. */
  56954. scene: Scene;
  56955. private _engine;
  56956. private _renderEffects;
  56957. private _needStencil;
  56958. private _previousStencilState;
  56959. /**
  56960. * Creates a new instance of the component for the given scene
  56961. * @param scene Defines the scene to register the component in
  56962. */
  56963. constructor(scene: Scene);
  56964. /**
  56965. * Registers the component in a given scene
  56966. */
  56967. register(): void;
  56968. /**
  56969. * Rebuilds the elements related to this component in case of
  56970. * context lost for instance.
  56971. */
  56972. rebuild(): void;
  56973. /**
  56974. * Serializes the component data to the specified json object
  56975. * @param serializationObject The object to serialize to
  56976. */
  56977. serialize(serializationObject: any): void;
  56978. /**
  56979. * Adds all the elements from the container to the scene
  56980. * @param container the container holding the elements
  56981. */
  56982. addFromContainer(container: AbstractScene): void;
  56983. /**
  56984. * Removes all the elements in the container from the scene
  56985. * @param container contains the elements to remove
  56986. * @param dispose if the removed element should be disposed (default: false)
  56987. */
  56988. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56989. /**
  56990. * Disposes the component and the associated ressources.
  56991. */
  56992. dispose(): void;
  56993. private _isReadyForMesh;
  56994. private _renderMainTexture;
  56995. private _setStencil;
  56996. private _setStencilBack;
  56997. private _draw;
  56998. private _drawCamera;
  56999. private _drawRenderingGroup;
  57000. }
  57001. }
  57002. declare module BABYLON {
  57003. /** @hidden */
  57004. export var glowMapMergePixelShader: {
  57005. name: string;
  57006. shader: string;
  57007. };
  57008. }
  57009. declare module BABYLON {
  57010. /** @hidden */
  57011. export var glowMapMergeVertexShader: {
  57012. name: string;
  57013. shader: string;
  57014. };
  57015. }
  57016. declare module BABYLON {
  57017. interface AbstractScene {
  57018. /**
  57019. * Return a the first highlight layer of the scene with a given name.
  57020. * @param name The name of the highlight layer to look for.
  57021. * @return The highlight layer if found otherwise null.
  57022. */
  57023. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57024. }
  57025. /**
  57026. * Glow layer options. This helps customizing the behaviour
  57027. * of the glow layer.
  57028. */
  57029. export interface IGlowLayerOptions {
  57030. /**
  57031. * Multiplication factor apply to the canvas size to compute the render target size
  57032. * used to generated the glowing objects (the smaller the faster).
  57033. */
  57034. mainTextureRatio: number;
  57035. /**
  57036. * Enforces a fixed size texture to ensure resize independant blur.
  57037. */
  57038. mainTextureFixedSize?: number;
  57039. /**
  57040. * How big is the kernel of the blur texture.
  57041. */
  57042. blurKernelSize: number;
  57043. /**
  57044. * The camera attached to the layer.
  57045. */
  57046. camera: Nullable<Camera>;
  57047. /**
  57048. * Enable MSAA by chosing the number of samples.
  57049. */
  57050. mainTextureSamples?: number;
  57051. /**
  57052. * The rendering group to draw the layer in.
  57053. */
  57054. renderingGroupId: number;
  57055. }
  57056. /**
  57057. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57058. *
  57059. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57060. *
  57061. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57062. */
  57063. export class GlowLayer extends EffectLayer {
  57064. /**
  57065. * Effect Name of the layer.
  57066. */
  57067. static readonly EffectName: string;
  57068. /**
  57069. * The default blur kernel size used for the glow.
  57070. */
  57071. static DefaultBlurKernelSize: number;
  57072. /**
  57073. * The default texture size ratio used for the glow.
  57074. */
  57075. static DefaultTextureRatio: number;
  57076. /**
  57077. * Sets the kernel size of the blur.
  57078. */
  57079. set blurKernelSize(value: number);
  57080. /**
  57081. * Gets the kernel size of the blur.
  57082. */
  57083. get blurKernelSize(): number;
  57084. /**
  57085. * Sets the glow intensity.
  57086. */
  57087. set intensity(value: number);
  57088. /**
  57089. * Gets the glow intensity.
  57090. */
  57091. get intensity(): number;
  57092. private _options;
  57093. private _intensity;
  57094. private _horizontalBlurPostprocess1;
  57095. private _verticalBlurPostprocess1;
  57096. private _horizontalBlurPostprocess2;
  57097. private _verticalBlurPostprocess2;
  57098. private _blurTexture1;
  57099. private _blurTexture2;
  57100. private _postProcesses1;
  57101. private _postProcesses2;
  57102. private _includedOnlyMeshes;
  57103. private _excludedMeshes;
  57104. private _meshesUsingTheirOwnMaterials;
  57105. /**
  57106. * Callback used to let the user override the color selection on a per mesh basis
  57107. */
  57108. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57109. /**
  57110. * Callback used to let the user override the texture selection on a per mesh basis
  57111. */
  57112. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57113. /**
  57114. * Instantiates a new glow Layer and references it to the scene.
  57115. * @param name The name of the layer
  57116. * @param scene The scene to use the layer in
  57117. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57118. */
  57119. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57120. /**
  57121. * Get the effect name of the layer.
  57122. * @return The effect name
  57123. */
  57124. getEffectName(): string;
  57125. /**
  57126. * Create the merge effect. This is the shader use to blit the information back
  57127. * to the main canvas at the end of the scene rendering.
  57128. */
  57129. protected _createMergeEffect(): Effect;
  57130. /**
  57131. * Creates the render target textures and post processes used in the glow layer.
  57132. */
  57133. protected _createTextureAndPostProcesses(): void;
  57134. /**
  57135. * Checks for the readiness of the element composing the layer.
  57136. * @param subMesh the mesh to check for
  57137. * @param useInstances specify wether or not to use instances to render the mesh
  57138. * @param emissiveTexture the associated emissive texture used to generate the glow
  57139. * @return true if ready otherwise, false
  57140. */
  57141. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57142. /**
  57143. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57144. */
  57145. needStencil(): boolean;
  57146. /**
  57147. * Returns true if the mesh can be rendered, otherwise false.
  57148. * @param mesh The mesh to render
  57149. * @param material The material used on the mesh
  57150. * @returns true if it can be rendered otherwise false
  57151. */
  57152. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57153. /**
  57154. * Implementation specific of rendering the generating effect on the main canvas.
  57155. * @param effect The effect used to render through
  57156. */
  57157. protected _internalRender(effect: Effect): void;
  57158. /**
  57159. * Sets the required values for both the emissive texture and and the main color.
  57160. */
  57161. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57162. /**
  57163. * Returns true if the mesh should render, otherwise false.
  57164. * @param mesh The mesh to render
  57165. * @returns true if it should render otherwise false
  57166. */
  57167. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57168. /**
  57169. * Adds specific effects defines.
  57170. * @param defines The defines to add specifics to.
  57171. */
  57172. protected _addCustomEffectDefines(defines: string[]): void;
  57173. /**
  57174. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57175. * @param mesh The mesh to exclude from the glow layer
  57176. */
  57177. addExcludedMesh(mesh: Mesh): void;
  57178. /**
  57179. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57180. * @param mesh The mesh to remove
  57181. */
  57182. removeExcludedMesh(mesh: Mesh): void;
  57183. /**
  57184. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57185. * @param mesh The mesh to include in the glow layer
  57186. */
  57187. addIncludedOnlyMesh(mesh: Mesh): void;
  57188. /**
  57189. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57190. * @param mesh The mesh to remove
  57191. */
  57192. removeIncludedOnlyMesh(mesh: Mesh): void;
  57193. /**
  57194. * Determine if a given mesh will be used in the glow layer
  57195. * @param mesh The mesh to test
  57196. * @returns true if the mesh will be highlighted by the current glow layer
  57197. */
  57198. hasMesh(mesh: AbstractMesh): boolean;
  57199. /**
  57200. * Defines whether the current material of the mesh should be use to render the effect.
  57201. * @param mesh defines the current mesh to render
  57202. */
  57203. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57204. /**
  57205. * Add a mesh to be rendered through its own material and not with emissive only.
  57206. * @param mesh The mesh for which we need to use its material
  57207. */
  57208. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57209. /**
  57210. * Remove a mesh from being rendered through its own material and not with emissive only.
  57211. * @param mesh The mesh for which we need to not use its material
  57212. */
  57213. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57214. /**
  57215. * Free any resources and references associated to a mesh.
  57216. * Internal use
  57217. * @param mesh The mesh to free.
  57218. * @hidden
  57219. */
  57220. _disposeMesh(mesh: Mesh): void;
  57221. /**
  57222. * Gets the class name of the effect layer
  57223. * @returns the string with the class name of the effect layer
  57224. */
  57225. getClassName(): string;
  57226. /**
  57227. * Serializes this glow layer
  57228. * @returns a serialized glow layer object
  57229. */
  57230. serialize(): any;
  57231. /**
  57232. * Creates a Glow Layer from parsed glow layer data
  57233. * @param parsedGlowLayer defines glow layer data
  57234. * @param scene defines the current scene
  57235. * @param rootUrl defines the root URL containing the glow layer information
  57236. * @returns a parsed Glow Layer
  57237. */
  57238. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57239. }
  57240. }
  57241. declare module BABYLON {
  57242. /** @hidden */
  57243. export var glowBlurPostProcessPixelShader: {
  57244. name: string;
  57245. shader: string;
  57246. };
  57247. }
  57248. declare module BABYLON {
  57249. interface AbstractScene {
  57250. /**
  57251. * Return a the first highlight layer of the scene with a given name.
  57252. * @param name The name of the highlight layer to look for.
  57253. * @return The highlight layer if found otherwise null.
  57254. */
  57255. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57256. }
  57257. /**
  57258. * Highlight layer options. This helps customizing the behaviour
  57259. * of the highlight layer.
  57260. */
  57261. export interface IHighlightLayerOptions {
  57262. /**
  57263. * Multiplication factor apply to the canvas size to compute the render target size
  57264. * used to generated the glowing objects (the smaller the faster).
  57265. */
  57266. mainTextureRatio: number;
  57267. /**
  57268. * Enforces a fixed size texture to ensure resize independant blur.
  57269. */
  57270. mainTextureFixedSize?: number;
  57271. /**
  57272. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57273. * of the picture to blur (the smaller the faster).
  57274. */
  57275. blurTextureSizeRatio: number;
  57276. /**
  57277. * How big in texel of the blur texture is the vertical blur.
  57278. */
  57279. blurVerticalSize: number;
  57280. /**
  57281. * How big in texel of the blur texture is the horizontal blur.
  57282. */
  57283. blurHorizontalSize: number;
  57284. /**
  57285. * Alpha blending mode used to apply the blur. Default is combine.
  57286. */
  57287. alphaBlendingMode: number;
  57288. /**
  57289. * The camera attached to the layer.
  57290. */
  57291. camera: Nullable<Camera>;
  57292. /**
  57293. * Should we display highlight as a solid stroke?
  57294. */
  57295. isStroke?: boolean;
  57296. /**
  57297. * The rendering group to draw the layer in.
  57298. */
  57299. renderingGroupId: number;
  57300. }
  57301. /**
  57302. * The highlight layer Helps adding a glow effect around a mesh.
  57303. *
  57304. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57305. * glowy meshes to your scene.
  57306. *
  57307. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57308. */
  57309. export class HighlightLayer extends EffectLayer {
  57310. name: string;
  57311. /**
  57312. * Effect Name of the highlight layer.
  57313. */
  57314. static readonly EffectName: string;
  57315. /**
  57316. * The neutral color used during the preparation of the glow effect.
  57317. * This is black by default as the blend operation is a blend operation.
  57318. */
  57319. static NeutralColor: Color4;
  57320. /**
  57321. * Stencil value used for glowing meshes.
  57322. */
  57323. static GlowingMeshStencilReference: number;
  57324. /**
  57325. * Stencil value used for the other meshes in the scene.
  57326. */
  57327. static NormalMeshStencilReference: number;
  57328. /**
  57329. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57330. */
  57331. innerGlow: boolean;
  57332. /**
  57333. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57334. */
  57335. outerGlow: boolean;
  57336. /**
  57337. * Specifies the horizontal size of the blur.
  57338. */
  57339. set blurHorizontalSize(value: number);
  57340. /**
  57341. * Specifies the vertical size of the blur.
  57342. */
  57343. set blurVerticalSize(value: number);
  57344. /**
  57345. * Gets the horizontal size of the blur.
  57346. */
  57347. get blurHorizontalSize(): number;
  57348. /**
  57349. * Gets the vertical size of the blur.
  57350. */
  57351. get blurVerticalSize(): number;
  57352. /**
  57353. * An event triggered when the highlight layer is being blurred.
  57354. */
  57355. onBeforeBlurObservable: Observable<HighlightLayer>;
  57356. /**
  57357. * An event triggered when the highlight layer has been blurred.
  57358. */
  57359. onAfterBlurObservable: Observable<HighlightLayer>;
  57360. private _instanceGlowingMeshStencilReference;
  57361. private _options;
  57362. private _downSamplePostprocess;
  57363. private _horizontalBlurPostprocess;
  57364. private _verticalBlurPostprocess;
  57365. private _blurTexture;
  57366. private _meshes;
  57367. private _excludedMeshes;
  57368. /**
  57369. * Instantiates a new highlight Layer and references it to the scene..
  57370. * @param name The name of the layer
  57371. * @param scene The scene to use the layer in
  57372. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57373. */
  57374. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57375. /**
  57376. * Get the effect name of the layer.
  57377. * @return The effect name
  57378. */
  57379. getEffectName(): string;
  57380. /**
  57381. * Create the merge effect. This is the shader use to blit the information back
  57382. * to the main canvas at the end of the scene rendering.
  57383. */
  57384. protected _createMergeEffect(): Effect;
  57385. /**
  57386. * Creates the render target textures and post processes used in the highlight layer.
  57387. */
  57388. protected _createTextureAndPostProcesses(): void;
  57389. /**
  57390. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57391. */
  57392. needStencil(): boolean;
  57393. /**
  57394. * Checks for the readiness of the element composing the layer.
  57395. * @param subMesh the mesh to check for
  57396. * @param useInstances specify wether or not to use instances to render the mesh
  57397. * @param emissiveTexture the associated emissive texture used to generate the glow
  57398. * @return true if ready otherwise, false
  57399. */
  57400. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57401. /**
  57402. * Implementation specific of rendering the generating effect on the main canvas.
  57403. * @param effect The effect used to render through
  57404. */
  57405. protected _internalRender(effect: Effect): void;
  57406. /**
  57407. * Returns true if the layer contains information to display, otherwise false.
  57408. */
  57409. shouldRender(): boolean;
  57410. /**
  57411. * Returns true if the mesh should render, otherwise false.
  57412. * @param mesh The mesh to render
  57413. * @returns true if it should render otherwise false
  57414. */
  57415. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57416. /**
  57417. * Adds specific effects defines.
  57418. * @param defines The defines to add specifics to.
  57419. */
  57420. protected _addCustomEffectDefines(defines: string[]): void;
  57421. /**
  57422. * Sets the required values for both the emissive texture and and the main color.
  57423. */
  57424. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57425. /**
  57426. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57427. * @param mesh The mesh to exclude from the highlight layer
  57428. */
  57429. addExcludedMesh(mesh: Mesh): void;
  57430. /**
  57431. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57432. * @param mesh The mesh to highlight
  57433. */
  57434. removeExcludedMesh(mesh: Mesh): void;
  57435. /**
  57436. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57437. * @param mesh mesh to test
  57438. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57439. */
  57440. hasMesh(mesh: AbstractMesh): boolean;
  57441. /**
  57442. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57443. * @param mesh The mesh to highlight
  57444. * @param color The color of the highlight
  57445. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57446. */
  57447. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57448. /**
  57449. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57450. * @param mesh The mesh to highlight
  57451. */
  57452. removeMesh(mesh: Mesh): void;
  57453. /**
  57454. * Remove all the meshes currently referenced in the highlight layer
  57455. */
  57456. removeAllMeshes(): void;
  57457. /**
  57458. * Force the stencil to the normal expected value for none glowing parts
  57459. */
  57460. private _defaultStencilReference;
  57461. /**
  57462. * Free any resources and references associated to a mesh.
  57463. * Internal use
  57464. * @param mesh The mesh to free.
  57465. * @hidden
  57466. */
  57467. _disposeMesh(mesh: Mesh): void;
  57468. /**
  57469. * Dispose the highlight layer and free resources.
  57470. */
  57471. dispose(): void;
  57472. /**
  57473. * Gets the class name of the effect layer
  57474. * @returns the string with the class name of the effect layer
  57475. */
  57476. getClassName(): string;
  57477. /**
  57478. * Serializes this Highlight layer
  57479. * @returns a serialized Highlight layer object
  57480. */
  57481. serialize(): any;
  57482. /**
  57483. * Creates a Highlight layer from parsed Highlight layer data
  57484. * @param parsedHightlightLayer defines the Highlight layer data
  57485. * @param scene defines the current scene
  57486. * @param rootUrl defines the root URL containing the Highlight layer information
  57487. * @returns a parsed Highlight layer
  57488. */
  57489. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57490. }
  57491. }
  57492. declare module BABYLON {
  57493. interface AbstractScene {
  57494. /**
  57495. * The list of layers (background and foreground) of the scene
  57496. */
  57497. layers: Array<Layer>;
  57498. }
  57499. /**
  57500. * Defines the layer scene component responsible to manage any layers
  57501. * in a given scene.
  57502. */
  57503. export class LayerSceneComponent implements ISceneComponent {
  57504. /**
  57505. * The component name helpfull to identify the component in the list of scene components.
  57506. */
  57507. readonly name: string;
  57508. /**
  57509. * The scene the component belongs to.
  57510. */
  57511. scene: Scene;
  57512. private _engine;
  57513. /**
  57514. * Creates a new instance of the component for the given scene
  57515. * @param scene Defines the scene to register the component in
  57516. */
  57517. constructor(scene: Scene);
  57518. /**
  57519. * Registers the component in a given scene
  57520. */
  57521. register(): void;
  57522. /**
  57523. * Rebuilds the elements related to this component in case of
  57524. * context lost for instance.
  57525. */
  57526. rebuild(): void;
  57527. /**
  57528. * Disposes the component and the associated ressources.
  57529. */
  57530. dispose(): void;
  57531. private _draw;
  57532. private _drawCameraPredicate;
  57533. private _drawCameraBackground;
  57534. private _drawCameraForeground;
  57535. private _drawRenderTargetPredicate;
  57536. private _drawRenderTargetBackground;
  57537. private _drawRenderTargetForeground;
  57538. /**
  57539. * Adds all the elements from the container to the scene
  57540. * @param container the container holding the elements
  57541. */
  57542. addFromContainer(container: AbstractScene): void;
  57543. /**
  57544. * Removes all the elements in the container from the scene
  57545. * @param container contains the elements to remove
  57546. * @param dispose if the removed element should be disposed (default: false)
  57547. */
  57548. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57549. }
  57550. }
  57551. declare module BABYLON {
  57552. /** @hidden */
  57553. export var layerPixelShader: {
  57554. name: string;
  57555. shader: string;
  57556. };
  57557. }
  57558. declare module BABYLON {
  57559. /** @hidden */
  57560. export var layerVertexShader: {
  57561. name: string;
  57562. shader: string;
  57563. };
  57564. }
  57565. declare module BABYLON {
  57566. /**
  57567. * This represents a full screen 2d layer.
  57568. * This can be useful to display a picture in the background of your scene for instance.
  57569. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57570. */
  57571. export class Layer {
  57572. /**
  57573. * Define the name of the layer.
  57574. */
  57575. name: string;
  57576. /**
  57577. * Define the texture the layer should display.
  57578. */
  57579. texture: Nullable<Texture>;
  57580. /**
  57581. * Is the layer in background or foreground.
  57582. */
  57583. isBackground: boolean;
  57584. /**
  57585. * Define the color of the layer (instead of texture).
  57586. */
  57587. color: Color4;
  57588. /**
  57589. * Define the scale of the layer in order to zoom in out of the texture.
  57590. */
  57591. scale: Vector2;
  57592. /**
  57593. * Define an offset for the layer in order to shift the texture.
  57594. */
  57595. offset: Vector2;
  57596. /**
  57597. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57598. */
  57599. alphaBlendingMode: number;
  57600. /**
  57601. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57602. * Alpha test will not mix with the background color in case of transparency.
  57603. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57604. */
  57605. alphaTest: boolean;
  57606. /**
  57607. * Define a mask to restrict the layer to only some of the scene cameras.
  57608. */
  57609. layerMask: number;
  57610. /**
  57611. * Define the list of render target the layer is visible into.
  57612. */
  57613. renderTargetTextures: RenderTargetTexture[];
  57614. /**
  57615. * Define if the layer is only used in renderTarget or if it also
  57616. * renders in the main frame buffer of the canvas.
  57617. */
  57618. renderOnlyInRenderTargetTextures: boolean;
  57619. private _scene;
  57620. private _vertexBuffers;
  57621. private _indexBuffer;
  57622. private _effect;
  57623. private _previousDefines;
  57624. /**
  57625. * An event triggered when the layer is disposed.
  57626. */
  57627. onDisposeObservable: Observable<Layer>;
  57628. private _onDisposeObserver;
  57629. /**
  57630. * Back compatibility with callback before the onDisposeObservable existed.
  57631. * The set callback will be triggered when the layer has been disposed.
  57632. */
  57633. set onDispose(callback: () => void);
  57634. /**
  57635. * An event triggered before rendering the scene
  57636. */
  57637. onBeforeRenderObservable: Observable<Layer>;
  57638. private _onBeforeRenderObserver;
  57639. /**
  57640. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57641. * The set callback will be triggered just before rendering the layer.
  57642. */
  57643. set onBeforeRender(callback: () => void);
  57644. /**
  57645. * An event triggered after rendering the scene
  57646. */
  57647. onAfterRenderObservable: Observable<Layer>;
  57648. private _onAfterRenderObserver;
  57649. /**
  57650. * Back compatibility with callback before the onAfterRenderObservable existed.
  57651. * The set callback will be triggered just after rendering the layer.
  57652. */
  57653. set onAfterRender(callback: () => void);
  57654. /**
  57655. * Instantiates a new layer.
  57656. * This represents a full screen 2d layer.
  57657. * This can be useful to display a picture in the background of your scene for instance.
  57658. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57659. * @param name Define the name of the layer in the scene
  57660. * @param imgUrl Define the url of the texture to display in the layer
  57661. * @param scene Define the scene the layer belongs to
  57662. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57663. * @param color Defines a color for the layer
  57664. */
  57665. constructor(
  57666. /**
  57667. * Define the name of the layer.
  57668. */
  57669. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57670. private _createIndexBuffer;
  57671. /** @hidden */
  57672. _rebuild(): void;
  57673. /**
  57674. * Renders the layer in the scene.
  57675. */
  57676. render(): void;
  57677. /**
  57678. * Disposes and releases the associated ressources.
  57679. */
  57680. dispose(): void;
  57681. }
  57682. }
  57683. declare module BABYLON {
  57684. /** @hidden */
  57685. export var lensFlarePixelShader: {
  57686. name: string;
  57687. shader: string;
  57688. };
  57689. }
  57690. declare module BABYLON {
  57691. /** @hidden */
  57692. export var lensFlareVertexShader: {
  57693. name: string;
  57694. shader: string;
  57695. };
  57696. }
  57697. declare module BABYLON {
  57698. /**
  57699. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57700. * It is usually composed of several `lensFlare`.
  57701. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57702. */
  57703. export class LensFlareSystem {
  57704. /**
  57705. * Define the name of the lens flare system
  57706. */
  57707. name: string;
  57708. /**
  57709. * List of lens flares used in this system.
  57710. */
  57711. lensFlares: LensFlare[];
  57712. /**
  57713. * Define a limit from the border the lens flare can be visible.
  57714. */
  57715. borderLimit: number;
  57716. /**
  57717. * Define a viewport border we do not want to see the lens flare in.
  57718. */
  57719. viewportBorder: number;
  57720. /**
  57721. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57722. */
  57723. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57724. /**
  57725. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57726. */
  57727. layerMask: number;
  57728. /**
  57729. * Define the id of the lens flare system in the scene.
  57730. * (equal to name by default)
  57731. */
  57732. id: string;
  57733. private _scene;
  57734. private _emitter;
  57735. private _vertexBuffers;
  57736. private _indexBuffer;
  57737. private _effect;
  57738. private _positionX;
  57739. private _positionY;
  57740. private _isEnabled;
  57741. /** @hidden */
  57742. static _SceneComponentInitialization: (scene: Scene) => void;
  57743. /**
  57744. * Instantiates a lens flare system.
  57745. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57746. * It is usually composed of several `lensFlare`.
  57747. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57748. * @param name Define the name of the lens flare system in the scene
  57749. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57750. * @param scene Define the scene the lens flare system belongs to
  57751. */
  57752. constructor(
  57753. /**
  57754. * Define the name of the lens flare system
  57755. */
  57756. name: string, emitter: any, scene: Scene);
  57757. /**
  57758. * Define if the lens flare system is enabled.
  57759. */
  57760. get isEnabled(): boolean;
  57761. set isEnabled(value: boolean);
  57762. /**
  57763. * Get the scene the effects belongs to.
  57764. * @returns the scene holding the lens flare system
  57765. */
  57766. getScene(): Scene;
  57767. /**
  57768. * Get the emitter of the lens flare system.
  57769. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57770. * @returns the emitter of the lens flare system
  57771. */
  57772. getEmitter(): any;
  57773. /**
  57774. * Set the emitter of the lens flare system.
  57775. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57776. * @param newEmitter Define the new emitter of the system
  57777. */
  57778. setEmitter(newEmitter: any): void;
  57779. /**
  57780. * Get the lens flare system emitter position.
  57781. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57782. * @returns the position
  57783. */
  57784. getEmitterPosition(): Vector3;
  57785. /**
  57786. * @hidden
  57787. */
  57788. computeEffectivePosition(globalViewport: Viewport): boolean;
  57789. /** @hidden */
  57790. _isVisible(): boolean;
  57791. /**
  57792. * @hidden
  57793. */
  57794. render(): boolean;
  57795. /**
  57796. * Dispose and release the lens flare with its associated resources.
  57797. */
  57798. dispose(): void;
  57799. /**
  57800. * Parse a lens flare system from a JSON repressentation
  57801. * @param parsedLensFlareSystem Define the JSON to parse
  57802. * @param scene Define the scene the parsed system should be instantiated in
  57803. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57804. * @returns the parsed system
  57805. */
  57806. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57807. /**
  57808. * Serialize the current Lens Flare System into a JSON representation.
  57809. * @returns the serialized JSON
  57810. */
  57811. serialize(): any;
  57812. }
  57813. }
  57814. declare module BABYLON {
  57815. /**
  57816. * This represents one of the lens effect in a `lensFlareSystem`.
  57817. * It controls one of the indiviual texture used in the effect.
  57818. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57819. */
  57820. export class LensFlare {
  57821. /**
  57822. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57823. */
  57824. size: number;
  57825. /**
  57826. * 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.
  57827. */
  57828. position: number;
  57829. /**
  57830. * Define the lens color.
  57831. */
  57832. color: Color3;
  57833. /**
  57834. * Define the lens texture.
  57835. */
  57836. texture: Nullable<Texture>;
  57837. /**
  57838. * Define the alpha mode to render this particular lens.
  57839. */
  57840. alphaMode: number;
  57841. private _system;
  57842. /**
  57843. * Creates a new Lens Flare.
  57844. * This represents one of the lens effect in a `lensFlareSystem`.
  57845. * It controls one of the indiviual texture used in the effect.
  57846. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57847. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57848. * @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.
  57849. * @param color Define the lens color
  57850. * @param imgUrl Define the lens texture url
  57851. * @param system Define the `lensFlareSystem` this flare is part of
  57852. * @returns The newly created Lens Flare
  57853. */
  57854. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57855. /**
  57856. * Instantiates a new Lens Flare.
  57857. * This represents one of the lens effect in a `lensFlareSystem`.
  57858. * It controls one of the indiviual texture used in the effect.
  57859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57860. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57861. * @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.
  57862. * @param color Define the lens color
  57863. * @param imgUrl Define the lens texture url
  57864. * @param system Define the `lensFlareSystem` this flare is part of
  57865. */
  57866. constructor(
  57867. /**
  57868. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57869. */
  57870. size: number,
  57871. /**
  57872. * 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.
  57873. */
  57874. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57875. /**
  57876. * Dispose and release the lens flare with its associated resources.
  57877. */
  57878. dispose(): void;
  57879. }
  57880. }
  57881. declare module BABYLON {
  57882. interface AbstractScene {
  57883. /**
  57884. * The list of lens flare system added to the scene
  57885. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57886. */
  57887. lensFlareSystems: Array<LensFlareSystem>;
  57888. /**
  57889. * Removes the given lens flare system from this scene.
  57890. * @param toRemove The lens flare system to remove
  57891. * @returns The index of the removed lens flare system
  57892. */
  57893. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57894. /**
  57895. * Adds the given lens flare system to this scene
  57896. * @param newLensFlareSystem The lens flare system to add
  57897. */
  57898. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57899. /**
  57900. * Gets a lens flare system using its name
  57901. * @param name defines the name to look for
  57902. * @returns the lens flare system or null if not found
  57903. */
  57904. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57905. /**
  57906. * Gets a lens flare system using its id
  57907. * @param id defines the id to look for
  57908. * @returns the lens flare system or null if not found
  57909. */
  57910. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57911. }
  57912. /**
  57913. * Defines the lens flare scene component responsible to manage any lens flares
  57914. * in a given scene.
  57915. */
  57916. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57917. /**
  57918. * The component name helpfull to identify the component in the list of scene components.
  57919. */
  57920. readonly name: string;
  57921. /**
  57922. * The scene the component belongs to.
  57923. */
  57924. scene: Scene;
  57925. /**
  57926. * Creates a new instance of the component for the given scene
  57927. * @param scene Defines the scene to register the component in
  57928. */
  57929. constructor(scene: Scene);
  57930. /**
  57931. * Registers the component in a given scene
  57932. */
  57933. register(): void;
  57934. /**
  57935. * Rebuilds the elements related to this component in case of
  57936. * context lost for instance.
  57937. */
  57938. rebuild(): void;
  57939. /**
  57940. * Adds all the elements from the container to the scene
  57941. * @param container the container holding the elements
  57942. */
  57943. addFromContainer(container: AbstractScene): void;
  57944. /**
  57945. * Removes all the elements in the container from the scene
  57946. * @param container contains the elements to remove
  57947. * @param dispose if the removed element should be disposed (default: false)
  57948. */
  57949. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57950. /**
  57951. * Serializes the component data to the specified json object
  57952. * @param serializationObject The object to serialize to
  57953. */
  57954. serialize(serializationObject: any): void;
  57955. /**
  57956. * Disposes the component and the associated ressources.
  57957. */
  57958. dispose(): void;
  57959. private _draw;
  57960. }
  57961. }
  57962. declare module BABYLON {
  57963. /** @hidden */
  57964. export var depthPixelShader: {
  57965. name: string;
  57966. shader: string;
  57967. };
  57968. }
  57969. declare module BABYLON {
  57970. /** @hidden */
  57971. export var depthVertexShader: {
  57972. name: string;
  57973. shader: string;
  57974. };
  57975. }
  57976. declare module BABYLON {
  57977. /**
  57978. * This represents a depth renderer in Babylon.
  57979. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57980. */
  57981. export class DepthRenderer {
  57982. private _scene;
  57983. private _depthMap;
  57984. private _effect;
  57985. private readonly _storeNonLinearDepth;
  57986. private readonly _clearColor;
  57987. /** Get if the depth renderer is using packed depth or not */
  57988. readonly isPacked: boolean;
  57989. private _cachedDefines;
  57990. private _camera;
  57991. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57992. enabled: boolean;
  57993. /**
  57994. * Specifiess that the depth renderer will only be used within
  57995. * the camera it is created for.
  57996. * This can help forcing its rendering during the camera processing.
  57997. */
  57998. useOnlyInActiveCamera: boolean;
  57999. /** @hidden */
  58000. static _SceneComponentInitialization: (scene: Scene) => void;
  58001. /**
  58002. * Instantiates a depth renderer
  58003. * @param scene The scene the renderer belongs to
  58004. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58005. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58006. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58007. */
  58008. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58009. /**
  58010. * Creates the depth rendering effect and checks if the effect is ready.
  58011. * @param subMesh The submesh to be used to render the depth map of
  58012. * @param useInstances If multiple world instances should be used
  58013. * @returns if the depth renderer is ready to render the depth map
  58014. */
  58015. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58016. /**
  58017. * Gets the texture which the depth map will be written to.
  58018. * @returns The depth map texture
  58019. */
  58020. getDepthMap(): RenderTargetTexture;
  58021. /**
  58022. * Disposes of the depth renderer.
  58023. */
  58024. dispose(): void;
  58025. }
  58026. }
  58027. declare module BABYLON {
  58028. /** @hidden */
  58029. export var minmaxReduxPixelShader: {
  58030. name: string;
  58031. shader: string;
  58032. };
  58033. }
  58034. declare module BABYLON {
  58035. /**
  58036. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58037. * and maximum values from all values of the texture.
  58038. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58039. * The source values are read from the red channel of the texture.
  58040. */
  58041. export class MinMaxReducer {
  58042. /**
  58043. * Observable triggered when the computation has been performed
  58044. */
  58045. onAfterReductionPerformed: Observable<{
  58046. min: number;
  58047. max: number;
  58048. }>;
  58049. protected _camera: Camera;
  58050. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58051. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58052. protected _postProcessManager: PostProcessManager;
  58053. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58054. protected _forceFullscreenViewport: boolean;
  58055. /**
  58056. * Creates a min/max reducer
  58057. * @param camera The camera to use for the post processes
  58058. */
  58059. constructor(camera: Camera);
  58060. /**
  58061. * Gets the texture used to read the values from.
  58062. */
  58063. get sourceTexture(): Nullable<RenderTargetTexture>;
  58064. /**
  58065. * Sets the source texture to read the values from.
  58066. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58067. * because in such textures '1' value must not be taken into account to compute the maximum
  58068. * as this value is used to clear the texture.
  58069. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58070. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58071. * @param depthRedux Indicates if the texture is a depth texture or not
  58072. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58073. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58074. */
  58075. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58076. /**
  58077. * Defines the refresh rate of the computation.
  58078. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58079. */
  58080. get refreshRate(): number;
  58081. set refreshRate(value: number);
  58082. protected _activated: boolean;
  58083. /**
  58084. * Gets the activation status of the reducer
  58085. */
  58086. get activated(): boolean;
  58087. /**
  58088. * Activates the reduction computation.
  58089. * When activated, the observers registered in onAfterReductionPerformed are
  58090. * called after the compuation is performed
  58091. */
  58092. activate(): void;
  58093. /**
  58094. * Deactivates the reduction computation.
  58095. */
  58096. deactivate(): void;
  58097. /**
  58098. * Disposes the min/max reducer
  58099. * @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.
  58100. */
  58101. dispose(disposeAll?: boolean): void;
  58102. }
  58103. }
  58104. declare module BABYLON {
  58105. /**
  58106. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58107. */
  58108. export class DepthReducer extends MinMaxReducer {
  58109. private _depthRenderer;
  58110. private _depthRendererId;
  58111. /**
  58112. * Gets the depth renderer used for the computation.
  58113. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58114. */
  58115. get depthRenderer(): Nullable<DepthRenderer>;
  58116. /**
  58117. * Creates a depth reducer
  58118. * @param camera The camera used to render the depth texture
  58119. */
  58120. constructor(camera: Camera);
  58121. /**
  58122. * Sets the depth renderer to use to generate the depth map
  58123. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58124. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58125. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58126. */
  58127. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58128. /** @hidden */
  58129. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58130. /**
  58131. * Activates the reduction computation.
  58132. * When activated, the observers registered in onAfterReductionPerformed are
  58133. * called after the compuation is performed
  58134. */
  58135. activate(): void;
  58136. /**
  58137. * Deactivates the reduction computation.
  58138. */
  58139. deactivate(): void;
  58140. /**
  58141. * Disposes the depth reducer
  58142. * @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.
  58143. */
  58144. dispose(disposeAll?: boolean): void;
  58145. }
  58146. }
  58147. declare module BABYLON {
  58148. /**
  58149. * A CSM implementation allowing casting shadows on large scenes.
  58150. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58151. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58152. */
  58153. export class CascadedShadowGenerator extends ShadowGenerator {
  58154. private static readonly frustumCornersNDCSpace;
  58155. /**
  58156. * Name of the CSM class
  58157. */
  58158. static CLASSNAME: string;
  58159. /**
  58160. * Defines the default number of cascades used by the CSM.
  58161. */
  58162. static readonly DEFAULT_CASCADES_COUNT: number;
  58163. /**
  58164. * Defines the minimum number of cascades used by the CSM.
  58165. */
  58166. static readonly MIN_CASCADES_COUNT: number;
  58167. /**
  58168. * Defines the maximum number of cascades used by the CSM.
  58169. */
  58170. static readonly MAX_CASCADES_COUNT: number;
  58171. protected _validateFilter(filter: number): number;
  58172. /**
  58173. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58174. */
  58175. penumbraDarkness: number;
  58176. private _numCascades;
  58177. /**
  58178. * Gets or set the number of cascades used by the CSM.
  58179. */
  58180. get numCascades(): number;
  58181. set numCascades(value: number);
  58182. /**
  58183. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58184. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58185. */
  58186. stabilizeCascades: boolean;
  58187. private _freezeShadowCastersBoundingInfo;
  58188. private _freezeShadowCastersBoundingInfoObservable;
  58189. /**
  58190. * Enables or disables the shadow casters bounding info computation.
  58191. * If your shadow casters don't move, you can disable this feature.
  58192. * If it is enabled, the bounding box computation is done every frame.
  58193. */
  58194. get freezeShadowCastersBoundingInfo(): boolean;
  58195. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58196. private _scbiMin;
  58197. private _scbiMax;
  58198. protected _computeShadowCastersBoundingInfo(): void;
  58199. protected _shadowCastersBoundingInfo: BoundingInfo;
  58200. /**
  58201. * Gets or sets the shadow casters bounding info.
  58202. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58203. * so that the system won't overwrite the bounds you provide
  58204. */
  58205. get shadowCastersBoundingInfo(): BoundingInfo;
  58206. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58207. protected _breaksAreDirty: boolean;
  58208. protected _minDistance: number;
  58209. protected _maxDistance: number;
  58210. /**
  58211. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58212. *
  58213. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58214. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58215. * @param min minimal distance for the breaks (default to 0.)
  58216. * @param max maximal distance for the breaks (default to 1.)
  58217. */
  58218. setMinMaxDistance(min: number, max: number): void;
  58219. /** Gets the minimal distance used in the cascade break computation */
  58220. get minDistance(): number;
  58221. /** Gets the maximal distance used in the cascade break computation */
  58222. get maxDistance(): number;
  58223. /**
  58224. * Gets the class name of that object
  58225. * @returns "CascadedShadowGenerator"
  58226. */
  58227. getClassName(): string;
  58228. private _cascadeMinExtents;
  58229. private _cascadeMaxExtents;
  58230. /**
  58231. * Gets a cascade minimum extents
  58232. * @param cascadeIndex index of the cascade
  58233. * @returns the minimum cascade extents
  58234. */
  58235. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58236. /**
  58237. * Gets a cascade maximum extents
  58238. * @param cascadeIndex index of the cascade
  58239. * @returns the maximum cascade extents
  58240. */
  58241. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58242. private _cascades;
  58243. private _currentLayer;
  58244. private _viewSpaceFrustumsZ;
  58245. private _viewMatrices;
  58246. private _projectionMatrices;
  58247. private _transformMatrices;
  58248. private _transformMatricesAsArray;
  58249. private _frustumLengths;
  58250. private _lightSizeUVCorrection;
  58251. private _depthCorrection;
  58252. private _frustumCornersWorldSpace;
  58253. private _frustumCenter;
  58254. private _shadowCameraPos;
  58255. private _shadowMaxZ;
  58256. /**
  58257. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58258. * It defaults to camera.maxZ
  58259. */
  58260. get shadowMaxZ(): number;
  58261. /**
  58262. * Sets the shadow max z distance.
  58263. */
  58264. set shadowMaxZ(value: number);
  58265. protected _debug: boolean;
  58266. /**
  58267. * Gets or sets the debug flag.
  58268. * When enabled, the cascades are materialized by different colors on the screen.
  58269. */
  58270. get debug(): boolean;
  58271. set debug(dbg: boolean);
  58272. private _depthClamp;
  58273. /**
  58274. * Gets or sets the depth clamping value.
  58275. *
  58276. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58277. * to account for the shadow casters far away.
  58278. *
  58279. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58280. */
  58281. get depthClamp(): boolean;
  58282. set depthClamp(value: boolean);
  58283. private _cascadeBlendPercentage;
  58284. /**
  58285. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58286. * It defaults to 0.1 (10% blending).
  58287. */
  58288. get cascadeBlendPercentage(): number;
  58289. set cascadeBlendPercentage(value: number);
  58290. private _lambda;
  58291. /**
  58292. * Gets or set the lambda parameter.
  58293. * This parameter is used to split the camera frustum and create the cascades.
  58294. * 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.
  58295. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58296. */
  58297. get lambda(): number;
  58298. set lambda(value: number);
  58299. /**
  58300. * Gets the view matrix corresponding to a given cascade
  58301. * @param cascadeNum cascade to retrieve the view matrix from
  58302. * @returns the cascade view matrix
  58303. */
  58304. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58305. /**
  58306. * Gets the projection matrix corresponding to a given cascade
  58307. * @param cascadeNum cascade to retrieve the projection matrix from
  58308. * @returns the cascade projection matrix
  58309. */
  58310. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58311. /**
  58312. * Gets the transformation matrix corresponding to a given cascade
  58313. * @param cascadeNum cascade to retrieve the transformation matrix from
  58314. * @returns the cascade transformation matrix
  58315. */
  58316. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58317. private _depthRenderer;
  58318. /**
  58319. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58320. *
  58321. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58322. *
  58323. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58324. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58325. * @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
  58326. */
  58327. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58328. private _depthReducer;
  58329. private _autoCalcDepthBounds;
  58330. /**
  58331. * Gets or sets the autoCalcDepthBounds property.
  58332. *
  58333. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58334. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58335. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58336. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58337. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58338. */
  58339. get autoCalcDepthBounds(): boolean;
  58340. set autoCalcDepthBounds(value: boolean);
  58341. /**
  58342. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58343. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58344. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58345. * for setting the refresh rate on the renderer yourself!
  58346. */
  58347. get autoCalcDepthBoundsRefreshRate(): number;
  58348. set autoCalcDepthBoundsRefreshRate(value: number);
  58349. /**
  58350. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58351. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58352. * you change the camera near/far planes!
  58353. */
  58354. splitFrustum(): void;
  58355. private _splitFrustum;
  58356. private _computeMatrices;
  58357. private _computeFrustumInWorldSpace;
  58358. private _computeCascadeFrustum;
  58359. /**
  58360. * Support test.
  58361. */
  58362. static get IsSupported(): boolean;
  58363. /** @hidden */
  58364. static _SceneComponentInitialization: (scene: Scene) => void;
  58365. /**
  58366. * Creates a Cascaded Shadow Generator object.
  58367. * A ShadowGenerator is the required tool to use the shadows.
  58368. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58369. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58370. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58371. * @param light The directional light object generating the shadows.
  58372. * @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.
  58373. */
  58374. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58375. protected _initializeGenerator(): void;
  58376. protected _createTargetRenderTexture(): void;
  58377. protected _initializeShadowMap(): void;
  58378. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58379. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58380. /**
  58381. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58382. * @param defines Defines of the material we want to update
  58383. * @param lightIndex Index of the light in the enabled light list of the material
  58384. */
  58385. prepareDefines(defines: any, lightIndex: number): void;
  58386. /**
  58387. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58388. * defined in the generator but impacting the effect).
  58389. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58390. * @param effect The effect we are binfing the information for
  58391. */
  58392. bindShadowLight(lightIndex: string, effect: Effect): void;
  58393. /**
  58394. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58395. * (eq to view projection * shadow projection matrices)
  58396. * @returns The transform matrix used to create the shadow map
  58397. */
  58398. getTransformMatrix(): Matrix;
  58399. /**
  58400. * Disposes the ShadowGenerator.
  58401. * Returns nothing.
  58402. */
  58403. dispose(): void;
  58404. /**
  58405. * Serializes the shadow generator setup to a json object.
  58406. * @returns The serialized JSON object
  58407. */
  58408. serialize(): any;
  58409. /**
  58410. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58411. * @param parsedShadowGenerator The JSON object to parse
  58412. * @param scene The scene to create the shadow map for
  58413. * @returns The parsed shadow generator
  58414. */
  58415. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58416. }
  58417. }
  58418. declare module BABYLON {
  58419. /**
  58420. * Defines the shadow generator component responsible to manage any shadow generators
  58421. * in a given scene.
  58422. */
  58423. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58424. /**
  58425. * The component name helpfull to identify the component in the list of scene components.
  58426. */
  58427. readonly name: string;
  58428. /**
  58429. * The scene the component belongs to.
  58430. */
  58431. scene: Scene;
  58432. /**
  58433. * Creates a new instance of the component for the given scene
  58434. * @param scene Defines the scene to register the component in
  58435. */
  58436. constructor(scene: Scene);
  58437. /**
  58438. * Registers the component in a given scene
  58439. */
  58440. register(): void;
  58441. /**
  58442. * Rebuilds the elements related to this component in case of
  58443. * context lost for instance.
  58444. */
  58445. rebuild(): void;
  58446. /**
  58447. * Serializes the component data to the specified json object
  58448. * @param serializationObject The object to serialize to
  58449. */
  58450. serialize(serializationObject: any): void;
  58451. /**
  58452. * Adds all the elements from the container to the scene
  58453. * @param container the container holding the elements
  58454. */
  58455. addFromContainer(container: AbstractScene): void;
  58456. /**
  58457. * Removes all the elements in the container from the scene
  58458. * @param container contains the elements to remove
  58459. * @param dispose if the removed element should be disposed (default: false)
  58460. */
  58461. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58462. /**
  58463. * Rebuilds the elements related to this component in case of
  58464. * context lost for instance.
  58465. */
  58466. dispose(): void;
  58467. private _gatherRenderTargets;
  58468. }
  58469. }
  58470. declare module BABYLON {
  58471. /**
  58472. * A point light is a light defined by an unique point in world space.
  58473. * The light is emitted in every direction from this point.
  58474. * A good example of a point light is a standard light bulb.
  58475. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58476. */
  58477. export class PointLight extends ShadowLight {
  58478. private _shadowAngle;
  58479. /**
  58480. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58481. * This specifies what angle the shadow will use to be created.
  58482. *
  58483. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58484. */
  58485. get shadowAngle(): number;
  58486. /**
  58487. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58488. * This specifies what angle the shadow will use to be created.
  58489. *
  58490. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58491. */
  58492. set shadowAngle(value: number);
  58493. /**
  58494. * Gets the direction if it has been set.
  58495. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58496. */
  58497. get direction(): Vector3;
  58498. /**
  58499. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58500. */
  58501. set direction(value: Vector3);
  58502. /**
  58503. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58504. * A PointLight emits the light in every direction.
  58505. * It can cast shadows.
  58506. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58507. * ```javascript
  58508. * var pointLight = new PointLight("pl", camera.position, scene);
  58509. * ```
  58510. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58511. * @param name The light friendly name
  58512. * @param position The position of the point light in the scene
  58513. * @param scene The scene the lights belongs to
  58514. */
  58515. constructor(name: string, position: Vector3, scene: Scene);
  58516. /**
  58517. * Returns the string "PointLight"
  58518. * @returns the class name
  58519. */
  58520. getClassName(): string;
  58521. /**
  58522. * Returns the integer 0.
  58523. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58524. */
  58525. getTypeID(): number;
  58526. /**
  58527. * Specifies wether or not the shadowmap should be a cube texture.
  58528. * @returns true if the shadowmap needs to be a cube texture.
  58529. */
  58530. needCube(): boolean;
  58531. /**
  58532. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58533. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58534. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58535. */
  58536. getShadowDirection(faceIndex?: number): Vector3;
  58537. /**
  58538. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58539. * - fov = PI / 2
  58540. * - aspect ratio : 1.0
  58541. * - z-near and far equal to the active camera minZ and maxZ.
  58542. * Returns the PointLight.
  58543. */
  58544. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58545. protected _buildUniformLayout(): void;
  58546. /**
  58547. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58548. * @param effect The effect to update
  58549. * @param lightIndex The index of the light in the effect to update
  58550. * @returns The point light
  58551. */
  58552. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58553. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58554. /**
  58555. * Prepares the list of defines specific to the light type.
  58556. * @param defines the list of defines
  58557. * @param lightIndex defines the index of the light for the effect
  58558. */
  58559. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58560. }
  58561. }
  58562. declare module BABYLON {
  58563. /**
  58564. * Header information of HDR texture files.
  58565. */
  58566. export interface HDRInfo {
  58567. /**
  58568. * The height of the texture in pixels.
  58569. */
  58570. height: number;
  58571. /**
  58572. * The width of the texture in pixels.
  58573. */
  58574. width: number;
  58575. /**
  58576. * The index of the beginning of the data in the binary file.
  58577. */
  58578. dataPosition: number;
  58579. }
  58580. /**
  58581. * This groups tools to convert HDR texture to native colors array.
  58582. */
  58583. export class HDRTools {
  58584. private static Ldexp;
  58585. private static Rgbe2float;
  58586. private static readStringLine;
  58587. /**
  58588. * Reads header information from an RGBE texture stored in a native array.
  58589. * More information on this format are available here:
  58590. * https://en.wikipedia.org/wiki/RGBE_image_format
  58591. *
  58592. * @param uint8array The binary file stored in native array.
  58593. * @return The header information.
  58594. */
  58595. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58596. /**
  58597. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58598. * This RGBE texture needs to store the information as a panorama.
  58599. *
  58600. * More information on this format are available here:
  58601. * https://en.wikipedia.org/wiki/RGBE_image_format
  58602. *
  58603. * @param buffer The binary file stored in an array buffer.
  58604. * @param size The expected size of the extracted cubemap.
  58605. * @return The Cube Map information.
  58606. */
  58607. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58608. /**
  58609. * Returns the pixels data extracted from an RGBE texture.
  58610. * This pixels will be stored left to right up to down in the R G B order in one array.
  58611. *
  58612. * More information on this format are available here:
  58613. * https://en.wikipedia.org/wiki/RGBE_image_format
  58614. *
  58615. * @param uint8array The binary file stored in an array buffer.
  58616. * @param hdrInfo The header information of the file.
  58617. * @return The pixels data in RGB right to left up to down order.
  58618. */
  58619. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58620. private static RGBE_ReadPixels_RLE;
  58621. }
  58622. }
  58623. declare module BABYLON {
  58624. /**
  58625. * Effect Render Options
  58626. */
  58627. export interface IEffectRendererOptions {
  58628. /**
  58629. * Defines the vertices positions.
  58630. */
  58631. positions?: number[];
  58632. /**
  58633. * Defines the indices.
  58634. */
  58635. indices?: number[];
  58636. }
  58637. /**
  58638. * Helper class to render one or more effects.
  58639. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58640. */
  58641. export class EffectRenderer {
  58642. private engine;
  58643. private static _DefaultOptions;
  58644. private _vertexBuffers;
  58645. private _indexBuffer;
  58646. private _fullscreenViewport;
  58647. /**
  58648. * Creates an effect renderer
  58649. * @param engine the engine to use for rendering
  58650. * @param options defines the options of the effect renderer
  58651. */
  58652. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58653. /**
  58654. * Sets the current viewport in normalized coordinates 0-1
  58655. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58656. */
  58657. setViewport(viewport?: Viewport): void;
  58658. /**
  58659. * Binds the embedded attributes buffer to the effect.
  58660. * @param effect Defines the effect to bind the attributes for
  58661. */
  58662. bindBuffers(effect: Effect): void;
  58663. /**
  58664. * Sets the current effect wrapper to use during draw.
  58665. * The effect needs to be ready before calling this api.
  58666. * This also sets the default full screen position attribute.
  58667. * @param effectWrapper Defines the effect to draw with
  58668. */
  58669. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58670. /**
  58671. * Restores engine states
  58672. */
  58673. restoreStates(): void;
  58674. /**
  58675. * Draws a full screen quad.
  58676. */
  58677. draw(): void;
  58678. private isRenderTargetTexture;
  58679. /**
  58680. * renders one or more effects to a specified texture
  58681. * @param effectWrapper the effect to renderer
  58682. * @param outputTexture texture to draw to, if null it will render to the screen.
  58683. */
  58684. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58685. /**
  58686. * Disposes of the effect renderer
  58687. */
  58688. dispose(): void;
  58689. }
  58690. /**
  58691. * Options to create an EffectWrapper
  58692. */
  58693. interface EffectWrapperCreationOptions {
  58694. /**
  58695. * Engine to use to create the effect
  58696. */
  58697. engine: ThinEngine;
  58698. /**
  58699. * Fragment shader for the effect
  58700. */
  58701. fragmentShader: string;
  58702. /**
  58703. * Use the shader store instead of direct source code
  58704. */
  58705. useShaderStore?: boolean;
  58706. /**
  58707. * Vertex shader for the effect
  58708. */
  58709. vertexShader?: string;
  58710. /**
  58711. * Attributes to use in the shader
  58712. */
  58713. attributeNames?: Array<string>;
  58714. /**
  58715. * Uniforms to use in the shader
  58716. */
  58717. uniformNames?: Array<string>;
  58718. /**
  58719. * Texture sampler names to use in the shader
  58720. */
  58721. samplerNames?: Array<string>;
  58722. /**
  58723. * Defines to use in the shader
  58724. */
  58725. defines?: Array<string>;
  58726. /**
  58727. * Callback when effect is compiled
  58728. */
  58729. onCompiled?: Nullable<(effect: Effect) => void>;
  58730. /**
  58731. * The friendly name of the effect displayed in Spector.
  58732. */
  58733. name?: string;
  58734. }
  58735. /**
  58736. * Wraps an effect to be used for rendering
  58737. */
  58738. export class EffectWrapper {
  58739. /**
  58740. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58741. */
  58742. onApplyObservable: Observable<{}>;
  58743. /**
  58744. * The underlying effect
  58745. */
  58746. effect: Effect;
  58747. /**
  58748. * Creates an effect to be renderer
  58749. * @param creationOptions options to create the effect
  58750. */
  58751. constructor(creationOptions: EffectWrapperCreationOptions);
  58752. /**
  58753. * Disposes of the effect wrapper
  58754. */
  58755. dispose(): void;
  58756. }
  58757. }
  58758. declare module BABYLON {
  58759. /** @hidden */
  58760. export var hdrFilteringVertexShader: {
  58761. name: string;
  58762. shader: string;
  58763. };
  58764. }
  58765. declare module BABYLON {
  58766. /** @hidden */
  58767. export var hdrFilteringPixelShader: {
  58768. name: string;
  58769. shader: string;
  58770. };
  58771. }
  58772. declare module BABYLON {
  58773. /**
  58774. * Options for texture filtering
  58775. */
  58776. interface IHDRFilteringOptions {
  58777. /**
  58778. * Scales pixel intensity for the input HDR map.
  58779. */
  58780. hdrScale?: number;
  58781. /**
  58782. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58783. */
  58784. quality?: number;
  58785. }
  58786. /**
  58787. * Filters HDR maps to get correct renderings of PBR reflections
  58788. */
  58789. export class HDRFiltering {
  58790. private _engine;
  58791. private _effectRenderer;
  58792. private _effectWrapper;
  58793. private _lodGenerationOffset;
  58794. private _lodGenerationScale;
  58795. /**
  58796. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58797. * you care about baking speed.
  58798. */
  58799. quality: number;
  58800. /**
  58801. * Scales pixel intensity for the input HDR map.
  58802. */
  58803. hdrScale: number;
  58804. /**
  58805. * Instantiates HDR filter for reflection maps
  58806. *
  58807. * @param engine Thin engine
  58808. * @param options Options
  58809. */
  58810. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58811. private _createRenderTarget;
  58812. private _prefilterInternal;
  58813. private _createEffect;
  58814. /**
  58815. * Get a value indicating if the filter is ready to be used
  58816. * @param texture Texture to filter
  58817. * @returns true if the filter is ready
  58818. */
  58819. isReady(texture: BaseTexture): boolean;
  58820. /**
  58821. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58822. * Prefiltering will be invoked at the end of next rendering pass.
  58823. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58824. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58825. * @param texture Texture to filter
  58826. * @param onFinished Callback when filtering is done
  58827. * @return Promise called when prefiltering is done
  58828. */
  58829. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58830. }
  58831. }
  58832. declare module BABYLON {
  58833. /**
  58834. * This represents a texture coming from an HDR input.
  58835. *
  58836. * The only supported format is currently panorama picture stored in RGBE format.
  58837. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58838. */
  58839. export class HDRCubeTexture extends BaseTexture {
  58840. private static _facesMapping;
  58841. private _generateHarmonics;
  58842. private _noMipmap;
  58843. private _prefilterOnLoad;
  58844. private _textureMatrix;
  58845. private _size;
  58846. private _onLoad;
  58847. private _onError;
  58848. /**
  58849. * The texture URL.
  58850. */
  58851. url: string;
  58852. /**
  58853. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58854. */
  58855. coordinatesMode: number;
  58856. protected _isBlocking: boolean;
  58857. /**
  58858. * Sets wether or not the texture is blocking during loading.
  58859. */
  58860. set isBlocking(value: boolean);
  58861. /**
  58862. * Gets wether or not the texture is blocking during loading.
  58863. */
  58864. get isBlocking(): boolean;
  58865. protected _rotationY: number;
  58866. /**
  58867. * Sets texture matrix rotation angle around Y axis in radians.
  58868. */
  58869. set rotationY(value: number);
  58870. /**
  58871. * Gets texture matrix rotation angle around Y axis radians.
  58872. */
  58873. get rotationY(): number;
  58874. /**
  58875. * Gets or sets the center of the bounding box associated with the cube texture
  58876. * It must define where the camera used to render the texture was set
  58877. */
  58878. boundingBoxPosition: Vector3;
  58879. private _boundingBoxSize;
  58880. /**
  58881. * Gets or sets the size of the bounding box associated with the cube texture
  58882. * When defined, the cubemap will switch to local mode
  58883. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58884. * @example https://www.babylonjs-playground.com/#RNASML
  58885. */
  58886. set boundingBoxSize(value: Vector3);
  58887. get boundingBoxSize(): Vector3;
  58888. /**
  58889. * Instantiates an HDRTexture from the following parameters.
  58890. *
  58891. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58892. * @param sceneOrEngine The scene or engine the texture will be used in
  58893. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58894. * @param noMipmap Forces to not generate the mipmap if true
  58895. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58896. * @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)
  58897. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58898. */
  58899. 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>);
  58900. /**
  58901. * Get the current class name of the texture useful for serialization or dynamic coding.
  58902. * @returns "HDRCubeTexture"
  58903. */
  58904. getClassName(): string;
  58905. /**
  58906. * Occurs when the file is raw .hdr file.
  58907. */
  58908. private loadTexture;
  58909. clone(): HDRCubeTexture;
  58910. delayLoad(): void;
  58911. /**
  58912. * Get the texture reflection matrix used to rotate/transform the reflection.
  58913. * @returns the reflection matrix
  58914. */
  58915. getReflectionTextureMatrix(): Matrix;
  58916. /**
  58917. * Set the texture reflection matrix used to rotate/transform the reflection.
  58918. * @param value Define the reflection matrix to set
  58919. */
  58920. setReflectionTextureMatrix(value: Matrix): void;
  58921. /**
  58922. * Parses a JSON representation of an HDR Texture in order to create the texture
  58923. * @param parsedTexture Define the JSON representation
  58924. * @param scene Define the scene the texture should be created in
  58925. * @param rootUrl Define the root url in case we need to load relative dependencies
  58926. * @returns the newly created texture after parsing
  58927. */
  58928. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58929. serialize(): any;
  58930. }
  58931. }
  58932. declare module BABYLON {
  58933. /**
  58934. * Class used to control physics engine
  58935. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58936. */
  58937. export class PhysicsEngine implements IPhysicsEngine {
  58938. private _physicsPlugin;
  58939. /**
  58940. * Global value used to control the smallest number supported by the simulation
  58941. */
  58942. static Epsilon: number;
  58943. private _impostors;
  58944. private _joints;
  58945. private _subTimeStep;
  58946. /**
  58947. * Gets the gravity vector used by the simulation
  58948. */
  58949. gravity: Vector3;
  58950. /**
  58951. * Factory used to create the default physics plugin.
  58952. * @returns The default physics plugin
  58953. */
  58954. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58955. /**
  58956. * Creates a new Physics Engine
  58957. * @param gravity defines the gravity vector used by the simulation
  58958. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58959. */
  58960. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58961. /**
  58962. * Sets the gravity vector used by the simulation
  58963. * @param gravity defines the gravity vector to use
  58964. */
  58965. setGravity(gravity: Vector3): void;
  58966. /**
  58967. * Set the time step of the physics engine.
  58968. * Default is 1/60.
  58969. * To slow it down, enter 1/600 for example.
  58970. * To speed it up, 1/30
  58971. * @param newTimeStep defines the new timestep to apply to this world.
  58972. */
  58973. setTimeStep(newTimeStep?: number): void;
  58974. /**
  58975. * Get the time step of the physics engine.
  58976. * @returns the current time step
  58977. */
  58978. getTimeStep(): number;
  58979. /**
  58980. * Set the sub time step of the physics engine.
  58981. * Default is 0 meaning there is no sub steps
  58982. * To increase physics resolution precision, set a small value (like 1 ms)
  58983. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58984. */
  58985. setSubTimeStep(subTimeStep?: number): void;
  58986. /**
  58987. * Get the sub time step of the physics engine.
  58988. * @returns the current sub time step
  58989. */
  58990. getSubTimeStep(): number;
  58991. /**
  58992. * Release all resources
  58993. */
  58994. dispose(): void;
  58995. /**
  58996. * Gets the name of the current physics plugin
  58997. * @returns the name of the plugin
  58998. */
  58999. getPhysicsPluginName(): string;
  59000. /**
  59001. * Adding a new impostor for the impostor tracking.
  59002. * This will be done by the impostor itself.
  59003. * @param impostor the impostor to add
  59004. */
  59005. addImpostor(impostor: PhysicsImpostor): void;
  59006. /**
  59007. * Remove an impostor from the engine.
  59008. * This impostor and its mesh will not longer be updated by the physics engine.
  59009. * @param impostor the impostor to remove
  59010. */
  59011. removeImpostor(impostor: PhysicsImpostor): void;
  59012. /**
  59013. * Add a joint to the physics engine
  59014. * @param mainImpostor defines the main impostor to which the joint is added.
  59015. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59016. * @param joint defines the joint that will connect both impostors.
  59017. */
  59018. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59019. /**
  59020. * Removes a joint from the simulation
  59021. * @param mainImpostor defines the impostor used with the joint
  59022. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59023. * @param joint defines the joint to remove
  59024. */
  59025. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59026. /**
  59027. * Called by the scene. No need to call it.
  59028. * @param delta defines the timespam between frames
  59029. */
  59030. _step(delta: number): void;
  59031. /**
  59032. * Gets the current plugin used to run the simulation
  59033. * @returns current plugin
  59034. */
  59035. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59036. /**
  59037. * Gets the list of physic impostors
  59038. * @returns an array of PhysicsImpostor
  59039. */
  59040. getImpostors(): Array<PhysicsImpostor>;
  59041. /**
  59042. * Gets the impostor for a physics enabled object
  59043. * @param object defines the object impersonated by the impostor
  59044. * @returns the PhysicsImpostor or null if not found
  59045. */
  59046. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59047. /**
  59048. * Gets the impostor for a physics body object
  59049. * @param body defines physics body used by the impostor
  59050. * @returns the PhysicsImpostor or null if not found
  59051. */
  59052. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59053. /**
  59054. * Does a raycast in the physics world
  59055. * @param from when should the ray start?
  59056. * @param to when should the ray end?
  59057. * @returns PhysicsRaycastResult
  59058. */
  59059. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59060. }
  59061. }
  59062. declare module BABYLON {
  59063. /** @hidden */
  59064. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59065. private _useDeltaForWorldStep;
  59066. world: any;
  59067. name: string;
  59068. private _physicsMaterials;
  59069. private _fixedTimeStep;
  59070. private _cannonRaycastResult;
  59071. private _raycastResult;
  59072. private _physicsBodysToRemoveAfterStep;
  59073. private _firstFrame;
  59074. BJSCANNON: any;
  59075. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59076. setGravity(gravity: Vector3): void;
  59077. setTimeStep(timeStep: number): void;
  59078. getTimeStep(): number;
  59079. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59080. private _removeMarkedPhysicsBodiesFromWorld;
  59081. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59082. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59083. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59084. private _processChildMeshes;
  59085. removePhysicsBody(impostor: PhysicsImpostor): void;
  59086. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59087. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59088. private _addMaterial;
  59089. private _checkWithEpsilon;
  59090. private _createShape;
  59091. private _createHeightmap;
  59092. private _minus90X;
  59093. private _plus90X;
  59094. private _tmpPosition;
  59095. private _tmpDeltaPosition;
  59096. private _tmpUnityRotation;
  59097. private _updatePhysicsBodyTransformation;
  59098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59099. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59100. isSupported(): boolean;
  59101. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59102. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59103. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59104. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59105. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59106. getBodyMass(impostor: PhysicsImpostor): number;
  59107. getBodyFriction(impostor: PhysicsImpostor): number;
  59108. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59109. getBodyRestitution(impostor: PhysicsImpostor): number;
  59110. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59111. sleepBody(impostor: PhysicsImpostor): void;
  59112. wakeUpBody(impostor: PhysicsImpostor): void;
  59113. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59114. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59115. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59116. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59117. getRadius(impostor: PhysicsImpostor): number;
  59118. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59119. dispose(): void;
  59120. private _extendNamespace;
  59121. /**
  59122. * Does a raycast in the physics world
  59123. * @param from when should the ray start?
  59124. * @param to when should the ray end?
  59125. * @returns PhysicsRaycastResult
  59126. */
  59127. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59128. }
  59129. }
  59130. declare module BABYLON {
  59131. /** @hidden */
  59132. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59133. private _useDeltaForWorldStep;
  59134. world: any;
  59135. name: string;
  59136. BJSOIMO: any;
  59137. private _raycastResult;
  59138. private _fixedTimeStep;
  59139. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59140. setGravity(gravity: Vector3): void;
  59141. setTimeStep(timeStep: number): void;
  59142. getTimeStep(): number;
  59143. private _tmpImpostorsArray;
  59144. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59145. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59146. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59147. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59148. private _tmpPositionVector;
  59149. removePhysicsBody(impostor: PhysicsImpostor): void;
  59150. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59151. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59152. isSupported(): boolean;
  59153. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59154. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59155. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59156. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59157. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59159. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59160. getBodyMass(impostor: PhysicsImpostor): number;
  59161. getBodyFriction(impostor: PhysicsImpostor): number;
  59162. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59163. getBodyRestitution(impostor: PhysicsImpostor): number;
  59164. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59165. sleepBody(impostor: PhysicsImpostor): void;
  59166. wakeUpBody(impostor: PhysicsImpostor): void;
  59167. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59168. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59169. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59170. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59171. getRadius(impostor: PhysicsImpostor): number;
  59172. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59173. dispose(): void;
  59174. /**
  59175. * Does a raycast in the physics world
  59176. * @param from when should the ray start?
  59177. * @param to when should the ray end?
  59178. * @returns PhysicsRaycastResult
  59179. */
  59180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * Class containing static functions to help procedurally build meshes
  59186. */
  59187. export class RibbonBuilder {
  59188. /**
  59189. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59190. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59191. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59192. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59193. * * 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
  59194. * * 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
  59195. * * 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
  59196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59197. * * 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
  59198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59199. * * 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
  59200. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59201. * * 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
  59202. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59204. * @param name defines the name of the mesh
  59205. * @param options defines the options used to create the mesh
  59206. * @param scene defines the hosting scene
  59207. * @returns the ribbon mesh
  59208. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59209. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59210. */
  59211. static CreateRibbon(name: string, options: {
  59212. pathArray: Vector3[][];
  59213. closeArray?: boolean;
  59214. closePath?: boolean;
  59215. offset?: number;
  59216. updatable?: boolean;
  59217. sideOrientation?: number;
  59218. frontUVs?: Vector4;
  59219. backUVs?: Vector4;
  59220. instance?: Mesh;
  59221. invertUV?: boolean;
  59222. uvs?: Vector2[];
  59223. colors?: Color4[];
  59224. }, scene?: Nullable<Scene>): Mesh;
  59225. }
  59226. }
  59227. declare module BABYLON {
  59228. /**
  59229. * Class containing static functions to help procedurally build meshes
  59230. */
  59231. export class ShapeBuilder {
  59232. /**
  59233. * 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.
  59234. * * 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.
  59235. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59236. * * 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.
  59237. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59238. * * 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
  59239. * * 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
  59240. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59242. * * 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
  59243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59245. * @param name defines the name of the mesh
  59246. * @param options defines the options used to create the mesh
  59247. * @param scene defines the hosting scene
  59248. * @returns the extruded shape mesh
  59249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59251. */
  59252. static ExtrudeShape(name: string, options: {
  59253. shape: Vector3[];
  59254. path: Vector3[];
  59255. scale?: number;
  59256. rotation?: number;
  59257. cap?: number;
  59258. updatable?: boolean;
  59259. sideOrientation?: number;
  59260. frontUVs?: Vector4;
  59261. backUVs?: Vector4;
  59262. instance?: Mesh;
  59263. invertUV?: boolean;
  59264. }, scene?: Nullable<Scene>): Mesh;
  59265. /**
  59266. * Creates an custom extruded shape mesh.
  59267. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59268. * * 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.
  59269. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59270. * * 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
  59271. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59272. * * 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
  59273. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59274. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59275. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59276. * * 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
  59277. * * 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
  59278. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59280. * * 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
  59281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59283. * @param name defines the name of the mesh
  59284. * @param options defines the options used to create the mesh
  59285. * @param scene defines the hosting scene
  59286. * @returns the custom extruded shape mesh
  59287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59290. */
  59291. static ExtrudeShapeCustom(name: string, options: {
  59292. shape: Vector3[];
  59293. path: Vector3[];
  59294. scaleFunction?: any;
  59295. rotationFunction?: any;
  59296. ribbonCloseArray?: boolean;
  59297. ribbonClosePath?: boolean;
  59298. cap?: number;
  59299. updatable?: boolean;
  59300. sideOrientation?: number;
  59301. frontUVs?: Vector4;
  59302. backUVs?: Vector4;
  59303. instance?: Mesh;
  59304. invertUV?: boolean;
  59305. }, scene?: Nullable<Scene>): Mesh;
  59306. private static _ExtrudeShapeGeneric;
  59307. }
  59308. }
  59309. declare module BABYLON {
  59310. /**
  59311. * AmmoJS Physics plugin
  59312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59313. * @see https://github.com/kripken/ammo.js/
  59314. */
  59315. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59316. private _useDeltaForWorldStep;
  59317. /**
  59318. * Reference to the Ammo library
  59319. */
  59320. bjsAMMO: any;
  59321. /**
  59322. * Created ammoJS world which physics bodies are added to
  59323. */
  59324. world: any;
  59325. /**
  59326. * Name of the plugin
  59327. */
  59328. name: string;
  59329. private _timeStep;
  59330. private _fixedTimeStep;
  59331. private _maxSteps;
  59332. private _tmpQuaternion;
  59333. private _tmpAmmoTransform;
  59334. private _tmpAmmoQuaternion;
  59335. private _tmpAmmoConcreteContactResultCallback;
  59336. private _collisionConfiguration;
  59337. private _dispatcher;
  59338. private _overlappingPairCache;
  59339. private _solver;
  59340. private _softBodySolver;
  59341. private _tmpAmmoVectorA;
  59342. private _tmpAmmoVectorB;
  59343. private _tmpAmmoVectorC;
  59344. private _tmpAmmoVectorD;
  59345. private _tmpContactCallbackResult;
  59346. private _tmpAmmoVectorRCA;
  59347. private _tmpAmmoVectorRCB;
  59348. private _raycastResult;
  59349. private static readonly DISABLE_COLLISION_FLAG;
  59350. private static readonly KINEMATIC_FLAG;
  59351. private static readonly DISABLE_DEACTIVATION_FLAG;
  59352. /**
  59353. * Initializes the ammoJS plugin
  59354. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59355. * @param ammoInjection can be used to inject your own ammo reference
  59356. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59357. */
  59358. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59359. /**
  59360. * Sets the gravity of the physics world (m/(s^2))
  59361. * @param gravity Gravity to set
  59362. */
  59363. setGravity(gravity: Vector3): void;
  59364. /**
  59365. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59366. * @param timeStep timestep to use in seconds
  59367. */
  59368. setTimeStep(timeStep: number): void;
  59369. /**
  59370. * 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)
  59371. * @param fixedTimeStep fixedTimeStep to use in seconds
  59372. */
  59373. setFixedTimeStep(fixedTimeStep: number): void;
  59374. /**
  59375. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59376. * @param maxSteps the maximum number of steps by the physics engine per frame
  59377. */
  59378. setMaxSteps(maxSteps: number): void;
  59379. /**
  59380. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59381. * @returns the current timestep in seconds
  59382. */
  59383. getTimeStep(): number;
  59384. /**
  59385. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59386. */
  59387. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59388. private _isImpostorInContact;
  59389. private _isImpostorPairInContact;
  59390. private _stepSimulation;
  59391. /**
  59392. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59393. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59394. * After the step the babylon meshes are set to the position of the physics imposters
  59395. * @param delta amount of time to step forward
  59396. * @param impostors array of imposters to update before/after the step
  59397. */
  59398. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59399. /**
  59400. * Update babylon mesh to match physics world object
  59401. * @param impostor imposter to match
  59402. */
  59403. private _afterSoftStep;
  59404. /**
  59405. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59406. * @param impostor imposter to match
  59407. */
  59408. private _ropeStep;
  59409. /**
  59410. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59411. * @param impostor imposter to match
  59412. */
  59413. private _softbodyOrClothStep;
  59414. private _tmpMatrix;
  59415. /**
  59416. * Applies an impulse on the imposter
  59417. * @param impostor imposter to apply impulse to
  59418. * @param force amount of force to be applied to the imposter
  59419. * @param contactPoint the location to apply the impulse on the imposter
  59420. */
  59421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59422. /**
  59423. * Applies a force on the imposter
  59424. * @param impostor imposter to apply force
  59425. * @param force amount of force to be applied to the imposter
  59426. * @param contactPoint the location to apply the force on the imposter
  59427. */
  59428. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59429. /**
  59430. * Creates a physics body using the plugin
  59431. * @param impostor the imposter to create the physics body on
  59432. */
  59433. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59434. /**
  59435. * Removes the physics body from the imposter and disposes of the body's memory
  59436. * @param impostor imposter to remove the physics body from
  59437. */
  59438. removePhysicsBody(impostor: PhysicsImpostor): void;
  59439. /**
  59440. * Generates a joint
  59441. * @param impostorJoint the imposter joint to create the joint with
  59442. */
  59443. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59444. /**
  59445. * Removes a joint
  59446. * @param impostorJoint the imposter joint to remove the joint from
  59447. */
  59448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59449. private _addMeshVerts;
  59450. /**
  59451. * Initialise the soft body vertices to match its object's (mesh) vertices
  59452. * Softbody vertices (nodes) are in world space and to match this
  59453. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59454. * @param impostor to create the softbody for
  59455. */
  59456. private _softVertexData;
  59457. /**
  59458. * Create an impostor's soft body
  59459. * @param impostor to create the softbody for
  59460. */
  59461. private _createSoftbody;
  59462. /**
  59463. * Create cloth for an impostor
  59464. * @param impostor to create the softbody for
  59465. */
  59466. private _createCloth;
  59467. /**
  59468. * Create rope for an impostor
  59469. * @param impostor to create the softbody for
  59470. */
  59471. private _createRope;
  59472. /**
  59473. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59474. * @param impostor to create the custom physics shape for
  59475. */
  59476. private _createCustom;
  59477. private _addHullVerts;
  59478. private _createShape;
  59479. /**
  59480. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59481. * @param impostor imposter containing the physics body and babylon object
  59482. */
  59483. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59484. /**
  59485. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59486. * @param impostor imposter containing the physics body and babylon object
  59487. * @param newPosition new position
  59488. * @param newRotation new rotation
  59489. */
  59490. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59491. /**
  59492. * If this plugin is supported
  59493. * @returns true if its supported
  59494. */
  59495. isSupported(): boolean;
  59496. /**
  59497. * Sets the linear velocity of the physics body
  59498. * @param impostor imposter to set the velocity on
  59499. * @param velocity velocity to set
  59500. */
  59501. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59502. /**
  59503. * Sets the angular velocity of the physics body
  59504. * @param impostor imposter to set the velocity on
  59505. * @param velocity velocity to set
  59506. */
  59507. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59508. /**
  59509. * gets the linear velocity
  59510. * @param impostor imposter to get linear velocity from
  59511. * @returns linear velocity
  59512. */
  59513. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59514. /**
  59515. * gets the angular velocity
  59516. * @param impostor imposter to get angular velocity from
  59517. * @returns angular velocity
  59518. */
  59519. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59520. /**
  59521. * Sets the mass of physics body
  59522. * @param impostor imposter to set the mass on
  59523. * @param mass mass to set
  59524. */
  59525. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59526. /**
  59527. * Gets the mass of the physics body
  59528. * @param impostor imposter to get the mass from
  59529. * @returns mass
  59530. */
  59531. getBodyMass(impostor: PhysicsImpostor): number;
  59532. /**
  59533. * Gets friction of the impostor
  59534. * @param impostor impostor to get friction from
  59535. * @returns friction value
  59536. */
  59537. getBodyFriction(impostor: PhysicsImpostor): number;
  59538. /**
  59539. * Sets friction of the impostor
  59540. * @param impostor impostor to set friction on
  59541. * @param friction friction value
  59542. */
  59543. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59544. /**
  59545. * Gets restitution of the impostor
  59546. * @param impostor impostor to get restitution from
  59547. * @returns restitution value
  59548. */
  59549. getBodyRestitution(impostor: PhysicsImpostor): number;
  59550. /**
  59551. * Sets resitution of the impostor
  59552. * @param impostor impostor to set resitution on
  59553. * @param restitution resitution value
  59554. */
  59555. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59556. /**
  59557. * Gets pressure inside the impostor
  59558. * @param impostor impostor to get pressure from
  59559. * @returns pressure value
  59560. */
  59561. getBodyPressure(impostor: PhysicsImpostor): number;
  59562. /**
  59563. * Sets pressure inside a soft body impostor
  59564. * Cloth and rope must remain 0 pressure
  59565. * @param impostor impostor to set pressure on
  59566. * @param pressure pressure value
  59567. */
  59568. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59569. /**
  59570. * Gets stiffness of the impostor
  59571. * @param impostor impostor to get stiffness from
  59572. * @returns pressure value
  59573. */
  59574. getBodyStiffness(impostor: PhysicsImpostor): number;
  59575. /**
  59576. * Sets stiffness of the impostor
  59577. * @param impostor impostor to set stiffness on
  59578. * @param stiffness stiffness value from 0 to 1
  59579. */
  59580. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59581. /**
  59582. * Gets velocityIterations of the impostor
  59583. * @param impostor impostor to get velocity iterations from
  59584. * @returns velocityIterations value
  59585. */
  59586. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59587. /**
  59588. * Sets velocityIterations of the impostor
  59589. * @param impostor impostor to set velocity iterations on
  59590. * @param velocityIterations velocityIterations value
  59591. */
  59592. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59593. /**
  59594. * Gets positionIterations of the impostor
  59595. * @param impostor impostor to get position iterations from
  59596. * @returns positionIterations value
  59597. */
  59598. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59599. /**
  59600. * Sets positionIterations of the impostor
  59601. * @param impostor impostor to set position on
  59602. * @param positionIterations positionIterations value
  59603. */
  59604. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59605. /**
  59606. * Append an anchor to a cloth object
  59607. * @param impostor is the cloth impostor to add anchor to
  59608. * @param otherImpostor is the rigid impostor to anchor to
  59609. * @param width ratio across width from 0 to 1
  59610. * @param height ratio up height from 0 to 1
  59611. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59612. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59613. */
  59614. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59615. /**
  59616. * Append an hook to a rope object
  59617. * @param impostor is the rope impostor to add hook to
  59618. * @param otherImpostor is the rigid impostor to hook to
  59619. * @param length ratio along the rope from 0 to 1
  59620. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59621. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59622. */
  59623. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59624. /**
  59625. * Sleeps the physics body and stops it from being active
  59626. * @param impostor impostor to sleep
  59627. */
  59628. sleepBody(impostor: PhysicsImpostor): void;
  59629. /**
  59630. * Activates the physics body
  59631. * @param impostor impostor to activate
  59632. */
  59633. wakeUpBody(impostor: PhysicsImpostor): void;
  59634. /**
  59635. * Updates the distance parameters of the joint
  59636. * @param joint joint to update
  59637. * @param maxDistance maximum distance of the joint
  59638. * @param minDistance minimum distance of the joint
  59639. */
  59640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59641. /**
  59642. * Sets a motor on the joint
  59643. * @param joint joint to set motor on
  59644. * @param speed speed of the motor
  59645. * @param maxForce maximum force of the motor
  59646. * @param motorIndex index of the motor
  59647. */
  59648. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59649. /**
  59650. * Sets the motors limit
  59651. * @param joint joint to set limit on
  59652. * @param upperLimit upper limit
  59653. * @param lowerLimit lower limit
  59654. */
  59655. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59656. /**
  59657. * Syncs the position and rotation of a mesh with the impostor
  59658. * @param mesh mesh to sync
  59659. * @param impostor impostor to update the mesh with
  59660. */
  59661. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59662. /**
  59663. * Gets the radius of the impostor
  59664. * @param impostor impostor to get radius from
  59665. * @returns the radius
  59666. */
  59667. getRadius(impostor: PhysicsImpostor): number;
  59668. /**
  59669. * Gets the box size of the impostor
  59670. * @param impostor impostor to get box size from
  59671. * @param result the resulting box size
  59672. */
  59673. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59674. /**
  59675. * Disposes of the impostor
  59676. */
  59677. dispose(): void;
  59678. /**
  59679. * Does a raycast in the physics world
  59680. * @param from when should the ray start?
  59681. * @param to when should the ray end?
  59682. * @returns PhysicsRaycastResult
  59683. */
  59684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59685. }
  59686. }
  59687. declare module BABYLON {
  59688. interface AbstractScene {
  59689. /**
  59690. * The list of reflection probes added to the scene
  59691. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59692. */
  59693. reflectionProbes: Array<ReflectionProbe>;
  59694. /**
  59695. * Removes the given reflection probe from this scene.
  59696. * @param toRemove The reflection probe to remove
  59697. * @returns The index of the removed reflection probe
  59698. */
  59699. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59700. /**
  59701. * Adds the given reflection probe to this scene.
  59702. * @param newReflectionProbe The reflection probe to add
  59703. */
  59704. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59705. }
  59706. /**
  59707. * Class used to generate realtime reflection / refraction cube textures
  59708. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59709. */
  59710. export class ReflectionProbe {
  59711. /** defines the name of the probe */
  59712. name: string;
  59713. private _scene;
  59714. private _renderTargetTexture;
  59715. private _projectionMatrix;
  59716. private _viewMatrix;
  59717. private _target;
  59718. private _add;
  59719. private _attachedMesh;
  59720. private _invertYAxis;
  59721. /** Gets or sets probe position (center of the cube map) */
  59722. position: Vector3;
  59723. /**
  59724. * Creates a new reflection probe
  59725. * @param name defines the name of the probe
  59726. * @param size defines the texture resolution (for each face)
  59727. * @param scene defines the hosting scene
  59728. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59729. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59730. */
  59731. constructor(
  59732. /** defines the name of the probe */
  59733. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59734. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59735. get samples(): number;
  59736. set samples(value: number);
  59737. /** Gets or sets the refresh rate to use (on every frame by default) */
  59738. get refreshRate(): number;
  59739. set refreshRate(value: number);
  59740. /**
  59741. * Gets the hosting scene
  59742. * @returns a Scene
  59743. */
  59744. getScene(): Scene;
  59745. /** Gets the internal CubeTexture used to render to */
  59746. get cubeTexture(): RenderTargetTexture;
  59747. /** Gets the list of meshes to render */
  59748. get renderList(): Nullable<AbstractMesh[]>;
  59749. /**
  59750. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59751. * @param mesh defines the mesh to attach to
  59752. */
  59753. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59754. /**
  59755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59756. * @param renderingGroupId The rendering group id corresponding to its index
  59757. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59758. */
  59759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59760. /**
  59761. * Clean all associated resources
  59762. */
  59763. dispose(): void;
  59764. /**
  59765. * Converts the reflection probe information to a readable string for debug purpose.
  59766. * @param fullDetails Supports for multiple levels of logging within scene loading
  59767. * @returns the human readable reflection probe info
  59768. */
  59769. toString(fullDetails?: boolean): string;
  59770. /**
  59771. * Get the class name of the relfection probe.
  59772. * @returns "ReflectionProbe"
  59773. */
  59774. getClassName(): string;
  59775. /**
  59776. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59777. * @returns The JSON representation of the texture
  59778. */
  59779. serialize(): any;
  59780. /**
  59781. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59782. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59783. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59784. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59785. * @returns The parsed reflection probe if successful
  59786. */
  59787. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59788. }
  59789. }
  59790. declare module BABYLON {
  59791. /** @hidden */
  59792. export var _BabylonLoaderRegistered: boolean;
  59793. /**
  59794. * Helps setting up some configuration for the babylon file loader.
  59795. */
  59796. export class BabylonFileLoaderConfiguration {
  59797. /**
  59798. * The loader does not allow injecting custom physix engine into the plugins.
  59799. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59800. * So you could set this variable to your engine import to make it work.
  59801. */
  59802. static LoaderInjectedPhysicsEngine: any;
  59803. }
  59804. }
  59805. declare module BABYLON {
  59806. /**
  59807. * The Physically based simple base material of BJS.
  59808. *
  59809. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59810. * It is used as the base class for both the specGloss and metalRough conventions.
  59811. */
  59812. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59813. /**
  59814. * Number of Simultaneous lights allowed on the material.
  59815. */
  59816. maxSimultaneousLights: number;
  59817. /**
  59818. * If sets to true, disables all the lights affecting the material.
  59819. */
  59820. disableLighting: boolean;
  59821. /**
  59822. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59823. */
  59824. environmentTexture: BaseTexture;
  59825. /**
  59826. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59827. */
  59828. invertNormalMapX: boolean;
  59829. /**
  59830. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59831. */
  59832. invertNormalMapY: boolean;
  59833. /**
  59834. * Normal map used in the model.
  59835. */
  59836. normalTexture: BaseTexture;
  59837. /**
  59838. * Emissivie color used to self-illuminate the model.
  59839. */
  59840. emissiveColor: Color3;
  59841. /**
  59842. * Emissivie texture used to self-illuminate the model.
  59843. */
  59844. emissiveTexture: BaseTexture;
  59845. /**
  59846. * Occlusion Channel Strenght.
  59847. */
  59848. occlusionStrength: number;
  59849. /**
  59850. * Occlusion Texture of the material (adding extra occlusion effects).
  59851. */
  59852. occlusionTexture: BaseTexture;
  59853. /**
  59854. * Defines the alpha limits in alpha test mode.
  59855. */
  59856. alphaCutOff: number;
  59857. /**
  59858. * Gets the current double sided mode.
  59859. */
  59860. get doubleSided(): boolean;
  59861. /**
  59862. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59863. */
  59864. set doubleSided(value: boolean);
  59865. /**
  59866. * Stores the pre-calculated light information of a mesh in a texture.
  59867. */
  59868. lightmapTexture: BaseTexture;
  59869. /**
  59870. * If true, the light map contains occlusion information instead of lighting info.
  59871. */
  59872. useLightmapAsShadowmap: boolean;
  59873. /**
  59874. * Instantiates a new PBRMaterial instance.
  59875. *
  59876. * @param name The material name
  59877. * @param scene The scene the material will be use in.
  59878. */
  59879. constructor(name: string, scene: Scene);
  59880. getClassName(): string;
  59881. }
  59882. }
  59883. declare module BABYLON {
  59884. /**
  59885. * The PBR material of BJS following the metal roughness convention.
  59886. *
  59887. * This fits to the PBR convention in the GLTF definition:
  59888. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59889. */
  59890. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59891. /**
  59892. * The base color has two different interpretations depending on the value of metalness.
  59893. * When the material is a metal, the base color is the specific measured reflectance value
  59894. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59895. * of the material.
  59896. */
  59897. baseColor: Color3;
  59898. /**
  59899. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59900. * well as opacity information in the alpha channel.
  59901. */
  59902. baseTexture: BaseTexture;
  59903. /**
  59904. * Specifies the metallic scalar value of the material.
  59905. * Can also be used to scale the metalness values of the metallic texture.
  59906. */
  59907. metallic: number;
  59908. /**
  59909. * Specifies the roughness scalar value of the material.
  59910. * Can also be used to scale the roughness values of the metallic texture.
  59911. */
  59912. roughness: number;
  59913. /**
  59914. * Texture containing both the metallic value in the B channel and the
  59915. * roughness value in the G channel to keep better precision.
  59916. */
  59917. metallicRoughnessTexture: BaseTexture;
  59918. /**
  59919. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59920. *
  59921. * @param name The material name
  59922. * @param scene The scene the material will be use in.
  59923. */
  59924. constructor(name: string, scene: Scene);
  59925. /**
  59926. * Return the currrent class name of the material.
  59927. */
  59928. getClassName(): string;
  59929. /**
  59930. * Makes a duplicate of the current material.
  59931. * @param name - name to use for the new material.
  59932. */
  59933. clone(name: string): PBRMetallicRoughnessMaterial;
  59934. /**
  59935. * Serialize the material to a parsable JSON object.
  59936. */
  59937. serialize(): any;
  59938. /**
  59939. * Parses a JSON object correponding to the serialize function.
  59940. */
  59941. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59942. }
  59943. }
  59944. declare module BABYLON {
  59945. /**
  59946. * The PBR material of BJS following the specular glossiness convention.
  59947. *
  59948. * This fits to the PBR convention in the GLTF definition:
  59949. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59950. */
  59951. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59952. /**
  59953. * Specifies the diffuse color of the material.
  59954. */
  59955. diffuseColor: Color3;
  59956. /**
  59957. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59958. * channel.
  59959. */
  59960. diffuseTexture: BaseTexture;
  59961. /**
  59962. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59963. */
  59964. specularColor: Color3;
  59965. /**
  59966. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59967. */
  59968. glossiness: number;
  59969. /**
  59970. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59971. */
  59972. specularGlossinessTexture: BaseTexture;
  59973. /**
  59974. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59975. *
  59976. * @param name The material name
  59977. * @param scene The scene the material will be use in.
  59978. */
  59979. constructor(name: string, scene: Scene);
  59980. /**
  59981. * Return the currrent class name of the material.
  59982. */
  59983. getClassName(): string;
  59984. /**
  59985. * Makes a duplicate of the current material.
  59986. * @param name - name to use for the new material.
  59987. */
  59988. clone(name: string): PBRSpecularGlossinessMaterial;
  59989. /**
  59990. * Serialize the material to a parsable JSON object.
  59991. */
  59992. serialize(): any;
  59993. /**
  59994. * Parses a JSON object correponding to the serialize function.
  59995. */
  59996. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59997. }
  59998. }
  59999. declare module BABYLON {
  60000. /**
  60001. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60002. * It can help converting any input color in a desired output one. This can then be used to create effects
  60003. * from sepia, black and white to sixties or futuristic rendering...
  60004. *
  60005. * The only supported format is currently 3dl.
  60006. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60007. */
  60008. export class ColorGradingTexture extends BaseTexture {
  60009. /**
  60010. * The texture URL.
  60011. */
  60012. url: string;
  60013. /**
  60014. * Empty line regex stored for GC.
  60015. */
  60016. private static _noneEmptyLineRegex;
  60017. private _textureMatrix;
  60018. private _onLoad;
  60019. /**
  60020. * Instantiates a ColorGradingTexture from the following parameters.
  60021. *
  60022. * @param url The location of the color gradind data (currently only supporting 3dl)
  60023. * @param sceneOrEngine The scene or engine the texture will be used in
  60024. * @param onLoad defines a callback triggered when the texture has been loaded
  60025. */
  60026. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60027. /**
  60028. * Fires the onload event from the constructor if requested.
  60029. */
  60030. private _triggerOnLoad;
  60031. /**
  60032. * Returns the texture matrix used in most of the material.
  60033. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60034. */
  60035. getTextureMatrix(): Matrix;
  60036. /**
  60037. * Occurs when the file being loaded is a .3dl LUT file.
  60038. */
  60039. private load3dlTexture;
  60040. /**
  60041. * Starts the loading process of the texture.
  60042. */
  60043. private loadTexture;
  60044. /**
  60045. * Clones the color gradind texture.
  60046. */
  60047. clone(): ColorGradingTexture;
  60048. /**
  60049. * Called during delayed load for textures.
  60050. */
  60051. delayLoad(): void;
  60052. /**
  60053. * Parses a color grading texture serialized by Babylon.
  60054. * @param parsedTexture The texture information being parsedTexture
  60055. * @param scene The scene to load the texture in
  60056. * @param rootUrl The root url of the data assets to load
  60057. * @return A color gradind texture
  60058. */
  60059. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60060. /**
  60061. * Serializes the LUT texture to json format.
  60062. */
  60063. serialize(): any;
  60064. }
  60065. }
  60066. declare module BABYLON {
  60067. /**
  60068. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60069. */
  60070. export class EquiRectangularCubeTexture extends BaseTexture {
  60071. /** The six faces of the cube. */
  60072. private static _FacesMapping;
  60073. private _noMipmap;
  60074. private _onLoad;
  60075. private _onError;
  60076. /** The size of the cubemap. */
  60077. private _size;
  60078. /** The buffer of the image. */
  60079. private _buffer;
  60080. /** The width of the input image. */
  60081. private _width;
  60082. /** The height of the input image. */
  60083. private _height;
  60084. /** The URL to the image. */
  60085. url: string;
  60086. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60087. coordinatesMode: number;
  60088. /**
  60089. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60090. * @param url The location of the image
  60091. * @param scene The scene the texture will be used in
  60092. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60093. * @param noMipmap Forces to not generate the mipmap if true
  60094. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60095. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60096. * @param onLoad — defines a callback called when texture is loaded
  60097. * @param onError — defines a callback called if there is an error
  60098. */
  60099. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60100. /**
  60101. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60102. */
  60103. private loadImage;
  60104. /**
  60105. * Convert the image buffer into a cubemap and create a CubeTexture.
  60106. */
  60107. private loadTexture;
  60108. /**
  60109. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60110. * @param buffer The ArrayBuffer that should be converted.
  60111. * @returns The buffer as Float32Array.
  60112. */
  60113. private getFloat32ArrayFromArrayBuffer;
  60114. /**
  60115. * Get the current class name of the texture useful for serialization or dynamic coding.
  60116. * @returns "EquiRectangularCubeTexture"
  60117. */
  60118. getClassName(): string;
  60119. /**
  60120. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60121. * @returns A clone of the current EquiRectangularCubeTexture.
  60122. */
  60123. clone(): EquiRectangularCubeTexture;
  60124. }
  60125. }
  60126. declare module BABYLON {
  60127. /**
  60128. * Defines the options related to the creation of an HtmlElementTexture
  60129. */
  60130. export interface IHtmlElementTextureOptions {
  60131. /**
  60132. * Defines wether mip maps should be created or not.
  60133. */
  60134. generateMipMaps?: boolean;
  60135. /**
  60136. * Defines the sampling mode of the texture.
  60137. */
  60138. samplingMode?: number;
  60139. /**
  60140. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60141. */
  60142. engine: Nullable<ThinEngine>;
  60143. /**
  60144. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60145. */
  60146. scene: Nullable<Scene>;
  60147. }
  60148. /**
  60149. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60150. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60151. * is automatically managed.
  60152. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60153. * in your application.
  60154. *
  60155. * As the update is not automatic, you need to call them manually.
  60156. */
  60157. export class HtmlElementTexture extends BaseTexture {
  60158. /**
  60159. * The texture URL.
  60160. */
  60161. element: HTMLVideoElement | HTMLCanvasElement;
  60162. private static readonly DefaultOptions;
  60163. private _textureMatrix;
  60164. private _isVideo;
  60165. private _generateMipMaps;
  60166. private _samplingMode;
  60167. /**
  60168. * Instantiates a HtmlElementTexture from the following parameters.
  60169. *
  60170. * @param name Defines the name of the texture
  60171. * @param element Defines the video or canvas the texture is filled with
  60172. * @param options Defines the other none mandatory texture creation options
  60173. */
  60174. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60175. private _createInternalTexture;
  60176. /**
  60177. * Returns the texture matrix used in most of the material.
  60178. */
  60179. getTextureMatrix(): Matrix;
  60180. /**
  60181. * Updates the content of the texture.
  60182. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60183. */
  60184. update(invertY?: Nullable<boolean>): void;
  60185. }
  60186. }
  60187. declare module BABYLON {
  60188. /**
  60189. * Based on jsTGALoader - Javascript loader for TGA file
  60190. * By Vincent Thibault
  60191. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60192. */
  60193. export class TGATools {
  60194. private static _TYPE_INDEXED;
  60195. private static _TYPE_RGB;
  60196. private static _TYPE_GREY;
  60197. private static _TYPE_RLE_INDEXED;
  60198. private static _TYPE_RLE_RGB;
  60199. private static _TYPE_RLE_GREY;
  60200. private static _ORIGIN_MASK;
  60201. private static _ORIGIN_SHIFT;
  60202. private static _ORIGIN_BL;
  60203. private static _ORIGIN_BR;
  60204. private static _ORIGIN_UL;
  60205. private static _ORIGIN_UR;
  60206. /**
  60207. * Gets the header of a TGA file
  60208. * @param data defines the TGA data
  60209. * @returns the header
  60210. */
  60211. static GetTGAHeader(data: Uint8Array): any;
  60212. /**
  60213. * Uploads TGA content to a Babylon Texture
  60214. * @hidden
  60215. */
  60216. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60217. /** @hidden */
  60218. 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;
  60219. /** @hidden */
  60220. 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;
  60221. /** @hidden */
  60222. 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;
  60223. /** @hidden */
  60224. 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;
  60225. /** @hidden */
  60226. 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;
  60227. /** @hidden */
  60228. 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;
  60229. }
  60230. }
  60231. declare module BABYLON {
  60232. /**
  60233. * Implementation of the TGA Texture Loader.
  60234. * @hidden
  60235. */
  60236. export class _TGATextureLoader implements IInternalTextureLoader {
  60237. /**
  60238. * Defines wether the loader supports cascade loading the different faces.
  60239. */
  60240. readonly supportCascades: boolean;
  60241. /**
  60242. * This returns if the loader support the current file information.
  60243. * @param extension defines the file extension of the file being loaded
  60244. * @returns true if the loader can load the specified file
  60245. */
  60246. canLoad(extension: string): boolean;
  60247. /**
  60248. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60249. * @param data contains the texture data
  60250. * @param texture defines the BabylonJS internal texture
  60251. * @param createPolynomials will be true if polynomials have been requested
  60252. * @param onLoad defines the callback to trigger once the texture is ready
  60253. * @param onError defines the callback to trigger in case of error
  60254. */
  60255. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60256. /**
  60257. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60258. * @param data contains the texture data
  60259. * @param texture defines the BabylonJS internal texture
  60260. * @param callback defines the method to call once ready to upload
  60261. */
  60262. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60263. }
  60264. }
  60265. declare module BABYLON {
  60266. /**
  60267. * Info about the .basis files
  60268. */
  60269. class BasisFileInfo {
  60270. /**
  60271. * If the file has alpha
  60272. */
  60273. hasAlpha: boolean;
  60274. /**
  60275. * Info about each image of the basis file
  60276. */
  60277. images: Array<{
  60278. levels: Array<{
  60279. width: number;
  60280. height: number;
  60281. transcodedPixels: ArrayBufferView;
  60282. }>;
  60283. }>;
  60284. }
  60285. /**
  60286. * Result of transcoding a basis file
  60287. */
  60288. class TranscodeResult {
  60289. /**
  60290. * Info about the .basis file
  60291. */
  60292. fileInfo: BasisFileInfo;
  60293. /**
  60294. * Format to use when loading the file
  60295. */
  60296. format: number;
  60297. }
  60298. /**
  60299. * Configuration options for the Basis transcoder
  60300. */
  60301. export class BasisTranscodeConfiguration {
  60302. /**
  60303. * Supported compression formats used to determine the supported output format of the transcoder
  60304. */
  60305. supportedCompressionFormats?: {
  60306. /**
  60307. * etc1 compression format
  60308. */
  60309. etc1?: boolean;
  60310. /**
  60311. * s3tc compression format
  60312. */
  60313. s3tc?: boolean;
  60314. /**
  60315. * pvrtc compression format
  60316. */
  60317. pvrtc?: boolean;
  60318. /**
  60319. * etc2 compression format
  60320. */
  60321. etc2?: boolean;
  60322. };
  60323. /**
  60324. * If mipmap levels should be loaded for transcoded images (Default: true)
  60325. */
  60326. loadMipmapLevels?: boolean;
  60327. /**
  60328. * Index of a single image to load (Default: all images)
  60329. */
  60330. loadSingleImage?: number;
  60331. }
  60332. /**
  60333. * Used to load .Basis files
  60334. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60335. */
  60336. export class BasisTools {
  60337. private static _IgnoreSupportedFormats;
  60338. /**
  60339. * URL to use when loading the basis transcoder
  60340. */
  60341. static JSModuleURL: string;
  60342. /**
  60343. * URL to use when loading the wasm module for the transcoder
  60344. */
  60345. static WasmModuleURL: string;
  60346. /**
  60347. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60348. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60349. * @returns internal format corresponding to the Basis format
  60350. */
  60351. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60352. private static _WorkerPromise;
  60353. private static _Worker;
  60354. private static _actionId;
  60355. private static _CreateWorkerAsync;
  60356. /**
  60357. * Transcodes a loaded image file to compressed pixel data
  60358. * @param data image data to transcode
  60359. * @param config configuration options for the transcoding
  60360. * @returns a promise resulting in the transcoded image
  60361. */
  60362. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60363. /**
  60364. * Loads a texture from the transcode result
  60365. * @param texture texture load to
  60366. * @param transcodeResult the result of transcoding the basis file to load from
  60367. */
  60368. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60369. }
  60370. }
  60371. declare module BABYLON {
  60372. /**
  60373. * Loader for .basis file format
  60374. */
  60375. export class _BasisTextureLoader implements IInternalTextureLoader {
  60376. /**
  60377. * Defines whether the loader supports cascade loading the different faces.
  60378. */
  60379. readonly supportCascades: boolean;
  60380. /**
  60381. * This returns if the loader support the current file information.
  60382. * @param extension defines the file extension of the file being loaded
  60383. * @returns true if the loader can load the specified file
  60384. */
  60385. canLoad(extension: string): boolean;
  60386. /**
  60387. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60388. * @param data contains the texture data
  60389. * @param texture defines the BabylonJS internal texture
  60390. * @param createPolynomials will be true if polynomials have been requested
  60391. * @param onLoad defines the callback to trigger once the texture is ready
  60392. * @param onError defines the callback to trigger in case of error
  60393. */
  60394. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60395. /**
  60396. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60397. * @param data contains the texture data
  60398. * @param texture defines the BabylonJS internal texture
  60399. * @param callback defines the method to call once ready to upload
  60400. */
  60401. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60402. }
  60403. }
  60404. declare module BABYLON {
  60405. /**
  60406. * Defines the basic options interface of a TexturePacker Frame
  60407. */
  60408. export interface ITexturePackerFrame {
  60409. /**
  60410. * The frame ID
  60411. */
  60412. id: number;
  60413. /**
  60414. * The frames Scale
  60415. */
  60416. scale: Vector2;
  60417. /**
  60418. * The Frames offset
  60419. */
  60420. offset: Vector2;
  60421. }
  60422. /**
  60423. * This is a support class for frame Data on texture packer sets.
  60424. */
  60425. export class TexturePackerFrame implements ITexturePackerFrame {
  60426. /**
  60427. * The frame ID
  60428. */
  60429. id: number;
  60430. /**
  60431. * The frames Scale
  60432. */
  60433. scale: Vector2;
  60434. /**
  60435. * The Frames offset
  60436. */
  60437. offset: Vector2;
  60438. /**
  60439. * Initializes a texture package frame.
  60440. * @param id The numerical frame identifier
  60441. * @param scale Scalar Vector2 for UV frame
  60442. * @param offset Vector2 for the frame position in UV units.
  60443. * @returns TexturePackerFrame
  60444. */
  60445. constructor(id: number, scale: Vector2, offset: Vector2);
  60446. }
  60447. }
  60448. declare module BABYLON {
  60449. /**
  60450. * Defines the basic options interface of a TexturePacker
  60451. */
  60452. export interface ITexturePackerOptions {
  60453. /**
  60454. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60455. */
  60456. map?: string[];
  60457. /**
  60458. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60459. */
  60460. uvsIn?: string;
  60461. /**
  60462. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60463. */
  60464. uvsOut?: string;
  60465. /**
  60466. * number representing the layout style. Defaults to LAYOUT_STRIP
  60467. */
  60468. layout?: number;
  60469. /**
  60470. * number of columns if using custom column count layout(2). This defaults to 4.
  60471. */
  60472. colnum?: number;
  60473. /**
  60474. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60475. */
  60476. updateInputMeshes?: boolean;
  60477. /**
  60478. * boolean flag to dispose all the source textures. Defaults to true.
  60479. */
  60480. disposeSources?: boolean;
  60481. /**
  60482. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60483. */
  60484. fillBlanks?: boolean;
  60485. /**
  60486. * string value representing the context fill style color. Defaults to 'black'.
  60487. */
  60488. customFillColor?: string;
  60489. /**
  60490. * Width and Height Value of each Frame in the TexturePacker Sets
  60491. */
  60492. frameSize?: number;
  60493. /**
  60494. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60495. */
  60496. paddingRatio?: number;
  60497. /**
  60498. * Number that declares the fill method for the padding gutter.
  60499. */
  60500. paddingMode?: number;
  60501. /**
  60502. * If in SUBUV_COLOR padding mode what color to use.
  60503. */
  60504. paddingColor?: Color3 | Color4;
  60505. }
  60506. /**
  60507. * Defines the basic interface of a TexturePacker JSON File
  60508. */
  60509. export interface ITexturePackerJSON {
  60510. /**
  60511. * The frame ID
  60512. */
  60513. name: string;
  60514. /**
  60515. * The base64 channel data
  60516. */
  60517. sets: any;
  60518. /**
  60519. * The options of the Packer
  60520. */
  60521. options: ITexturePackerOptions;
  60522. /**
  60523. * The frame data of the Packer
  60524. */
  60525. frames: Array<number>;
  60526. }
  60527. /**
  60528. * This is a support class that generates a series of packed texture sets.
  60529. * @see https://doc.babylonjs.com/babylon101/materials
  60530. */
  60531. export class TexturePacker {
  60532. /** Packer Layout Constant 0 */
  60533. static readonly LAYOUT_STRIP: number;
  60534. /** Packer Layout Constant 1 */
  60535. static readonly LAYOUT_POWER2: number;
  60536. /** Packer Layout Constant 2 */
  60537. static readonly LAYOUT_COLNUM: number;
  60538. /** Packer Layout Constant 0 */
  60539. static readonly SUBUV_WRAP: number;
  60540. /** Packer Layout Constant 1 */
  60541. static readonly SUBUV_EXTEND: number;
  60542. /** Packer Layout Constant 2 */
  60543. static readonly SUBUV_COLOR: number;
  60544. /** The Name of the Texture Package */
  60545. name: string;
  60546. /** The scene scope of the TexturePacker */
  60547. scene: Scene;
  60548. /** The Meshes to target */
  60549. meshes: AbstractMesh[];
  60550. /** Arguments passed with the Constructor */
  60551. options: ITexturePackerOptions;
  60552. /** The promise that is started upon initialization */
  60553. promise: Nullable<Promise<TexturePacker | string>>;
  60554. /** The Container object for the channel sets that are generated */
  60555. sets: object;
  60556. /** The Container array for the frames that are generated */
  60557. frames: TexturePackerFrame[];
  60558. /** The expected number of textures the system is parsing. */
  60559. private _expecting;
  60560. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60561. private _paddingValue;
  60562. /**
  60563. * Initializes a texture package series from an array of meshes or a single mesh.
  60564. * @param name The name of the package
  60565. * @param meshes The target meshes to compose the package from
  60566. * @param options The arguments that texture packer should follow while building.
  60567. * @param scene The scene which the textures are scoped to.
  60568. * @returns TexturePacker
  60569. */
  60570. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60571. /**
  60572. * Starts the package process
  60573. * @param resolve The promises resolution function
  60574. * @returns TexturePacker
  60575. */
  60576. private _createFrames;
  60577. /**
  60578. * Calculates the Size of the Channel Sets
  60579. * @returns Vector2
  60580. */
  60581. private _calculateSize;
  60582. /**
  60583. * Calculates the UV data for the frames.
  60584. * @param baseSize the base frameSize
  60585. * @param padding the base frame padding
  60586. * @param dtSize size of the Dynamic Texture for that channel
  60587. * @param dtUnits is 1/dtSize
  60588. * @param update flag to update the input meshes
  60589. */
  60590. private _calculateMeshUVFrames;
  60591. /**
  60592. * Calculates the frames Offset.
  60593. * @param index of the frame
  60594. * @returns Vector2
  60595. */
  60596. private _getFrameOffset;
  60597. /**
  60598. * Updates a Mesh to the frame data
  60599. * @param mesh that is the target
  60600. * @param frameID or the frame index
  60601. */
  60602. private _updateMeshUV;
  60603. /**
  60604. * Updates a Meshes materials to use the texture packer channels
  60605. * @param m is the mesh to target
  60606. * @param force all channels on the packer to be set.
  60607. */
  60608. private _updateTextureReferences;
  60609. /**
  60610. * Public method to set a Mesh to a frame
  60611. * @param m that is the target
  60612. * @param frameID or the frame index
  60613. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60614. */
  60615. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60616. /**
  60617. * Starts the async promise to compile the texture packer.
  60618. * @returns Promise<void>
  60619. */
  60620. processAsync(): Promise<void>;
  60621. /**
  60622. * Disposes all textures associated with this packer
  60623. */
  60624. dispose(): void;
  60625. /**
  60626. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60627. * @param imageType is the image type to use.
  60628. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60629. */
  60630. download(imageType?: string, quality?: number): void;
  60631. /**
  60632. * Public method to load a texturePacker JSON file.
  60633. * @param data of the JSON file in string format.
  60634. */
  60635. updateFromJSON(data: string): void;
  60636. }
  60637. }
  60638. declare module BABYLON {
  60639. /**
  60640. * 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.
  60641. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60642. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60643. */
  60644. export class CustomProceduralTexture extends ProceduralTexture {
  60645. private _animate;
  60646. private _time;
  60647. private _config;
  60648. private _texturePath;
  60649. /**
  60650. * Instantiates a new Custom Procedural Texture.
  60651. * 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.
  60652. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60653. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60654. * @param name Define the name of the texture
  60655. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60656. * @param size Define the size of the texture to create
  60657. * @param scene Define the scene the texture belongs to
  60658. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60659. * @param generateMipMaps Define if the texture should creates mip maps or not
  60660. */
  60661. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60662. private _loadJson;
  60663. /**
  60664. * Is the texture ready to be used ? (rendered at least once)
  60665. * @returns true if ready, otherwise, false.
  60666. */
  60667. isReady(): boolean;
  60668. /**
  60669. * Render the texture to its associated render target.
  60670. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60671. */
  60672. render(useCameraPostProcess?: boolean): void;
  60673. /**
  60674. * Update the list of dependant textures samplers in the shader.
  60675. */
  60676. updateTextures(): void;
  60677. /**
  60678. * Update the uniform values of the procedural texture in the shader.
  60679. */
  60680. updateShaderUniforms(): void;
  60681. /**
  60682. * Define if the texture animates or not.
  60683. */
  60684. get animate(): boolean;
  60685. set animate(value: boolean);
  60686. }
  60687. }
  60688. declare module BABYLON {
  60689. /** @hidden */
  60690. export var noisePixelShader: {
  60691. name: string;
  60692. shader: string;
  60693. };
  60694. }
  60695. declare module BABYLON {
  60696. /**
  60697. * Class used to generate noise procedural textures
  60698. */
  60699. export class NoiseProceduralTexture extends ProceduralTexture {
  60700. private _time;
  60701. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60702. brightness: number;
  60703. /** Defines the number of octaves to process */
  60704. octaves: number;
  60705. /** Defines the level of persistence (0.8 by default) */
  60706. persistence: number;
  60707. /** Gets or sets animation speed factor (default is 1) */
  60708. animationSpeedFactor: number;
  60709. /**
  60710. * Creates a new NoiseProceduralTexture
  60711. * @param name defines the name fo the texture
  60712. * @param size defines the size of the texture (default is 256)
  60713. * @param scene defines the hosting scene
  60714. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60715. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60716. */
  60717. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60718. private _updateShaderUniforms;
  60719. protected _getDefines(): string;
  60720. /** Generate the current state of the procedural texture */
  60721. render(useCameraPostProcess?: boolean): void;
  60722. /**
  60723. * Serializes this noise procedural texture
  60724. * @returns a serialized noise procedural texture object
  60725. */
  60726. serialize(): any;
  60727. /**
  60728. * Clone the texture.
  60729. * @returns the cloned texture
  60730. */
  60731. clone(): NoiseProceduralTexture;
  60732. /**
  60733. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60734. * @param parsedTexture defines parsed texture data
  60735. * @param scene defines the current scene
  60736. * @param rootUrl defines the root URL containing noise procedural texture information
  60737. * @returns a parsed NoiseProceduralTexture
  60738. */
  60739. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60740. }
  60741. }
  60742. declare module BABYLON {
  60743. /**
  60744. * Raw cube texture where the raw buffers are passed in
  60745. */
  60746. export class RawCubeTexture extends CubeTexture {
  60747. /**
  60748. * Creates a cube texture where the raw buffers are passed in.
  60749. * @param scene defines the scene the texture is attached to
  60750. * @param data defines the array of data to use to create each face
  60751. * @param size defines the size of the textures
  60752. * @param format defines the format of the data
  60753. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60754. * @param generateMipMaps defines if the engine should generate the mip levels
  60755. * @param invertY defines if data must be stored with Y axis inverted
  60756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60757. * @param compression defines the compression used (null by default)
  60758. */
  60759. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60760. /**
  60761. * Updates the raw cube texture.
  60762. * @param data defines the data to store
  60763. * @param format defines the data format
  60764. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60765. * @param invertY defines if data must be stored with Y axis inverted
  60766. * @param compression defines the compression used (null by default)
  60767. * @param level defines which level of the texture to update
  60768. */
  60769. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60770. /**
  60771. * Updates a raw cube texture with RGBD encoded data.
  60772. * @param data defines the array of data [mipmap][face] to use to create each face
  60773. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60774. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60775. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60776. * @returns a promsie that resolves when the operation is complete
  60777. */
  60778. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60779. /**
  60780. * Clones the raw cube texture.
  60781. * @return a new cube texture
  60782. */
  60783. clone(): CubeTexture;
  60784. /** @hidden */
  60785. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60786. }
  60787. }
  60788. declare module BABYLON {
  60789. /**
  60790. * Class used to store 2D array textures containing user data
  60791. */
  60792. export class RawTexture2DArray extends Texture {
  60793. /** Gets or sets the texture format to use */
  60794. format: number;
  60795. /**
  60796. * Create a new RawTexture2DArray
  60797. * @param data defines the data of the texture
  60798. * @param width defines the width of the texture
  60799. * @param height defines the height of the texture
  60800. * @param depth defines the number of layers of the texture
  60801. * @param format defines the texture format to use
  60802. * @param scene defines the hosting scene
  60803. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60804. * @param invertY defines if texture must be stored with Y axis inverted
  60805. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60806. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60807. */
  60808. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60809. /** Gets or sets the texture format to use */
  60810. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60811. /**
  60812. * Update the texture with new data
  60813. * @param data defines the data to store in the texture
  60814. */
  60815. update(data: ArrayBufferView): void;
  60816. }
  60817. }
  60818. declare module BABYLON {
  60819. /**
  60820. * Class used to store 3D textures containing user data
  60821. */
  60822. export class RawTexture3D extends Texture {
  60823. /** Gets or sets the texture format to use */
  60824. format: number;
  60825. /**
  60826. * Create a new RawTexture3D
  60827. * @param data defines the data of the texture
  60828. * @param width defines the width of the texture
  60829. * @param height defines the height of the texture
  60830. * @param depth defines the depth of the texture
  60831. * @param format defines the texture format to use
  60832. * @param scene defines the hosting scene
  60833. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60834. * @param invertY defines if texture must be stored with Y axis inverted
  60835. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60836. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60837. */
  60838. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60839. /** Gets or sets the texture format to use */
  60840. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60841. /**
  60842. * Update the texture with new data
  60843. * @param data defines the data to store in the texture
  60844. */
  60845. update(data: ArrayBufferView): void;
  60846. }
  60847. }
  60848. declare module BABYLON {
  60849. /**
  60850. * Creates a refraction texture used by refraction channel of the standard material.
  60851. * It is like a mirror but to see through a material.
  60852. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60853. */
  60854. export class RefractionTexture extends RenderTargetTexture {
  60855. /**
  60856. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60857. * 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.
  60858. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60859. */
  60860. refractionPlane: Plane;
  60861. /**
  60862. * Define how deep under the surface we should see.
  60863. */
  60864. depth: number;
  60865. /**
  60866. * Creates a refraction texture used by refraction channel of the standard material.
  60867. * It is like a mirror but to see through a material.
  60868. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60869. * @param name Define the texture name
  60870. * @param size Define the size of the underlying texture
  60871. * @param scene Define the scene the refraction belongs to
  60872. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60873. */
  60874. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60875. /**
  60876. * Clone the refraction texture.
  60877. * @returns the cloned texture
  60878. */
  60879. clone(): RefractionTexture;
  60880. /**
  60881. * Serialize the texture to a JSON representation you could use in Parse later on
  60882. * @returns the serialized JSON representation
  60883. */
  60884. serialize(): any;
  60885. }
  60886. }
  60887. declare module BABYLON {
  60888. /**
  60889. * Block used to add support for vertex skinning (bones)
  60890. */
  60891. export class BonesBlock extends NodeMaterialBlock {
  60892. /**
  60893. * Creates a new BonesBlock
  60894. * @param name defines the block name
  60895. */
  60896. constructor(name: string);
  60897. /**
  60898. * Initialize the block and prepare the context for build
  60899. * @param state defines the state that will be used for the build
  60900. */
  60901. initialize(state: NodeMaterialBuildState): void;
  60902. /**
  60903. * Gets the current class name
  60904. * @returns the class name
  60905. */
  60906. getClassName(): string;
  60907. /**
  60908. * Gets the matrix indices input component
  60909. */
  60910. get matricesIndices(): NodeMaterialConnectionPoint;
  60911. /**
  60912. * Gets the matrix weights input component
  60913. */
  60914. get matricesWeights(): NodeMaterialConnectionPoint;
  60915. /**
  60916. * Gets the extra matrix indices input component
  60917. */
  60918. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60919. /**
  60920. * Gets the extra matrix weights input component
  60921. */
  60922. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60923. /**
  60924. * Gets the world input component
  60925. */
  60926. get world(): NodeMaterialConnectionPoint;
  60927. /**
  60928. * Gets the output component
  60929. */
  60930. get output(): NodeMaterialConnectionPoint;
  60931. autoConfigure(material: NodeMaterial): void;
  60932. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60935. protected _buildBlock(state: NodeMaterialBuildState): this;
  60936. }
  60937. }
  60938. declare module BABYLON {
  60939. /**
  60940. * Block used to add support for instances
  60941. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60942. */
  60943. export class InstancesBlock extends NodeMaterialBlock {
  60944. /**
  60945. * Creates a new InstancesBlock
  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 first world row input component
  60956. */
  60957. get world0(): NodeMaterialConnectionPoint;
  60958. /**
  60959. * Gets the second world row input component
  60960. */
  60961. get world1(): NodeMaterialConnectionPoint;
  60962. /**
  60963. * Gets the third world row input component
  60964. */
  60965. get world2(): NodeMaterialConnectionPoint;
  60966. /**
  60967. * Gets the forth world row input component
  60968. */
  60969. get world3(): NodeMaterialConnectionPoint;
  60970. /**
  60971. * Gets the world input component
  60972. */
  60973. get world(): NodeMaterialConnectionPoint;
  60974. /**
  60975. * Gets the output component
  60976. */
  60977. get output(): NodeMaterialConnectionPoint;
  60978. /**
  60979. * Gets the isntanceID component
  60980. */
  60981. get instanceID(): NodeMaterialConnectionPoint;
  60982. autoConfigure(material: NodeMaterial): void;
  60983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  60984. protected _buildBlock(state: NodeMaterialBuildState): this;
  60985. }
  60986. }
  60987. declare module BABYLON {
  60988. /**
  60989. * Block used to add morph targets support to vertex shader
  60990. */
  60991. export class MorphTargetsBlock extends NodeMaterialBlock {
  60992. private _repeatableContentAnchor;
  60993. /**
  60994. * Create a new MorphTargetsBlock
  60995. * @param name defines the block name
  60996. */
  60997. constructor(name: string);
  60998. /**
  60999. * Gets the current class name
  61000. * @returns the class name
  61001. */
  61002. getClassName(): string;
  61003. /**
  61004. * Gets the position input component
  61005. */
  61006. get position(): NodeMaterialConnectionPoint;
  61007. /**
  61008. * Gets the normal input component
  61009. */
  61010. get normal(): NodeMaterialConnectionPoint;
  61011. /**
  61012. * Gets the tangent input component
  61013. */
  61014. get tangent(): NodeMaterialConnectionPoint;
  61015. /**
  61016. * Gets the tangent input component
  61017. */
  61018. get uv(): NodeMaterialConnectionPoint;
  61019. /**
  61020. * Gets the position output component
  61021. */
  61022. get positionOutput(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the normal output component
  61025. */
  61026. get normalOutput(): NodeMaterialConnectionPoint;
  61027. /**
  61028. * Gets the tangent output component
  61029. */
  61030. get tangentOutput(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the tangent output component
  61033. */
  61034. get uvOutput(): NodeMaterialConnectionPoint;
  61035. initialize(state: NodeMaterialBuildState): void;
  61036. autoConfigure(material: NodeMaterial): void;
  61037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61038. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61039. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61040. protected _buildBlock(state: NodeMaterialBuildState): this;
  61041. }
  61042. }
  61043. declare module BABYLON {
  61044. /**
  61045. * Block used to get data information from a light
  61046. */
  61047. export class LightInformationBlock extends NodeMaterialBlock {
  61048. private _lightDataUniformName;
  61049. private _lightColorUniformName;
  61050. private _lightTypeDefineName;
  61051. /**
  61052. * Gets or sets the light associated with this block
  61053. */
  61054. light: Nullable<Light>;
  61055. /**
  61056. * Creates a new LightInformationBlock
  61057. * @param name defines the block name
  61058. */
  61059. constructor(name: string);
  61060. /**
  61061. * Gets the current class name
  61062. * @returns the class name
  61063. */
  61064. getClassName(): string;
  61065. /**
  61066. * Gets the world position input component
  61067. */
  61068. get worldPosition(): NodeMaterialConnectionPoint;
  61069. /**
  61070. * Gets the direction output component
  61071. */
  61072. get direction(): NodeMaterialConnectionPoint;
  61073. /**
  61074. * Gets the direction output component
  61075. */
  61076. get color(): NodeMaterialConnectionPoint;
  61077. /**
  61078. * Gets the direction output component
  61079. */
  61080. get intensity(): NodeMaterialConnectionPoint;
  61081. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61082. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61083. protected _buildBlock(state: NodeMaterialBuildState): this;
  61084. serialize(): any;
  61085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61086. }
  61087. }
  61088. declare module BABYLON {
  61089. /**
  61090. * Block used to add image processing support to fragment shader
  61091. */
  61092. export class ImageProcessingBlock extends NodeMaterialBlock {
  61093. /**
  61094. * Create a new ImageProcessingBlock
  61095. * @param name defines the block name
  61096. */
  61097. constructor(name: string);
  61098. /**
  61099. * Gets the current class name
  61100. * @returns the class name
  61101. */
  61102. getClassName(): string;
  61103. /**
  61104. * Gets the color input component
  61105. */
  61106. get color(): NodeMaterialConnectionPoint;
  61107. /**
  61108. * Gets the output component
  61109. */
  61110. get output(): NodeMaterialConnectionPoint;
  61111. /**
  61112. * Initialize the block and prepare the context for build
  61113. * @param state defines the state that will be used for the build
  61114. */
  61115. initialize(state: NodeMaterialBuildState): void;
  61116. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61119. protected _buildBlock(state: NodeMaterialBuildState): this;
  61120. }
  61121. }
  61122. declare module BABYLON {
  61123. /**
  61124. * Block used to pertub normals based on a normal map
  61125. */
  61126. export class PerturbNormalBlock extends NodeMaterialBlock {
  61127. private _tangentSpaceParameterName;
  61128. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61129. invertX: boolean;
  61130. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61131. invertY: boolean;
  61132. /**
  61133. * Create a new PerturbNormalBlock
  61134. * @param name defines the block name
  61135. */
  61136. constructor(name: string);
  61137. /**
  61138. * Gets the current class name
  61139. * @returns the class name
  61140. */
  61141. getClassName(): string;
  61142. /**
  61143. * Gets the world position input component
  61144. */
  61145. get worldPosition(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the world normal input component
  61148. */
  61149. get worldNormal(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Gets the world tangent input component
  61152. */
  61153. get worldTangent(): NodeMaterialConnectionPoint;
  61154. /**
  61155. * Gets the uv input component
  61156. */
  61157. get uv(): NodeMaterialConnectionPoint;
  61158. /**
  61159. * Gets the normal map color input component
  61160. */
  61161. get normalMapColor(): NodeMaterialConnectionPoint;
  61162. /**
  61163. * Gets the strength input component
  61164. */
  61165. get strength(): NodeMaterialConnectionPoint;
  61166. /**
  61167. * Gets the output component
  61168. */
  61169. get output(): NodeMaterialConnectionPoint;
  61170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61172. autoConfigure(material: NodeMaterial): void;
  61173. protected _buildBlock(state: NodeMaterialBuildState): this;
  61174. protected _dumpPropertiesCode(): string;
  61175. serialize(): any;
  61176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61177. }
  61178. }
  61179. declare module BABYLON {
  61180. /**
  61181. * Block used to discard a pixel if a value is smaller than a cutoff
  61182. */
  61183. export class DiscardBlock extends NodeMaterialBlock {
  61184. /**
  61185. * Create a new DiscardBlock
  61186. * @param name defines the block name
  61187. */
  61188. constructor(name: string);
  61189. /**
  61190. * Gets the current class name
  61191. * @returns the class name
  61192. */
  61193. getClassName(): string;
  61194. /**
  61195. * Gets the color input component
  61196. */
  61197. get value(): NodeMaterialConnectionPoint;
  61198. /**
  61199. * Gets the cutoff input component
  61200. */
  61201. get cutoff(): NodeMaterialConnectionPoint;
  61202. protected _buildBlock(state: NodeMaterialBuildState): this;
  61203. }
  61204. }
  61205. declare module BABYLON {
  61206. /**
  61207. * Block used to test if the fragment shader is front facing
  61208. */
  61209. export class FrontFacingBlock extends NodeMaterialBlock {
  61210. /**
  61211. * Creates a new FrontFacingBlock
  61212. * @param name defines the block name
  61213. */
  61214. constructor(name: string);
  61215. /**
  61216. * Gets the current class name
  61217. * @returns the class name
  61218. */
  61219. getClassName(): string;
  61220. /**
  61221. * Gets the output component
  61222. */
  61223. get output(): NodeMaterialConnectionPoint;
  61224. protected _buildBlock(state: NodeMaterialBuildState): this;
  61225. }
  61226. }
  61227. declare module BABYLON {
  61228. /**
  61229. * Block used to get the derivative value on x and y of a given input
  61230. */
  61231. export class DerivativeBlock extends NodeMaterialBlock {
  61232. /**
  61233. * Create a new DerivativeBlock
  61234. * @param name defines the block name
  61235. */
  61236. constructor(name: string);
  61237. /**
  61238. * Gets the current class name
  61239. * @returns the class name
  61240. */
  61241. getClassName(): string;
  61242. /**
  61243. * Gets the input component
  61244. */
  61245. get input(): NodeMaterialConnectionPoint;
  61246. /**
  61247. * Gets the derivative output on x
  61248. */
  61249. get dx(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the derivative output on y
  61252. */
  61253. get dy(): NodeMaterialConnectionPoint;
  61254. protected _buildBlock(state: NodeMaterialBuildState): this;
  61255. }
  61256. }
  61257. declare module BABYLON {
  61258. /**
  61259. * Block used to make gl_FragCoord available
  61260. */
  61261. export class FragCoordBlock extends NodeMaterialBlock {
  61262. /**
  61263. * Creates a new FragCoordBlock
  61264. * @param name defines the block name
  61265. */
  61266. constructor(name: string);
  61267. /**
  61268. * Gets the current class name
  61269. * @returns the class name
  61270. */
  61271. getClassName(): string;
  61272. /**
  61273. * Gets the xy component
  61274. */
  61275. get xy(): NodeMaterialConnectionPoint;
  61276. /**
  61277. * Gets the xyz component
  61278. */
  61279. get xyz(): NodeMaterialConnectionPoint;
  61280. /**
  61281. * Gets the xyzw component
  61282. */
  61283. get xyzw(): NodeMaterialConnectionPoint;
  61284. /**
  61285. * Gets the x component
  61286. */
  61287. get x(): NodeMaterialConnectionPoint;
  61288. /**
  61289. * Gets the y component
  61290. */
  61291. get y(): NodeMaterialConnectionPoint;
  61292. /**
  61293. * Gets the z component
  61294. */
  61295. get z(): NodeMaterialConnectionPoint;
  61296. /**
  61297. * Gets the w component
  61298. */
  61299. get output(): NodeMaterialConnectionPoint;
  61300. protected writeOutputs(state: NodeMaterialBuildState): string;
  61301. protected _buildBlock(state: NodeMaterialBuildState): this;
  61302. }
  61303. }
  61304. declare module BABYLON {
  61305. /**
  61306. * Block used to get the screen sizes
  61307. */
  61308. export class ScreenSizeBlock extends NodeMaterialBlock {
  61309. private _varName;
  61310. private _scene;
  61311. /**
  61312. * Creates a new ScreenSizeBlock
  61313. * @param name defines the block name
  61314. */
  61315. constructor(name: string);
  61316. /**
  61317. * Gets the current class name
  61318. * @returns the class name
  61319. */
  61320. getClassName(): string;
  61321. /**
  61322. * Gets the xy component
  61323. */
  61324. get xy(): NodeMaterialConnectionPoint;
  61325. /**
  61326. * Gets the x component
  61327. */
  61328. get x(): NodeMaterialConnectionPoint;
  61329. /**
  61330. * Gets the y component
  61331. */
  61332. get y(): NodeMaterialConnectionPoint;
  61333. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61334. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61335. protected _buildBlock(state: NodeMaterialBuildState): this;
  61336. }
  61337. }
  61338. declare module BABYLON {
  61339. /**
  61340. * Block used to add support for scene fog
  61341. */
  61342. export class FogBlock extends NodeMaterialBlock {
  61343. private _fogDistanceName;
  61344. private _fogParameters;
  61345. /**
  61346. * Create a new FogBlock
  61347. * @param name defines the block name
  61348. */
  61349. constructor(name: string);
  61350. /**
  61351. * Gets the current class name
  61352. * @returns the class name
  61353. */
  61354. getClassName(): string;
  61355. /**
  61356. * Gets the world position input component
  61357. */
  61358. get worldPosition(): NodeMaterialConnectionPoint;
  61359. /**
  61360. * Gets the view input component
  61361. */
  61362. get view(): NodeMaterialConnectionPoint;
  61363. /**
  61364. * Gets the color input component
  61365. */
  61366. get input(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the fog color input component
  61369. */
  61370. get fogColor(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the output component
  61373. */
  61374. get output(): NodeMaterialConnectionPoint;
  61375. autoConfigure(material: NodeMaterial): void;
  61376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61378. protected _buildBlock(state: NodeMaterialBuildState): this;
  61379. }
  61380. }
  61381. declare module BABYLON {
  61382. /**
  61383. * Block used to add light in the fragment shader
  61384. */
  61385. export class LightBlock extends NodeMaterialBlock {
  61386. private _lightId;
  61387. /**
  61388. * Gets or sets the light associated with this block
  61389. */
  61390. light: Nullable<Light>;
  61391. /**
  61392. * Create a new LightBlock
  61393. * @param name defines the block name
  61394. */
  61395. constructor(name: string);
  61396. /**
  61397. * Gets the current class name
  61398. * @returns the class name
  61399. */
  61400. getClassName(): string;
  61401. /**
  61402. * Gets the world position input component
  61403. */
  61404. get worldPosition(): NodeMaterialConnectionPoint;
  61405. /**
  61406. * Gets the world normal input component
  61407. */
  61408. get worldNormal(): NodeMaterialConnectionPoint;
  61409. /**
  61410. * Gets the camera (or eye) position component
  61411. */
  61412. get cameraPosition(): NodeMaterialConnectionPoint;
  61413. /**
  61414. * Gets the glossiness component
  61415. */
  61416. get glossiness(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the glossinness power component
  61419. */
  61420. get glossPower(): NodeMaterialConnectionPoint;
  61421. /**
  61422. * Gets the diffuse color component
  61423. */
  61424. get diffuseColor(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the specular color component
  61427. */
  61428. get specularColor(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the diffuse output component
  61431. */
  61432. get diffuseOutput(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the specular output component
  61435. */
  61436. get specularOutput(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the shadow output component
  61439. */
  61440. get shadow(): NodeMaterialConnectionPoint;
  61441. autoConfigure(material: NodeMaterial): void;
  61442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61443. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61444. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61445. private _injectVertexCode;
  61446. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61447. serialize(): any;
  61448. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61449. }
  61450. }
  61451. declare module BABYLON {
  61452. /**
  61453. * Block used to read a reflection texture from a sampler
  61454. */
  61455. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61456. /**
  61457. * Create a new ReflectionTextureBlock
  61458. * @param name defines the block name
  61459. */
  61460. constructor(name: string);
  61461. /**
  61462. * Gets the current class name
  61463. * @returns the class name
  61464. */
  61465. getClassName(): string;
  61466. /**
  61467. * Gets the world position input component
  61468. */
  61469. get position(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the world position input component
  61472. */
  61473. get worldPosition(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the world normal input component
  61476. */
  61477. get worldNormal(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the world input component
  61480. */
  61481. get world(): NodeMaterialConnectionPoint;
  61482. /**
  61483. * Gets the camera (or eye) position component
  61484. */
  61485. get cameraPosition(): NodeMaterialConnectionPoint;
  61486. /**
  61487. * Gets the view input component
  61488. */
  61489. get view(): NodeMaterialConnectionPoint;
  61490. /**
  61491. * Gets the rgb output component
  61492. */
  61493. get rgb(): NodeMaterialConnectionPoint;
  61494. /**
  61495. * Gets the r output component
  61496. */
  61497. get r(): NodeMaterialConnectionPoint;
  61498. /**
  61499. * Gets the g output component
  61500. */
  61501. get g(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the b output component
  61504. */
  61505. get b(): NodeMaterialConnectionPoint;
  61506. autoConfigure(material: NodeMaterial): void;
  61507. protected _buildBlock(state: NodeMaterialBuildState): this;
  61508. }
  61509. }
  61510. declare module BABYLON {
  61511. /**
  61512. * Block used to add 2 vectors
  61513. */
  61514. export class AddBlock extends NodeMaterialBlock {
  61515. /**
  61516. * Creates a new AddBlock
  61517. * @param name defines the block name
  61518. */
  61519. constructor(name: string);
  61520. /**
  61521. * Gets the current class name
  61522. * @returns the class name
  61523. */
  61524. getClassName(): string;
  61525. /**
  61526. * Gets the left operand input component
  61527. */
  61528. get left(): NodeMaterialConnectionPoint;
  61529. /**
  61530. * Gets the right operand input component
  61531. */
  61532. get right(): NodeMaterialConnectionPoint;
  61533. /**
  61534. * Gets the output component
  61535. */
  61536. get output(): NodeMaterialConnectionPoint;
  61537. protected _buildBlock(state: NodeMaterialBuildState): this;
  61538. }
  61539. }
  61540. declare module BABYLON {
  61541. /**
  61542. * Block used to scale a vector by a float
  61543. */
  61544. export class ScaleBlock extends NodeMaterialBlock {
  61545. /**
  61546. * Creates a new ScaleBlock
  61547. * @param name defines the block name
  61548. */
  61549. constructor(name: string);
  61550. /**
  61551. * Gets the current class name
  61552. * @returns the class name
  61553. */
  61554. getClassName(): string;
  61555. /**
  61556. * Gets the input component
  61557. */
  61558. get input(): NodeMaterialConnectionPoint;
  61559. /**
  61560. * Gets the factor input component
  61561. */
  61562. get factor(): NodeMaterialConnectionPoint;
  61563. /**
  61564. * Gets the output component
  61565. */
  61566. get output(): NodeMaterialConnectionPoint;
  61567. protected _buildBlock(state: NodeMaterialBuildState): this;
  61568. }
  61569. }
  61570. declare module BABYLON {
  61571. /**
  61572. * Block used to clamp a float
  61573. */
  61574. export class ClampBlock extends NodeMaterialBlock {
  61575. /** Gets or sets the minimum range */
  61576. minimum: number;
  61577. /** Gets or sets the maximum range */
  61578. maximum: number;
  61579. /**
  61580. * Creates a new ClampBlock
  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 value input component
  61591. */
  61592. get value(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the output component
  61595. */
  61596. get output(): NodeMaterialConnectionPoint;
  61597. protected _buildBlock(state: NodeMaterialBuildState): this;
  61598. protected _dumpPropertiesCode(): string;
  61599. serialize(): any;
  61600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61601. }
  61602. }
  61603. declare module BABYLON {
  61604. /**
  61605. * Block used to apply a cross product between 2 vectors
  61606. */
  61607. export class CrossBlock extends NodeMaterialBlock {
  61608. /**
  61609. * Creates a new CrossBlock
  61610. * @param name defines the block name
  61611. */
  61612. constructor(name: string);
  61613. /**
  61614. * Gets the current class name
  61615. * @returns the class name
  61616. */
  61617. getClassName(): string;
  61618. /**
  61619. * Gets the left operand input component
  61620. */
  61621. get left(): NodeMaterialConnectionPoint;
  61622. /**
  61623. * Gets the right operand input component
  61624. */
  61625. get right(): NodeMaterialConnectionPoint;
  61626. /**
  61627. * Gets the output component
  61628. */
  61629. get output(): NodeMaterialConnectionPoint;
  61630. protected _buildBlock(state: NodeMaterialBuildState): this;
  61631. }
  61632. }
  61633. declare module BABYLON {
  61634. /**
  61635. * Block used to apply a dot product between 2 vectors
  61636. */
  61637. export class DotBlock extends NodeMaterialBlock {
  61638. /**
  61639. * Creates a new DotBlock
  61640. * @param name defines the block name
  61641. */
  61642. constructor(name: string);
  61643. /**
  61644. * Gets the current class name
  61645. * @returns the class name
  61646. */
  61647. getClassName(): string;
  61648. /**
  61649. * Gets the left operand input component
  61650. */
  61651. get left(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the right operand input component
  61654. */
  61655. get right(): NodeMaterialConnectionPoint;
  61656. /**
  61657. * Gets the output component
  61658. */
  61659. get output(): NodeMaterialConnectionPoint;
  61660. protected _buildBlock(state: NodeMaterialBuildState): this;
  61661. }
  61662. }
  61663. declare module BABYLON {
  61664. /**
  61665. * Block used to normalize a vector
  61666. */
  61667. export class NormalizeBlock extends NodeMaterialBlock {
  61668. /**
  61669. * Creates a new NormalizeBlock
  61670. * @param name defines the block name
  61671. */
  61672. constructor(name: string);
  61673. /**
  61674. * Gets the current class name
  61675. * @returns the class name
  61676. */
  61677. getClassName(): string;
  61678. /**
  61679. * Gets the input component
  61680. */
  61681. get input(): NodeMaterialConnectionPoint;
  61682. /**
  61683. * Gets the output component
  61684. */
  61685. get output(): NodeMaterialConnectionPoint;
  61686. protected _buildBlock(state: NodeMaterialBuildState): this;
  61687. }
  61688. }
  61689. declare module BABYLON {
  61690. /**
  61691. * Operations supported by the Trigonometry block
  61692. */
  61693. export enum TrigonometryBlockOperations {
  61694. /** Cos */
  61695. Cos = 0,
  61696. /** Sin */
  61697. Sin = 1,
  61698. /** Abs */
  61699. Abs = 2,
  61700. /** Exp */
  61701. Exp = 3,
  61702. /** Exp2 */
  61703. Exp2 = 4,
  61704. /** Round */
  61705. Round = 5,
  61706. /** Floor */
  61707. Floor = 6,
  61708. /** Ceiling */
  61709. Ceiling = 7,
  61710. /** Square root */
  61711. Sqrt = 8,
  61712. /** Log */
  61713. Log = 9,
  61714. /** Tangent */
  61715. Tan = 10,
  61716. /** Arc tangent */
  61717. ArcTan = 11,
  61718. /** Arc cosinus */
  61719. ArcCos = 12,
  61720. /** Arc sinus */
  61721. ArcSin = 13,
  61722. /** Fraction */
  61723. Fract = 14,
  61724. /** Sign */
  61725. Sign = 15,
  61726. /** To radians (from degrees) */
  61727. Radians = 16,
  61728. /** To degrees (from radians) */
  61729. Degrees = 17
  61730. }
  61731. /**
  61732. * Block used to apply trigonometry operation to floats
  61733. */
  61734. export class TrigonometryBlock extends NodeMaterialBlock {
  61735. /**
  61736. * Gets or sets the operation applied by the block
  61737. */
  61738. operation: TrigonometryBlockOperations;
  61739. /**
  61740. * Creates a new TrigonometryBlock
  61741. * @param name defines the block name
  61742. */
  61743. constructor(name: string);
  61744. /**
  61745. * Gets the current class name
  61746. * @returns the class name
  61747. */
  61748. getClassName(): string;
  61749. /**
  61750. * Gets the input component
  61751. */
  61752. get input(): NodeMaterialConnectionPoint;
  61753. /**
  61754. * Gets the output component
  61755. */
  61756. get output(): NodeMaterialConnectionPoint;
  61757. protected _buildBlock(state: NodeMaterialBuildState): this;
  61758. serialize(): any;
  61759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61760. protected _dumpPropertiesCode(): string;
  61761. }
  61762. }
  61763. declare module BABYLON {
  61764. /**
  61765. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61766. */
  61767. export class ColorMergerBlock extends NodeMaterialBlock {
  61768. /**
  61769. * Create a new ColorMergerBlock
  61770. * @param name defines the block name
  61771. */
  61772. constructor(name: string);
  61773. /**
  61774. * Gets the current class name
  61775. * @returns the class name
  61776. */
  61777. getClassName(): string;
  61778. /**
  61779. * Gets the rgb component (input)
  61780. */
  61781. get rgbIn(): NodeMaterialConnectionPoint;
  61782. /**
  61783. * Gets the r component (input)
  61784. */
  61785. get r(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the g component (input)
  61788. */
  61789. get g(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the b component (input)
  61792. */
  61793. get b(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the a component (input)
  61796. */
  61797. get a(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the rgba component (output)
  61800. */
  61801. get rgba(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the rgb component (output)
  61804. */
  61805. get rgbOut(): NodeMaterialConnectionPoint;
  61806. /**
  61807. * Gets the rgb component (output)
  61808. * @deprecated Please use rgbOut instead.
  61809. */
  61810. get rgb(): NodeMaterialConnectionPoint;
  61811. protected _buildBlock(state: NodeMaterialBuildState): this;
  61812. }
  61813. }
  61814. declare module BABYLON {
  61815. /**
  61816. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61817. */
  61818. export class VectorSplitterBlock extends NodeMaterialBlock {
  61819. /**
  61820. * Create a new VectorSplitterBlock
  61821. * @param name defines the block name
  61822. */
  61823. constructor(name: string);
  61824. /**
  61825. * Gets the current class name
  61826. * @returns the class name
  61827. */
  61828. getClassName(): string;
  61829. /**
  61830. * Gets the xyzw component (input)
  61831. */
  61832. get xyzw(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the xyz component (input)
  61835. */
  61836. get xyzIn(): NodeMaterialConnectionPoint;
  61837. /**
  61838. * Gets the xy component (input)
  61839. */
  61840. get xyIn(): NodeMaterialConnectionPoint;
  61841. /**
  61842. * Gets the xyz component (output)
  61843. */
  61844. get xyzOut(): NodeMaterialConnectionPoint;
  61845. /**
  61846. * Gets the xy component (output)
  61847. */
  61848. get xyOut(): NodeMaterialConnectionPoint;
  61849. /**
  61850. * Gets the x component (output)
  61851. */
  61852. get x(): NodeMaterialConnectionPoint;
  61853. /**
  61854. * Gets the y component (output)
  61855. */
  61856. get y(): NodeMaterialConnectionPoint;
  61857. /**
  61858. * Gets the z component (output)
  61859. */
  61860. get z(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the w component (output)
  61863. */
  61864. get w(): NodeMaterialConnectionPoint;
  61865. protected _inputRename(name: string): string;
  61866. protected _outputRename(name: string): string;
  61867. protected _buildBlock(state: NodeMaterialBuildState): this;
  61868. }
  61869. }
  61870. declare module BABYLON {
  61871. /**
  61872. * Block used to lerp between 2 values
  61873. */
  61874. export class LerpBlock extends NodeMaterialBlock {
  61875. /**
  61876. * Creates a new LerpBlock
  61877. * @param name defines the block name
  61878. */
  61879. constructor(name: string);
  61880. /**
  61881. * Gets the current class name
  61882. * @returns the class name
  61883. */
  61884. getClassName(): string;
  61885. /**
  61886. * Gets the left operand input component
  61887. */
  61888. get left(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the right operand input component
  61891. */
  61892. get right(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the gradient operand input component
  61895. */
  61896. get gradient(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the output component
  61899. */
  61900. get output(): NodeMaterialConnectionPoint;
  61901. protected _buildBlock(state: NodeMaterialBuildState): this;
  61902. }
  61903. }
  61904. declare module BABYLON {
  61905. /**
  61906. * Block used to divide 2 vectors
  61907. */
  61908. export class DivideBlock extends NodeMaterialBlock {
  61909. /**
  61910. * Creates a new DivideBlock
  61911. * @param name defines the block name
  61912. */
  61913. constructor(name: string);
  61914. /**
  61915. * Gets the current class name
  61916. * @returns the class name
  61917. */
  61918. getClassName(): string;
  61919. /**
  61920. * Gets the left operand input component
  61921. */
  61922. get left(): NodeMaterialConnectionPoint;
  61923. /**
  61924. * Gets the right operand input component
  61925. */
  61926. get right(): NodeMaterialConnectionPoint;
  61927. /**
  61928. * Gets the output component
  61929. */
  61930. get output(): NodeMaterialConnectionPoint;
  61931. protected _buildBlock(state: NodeMaterialBuildState): this;
  61932. }
  61933. }
  61934. declare module BABYLON {
  61935. /**
  61936. * Block used to subtract 2 vectors
  61937. */
  61938. export class SubtractBlock extends NodeMaterialBlock {
  61939. /**
  61940. * Creates a new SubtractBlock
  61941. * @param name defines the block name
  61942. */
  61943. constructor(name: string);
  61944. /**
  61945. * Gets the current class name
  61946. * @returns the class name
  61947. */
  61948. getClassName(): string;
  61949. /**
  61950. * Gets the left operand input component
  61951. */
  61952. get left(): NodeMaterialConnectionPoint;
  61953. /**
  61954. * Gets the right operand input component
  61955. */
  61956. get right(): NodeMaterialConnectionPoint;
  61957. /**
  61958. * Gets the output component
  61959. */
  61960. get output(): NodeMaterialConnectionPoint;
  61961. protected _buildBlock(state: NodeMaterialBuildState): this;
  61962. }
  61963. }
  61964. declare module BABYLON {
  61965. /**
  61966. * Block used to step a value
  61967. */
  61968. export class StepBlock extends NodeMaterialBlock {
  61969. /**
  61970. * Creates a new StepBlock
  61971. * @param name defines the block name
  61972. */
  61973. constructor(name: string);
  61974. /**
  61975. * Gets the current class name
  61976. * @returns the class name
  61977. */
  61978. getClassName(): string;
  61979. /**
  61980. * Gets the value operand input component
  61981. */
  61982. get value(): NodeMaterialConnectionPoint;
  61983. /**
  61984. * Gets the edge operand input component
  61985. */
  61986. get edge(): NodeMaterialConnectionPoint;
  61987. /**
  61988. * Gets the output component
  61989. */
  61990. get output(): NodeMaterialConnectionPoint;
  61991. protected _buildBlock(state: NodeMaterialBuildState): this;
  61992. }
  61993. }
  61994. declare module BABYLON {
  61995. /**
  61996. * Block used to get the opposite (1 - x) of a value
  61997. */
  61998. export class OneMinusBlock extends NodeMaterialBlock {
  61999. /**
  62000. * Creates a new OneMinusBlock
  62001. * @param name defines the block name
  62002. */
  62003. constructor(name: string);
  62004. /**
  62005. * Gets the current class name
  62006. * @returns the class name
  62007. */
  62008. getClassName(): string;
  62009. /**
  62010. * Gets the input component
  62011. */
  62012. get input(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the output component
  62015. */
  62016. get output(): NodeMaterialConnectionPoint;
  62017. protected _buildBlock(state: NodeMaterialBuildState): this;
  62018. }
  62019. }
  62020. declare module BABYLON {
  62021. /**
  62022. * Block used to get the view direction
  62023. */
  62024. export class ViewDirectionBlock extends NodeMaterialBlock {
  62025. /**
  62026. * Creates a new ViewDirectionBlock
  62027. * @param name defines the block name
  62028. */
  62029. constructor(name: string);
  62030. /**
  62031. * Gets the current class name
  62032. * @returns the class name
  62033. */
  62034. getClassName(): string;
  62035. /**
  62036. * Gets the world position component
  62037. */
  62038. get worldPosition(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the camera position component
  62041. */
  62042. get cameraPosition(): NodeMaterialConnectionPoint;
  62043. /**
  62044. * Gets the output component
  62045. */
  62046. get output(): NodeMaterialConnectionPoint;
  62047. autoConfigure(material: NodeMaterial): void;
  62048. protected _buildBlock(state: NodeMaterialBuildState): this;
  62049. }
  62050. }
  62051. declare module BABYLON {
  62052. /**
  62053. * Block used to compute fresnel value
  62054. */
  62055. export class FresnelBlock extends NodeMaterialBlock {
  62056. /**
  62057. * Create a new FresnelBlock
  62058. * @param name defines the block name
  62059. */
  62060. constructor(name: string);
  62061. /**
  62062. * Gets the current class name
  62063. * @returns the class name
  62064. */
  62065. getClassName(): string;
  62066. /**
  62067. * Gets the world normal input component
  62068. */
  62069. get worldNormal(): NodeMaterialConnectionPoint;
  62070. /**
  62071. * Gets the view direction input component
  62072. */
  62073. get viewDirection(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the bias input component
  62076. */
  62077. get bias(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the camera (or eye) position component
  62080. */
  62081. get power(): NodeMaterialConnectionPoint;
  62082. /**
  62083. * Gets the fresnel output component
  62084. */
  62085. get fresnel(): NodeMaterialConnectionPoint;
  62086. autoConfigure(material: NodeMaterial): void;
  62087. protected _buildBlock(state: NodeMaterialBuildState): this;
  62088. }
  62089. }
  62090. declare module BABYLON {
  62091. /**
  62092. * Block used to get the max of 2 values
  62093. */
  62094. export class MaxBlock extends NodeMaterialBlock {
  62095. /**
  62096. * Creates a new MaxBlock
  62097. * @param name defines the block name
  62098. */
  62099. constructor(name: string);
  62100. /**
  62101. * Gets the current class name
  62102. * @returns the class name
  62103. */
  62104. getClassName(): string;
  62105. /**
  62106. * Gets the left operand input component
  62107. */
  62108. get left(): NodeMaterialConnectionPoint;
  62109. /**
  62110. * Gets the right operand input component
  62111. */
  62112. get right(): NodeMaterialConnectionPoint;
  62113. /**
  62114. * Gets the output component
  62115. */
  62116. get output(): NodeMaterialConnectionPoint;
  62117. protected _buildBlock(state: NodeMaterialBuildState): this;
  62118. }
  62119. }
  62120. declare module BABYLON {
  62121. /**
  62122. * Block used to get the min of 2 values
  62123. */
  62124. export class MinBlock extends NodeMaterialBlock {
  62125. /**
  62126. * Creates a new MinBlock
  62127. * @param name defines the block name
  62128. */
  62129. constructor(name: string);
  62130. /**
  62131. * Gets the current class name
  62132. * @returns the class name
  62133. */
  62134. getClassName(): string;
  62135. /**
  62136. * Gets the left operand input component
  62137. */
  62138. get left(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the right operand input component
  62141. */
  62142. get right(): NodeMaterialConnectionPoint;
  62143. /**
  62144. * Gets the output component
  62145. */
  62146. get output(): NodeMaterialConnectionPoint;
  62147. protected _buildBlock(state: NodeMaterialBuildState): this;
  62148. }
  62149. }
  62150. declare module BABYLON {
  62151. /**
  62152. * Block used to get the distance between 2 values
  62153. */
  62154. export class DistanceBlock extends NodeMaterialBlock {
  62155. /**
  62156. * Creates a new DistanceBlock
  62157. * @param name defines the block name
  62158. */
  62159. constructor(name: string);
  62160. /**
  62161. * Gets the current class name
  62162. * @returns the class name
  62163. */
  62164. getClassName(): string;
  62165. /**
  62166. * Gets the left operand input component
  62167. */
  62168. get left(): NodeMaterialConnectionPoint;
  62169. /**
  62170. * Gets the right operand input component
  62171. */
  62172. get right(): NodeMaterialConnectionPoint;
  62173. /**
  62174. * Gets the output component
  62175. */
  62176. get output(): NodeMaterialConnectionPoint;
  62177. protected _buildBlock(state: NodeMaterialBuildState): this;
  62178. }
  62179. }
  62180. declare module BABYLON {
  62181. /**
  62182. * Block used to get the length of a vector
  62183. */
  62184. export class LengthBlock extends NodeMaterialBlock {
  62185. /**
  62186. * Creates a new LengthBlock
  62187. * @param name defines the block name
  62188. */
  62189. constructor(name: string);
  62190. /**
  62191. * Gets the current class name
  62192. * @returns the class name
  62193. */
  62194. getClassName(): string;
  62195. /**
  62196. * Gets the value input component
  62197. */
  62198. get value(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the output component
  62201. */
  62202. get output(): NodeMaterialConnectionPoint;
  62203. protected _buildBlock(state: NodeMaterialBuildState): this;
  62204. }
  62205. }
  62206. declare module BABYLON {
  62207. /**
  62208. * Block used to get negative version of a value (i.e. x * -1)
  62209. */
  62210. export class NegateBlock extends NodeMaterialBlock {
  62211. /**
  62212. * Creates a new NegateBlock
  62213. * @param name defines the block name
  62214. */
  62215. constructor(name: string);
  62216. /**
  62217. * Gets the current class name
  62218. * @returns the class name
  62219. */
  62220. getClassName(): string;
  62221. /**
  62222. * Gets the value input component
  62223. */
  62224. get value(): NodeMaterialConnectionPoint;
  62225. /**
  62226. * Gets the output component
  62227. */
  62228. get output(): NodeMaterialConnectionPoint;
  62229. protected _buildBlock(state: NodeMaterialBuildState): this;
  62230. }
  62231. }
  62232. declare module BABYLON {
  62233. /**
  62234. * Block used to get the value of the first parameter raised to the power of the second
  62235. */
  62236. export class PowBlock extends NodeMaterialBlock {
  62237. /**
  62238. * Creates a new PowBlock
  62239. * @param name defines the block name
  62240. */
  62241. constructor(name: string);
  62242. /**
  62243. * Gets the current class name
  62244. * @returns the class name
  62245. */
  62246. getClassName(): string;
  62247. /**
  62248. * Gets the value operand input component
  62249. */
  62250. get value(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the power operand input component
  62253. */
  62254. get power(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the output component
  62257. */
  62258. get output(): NodeMaterialConnectionPoint;
  62259. protected _buildBlock(state: NodeMaterialBuildState): this;
  62260. }
  62261. }
  62262. declare module BABYLON {
  62263. /**
  62264. * Block used to get a random number
  62265. */
  62266. export class RandomNumberBlock extends NodeMaterialBlock {
  62267. /**
  62268. * Creates a new RandomNumberBlock
  62269. * @param name defines the block name
  62270. */
  62271. constructor(name: string);
  62272. /**
  62273. * Gets the current class name
  62274. * @returns the class name
  62275. */
  62276. getClassName(): string;
  62277. /**
  62278. * Gets the seed input component
  62279. */
  62280. get seed(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the output component
  62283. */
  62284. get output(): NodeMaterialConnectionPoint;
  62285. protected _buildBlock(state: NodeMaterialBuildState): this;
  62286. }
  62287. }
  62288. declare module BABYLON {
  62289. /**
  62290. * Block used to compute arc tangent of 2 values
  62291. */
  62292. export class ArcTan2Block extends NodeMaterialBlock {
  62293. /**
  62294. * Creates a new ArcTan2Block
  62295. * @param name defines the block name
  62296. */
  62297. constructor(name: string);
  62298. /**
  62299. * Gets the current class name
  62300. * @returns the class name
  62301. */
  62302. getClassName(): string;
  62303. /**
  62304. * Gets the x operand input component
  62305. */
  62306. get x(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the y operand input component
  62309. */
  62310. get y(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the output component
  62313. */
  62314. get output(): NodeMaterialConnectionPoint;
  62315. protected _buildBlock(state: NodeMaterialBuildState): this;
  62316. }
  62317. }
  62318. declare module BABYLON {
  62319. /**
  62320. * Block used to smooth step a value
  62321. */
  62322. export class SmoothStepBlock extends NodeMaterialBlock {
  62323. /**
  62324. * Creates a new SmoothStepBlock
  62325. * @param name defines the block name
  62326. */
  62327. constructor(name: string);
  62328. /**
  62329. * Gets the current class name
  62330. * @returns the class name
  62331. */
  62332. getClassName(): string;
  62333. /**
  62334. * Gets the value operand input component
  62335. */
  62336. get value(): NodeMaterialConnectionPoint;
  62337. /**
  62338. * Gets the first edge operand input component
  62339. */
  62340. get edge0(): NodeMaterialConnectionPoint;
  62341. /**
  62342. * Gets the second edge operand input component
  62343. */
  62344. get edge1(): NodeMaterialConnectionPoint;
  62345. /**
  62346. * Gets the output component
  62347. */
  62348. get output(): NodeMaterialConnectionPoint;
  62349. protected _buildBlock(state: NodeMaterialBuildState): this;
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. /**
  62354. * Block used to get the reciprocal (1 / x) of a value
  62355. */
  62356. export class ReciprocalBlock extends NodeMaterialBlock {
  62357. /**
  62358. * Creates a new ReciprocalBlock
  62359. * @param name defines the block name
  62360. */
  62361. constructor(name: string);
  62362. /**
  62363. * Gets the current class name
  62364. * @returns the class name
  62365. */
  62366. getClassName(): string;
  62367. /**
  62368. * Gets the input component
  62369. */
  62370. get input(): NodeMaterialConnectionPoint;
  62371. /**
  62372. * Gets the output component
  62373. */
  62374. get output(): NodeMaterialConnectionPoint;
  62375. protected _buildBlock(state: NodeMaterialBuildState): this;
  62376. }
  62377. }
  62378. declare module BABYLON {
  62379. /**
  62380. * Block used to replace a color by another one
  62381. */
  62382. export class ReplaceColorBlock extends NodeMaterialBlock {
  62383. /**
  62384. * Creates a new ReplaceColorBlock
  62385. * @param name defines the block name
  62386. */
  62387. constructor(name: string);
  62388. /**
  62389. * Gets the current class name
  62390. * @returns the class name
  62391. */
  62392. getClassName(): string;
  62393. /**
  62394. * Gets the value input component
  62395. */
  62396. get value(): NodeMaterialConnectionPoint;
  62397. /**
  62398. * Gets the reference input component
  62399. */
  62400. get reference(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the distance input component
  62403. */
  62404. get distance(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the replacement input component
  62407. */
  62408. get replacement(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the output component
  62411. */
  62412. get output(): NodeMaterialConnectionPoint;
  62413. protected _buildBlock(state: NodeMaterialBuildState): this;
  62414. }
  62415. }
  62416. declare module BABYLON {
  62417. /**
  62418. * Block used to posterize a value
  62419. * @see https://en.wikipedia.org/wiki/Posterization
  62420. */
  62421. export class PosterizeBlock extends NodeMaterialBlock {
  62422. /**
  62423. * Creates a new PosterizeBlock
  62424. * @param name defines the block name
  62425. */
  62426. constructor(name: string);
  62427. /**
  62428. * Gets the current class name
  62429. * @returns the class name
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Gets the value input component
  62434. */
  62435. get value(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the steps input component
  62438. */
  62439. get steps(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the output component
  62442. */
  62443. get output(): NodeMaterialConnectionPoint;
  62444. protected _buildBlock(state: NodeMaterialBuildState): this;
  62445. }
  62446. }
  62447. declare module BABYLON {
  62448. /**
  62449. * Operations supported by the Wave block
  62450. */
  62451. export enum WaveBlockKind {
  62452. /** SawTooth */
  62453. SawTooth = 0,
  62454. /** Square */
  62455. Square = 1,
  62456. /** Triangle */
  62457. Triangle = 2
  62458. }
  62459. /**
  62460. * Block used to apply wave operation to floats
  62461. */
  62462. export class WaveBlock extends NodeMaterialBlock {
  62463. /**
  62464. * Gets or sets the kibnd of wave to be applied by the block
  62465. */
  62466. kind: WaveBlockKind;
  62467. /**
  62468. * Creates a new WaveBlock
  62469. * @param name defines the block name
  62470. */
  62471. constructor(name: string);
  62472. /**
  62473. * Gets the current class name
  62474. * @returns the class name
  62475. */
  62476. getClassName(): string;
  62477. /**
  62478. * Gets the input component
  62479. */
  62480. get input(): NodeMaterialConnectionPoint;
  62481. /**
  62482. * Gets the output component
  62483. */
  62484. get output(): NodeMaterialConnectionPoint;
  62485. protected _buildBlock(state: NodeMaterialBuildState): this;
  62486. serialize(): any;
  62487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62488. }
  62489. }
  62490. declare module BABYLON {
  62491. /**
  62492. * Class used to store a color step for the GradientBlock
  62493. */
  62494. export class GradientBlockColorStep {
  62495. /**
  62496. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62497. */
  62498. step: number;
  62499. /**
  62500. * Gets or sets the color associated with this step
  62501. */
  62502. color: Color3;
  62503. /**
  62504. * Creates a new GradientBlockColorStep
  62505. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62506. * @param color defines the color associated with this step
  62507. */
  62508. constructor(
  62509. /**
  62510. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62511. */
  62512. step: number,
  62513. /**
  62514. * Gets or sets the color associated with this step
  62515. */
  62516. color: Color3);
  62517. }
  62518. /**
  62519. * Block used to return a color from a gradient based on an input value between 0 and 1
  62520. */
  62521. export class GradientBlock extends NodeMaterialBlock {
  62522. /**
  62523. * Gets or sets the list of color steps
  62524. */
  62525. colorSteps: GradientBlockColorStep[];
  62526. /**
  62527. * Creates a new GradientBlock
  62528. * @param name defines the block name
  62529. */
  62530. constructor(name: string);
  62531. /**
  62532. * Gets the current class name
  62533. * @returns the class name
  62534. */
  62535. getClassName(): string;
  62536. /**
  62537. * Gets the gradient input component
  62538. */
  62539. get gradient(): NodeMaterialConnectionPoint;
  62540. /**
  62541. * Gets the output component
  62542. */
  62543. get output(): NodeMaterialConnectionPoint;
  62544. private _writeColorConstant;
  62545. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62546. serialize(): any;
  62547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62548. protected _dumpPropertiesCode(): string;
  62549. }
  62550. }
  62551. declare module BABYLON {
  62552. /**
  62553. * Block used to normalize lerp between 2 values
  62554. */
  62555. export class NLerpBlock extends NodeMaterialBlock {
  62556. /**
  62557. * Creates a new NLerpBlock
  62558. * @param name defines the block name
  62559. */
  62560. constructor(name: string);
  62561. /**
  62562. * Gets the current class name
  62563. * @returns the class name
  62564. */
  62565. getClassName(): string;
  62566. /**
  62567. * Gets the left operand input component
  62568. */
  62569. get left(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the right operand input component
  62572. */
  62573. get right(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the gradient operand input component
  62576. */
  62577. get gradient(): NodeMaterialConnectionPoint;
  62578. /**
  62579. * Gets the output component
  62580. */
  62581. get output(): NodeMaterialConnectionPoint;
  62582. protected _buildBlock(state: NodeMaterialBuildState): this;
  62583. }
  62584. }
  62585. declare module BABYLON {
  62586. /**
  62587. * block used to Generate a Worley Noise 3D Noise Pattern
  62588. */
  62589. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62590. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62591. manhattanDistance: boolean;
  62592. /**
  62593. * Creates a new WorleyNoise3DBlock
  62594. * @param name defines the block name
  62595. */
  62596. constructor(name: string);
  62597. /**
  62598. * Gets the current class name
  62599. * @returns the class name
  62600. */
  62601. getClassName(): string;
  62602. /**
  62603. * Gets the seed input component
  62604. */
  62605. get seed(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the jitter input component
  62608. */
  62609. get jitter(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the output component
  62612. */
  62613. get output(): NodeMaterialConnectionPoint;
  62614. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62615. /**
  62616. * Exposes the properties to the UI?
  62617. */
  62618. protected _dumpPropertiesCode(): string;
  62619. /**
  62620. * Exposes the properties to the Seralize?
  62621. */
  62622. serialize(): any;
  62623. /**
  62624. * Exposes the properties to the deseralize?
  62625. */
  62626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62627. }
  62628. }
  62629. declare module BABYLON {
  62630. /**
  62631. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62632. */
  62633. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62634. /**
  62635. * Creates a new SimplexPerlin3DBlock
  62636. * @param name defines the block name
  62637. */
  62638. constructor(name: string);
  62639. /**
  62640. * Gets the current class name
  62641. * @returns the class name
  62642. */
  62643. getClassName(): string;
  62644. /**
  62645. * Gets the seed operand input component
  62646. */
  62647. get seed(): NodeMaterialConnectionPoint;
  62648. /**
  62649. * Gets the output component
  62650. */
  62651. get output(): NodeMaterialConnectionPoint;
  62652. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62653. }
  62654. }
  62655. declare module BABYLON {
  62656. /**
  62657. * Block used to blend normals
  62658. */
  62659. export class NormalBlendBlock extends NodeMaterialBlock {
  62660. /**
  62661. * Creates a new NormalBlendBlock
  62662. * @param name defines the block name
  62663. */
  62664. constructor(name: string);
  62665. /**
  62666. * Gets the current class name
  62667. * @returns the class name
  62668. */
  62669. getClassName(): string;
  62670. /**
  62671. * Gets the first input component
  62672. */
  62673. get normalMap0(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the second input component
  62676. */
  62677. get normalMap1(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the output component
  62680. */
  62681. get output(): NodeMaterialConnectionPoint;
  62682. protected _buildBlock(state: NodeMaterialBuildState): this;
  62683. }
  62684. }
  62685. declare module BABYLON {
  62686. /**
  62687. * Block used to rotate a 2d vector by a given angle
  62688. */
  62689. export class Rotate2dBlock extends NodeMaterialBlock {
  62690. /**
  62691. * Creates a new Rotate2dBlock
  62692. * @param name defines the block name
  62693. */
  62694. constructor(name: string);
  62695. /**
  62696. * Gets the current class name
  62697. * @returns the class name
  62698. */
  62699. getClassName(): string;
  62700. /**
  62701. * Gets the input vector
  62702. */
  62703. get input(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the input angle
  62706. */
  62707. get angle(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the output component
  62710. */
  62711. get output(): NodeMaterialConnectionPoint;
  62712. autoConfigure(material: NodeMaterial): void;
  62713. protected _buildBlock(state: NodeMaterialBuildState): this;
  62714. }
  62715. }
  62716. declare module BABYLON {
  62717. /**
  62718. * Block used to get the reflected vector from a direction and a normal
  62719. */
  62720. export class ReflectBlock extends NodeMaterialBlock {
  62721. /**
  62722. * Creates a new ReflectBlock
  62723. * @param name defines the block name
  62724. */
  62725. constructor(name: string);
  62726. /**
  62727. * Gets the current class name
  62728. * @returns the class name
  62729. */
  62730. getClassName(): string;
  62731. /**
  62732. * Gets the incident component
  62733. */
  62734. get incident(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the normal component
  62737. */
  62738. get normal(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the output component
  62741. */
  62742. get output(): NodeMaterialConnectionPoint;
  62743. protected _buildBlock(state: NodeMaterialBuildState): this;
  62744. }
  62745. }
  62746. declare module BABYLON {
  62747. /**
  62748. * Block used to get the refracted vector from a direction and a normal
  62749. */
  62750. export class RefractBlock extends NodeMaterialBlock {
  62751. /**
  62752. * Creates a new RefractBlock
  62753. * @param name defines the block name
  62754. */
  62755. constructor(name: string);
  62756. /**
  62757. * Gets the current class name
  62758. * @returns the class name
  62759. */
  62760. getClassName(): string;
  62761. /**
  62762. * Gets the incident component
  62763. */
  62764. get incident(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the normal component
  62767. */
  62768. get normal(): NodeMaterialConnectionPoint;
  62769. /**
  62770. * Gets the index of refraction component
  62771. */
  62772. get ior(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the output component
  62775. */
  62776. get output(): NodeMaterialConnectionPoint;
  62777. protected _buildBlock(state: NodeMaterialBuildState): this;
  62778. }
  62779. }
  62780. declare module BABYLON {
  62781. /**
  62782. * Block used to desaturate a color
  62783. */
  62784. export class DesaturateBlock extends NodeMaterialBlock {
  62785. /**
  62786. * Creates a new DesaturateBlock
  62787. * @param name defines the block name
  62788. */
  62789. constructor(name: string);
  62790. /**
  62791. * Gets the current class name
  62792. * @returns the class name
  62793. */
  62794. getClassName(): string;
  62795. /**
  62796. * Gets the color operand input component
  62797. */
  62798. get color(): NodeMaterialConnectionPoint;
  62799. /**
  62800. * Gets the level operand input component
  62801. */
  62802. get level(): NodeMaterialConnectionPoint;
  62803. /**
  62804. * Gets the output component
  62805. */
  62806. get output(): NodeMaterialConnectionPoint;
  62807. protected _buildBlock(state: NodeMaterialBuildState): this;
  62808. }
  62809. }
  62810. declare module BABYLON {
  62811. /**
  62812. * Block used to implement the ambient occlusion module of the PBR material
  62813. */
  62814. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62815. /**
  62816. * Create a new AmbientOcclusionBlock
  62817. * @param name defines the block name
  62818. */
  62819. constructor(name: string);
  62820. /**
  62821. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62822. */
  62823. useAmbientInGrayScale: boolean;
  62824. /**
  62825. * Initialize the block and prepare the context for build
  62826. * @param state defines the state that will be used for the build
  62827. */
  62828. initialize(state: NodeMaterialBuildState): void;
  62829. /**
  62830. * Gets the current class name
  62831. * @returns the class name
  62832. */
  62833. getClassName(): string;
  62834. /**
  62835. * Gets the texture input component
  62836. */
  62837. get texture(): NodeMaterialConnectionPoint;
  62838. /**
  62839. * Gets the texture intensity component
  62840. */
  62841. get intensity(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the direct light intensity input component
  62844. */
  62845. get directLightIntensity(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the ambient occlusion object output component
  62848. */
  62849. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62850. /**
  62851. * Gets the main code of the block (fragment side)
  62852. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62853. * @returns the shader code
  62854. */
  62855. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62857. protected _buildBlock(state: NodeMaterialBuildState): this;
  62858. protected _dumpPropertiesCode(): string;
  62859. serialize(): any;
  62860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62861. }
  62862. }
  62863. declare module BABYLON {
  62864. /**
  62865. * Block used to implement the reflection module of the PBR material
  62866. */
  62867. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62868. /** @hidden */
  62869. _defineLODReflectionAlpha: string;
  62870. /** @hidden */
  62871. _defineLinearSpecularReflection: string;
  62872. private _vEnvironmentIrradianceName;
  62873. /** @hidden */
  62874. _vReflectionMicrosurfaceInfosName: string;
  62875. /** @hidden */
  62876. _vReflectionInfosName: string;
  62877. /** @hidden */
  62878. _vReflectionFilteringInfoName: string;
  62879. private _scene;
  62880. /**
  62881. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62882. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62883. * It's less burden on the user side in the editor part.
  62884. */
  62885. /** @hidden */
  62886. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62887. /** @hidden */
  62888. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62889. /** @hidden */
  62890. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62891. /**
  62892. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62893. * diffuse part of the IBL.
  62894. */
  62895. useSphericalHarmonics: boolean;
  62896. /**
  62897. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62898. */
  62899. forceIrradianceInFragment: boolean;
  62900. /**
  62901. * Create a new ReflectionBlock
  62902. * @param name defines the block name
  62903. */
  62904. constructor(name: string);
  62905. /**
  62906. * Gets the current class name
  62907. * @returns the class name
  62908. */
  62909. getClassName(): string;
  62910. /**
  62911. * Gets the position input component
  62912. */
  62913. get position(): NodeMaterialConnectionPoint;
  62914. /**
  62915. * Gets the world position input component
  62916. */
  62917. get worldPosition(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the world normal input component
  62920. */
  62921. get worldNormal(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the world input component
  62924. */
  62925. get world(): NodeMaterialConnectionPoint;
  62926. /**
  62927. * Gets the camera (or eye) position component
  62928. */
  62929. get cameraPosition(): NodeMaterialConnectionPoint;
  62930. /**
  62931. * Gets the view input component
  62932. */
  62933. get view(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the color input component
  62936. */
  62937. get color(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the reflection object output component
  62940. */
  62941. get reflection(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62944. */
  62945. get hasTexture(): boolean;
  62946. /**
  62947. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62948. */
  62949. get reflectionColor(): string;
  62950. protected _getTexture(): Nullable<BaseTexture>;
  62951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62952. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62953. /**
  62954. * Gets the code to inject in the vertex shader
  62955. * @param state current state of the node material building
  62956. * @returns the shader code
  62957. */
  62958. handleVertexSide(state: NodeMaterialBuildState): string;
  62959. /**
  62960. * Gets the main code of the block (fragment side)
  62961. * @param state current state of the node material building
  62962. * @param normalVarName name of the existing variable corresponding to the normal
  62963. * @returns the shader code
  62964. */
  62965. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62966. protected _buildBlock(state: NodeMaterialBuildState): this;
  62967. protected _dumpPropertiesCode(): string;
  62968. serialize(): any;
  62969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62970. }
  62971. }
  62972. declare module BABYLON {
  62973. /**
  62974. * Block used to implement the sheen module of the PBR material
  62975. */
  62976. export class SheenBlock extends NodeMaterialBlock {
  62977. /**
  62978. * Create a new SheenBlock
  62979. * @param name defines the block name
  62980. */
  62981. constructor(name: string);
  62982. /**
  62983. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62984. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62985. * making it easier to setup and tweak the effect
  62986. */
  62987. albedoScaling: boolean;
  62988. /**
  62989. * Defines if the sheen is linked to the sheen color.
  62990. */
  62991. linkSheenWithAlbedo: boolean;
  62992. /**
  62993. * Initialize the block and prepare the context for build
  62994. * @param state defines the state that will be used for the build
  62995. */
  62996. initialize(state: NodeMaterialBuildState): void;
  62997. /**
  62998. * Gets the current class name
  62999. * @returns the class name
  63000. */
  63001. getClassName(): string;
  63002. /**
  63003. * Gets the intensity input component
  63004. */
  63005. get intensity(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the color input component
  63008. */
  63009. get color(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the roughness input component
  63012. */
  63013. get roughness(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the sheen object output component
  63016. */
  63017. get sheen(): NodeMaterialConnectionPoint;
  63018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63019. /**
  63020. * Gets the main code of the block (fragment side)
  63021. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63022. * @returns the shader code
  63023. */
  63024. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63025. protected _buildBlock(state: NodeMaterialBuildState): this;
  63026. protected _dumpPropertiesCode(): string;
  63027. serialize(): any;
  63028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63029. }
  63030. }
  63031. declare module BABYLON {
  63032. /**
  63033. * Block used to implement the reflectivity module of the PBR material
  63034. */
  63035. export class ReflectivityBlock extends NodeMaterialBlock {
  63036. private _metallicReflectanceColor;
  63037. private _metallicF0Factor;
  63038. /** @hidden */
  63039. _vMetallicReflectanceFactorsName: string;
  63040. /**
  63041. * The property below is set by the main PBR block prior to calling methods of this class.
  63042. */
  63043. /** @hidden */
  63044. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63045. /**
  63046. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63047. */
  63048. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63049. /**
  63050. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63051. */
  63052. useMetallnessFromMetallicTextureBlue: boolean;
  63053. /**
  63054. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63055. */
  63056. useRoughnessFromMetallicTextureAlpha: boolean;
  63057. /**
  63058. * Specifies if the metallic texture contains the roughness information in its green channel.
  63059. */
  63060. useRoughnessFromMetallicTextureGreen: boolean;
  63061. /**
  63062. * Create a new ReflectivityBlock
  63063. * @param name defines the block name
  63064. */
  63065. constructor(name: string);
  63066. /**
  63067. * Initialize the block and prepare the context for build
  63068. * @param state defines the state that will be used for the build
  63069. */
  63070. initialize(state: NodeMaterialBuildState): void;
  63071. /**
  63072. * Gets the current class name
  63073. * @returns the class name
  63074. */
  63075. getClassName(): string;
  63076. /**
  63077. * Gets the metallic input component
  63078. */
  63079. get metallic(): NodeMaterialConnectionPoint;
  63080. /**
  63081. * Gets the roughness input component
  63082. */
  63083. get roughness(): NodeMaterialConnectionPoint;
  63084. /**
  63085. * Gets the texture input component
  63086. */
  63087. get texture(): NodeMaterialConnectionPoint;
  63088. /**
  63089. * Gets the reflectivity object output component
  63090. */
  63091. get reflectivity(): NodeMaterialConnectionPoint;
  63092. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63093. /**
  63094. * Gets the main code of the block (fragment side)
  63095. * @param state current state of the node material building
  63096. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63097. * @returns the shader code
  63098. */
  63099. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63101. protected _buildBlock(state: NodeMaterialBuildState): this;
  63102. protected _dumpPropertiesCode(): string;
  63103. serialize(): any;
  63104. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63105. }
  63106. }
  63107. declare module BABYLON {
  63108. /**
  63109. * Block used to implement the anisotropy module of the PBR material
  63110. */
  63111. export class AnisotropyBlock extends NodeMaterialBlock {
  63112. /**
  63113. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63114. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63115. * It's less burden on the user side in the editor part.
  63116. */
  63117. /** @hidden */
  63118. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63119. /** @hidden */
  63120. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63121. /**
  63122. * Create a new AnisotropyBlock
  63123. * @param name defines the block name
  63124. */
  63125. constructor(name: string);
  63126. /**
  63127. * Initialize the block and prepare the context for build
  63128. * @param state defines the state that will be used for the build
  63129. */
  63130. initialize(state: NodeMaterialBuildState): void;
  63131. /**
  63132. * Gets the current class name
  63133. * @returns the class name
  63134. */
  63135. getClassName(): string;
  63136. /**
  63137. * Gets the intensity input component
  63138. */
  63139. get intensity(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the direction input component
  63142. */
  63143. get direction(): NodeMaterialConnectionPoint;
  63144. /**
  63145. * Gets the texture input component
  63146. */
  63147. get texture(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the uv input component
  63150. */
  63151. get uv(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the worldTangent input component
  63154. */
  63155. get worldTangent(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the anisotropy object output component
  63158. */
  63159. get anisotropy(): NodeMaterialConnectionPoint;
  63160. private _generateTBNSpace;
  63161. /**
  63162. * Gets the main code of the block (fragment side)
  63163. * @param state current state of the node material building
  63164. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63165. * @returns the shader code
  63166. */
  63167. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63169. protected _buildBlock(state: NodeMaterialBuildState): this;
  63170. }
  63171. }
  63172. declare module BABYLON {
  63173. /**
  63174. * Block used to implement the clear coat module of the PBR material
  63175. */
  63176. export class ClearCoatBlock extends NodeMaterialBlock {
  63177. private _scene;
  63178. /**
  63179. * Create a new ClearCoatBlock
  63180. * @param name defines the block name
  63181. */
  63182. constructor(name: string);
  63183. /**
  63184. * Initialize the block and prepare the context for build
  63185. * @param state defines the state that will be used for the build
  63186. */
  63187. initialize(state: NodeMaterialBuildState): void;
  63188. /**
  63189. * Gets the current class name
  63190. * @returns the class name
  63191. */
  63192. getClassName(): string;
  63193. /**
  63194. * Gets the intensity input component
  63195. */
  63196. get intensity(): NodeMaterialConnectionPoint;
  63197. /**
  63198. * Gets the roughness input component
  63199. */
  63200. get roughness(): NodeMaterialConnectionPoint;
  63201. /**
  63202. * Gets the ior input component
  63203. */
  63204. get ior(): NodeMaterialConnectionPoint;
  63205. /**
  63206. * Gets the texture input component
  63207. */
  63208. get texture(): NodeMaterialConnectionPoint;
  63209. /**
  63210. * Gets the bump texture input component
  63211. */
  63212. get bumpTexture(): NodeMaterialConnectionPoint;
  63213. /**
  63214. * Gets the uv input component
  63215. */
  63216. get uv(): NodeMaterialConnectionPoint;
  63217. /**
  63218. * Gets the tint color input component
  63219. */
  63220. get tintColor(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the tint "at distance" input component
  63223. */
  63224. get tintAtDistance(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the tint thickness input component
  63227. */
  63228. get tintThickness(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the world tangent input component
  63231. */
  63232. get worldTangent(): NodeMaterialConnectionPoint;
  63233. /**
  63234. * Gets the clear coat object output component
  63235. */
  63236. get clearcoat(): NodeMaterialConnectionPoint;
  63237. autoConfigure(material: NodeMaterial): void;
  63238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63239. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63240. private _generateTBNSpace;
  63241. /**
  63242. * Gets the main code of the block (fragment side)
  63243. * @param state current state of the node material building
  63244. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63245. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63246. * @param worldPosVarName name of the variable holding the world position
  63247. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63248. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63249. * @param worldNormalVarName name of the variable holding the world normal
  63250. * @returns the shader code
  63251. */
  63252. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63253. protected _buildBlock(state: NodeMaterialBuildState): this;
  63254. }
  63255. }
  63256. declare module BABYLON {
  63257. /**
  63258. * Block used to implement the sub surface module of the PBR material
  63259. */
  63260. export class SubSurfaceBlock extends NodeMaterialBlock {
  63261. /**
  63262. * Create a new SubSurfaceBlock
  63263. * @param name defines the block name
  63264. */
  63265. constructor(name: string);
  63266. /**
  63267. * Stores the intensity of the different subsurface effects in the thickness texture.
  63268. * * the green channel is the translucency intensity.
  63269. * * the blue channel is the scattering intensity.
  63270. * * the alpha channel is the refraction intensity.
  63271. */
  63272. useMaskFromThicknessTexture: boolean;
  63273. /**
  63274. * Initialize the block and prepare the context for build
  63275. * @param state defines the state that will be used for the build
  63276. */
  63277. initialize(state: NodeMaterialBuildState): void;
  63278. /**
  63279. * Gets the current class name
  63280. * @returns the class name
  63281. */
  63282. getClassName(): string;
  63283. /**
  63284. * Gets the min thickness input component
  63285. */
  63286. get minThickness(): NodeMaterialConnectionPoint;
  63287. /**
  63288. * Gets the max thickness input component
  63289. */
  63290. get maxThickness(): NodeMaterialConnectionPoint;
  63291. /**
  63292. * Gets the thickness texture component
  63293. */
  63294. get thicknessTexture(): NodeMaterialConnectionPoint;
  63295. /**
  63296. * Gets the tint color input component
  63297. */
  63298. get tintColor(): NodeMaterialConnectionPoint;
  63299. /**
  63300. * Gets the translucency intensity input component
  63301. */
  63302. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63303. /**
  63304. * Gets the translucency diffusion distance input component
  63305. */
  63306. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63307. /**
  63308. * Gets the refraction object parameters
  63309. */
  63310. get refraction(): NodeMaterialConnectionPoint;
  63311. /**
  63312. * Gets the sub surface object output component
  63313. */
  63314. get subsurface(): NodeMaterialConnectionPoint;
  63315. autoConfigure(material: NodeMaterial): void;
  63316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63317. /**
  63318. * Gets the main code of the block (fragment side)
  63319. * @param state current state of the node material building
  63320. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63321. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63322. * @param worldPosVarName name of the variable holding the world position
  63323. * @returns the shader code
  63324. */
  63325. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63326. protected _buildBlock(state: NodeMaterialBuildState): this;
  63327. }
  63328. }
  63329. declare module BABYLON {
  63330. /**
  63331. * Block used to implement the PBR metallic/roughness model
  63332. */
  63333. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63334. /**
  63335. * Gets or sets the light associated with this block
  63336. */
  63337. light: Nullable<Light>;
  63338. private _lightId;
  63339. private _scene;
  63340. private _environmentBRDFTexture;
  63341. private _environmentBrdfSamplerName;
  63342. private _vNormalWName;
  63343. private _invertNormalName;
  63344. /**
  63345. * Create a new ReflectionBlock
  63346. * @param name defines the block name
  63347. */
  63348. constructor(name: string);
  63349. /**
  63350. * Intensity of the direct lights e.g. the four lights available in your scene.
  63351. * This impacts both the direct diffuse and specular highlights.
  63352. */
  63353. directIntensity: number;
  63354. /**
  63355. * Intensity of the environment e.g. how much the environment will light the object
  63356. * either through harmonics for rough material or through the refelction for shiny ones.
  63357. */
  63358. environmentIntensity: number;
  63359. /**
  63360. * This is a special control allowing the reduction of the specular highlights coming from the
  63361. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63362. */
  63363. specularIntensity: number;
  63364. /**
  63365. * Defines the falloff type used in this material.
  63366. * It by default is Physical.
  63367. */
  63368. lightFalloff: number;
  63369. /**
  63370. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63371. */
  63372. useAlphaFromAlbedoTexture: boolean;
  63373. /**
  63374. * Specifies that alpha test should be used
  63375. */
  63376. useAlphaTest: boolean;
  63377. /**
  63378. * Defines the alpha limits in alpha test mode.
  63379. */
  63380. alphaTestCutoff: number;
  63381. /**
  63382. * Specifies that alpha blending should be used
  63383. */
  63384. useAlphaBlending: boolean;
  63385. /**
  63386. * Defines if the alpha value should be determined via the rgb values.
  63387. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63388. */
  63389. opacityRGB: boolean;
  63390. /**
  63391. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63392. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63393. */
  63394. useRadianceOverAlpha: boolean;
  63395. /**
  63396. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63397. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63398. */
  63399. useSpecularOverAlpha: boolean;
  63400. /**
  63401. * Enables specular anti aliasing in the PBR shader.
  63402. * It will both interacts on the Geometry for analytical and IBL lighting.
  63403. * It also prefilter the roughness map based on the bump values.
  63404. */
  63405. enableSpecularAntiAliasing: boolean;
  63406. /**
  63407. * Enables realtime filtering on the texture.
  63408. */
  63409. realTimeFiltering: boolean;
  63410. /**
  63411. * Quality switch for realtime filtering
  63412. */
  63413. realTimeFilteringQuality: number;
  63414. /**
  63415. * Defines if the material uses energy conservation.
  63416. */
  63417. useEnergyConservation: boolean;
  63418. /**
  63419. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63420. * too much the area relying on ambient texture to define their ambient occlusion.
  63421. */
  63422. useRadianceOcclusion: boolean;
  63423. /**
  63424. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63425. * makes the reflect vector face the model (under horizon).
  63426. */
  63427. useHorizonOcclusion: boolean;
  63428. /**
  63429. * If set to true, no lighting calculations will be applied.
  63430. */
  63431. unlit: boolean;
  63432. /**
  63433. * Force normal to face away from face.
  63434. */
  63435. forceNormalForward: boolean;
  63436. /**
  63437. * Defines the material debug mode.
  63438. * It helps seeing only some components of the material while troubleshooting.
  63439. */
  63440. debugMode: number;
  63441. /**
  63442. * Specify from where on screen the debug mode should start.
  63443. * The value goes from -1 (full screen) to 1 (not visible)
  63444. * It helps with side by side comparison against the final render
  63445. * This defaults to 0
  63446. */
  63447. debugLimit: number;
  63448. /**
  63449. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63450. * You can use the factor to better multiply the final value.
  63451. */
  63452. debugFactor: number;
  63453. /**
  63454. * Initialize the block and prepare the context for build
  63455. * @param state defines the state that will be used for the build
  63456. */
  63457. initialize(state: NodeMaterialBuildState): void;
  63458. /**
  63459. * Gets the current class name
  63460. * @returns the class name
  63461. */
  63462. getClassName(): string;
  63463. /**
  63464. * Gets the world position input component
  63465. */
  63466. get worldPosition(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the world normal input component
  63469. */
  63470. get worldNormal(): NodeMaterialConnectionPoint;
  63471. /**
  63472. * Gets the perturbed normal input component
  63473. */
  63474. get perturbedNormal(): NodeMaterialConnectionPoint;
  63475. /**
  63476. * Gets the camera position input component
  63477. */
  63478. get cameraPosition(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the base color input component
  63481. */
  63482. get baseColor(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the opacity texture input component
  63485. */
  63486. get opacityTexture(): NodeMaterialConnectionPoint;
  63487. /**
  63488. * Gets the ambient color input component
  63489. */
  63490. get ambientColor(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the reflectivity object parameters
  63493. */
  63494. get reflectivity(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the ambient occlusion object parameters
  63497. */
  63498. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63499. /**
  63500. * Gets the reflection object parameters
  63501. */
  63502. get reflection(): NodeMaterialConnectionPoint;
  63503. /**
  63504. * Gets the sheen object parameters
  63505. */
  63506. get sheen(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the clear coat object parameters
  63509. */
  63510. get clearcoat(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the sub surface object parameters
  63513. */
  63514. get subsurface(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the anisotropy object parameters
  63517. */
  63518. get anisotropy(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the ambient output component
  63521. */
  63522. get ambient(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the diffuse output component
  63525. */
  63526. get diffuse(): NodeMaterialConnectionPoint;
  63527. /**
  63528. * Gets the specular output component
  63529. */
  63530. get specular(): NodeMaterialConnectionPoint;
  63531. /**
  63532. * Gets the sheen output component
  63533. */
  63534. get sheenDir(): NodeMaterialConnectionPoint;
  63535. /**
  63536. * Gets the clear coat output component
  63537. */
  63538. get clearcoatDir(): NodeMaterialConnectionPoint;
  63539. /**
  63540. * Gets the indirect diffuse output component
  63541. */
  63542. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63543. /**
  63544. * Gets the indirect specular output component
  63545. */
  63546. get specularIndirect(): NodeMaterialConnectionPoint;
  63547. /**
  63548. * Gets the indirect sheen output component
  63549. */
  63550. get sheenIndirect(): NodeMaterialConnectionPoint;
  63551. /**
  63552. * Gets the indirect clear coat output component
  63553. */
  63554. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63555. /**
  63556. * Gets the refraction output component
  63557. */
  63558. get refraction(): NodeMaterialConnectionPoint;
  63559. /**
  63560. * Gets the global lighting output component
  63561. */
  63562. get lighting(): NodeMaterialConnectionPoint;
  63563. /**
  63564. * Gets the shadow output component
  63565. */
  63566. get shadow(): NodeMaterialConnectionPoint;
  63567. /**
  63568. * Gets the alpha output component
  63569. */
  63570. get alpha(): NodeMaterialConnectionPoint;
  63571. autoConfigure(material: NodeMaterial): void;
  63572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63573. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63575. private _injectVertexCode;
  63576. /**
  63577. * Gets the code corresponding to the albedo/opacity module
  63578. * @returns the shader code
  63579. */
  63580. getAlbedoOpacityCode(): string;
  63581. protected _buildBlock(state: NodeMaterialBuildState): this;
  63582. protected _dumpPropertiesCode(): string;
  63583. serialize(): any;
  63584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. /**
  63589. * Block used to compute value of one parameter modulo another
  63590. */
  63591. export class ModBlock extends NodeMaterialBlock {
  63592. /**
  63593. * Creates a new ModBlock
  63594. * @param name defines the block name
  63595. */
  63596. constructor(name: string);
  63597. /**
  63598. * Gets the current class name
  63599. * @returns the class name
  63600. */
  63601. getClassName(): string;
  63602. /**
  63603. * Gets the left operand input component
  63604. */
  63605. get left(): NodeMaterialConnectionPoint;
  63606. /**
  63607. * Gets the right operand input component
  63608. */
  63609. get right(): NodeMaterialConnectionPoint;
  63610. /**
  63611. * Gets the output component
  63612. */
  63613. get output(): NodeMaterialConnectionPoint;
  63614. protected _buildBlock(state: NodeMaterialBuildState): this;
  63615. }
  63616. }
  63617. declare module BABYLON {
  63618. /**
  63619. * Helper class to push actions to a pool of workers.
  63620. */
  63621. export class WorkerPool implements IDisposable {
  63622. private _workerInfos;
  63623. private _pendingActions;
  63624. /**
  63625. * Constructor
  63626. * @param workers Array of workers to use for actions
  63627. */
  63628. constructor(workers: Array<Worker>);
  63629. /**
  63630. * Terminates all workers and clears any pending actions.
  63631. */
  63632. dispose(): void;
  63633. /**
  63634. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63635. * pended until a worker has completed its action.
  63636. * @param action The action to perform. Call onComplete when the action is complete.
  63637. */
  63638. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63639. private _execute;
  63640. }
  63641. }
  63642. declare module BABYLON {
  63643. /**
  63644. * Configuration for Draco compression
  63645. */
  63646. export interface IDracoCompressionConfiguration {
  63647. /**
  63648. * Configuration for the decoder.
  63649. */
  63650. decoder: {
  63651. /**
  63652. * The url to the WebAssembly module.
  63653. */
  63654. wasmUrl?: string;
  63655. /**
  63656. * The url to the WebAssembly binary.
  63657. */
  63658. wasmBinaryUrl?: string;
  63659. /**
  63660. * The url to the fallback JavaScript module.
  63661. */
  63662. fallbackUrl?: string;
  63663. };
  63664. }
  63665. /**
  63666. * Draco compression (https://google.github.io/draco/)
  63667. *
  63668. * This class wraps the Draco module.
  63669. *
  63670. * **Encoder**
  63671. *
  63672. * The encoder is not currently implemented.
  63673. *
  63674. * **Decoder**
  63675. *
  63676. * 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.
  63677. *
  63678. * To update the configuration, use the following code:
  63679. * ```javascript
  63680. * DracoCompression.Configuration = {
  63681. * decoder: {
  63682. * wasmUrl: "<url to the WebAssembly library>",
  63683. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63684. * fallbackUrl: "<url to the fallback JavaScript library>",
  63685. * }
  63686. * };
  63687. * ```
  63688. *
  63689. * 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.
  63690. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63691. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63692. *
  63693. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63694. * ```javascript
  63695. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63696. * ```
  63697. *
  63698. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63699. */
  63700. export class DracoCompression implements IDisposable {
  63701. private _workerPoolPromise?;
  63702. private _decoderModulePromise?;
  63703. /**
  63704. * The configuration. Defaults to the following urls:
  63705. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63706. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63707. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63708. */
  63709. static Configuration: IDracoCompressionConfiguration;
  63710. /**
  63711. * Returns true if the decoder configuration is available.
  63712. */
  63713. static get DecoderAvailable(): boolean;
  63714. /**
  63715. * Default number of workers to create when creating the draco compression object.
  63716. */
  63717. static DefaultNumWorkers: number;
  63718. private static GetDefaultNumWorkers;
  63719. private static _Default;
  63720. /**
  63721. * Default instance for the draco compression object.
  63722. */
  63723. static get Default(): DracoCompression;
  63724. /**
  63725. * Constructor
  63726. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63727. */
  63728. constructor(numWorkers?: number);
  63729. /**
  63730. * Stop all async operations and release resources.
  63731. */
  63732. dispose(): void;
  63733. /**
  63734. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63735. * @returns a promise that resolves when ready
  63736. */
  63737. whenReadyAsync(): Promise<void>;
  63738. /**
  63739. * Decode Draco compressed mesh data to vertex data.
  63740. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63741. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63742. * @returns A promise that resolves with the decoded vertex data
  63743. */
  63744. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63745. [kind: string]: number;
  63746. }): Promise<VertexData>;
  63747. }
  63748. }
  63749. declare module BABYLON {
  63750. /**
  63751. * Class for building Constructive Solid Geometry
  63752. */
  63753. export class CSG {
  63754. private polygons;
  63755. /**
  63756. * The world matrix
  63757. */
  63758. matrix: Matrix;
  63759. /**
  63760. * Stores the position
  63761. */
  63762. position: Vector3;
  63763. /**
  63764. * Stores the rotation
  63765. */
  63766. rotation: Vector3;
  63767. /**
  63768. * Stores the rotation quaternion
  63769. */
  63770. rotationQuaternion: Nullable<Quaternion>;
  63771. /**
  63772. * Stores the scaling vector
  63773. */
  63774. scaling: Vector3;
  63775. /**
  63776. * Convert the Mesh to CSG
  63777. * @param mesh The Mesh to convert to CSG
  63778. * @returns A new CSG from the Mesh
  63779. */
  63780. static FromMesh(mesh: Mesh): CSG;
  63781. /**
  63782. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63783. * @param polygons Polygons used to construct a CSG solid
  63784. */
  63785. private static FromPolygons;
  63786. /**
  63787. * Clones, or makes a deep copy, of the CSG
  63788. * @returns A new CSG
  63789. */
  63790. clone(): CSG;
  63791. /**
  63792. * Unions this CSG with another CSG
  63793. * @param csg The CSG to union against this CSG
  63794. * @returns The unioned CSG
  63795. */
  63796. union(csg: CSG): CSG;
  63797. /**
  63798. * Unions this CSG with another CSG in place
  63799. * @param csg The CSG to union against this CSG
  63800. */
  63801. unionInPlace(csg: CSG): void;
  63802. /**
  63803. * Subtracts this CSG with another CSG
  63804. * @param csg The CSG to subtract against this CSG
  63805. * @returns A new CSG
  63806. */
  63807. subtract(csg: CSG): CSG;
  63808. /**
  63809. * Subtracts this CSG with another CSG in place
  63810. * @param csg The CSG to subtact against this CSG
  63811. */
  63812. subtractInPlace(csg: CSG): void;
  63813. /**
  63814. * Intersect this CSG with another CSG
  63815. * @param csg The CSG to intersect against this CSG
  63816. * @returns A new CSG
  63817. */
  63818. intersect(csg: CSG): CSG;
  63819. /**
  63820. * Intersects this CSG with another CSG in place
  63821. * @param csg The CSG to intersect against this CSG
  63822. */
  63823. intersectInPlace(csg: CSG): void;
  63824. /**
  63825. * Return a new CSG solid with solid and empty space switched. This solid is
  63826. * not modified.
  63827. * @returns A new CSG solid with solid and empty space switched
  63828. */
  63829. inverse(): CSG;
  63830. /**
  63831. * Inverses the CSG in place
  63832. */
  63833. inverseInPlace(): void;
  63834. /**
  63835. * This is used to keep meshes transformations so they can be restored
  63836. * when we build back a Babylon Mesh
  63837. * NB : All CSG operations are performed in world coordinates
  63838. * @param csg The CSG to copy the transform attributes from
  63839. * @returns This CSG
  63840. */
  63841. copyTransformAttributes(csg: CSG): CSG;
  63842. /**
  63843. * Build Raw mesh from CSG
  63844. * Coordinates here are in world space
  63845. * @param name The name of the mesh geometry
  63846. * @param scene The Scene
  63847. * @param keepSubMeshes Specifies if the submeshes should be kept
  63848. * @returns A new Mesh
  63849. */
  63850. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63851. /**
  63852. * Build Mesh from CSG taking material and transforms into account
  63853. * @param name The name of the Mesh
  63854. * @param material The material of the Mesh
  63855. * @param scene The Scene
  63856. * @param keepSubMeshes Specifies if submeshes should be kept
  63857. * @returns The new Mesh
  63858. */
  63859. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63860. }
  63861. }
  63862. declare module BABYLON {
  63863. /**
  63864. * Class used to create a trail following a mesh
  63865. */
  63866. export class TrailMesh extends Mesh {
  63867. private _generator;
  63868. private _autoStart;
  63869. private _running;
  63870. private _diameter;
  63871. private _length;
  63872. private _sectionPolygonPointsCount;
  63873. private _sectionVectors;
  63874. private _sectionNormalVectors;
  63875. private _beforeRenderObserver;
  63876. /**
  63877. * @constructor
  63878. * @param name The value used by scene.getMeshByName() to do a lookup.
  63879. * @param generator The mesh or transform node to generate a trail.
  63880. * @param scene The scene to add this mesh to.
  63881. * @param diameter Diameter of trailing mesh. Default is 1.
  63882. * @param length Length of trailing mesh. Default is 60.
  63883. * @param autoStart Automatically start trailing mesh. Default true.
  63884. */
  63885. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63886. /**
  63887. * "TrailMesh"
  63888. * @returns "TrailMesh"
  63889. */
  63890. getClassName(): string;
  63891. private _createMesh;
  63892. /**
  63893. * Start trailing mesh.
  63894. */
  63895. start(): void;
  63896. /**
  63897. * Stop trailing mesh.
  63898. */
  63899. stop(): void;
  63900. /**
  63901. * Update trailing mesh geometry.
  63902. */
  63903. update(): void;
  63904. /**
  63905. * Returns a new TrailMesh object.
  63906. * @param name is a string, the name given to the new mesh
  63907. * @param newGenerator use new generator object for cloned trail mesh
  63908. * @returns a new mesh
  63909. */
  63910. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63911. /**
  63912. * Serializes this trail mesh
  63913. * @param serializationObject object to write serialization to
  63914. */
  63915. serialize(serializationObject: any): void;
  63916. /**
  63917. * Parses a serialized trail mesh
  63918. * @param parsedMesh the serialized mesh
  63919. * @param scene the scene to create the trail mesh in
  63920. * @returns the created trail mesh
  63921. */
  63922. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63923. }
  63924. }
  63925. declare module BABYLON {
  63926. /**
  63927. * Class containing static functions to help procedurally build meshes
  63928. */
  63929. export class TiledBoxBuilder {
  63930. /**
  63931. * Creates a box mesh
  63932. * 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)
  63933. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63935. * * 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
  63936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63937. * @param name defines the name of the mesh
  63938. * @param options defines the options used to create the mesh
  63939. * @param scene defines the hosting scene
  63940. * @returns the box mesh
  63941. */
  63942. static CreateTiledBox(name: string, options: {
  63943. pattern?: number;
  63944. width?: number;
  63945. height?: number;
  63946. depth?: number;
  63947. tileSize?: number;
  63948. tileWidth?: number;
  63949. tileHeight?: number;
  63950. alignHorizontal?: number;
  63951. alignVertical?: number;
  63952. faceUV?: Vector4[];
  63953. faceColors?: Color4[];
  63954. sideOrientation?: number;
  63955. updatable?: boolean;
  63956. }, scene?: Nullable<Scene>): Mesh;
  63957. }
  63958. }
  63959. declare module BABYLON {
  63960. /**
  63961. * Class containing static functions to help procedurally build meshes
  63962. */
  63963. export class TorusKnotBuilder {
  63964. /**
  63965. * Creates a torus knot mesh
  63966. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63967. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63968. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63969. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63971. * * 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
  63972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63973. * @param name defines the name of the mesh
  63974. * @param options defines the options used to create the mesh
  63975. * @param scene defines the hosting scene
  63976. * @returns the torus knot mesh
  63977. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63978. */
  63979. static CreateTorusKnot(name: string, options: {
  63980. radius?: number;
  63981. tube?: number;
  63982. radialSegments?: number;
  63983. tubularSegments?: number;
  63984. p?: number;
  63985. q?: number;
  63986. updatable?: boolean;
  63987. sideOrientation?: number;
  63988. frontUVs?: Vector4;
  63989. backUVs?: Vector4;
  63990. }, scene: any): Mesh;
  63991. }
  63992. }
  63993. declare module BABYLON {
  63994. /**
  63995. * Polygon
  63996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63997. */
  63998. export class Polygon {
  63999. /**
  64000. * Creates a rectangle
  64001. * @param xmin bottom X coord
  64002. * @param ymin bottom Y coord
  64003. * @param xmax top X coord
  64004. * @param ymax top Y coord
  64005. * @returns points that make the resulting rectation
  64006. */
  64007. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64008. /**
  64009. * Creates a circle
  64010. * @param radius radius of circle
  64011. * @param cx scale in x
  64012. * @param cy scale in y
  64013. * @param numberOfSides number of sides that make up the circle
  64014. * @returns points that make the resulting circle
  64015. */
  64016. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64017. /**
  64018. * Creates a polygon from input string
  64019. * @param input Input polygon data
  64020. * @returns the parsed points
  64021. */
  64022. static Parse(input: string): Vector2[];
  64023. /**
  64024. * Starts building a polygon from x and y coordinates
  64025. * @param x x coordinate
  64026. * @param y y coordinate
  64027. * @returns the started path2
  64028. */
  64029. static StartingAt(x: number, y: number): Path2;
  64030. }
  64031. /**
  64032. * Builds a polygon
  64033. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64034. */
  64035. export class PolygonMeshBuilder {
  64036. private _points;
  64037. private _outlinepoints;
  64038. private _holes;
  64039. private _name;
  64040. private _scene;
  64041. private _epoints;
  64042. private _eholes;
  64043. private _addToepoint;
  64044. /**
  64045. * Babylon reference to the earcut plugin.
  64046. */
  64047. bjsEarcut: any;
  64048. /**
  64049. * Creates a PolygonMeshBuilder
  64050. * @param name name of the builder
  64051. * @param contours Path of the polygon
  64052. * @param scene scene to add to when creating the mesh
  64053. * @param earcutInjection can be used to inject your own earcut reference
  64054. */
  64055. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64056. /**
  64057. * Adds a whole within the polygon
  64058. * @param hole Array of points defining the hole
  64059. * @returns this
  64060. */
  64061. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64062. /**
  64063. * Creates the polygon
  64064. * @param updatable If the mesh should be updatable
  64065. * @param depth The depth of the mesh created
  64066. * @returns the created mesh
  64067. */
  64068. build(updatable?: boolean, depth?: number): Mesh;
  64069. /**
  64070. * Creates the polygon
  64071. * @param depth The depth of the mesh created
  64072. * @returns the created VertexData
  64073. */
  64074. buildVertexData(depth?: number): VertexData;
  64075. /**
  64076. * Adds a side to the polygon
  64077. * @param positions points that make the polygon
  64078. * @param normals normals of the polygon
  64079. * @param uvs uvs of the polygon
  64080. * @param indices indices of the polygon
  64081. * @param bounds bounds of the polygon
  64082. * @param points points of the polygon
  64083. * @param depth depth of the polygon
  64084. * @param flip flip of the polygon
  64085. */
  64086. private addSide;
  64087. }
  64088. }
  64089. declare module BABYLON {
  64090. /**
  64091. * Class containing static functions to help procedurally build meshes
  64092. */
  64093. export class PolygonBuilder {
  64094. /**
  64095. * Creates a polygon mesh
  64096. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64097. * * 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
  64098. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64100. * * 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)
  64101. * * Remember you can only change the shape positions, not their number when updating a polygon
  64102. * @param name defines the name of the mesh
  64103. * @param options defines the options used to create the mesh
  64104. * @param scene defines the hosting scene
  64105. * @param earcutInjection can be used to inject your own earcut reference
  64106. * @returns the polygon mesh
  64107. */
  64108. static CreatePolygon(name: string, options: {
  64109. shape: Vector3[];
  64110. holes?: Vector3[][];
  64111. depth?: number;
  64112. faceUV?: Vector4[];
  64113. faceColors?: Color4[];
  64114. updatable?: boolean;
  64115. sideOrientation?: number;
  64116. frontUVs?: Vector4;
  64117. backUVs?: Vector4;
  64118. wrap?: boolean;
  64119. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64120. /**
  64121. * Creates an extruded polygon mesh, with depth in the Y direction.
  64122. * * 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)
  64123. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  64128. * @returns the polygon mesh
  64129. */
  64130. static ExtrudePolygon(name: string, options: {
  64131. shape: Vector3[];
  64132. holes?: Vector3[][];
  64133. depth?: number;
  64134. faceUV?: Vector4[];
  64135. faceColors?: Color4[];
  64136. updatable?: boolean;
  64137. sideOrientation?: number;
  64138. frontUVs?: Vector4;
  64139. backUVs?: Vector4;
  64140. wrap?: boolean;
  64141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64142. }
  64143. }
  64144. declare module BABYLON {
  64145. /**
  64146. * Class containing static functions to help procedurally build meshes
  64147. */
  64148. export class LatheBuilder {
  64149. /**
  64150. * Creates lathe mesh.
  64151. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64152. * * 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
  64153. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64154. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64155. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64156. * * 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
  64157. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64158. * * 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
  64159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64160. * * 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
  64161. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64163. * @param name defines the name of the mesh
  64164. * @param options defines the options used to create the mesh
  64165. * @param scene defines the hosting scene
  64166. * @returns the lathe mesh
  64167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64168. */
  64169. static CreateLathe(name: string, options: {
  64170. shape: Vector3[];
  64171. radius?: number;
  64172. tessellation?: number;
  64173. clip?: number;
  64174. arc?: number;
  64175. closed?: boolean;
  64176. updatable?: boolean;
  64177. sideOrientation?: number;
  64178. frontUVs?: Vector4;
  64179. backUVs?: Vector4;
  64180. cap?: number;
  64181. invertUV?: boolean;
  64182. }, scene?: Nullable<Scene>): Mesh;
  64183. }
  64184. }
  64185. declare module BABYLON {
  64186. /**
  64187. * Class containing static functions to help procedurally build meshes
  64188. */
  64189. export class TiledPlaneBuilder {
  64190. /**
  64191. * Creates a tiled plane mesh
  64192. * * The parameter `pattern` will, depending on value, do nothing or
  64193. * * * flip (reflect about central vertical) alternate tiles across and up
  64194. * * * flip every tile on alternate rows
  64195. * * * rotate (180 degs) alternate tiles across and up
  64196. * * * rotate every tile on alternate rows
  64197. * * * flip and rotate alternate tiles across and up
  64198. * * * flip and rotate every tile on alternate rows
  64199. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64200. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64201. * * 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
  64202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64203. * * 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)
  64204. * * 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)
  64205. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  64210. */
  64211. static CreateTiledPlane(name: string, options: {
  64212. pattern?: number;
  64213. tileSize?: number;
  64214. tileWidth?: number;
  64215. tileHeight?: number;
  64216. size?: number;
  64217. width?: number;
  64218. height?: number;
  64219. alignHorizontal?: number;
  64220. alignVertical?: number;
  64221. sideOrientation?: number;
  64222. frontUVs?: Vector4;
  64223. backUVs?: Vector4;
  64224. updatable?: boolean;
  64225. }, scene?: Nullable<Scene>): Mesh;
  64226. }
  64227. }
  64228. declare module BABYLON {
  64229. /**
  64230. * Class containing static functions to help procedurally build meshes
  64231. */
  64232. export class TubeBuilder {
  64233. /**
  64234. * Creates a tube mesh.
  64235. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64236. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64237. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64238. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64239. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64240. * * 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)
  64241. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64242. * * 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
  64243. * * 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
  64244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64245. * * 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
  64246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64248. * @param name defines the name of the mesh
  64249. * @param options defines the options used to create the mesh
  64250. * @param scene defines the hosting scene
  64251. * @returns the tube mesh
  64252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64253. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64254. */
  64255. static CreateTube(name: string, options: {
  64256. path: Vector3[];
  64257. radius?: number;
  64258. tessellation?: number;
  64259. radiusFunction?: {
  64260. (i: number, distance: number): number;
  64261. };
  64262. cap?: number;
  64263. arc?: number;
  64264. updatable?: boolean;
  64265. sideOrientation?: number;
  64266. frontUVs?: Vector4;
  64267. backUVs?: Vector4;
  64268. instance?: Mesh;
  64269. invertUV?: boolean;
  64270. }, scene?: Nullable<Scene>): Mesh;
  64271. }
  64272. }
  64273. declare module BABYLON {
  64274. /**
  64275. * Class containing static functions to help procedurally build meshes
  64276. */
  64277. export class IcoSphereBuilder {
  64278. /**
  64279. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64280. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64281. * * 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`)
  64282. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64283. * * 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
  64284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64285. * * 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
  64286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64287. * @param name defines the name of the mesh
  64288. * @param options defines the options used to create the mesh
  64289. * @param scene defines the hosting scene
  64290. * @returns the icosahedron mesh
  64291. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64292. */
  64293. static CreateIcoSphere(name: string, options: {
  64294. radius?: number;
  64295. radiusX?: number;
  64296. radiusY?: number;
  64297. radiusZ?: number;
  64298. flat?: boolean;
  64299. subdivisions?: number;
  64300. sideOrientation?: number;
  64301. frontUVs?: Vector4;
  64302. backUVs?: Vector4;
  64303. updatable?: boolean;
  64304. }, scene?: Nullable<Scene>): Mesh;
  64305. }
  64306. }
  64307. declare module BABYLON {
  64308. /**
  64309. * Class containing static functions to help procedurally build meshes
  64310. */
  64311. export class DecalBuilder {
  64312. /**
  64313. * Creates a decal mesh.
  64314. * 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
  64315. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64316. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64317. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64318. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64319. * @param name defines the name of the mesh
  64320. * @param sourceMesh defines the mesh where the decal must be applied
  64321. * @param options defines the options used to create the mesh
  64322. * @param scene defines the hosting scene
  64323. * @returns the decal mesh
  64324. * @see https://doc.babylonjs.com/how_to/decals
  64325. */
  64326. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64327. position?: Vector3;
  64328. normal?: Vector3;
  64329. size?: Vector3;
  64330. angle?: number;
  64331. }): Mesh;
  64332. }
  64333. }
  64334. declare module BABYLON {
  64335. /**
  64336. * Class containing static functions to help procedurally build meshes
  64337. */
  64338. export class MeshBuilder {
  64339. /**
  64340. * Creates a box mesh
  64341. * * The parameter `size` sets the size (float) of each box side (default 1)
  64342. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64343. * * 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)
  64344. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64346. * * 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
  64347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64348. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64349. * @param name defines the name of the mesh
  64350. * @param options defines the options used to create the mesh
  64351. * @param scene defines the hosting scene
  64352. * @returns the box mesh
  64353. */
  64354. static CreateBox(name: string, options: {
  64355. size?: number;
  64356. width?: number;
  64357. height?: number;
  64358. depth?: number;
  64359. faceUV?: Vector4[];
  64360. faceColors?: Color4[];
  64361. sideOrientation?: number;
  64362. frontUVs?: Vector4;
  64363. backUVs?: Vector4;
  64364. wrap?: boolean;
  64365. topBaseAt?: number;
  64366. bottomBaseAt?: number;
  64367. updatable?: boolean;
  64368. }, scene?: Nullable<Scene>): Mesh;
  64369. /**
  64370. * Creates a tiled box mesh
  64371. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64373. * @param name defines the name of the mesh
  64374. * @param options defines the options used to create the mesh
  64375. * @param scene defines the hosting scene
  64376. * @returns the tiled box mesh
  64377. */
  64378. static CreateTiledBox(name: string, options: {
  64379. pattern?: number;
  64380. size?: number;
  64381. width?: number;
  64382. height?: number;
  64383. depth: number;
  64384. tileSize?: number;
  64385. tileWidth?: number;
  64386. tileHeight?: number;
  64387. faceUV?: Vector4[];
  64388. faceColors?: Color4[];
  64389. alignHorizontal?: number;
  64390. alignVertical?: number;
  64391. sideOrientation?: number;
  64392. updatable?: boolean;
  64393. }, scene?: Nullable<Scene>): Mesh;
  64394. /**
  64395. * Creates a sphere mesh
  64396. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64397. * * 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`)
  64398. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64399. * * 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
  64400. * * 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)
  64401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64402. * * 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
  64403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64404. * @param name defines the name of the mesh
  64405. * @param options defines the options used to create the mesh
  64406. * @param scene defines the hosting scene
  64407. * @returns the sphere mesh
  64408. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64409. */
  64410. static CreateSphere(name: string, options: {
  64411. segments?: number;
  64412. diameter?: number;
  64413. diameterX?: number;
  64414. diameterY?: number;
  64415. diameterZ?: number;
  64416. arc?: number;
  64417. slice?: number;
  64418. sideOrientation?: number;
  64419. frontUVs?: Vector4;
  64420. backUVs?: Vector4;
  64421. updatable?: boolean;
  64422. }, scene?: Nullable<Scene>): Mesh;
  64423. /**
  64424. * Creates a plane polygonal mesh. By default, this is a disc
  64425. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64426. * * 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
  64427. * * 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
  64428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64429. * * 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
  64430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64431. * @param name defines the name of the mesh
  64432. * @param options defines the options used to create the mesh
  64433. * @param scene defines the hosting scene
  64434. * @returns the plane polygonal mesh
  64435. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64436. */
  64437. static CreateDisc(name: string, options: {
  64438. radius?: number;
  64439. tessellation?: number;
  64440. arc?: number;
  64441. updatable?: boolean;
  64442. sideOrientation?: number;
  64443. frontUVs?: Vector4;
  64444. backUVs?: Vector4;
  64445. }, scene?: Nullable<Scene>): Mesh;
  64446. /**
  64447. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64448. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64449. * * 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`)
  64450. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64451. * * 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
  64452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64453. * * 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
  64454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64455. * @param name defines the name of the mesh
  64456. * @param options defines the options used to create the mesh
  64457. * @param scene defines the hosting scene
  64458. * @returns the icosahedron mesh
  64459. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64460. */
  64461. static CreateIcoSphere(name: string, options: {
  64462. radius?: number;
  64463. radiusX?: number;
  64464. radiusY?: number;
  64465. radiusZ?: number;
  64466. flat?: boolean;
  64467. subdivisions?: number;
  64468. sideOrientation?: number;
  64469. frontUVs?: Vector4;
  64470. backUVs?: Vector4;
  64471. updatable?: boolean;
  64472. }, scene?: Nullable<Scene>): Mesh;
  64473. /**
  64474. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64475. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64476. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64477. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64478. * * 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
  64479. * * 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
  64480. * * 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
  64481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64482. * * 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
  64483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64484. * * 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
  64485. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64486. * * 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
  64487. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64489. * @param name defines the name of the mesh
  64490. * @param options defines the options used to create the mesh
  64491. * @param scene defines the hosting scene
  64492. * @returns the ribbon mesh
  64493. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64495. */
  64496. static CreateRibbon(name: string, options: {
  64497. pathArray: Vector3[][];
  64498. closeArray?: boolean;
  64499. closePath?: boolean;
  64500. offset?: number;
  64501. updatable?: boolean;
  64502. sideOrientation?: number;
  64503. frontUVs?: Vector4;
  64504. backUVs?: Vector4;
  64505. instance?: Mesh;
  64506. invertUV?: boolean;
  64507. uvs?: Vector2[];
  64508. colors?: Color4[];
  64509. }, scene?: Nullable<Scene>): Mesh;
  64510. /**
  64511. * Creates a cylinder or a cone mesh
  64512. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64513. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64514. * * 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.
  64515. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64516. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64517. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64518. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64519. * * 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).
  64520. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64521. * * 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).
  64522. * * 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
  64523. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64524. * * 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
  64525. * * 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.
  64526. * * If `enclose` is false, a ring surface is one element.
  64527. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64528. * * 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
  64529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64530. * * 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
  64531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64532. * @param name defines the name of the mesh
  64533. * @param options defines the options used to create the mesh
  64534. * @param scene defines the hosting scene
  64535. * @returns the cylinder mesh
  64536. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64537. */
  64538. static CreateCylinder(name: string, options: {
  64539. height?: number;
  64540. diameterTop?: number;
  64541. diameterBottom?: number;
  64542. diameter?: number;
  64543. tessellation?: number;
  64544. subdivisions?: number;
  64545. arc?: number;
  64546. faceColors?: Color4[];
  64547. faceUV?: Vector4[];
  64548. updatable?: boolean;
  64549. hasRings?: boolean;
  64550. enclose?: boolean;
  64551. cap?: number;
  64552. sideOrientation?: number;
  64553. frontUVs?: Vector4;
  64554. backUVs?: Vector4;
  64555. }, scene?: Nullable<Scene>): Mesh;
  64556. /**
  64557. * Creates a torus mesh
  64558. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64559. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64560. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64562. * * 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
  64563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64564. * @param name defines the name of the mesh
  64565. * @param options defines the options used to create the mesh
  64566. * @param scene defines the hosting scene
  64567. * @returns the torus mesh
  64568. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64569. */
  64570. static CreateTorus(name: string, options: {
  64571. diameter?: number;
  64572. thickness?: number;
  64573. tessellation?: number;
  64574. updatable?: boolean;
  64575. sideOrientation?: number;
  64576. frontUVs?: Vector4;
  64577. backUVs?: Vector4;
  64578. }, scene?: Nullable<Scene>): Mesh;
  64579. /**
  64580. * Creates a torus knot mesh
  64581. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64582. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64583. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64584. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64586. * * 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
  64587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64588. * @param name defines the name of the mesh
  64589. * @param options defines the options used to create the mesh
  64590. * @param scene defines the hosting scene
  64591. * @returns the torus knot mesh
  64592. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64593. */
  64594. static CreateTorusKnot(name: string, options: {
  64595. radius?: number;
  64596. tube?: number;
  64597. radialSegments?: number;
  64598. tubularSegments?: number;
  64599. p?: number;
  64600. q?: number;
  64601. updatable?: boolean;
  64602. sideOrientation?: number;
  64603. frontUVs?: Vector4;
  64604. backUVs?: Vector4;
  64605. }, scene?: Nullable<Scene>): Mesh;
  64606. /**
  64607. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64608. * * 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
  64609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64610. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64611. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64612. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64613. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64614. * * 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
  64615. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64618. * @param name defines the name of the new line system
  64619. * @param options defines the options used to create the line system
  64620. * @param scene defines the hosting scene
  64621. * @returns a new line system mesh
  64622. */
  64623. static CreateLineSystem(name: string, options: {
  64624. lines: Vector3[][];
  64625. updatable?: boolean;
  64626. instance?: Nullable<LinesMesh>;
  64627. colors?: Nullable<Color4[][]>;
  64628. useVertexAlpha?: boolean;
  64629. }, scene: Nullable<Scene>): LinesMesh;
  64630. /**
  64631. * Creates a line mesh
  64632. * 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
  64633. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64634. * * The parameter `points` is an array successive Vector3
  64635. * * 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
  64636. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64637. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64638. * * When updating an instance, remember that only point positions can change, not the number of points
  64639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64641. * @param name defines the name of the new line system
  64642. * @param options defines the options used to create the line system
  64643. * @param scene defines the hosting scene
  64644. * @returns a new line mesh
  64645. */
  64646. static CreateLines(name: string, options: {
  64647. points: Vector3[];
  64648. updatable?: boolean;
  64649. instance?: Nullable<LinesMesh>;
  64650. colors?: Color4[];
  64651. useVertexAlpha?: boolean;
  64652. }, scene?: Nullable<Scene>): LinesMesh;
  64653. /**
  64654. * Creates a dashed line mesh
  64655. * * 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
  64656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64657. * * The parameter `points` is an array successive Vector3
  64658. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64659. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64660. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64661. * * 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
  64662. * * When updating an instance, remember that only point positions can change, not the number of points
  64663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64664. * @param name defines the name of the mesh
  64665. * @param options defines the options used to create the mesh
  64666. * @param scene defines the hosting scene
  64667. * @returns the dashed line mesh
  64668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64669. */
  64670. static CreateDashedLines(name: string, options: {
  64671. points: Vector3[];
  64672. dashSize?: number;
  64673. gapSize?: number;
  64674. dashNb?: number;
  64675. updatable?: boolean;
  64676. instance?: LinesMesh;
  64677. }, scene?: Nullable<Scene>): LinesMesh;
  64678. /**
  64679. * 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.
  64680. * * 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.
  64681. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64682. * * 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.
  64683. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64684. * * 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
  64685. * * 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
  64686. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64688. * * 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
  64689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64691. * @param name defines the name of the mesh
  64692. * @param options defines the options used to create the mesh
  64693. * @param scene defines the hosting scene
  64694. * @returns the extruded shape mesh
  64695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64697. */
  64698. static ExtrudeShape(name: string, options: {
  64699. shape: Vector3[];
  64700. path: Vector3[];
  64701. scale?: number;
  64702. rotation?: number;
  64703. cap?: number;
  64704. updatable?: boolean;
  64705. sideOrientation?: number;
  64706. frontUVs?: Vector4;
  64707. backUVs?: Vector4;
  64708. instance?: Mesh;
  64709. invertUV?: boolean;
  64710. }, scene?: Nullable<Scene>): Mesh;
  64711. /**
  64712. * Creates an custom extruded shape mesh.
  64713. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64714. * * 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.
  64715. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64716. * * 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
  64717. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64718. * * 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
  64719. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64720. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64721. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64722. * * 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
  64723. * * 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
  64724. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64726. * * 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
  64727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64729. * @param name defines the name of the mesh
  64730. * @param options defines the options used to create the mesh
  64731. * @param scene defines the hosting scene
  64732. * @returns the custom extruded shape mesh
  64733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64736. */
  64737. static ExtrudeShapeCustom(name: string, options: {
  64738. shape: Vector3[];
  64739. path: Vector3[];
  64740. scaleFunction?: any;
  64741. rotationFunction?: any;
  64742. ribbonCloseArray?: boolean;
  64743. ribbonClosePath?: boolean;
  64744. cap?: number;
  64745. updatable?: boolean;
  64746. sideOrientation?: number;
  64747. frontUVs?: Vector4;
  64748. backUVs?: Vector4;
  64749. instance?: Mesh;
  64750. invertUV?: boolean;
  64751. }, scene?: Nullable<Scene>): Mesh;
  64752. /**
  64753. * Creates lathe mesh.
  64754. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64755. * * 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
  64756. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64757. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64758. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64759. * * 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
  64760. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64761. * * 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
  64762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64763. * * 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
  64764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64766. * @param name defines the name of the mesh
  64767. * @param options defines the options used to create the mesh
  64768. * @param scene defines the hosting scene
  64769. * @returns the lathe mesh
  64770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64771. */
  64772. static CreateLathe(name: string, options: {
  64773. shape: Vector3[];
  64774. radius?: number;
  64775. tessellation?: number;
  64776. clip?: number;
  64777. arc?: number;
  64778. closed?: boolean;
  64779. updatable?: boolean;
  64780. sideOrientation?: number;
  64781. frontUVs?: Vector4;
  64782. backUVs?: Vector4;
  64783. cap?: number;
  64784. invertUV?: boolean;
  64785. }, scene?: Nullable<Scene>): Mesh;
  64786. /**
  64787. * Creates a tiled plane mesh
  64788. * * You can set a limited pattern arrangement with the tiles
  64789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64790. * * 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
  64791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64792. * @param name defines the name of the mesh
  64793. * @param options defines the options used to create the mesh
  64794. * @param scene defines the hosting scene
  64795. * @returns the plane mesh
  64796. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64797. */
  64798. static CreateTiledPlane(name: string, options: {
  64799. pattern?: number;
  64800. tileSize?: number;
  64801. tileWidth?: number;
  64802. tileHeight?: number;
  64803. size?: number;
  64804. width?: number;
  64805. height?: number;
  64806. alignHorizontal?: number;
  64807. alignVertical?: number;
  64808. sideOrientation?: number;
  64809. frontUVs?: Vector4;
  64810. backUVs?: Vector4;
  64811. updatable?: boolean;
  64812. }, scene?: Nullable<Scene>): Mesh;
  64813. /**
  64814. * Creates a plane mesh
  64815. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64816. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64817. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64819. * * 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
  64820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64821. * @param name defines the name of the mesh
  64822. * @param options defines the options used to create the mesh
  64823. * @param scene defines the hosting scene
  64824. * @returns the plane mesh
  64825. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64826. */
  64827. static CreatePlane(name: string, options: {
  64828. size?: number;
  64829. width?: number;
  64830. height?: number;
  64831. sideOrientation?: number;
  64832. frontUVs?: Vector4;
  64833. backUVs?: Vector4;
  64834. updatable?: boolean;
  64835. sourcePlane?: Plane;
  64836. }, scene?: Nullable<Scene>): Mesh;
  64837. /**
  64838. * Creates a ground mesh
  64839. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64840. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64842. * @param name defines the name of the mesh
  64843. * @param options defines the options used to create the mesh
  64844. * @param scene defines the hosting scene
  64845. * @returns the ground mesh
  64846. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64847. */
  64848. static CreateGround(name: string, options: {
  64849. width?: number;
  64850. height?: number;
  64851. subdivisions?: number;
  64852. subdivisionsX?: number;
  64853. subdivisionsY?: number;
  64854. updatable?: boolean;
  64855. }, scene?: Nullable<Scene>): Mesh;
  64856. /**
  64857. * Creates a tiled ground mesh
  64858. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64859. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64860. * * 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
  64861. * * 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
  64862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64863. * @param name defines the name of the mesh
  64864. * @param options defines the options used to create the mesh
  64865. * @param scene defines the hosting scene
  64866. * @returns the tiled ground mesh
  64867. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64868. */
  64869. static CreateTiledGround(name: string, options: {
  64870. xmin: number;
  64871. zmin: number;
  64872. xmax: number;
  64873. zmax: number;
  64874. subdivisions?: {
  64875. w: number;
  64876. h: number;
  64877. };
  64878. precision?: {
  64879. w: number;
  64880. h: number;
  64881. };
  64882. updatable?: boolean;
  64883. }, scene?: Nullable<Scene>): Mesh;
  64884. /**
  64885. * Creates a ground mesh from a height map
  64886. * * The parameter `url` sets the URL of the height map image resource.
  64887. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64888. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64889. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64890. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64891. * * 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.
  64892. * * 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).
  64893. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64895. * @param name defines the name of the mesh
  64896. * @param url defines the url to the height map
  64897. * @param options defines the options used to create the mesh
  64898. * @param scene defines the hosting scene
  64899. * @returns the ground mesh
  64900. * @see https://doc.babylonjs.com/babylon101/height_map
  64901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64902. */
  64903. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64904. width?: number;
  64905. height?: number;
  64906. subdivisions?: number;
  64907. minHeight?: number;
  64908. maxHeight?: number;
  64909. colorFilter?: Color3;
  64910. alphaFilter?: number;
  64911. updatable?: boolean;
  64912. onReady?: (mesh: GroundMesh) => void;
  64913. }, scene?: Nullable<Scene>): GroundMesh;
  64914. /**
  64915. * Creates a polygon mesh
  64916. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64917. * * 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
  64918. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64920. * * 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)
  64921. * * Remember you can only change the shape positions, not their number when updating a polygon
  64922. * @param name defines the name of the mesh
  64923. * @param options defines the options used to create the mesh
  64924. * @param scene defines the hosting scene
  64925. * @param earcutInjection can be used to inject your own earcut reference
  64926. * @returns the polygon mesh
  64927. */
  64928. static CreatePolygon(name: string, options: {
  64929. shape: Vector3[];
  64930. holes?: Vector3[][];
  64931. depth?: number;
  64932. faceUV?: Vector4[];
  64933. faceColors?: Color4[];
  64934. updatable?: boolean;
  64935. sideOrientation?: number;
  64936. frontUVs?: Vector4;
  64937. backUVs?: Vector4;
  64938. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64939. /**
  64940. * Creates an extruded polygon mesh, with depth in the Y direction.
  64941. * * 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)
  64942. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64943. * @param name defines the name of the mesh
  64944. * @param options defines the options used to create the mesh
  64945. * @param scene defines the hosting scene
  64946. * @param earcutInjection can be used to inject your own earcut reference
  64947. * @returns the polygon mesh
  64948. */
  64949. static ExtrudePolygon(name: string, options: {
  64950. shape: Vector3[];
  64951. holes?: Vector3[][];
  64952. depth?: number;
  64953. faceUV?: Vector4[];
  64954. faceColors?: Color4[];
  64955. updatable?: boolean;
  64956. sideOrientation?: number;
  64957. frontUVs?: Vector4;
  64958. backUVs?: Vector4;
  64959. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64960. /**
  64961. * Creates a tube mesh.
  64962. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64963. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64964. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64965. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64966. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64967. * * 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)
  64968. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64969. * * 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
  64970. * * 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
  64971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64972. * * 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
  64973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64975. * @param name defines the name of the mesh
  64976. * @param options defines the options used to create the mesh
  64977. * @param scene defines the hosting scene
  64978. * @returns the tube mesh
  64979. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64980. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64981. */
  64982. static CreateTube(name: string, options: {
  64983. path: Vector3[];
  64984. radius?: number;
  64985. tessellation?: number;
  64986. radiusFunction?: {
  64987. (i: number, distance: number): number;
  64988. };
  64989. cap?: number;
  64990. arc?: number;
  64991. updatable?: boolean;
  64992. sideOrientation?: number;
  64993. frontUVs?: Vector4;
  64994. backUVs?: Vector4;
  64995. instance?: Mesh;
  64996. invertUV?: boolean;
  64997. }, scene?: Nullable<Scene>): Mesh;
  64998. /**
  64999. * Creates a polyhedron mesh
  65000. * * 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
  65001. * * The parameter `size` (positive float, default 1) sets the polygon size
  65002. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65003. * * 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`
  65004. * * 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
  65005. * * 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)`)
  65006. * * 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
  65007. * * 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
  65008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65009. * * 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
  65010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65011. * @param name defines the name of the mesh
  65012. * @param options defines the options used to create the mesh
  65013. * @param scene defines the hosting scene
  65014. * @returns the polyhedron mesh
  65015. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65016. */
  65017. static CreatePolyhedron(name: string, options: {
  65018. type?: number;
  65019. size?: number;
  65020. sizeX?: number;
  65021. sizeY?: number;
  65022. sizeZ?: number;
  65023. custom?: any;
  65024. faceUV?: Vector4[];
  65025. faceColors?: Color4[];
  65026. flat?: boolean;
  65027. updatable?: boolean;
  65028. sideOrientation?: number;
  65029. frontUVs?: Vector4;
  65030. backUVs?: Vector4;
  65031. }, scene?: Nullable<Scene>): Mesh;
  65032. /**
  65033. * Creates a decal mesh.
  65034. * 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
  65035. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65036. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65037. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65038. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65039. * @param name defines the name of the mesh
  65040. * @param sourceMesh defines the mesh where the decal must be applied
  65041. * @param options defines the options used to create the mesh
  65042. * @param scene defines the hosting scene
  65043. * @returns the decal mesh
  65044. * @see https://doc.babylonjs.com/how_to/decals
  65045. */
  65046. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65047. position?: Vector3;
  65048. normal?: Vector3;
  65049. size?: Vector3;
  65050. angle?: number;
  65051. }): Mesh;
  65052. }
  65053. }
  65054. declare module BABYLON {
  65055. /**
  65056. * A simplifier interface for future simplification implementations
  65057. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65058. */
  65059. export interface ISimplifier {
  65060. /**
  65061. * Simplification of a given mesh according to the given settings.
  65062. * Since this requires computation, it is assumed that the function runs async.
  65063. * @param settings The settings of the simplification, including quality and distance
  65064. * @param successCallback A callback that will be called after the mesh was simplified.
  65065. * @param errorCallback in case of an error, this callback will be called. optional.
  65066. */
  65067. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65068. }
  65069. /**
  65070. * Expected simplification settings.
  65071. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65072. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65073. */
  65074. export interface ISimplificationSettings {
  65075. /**
  65076. * Gets or sets the expected quality
  65077. */
  65078. quality: number;
  65079. /**
  65080. * Gets or sets the distance when this optimized version should be used
  65081. */
  65082. distance: number;
  65083. /**
  65084. * Gets an already optimized mesh
  65085. */
  65086. optimizeMesh?: boolean;
  65087. }
  65088. /**
  65089. * Class used to specify simplification options
  65090. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65091. */
  65092. export class SimplificationSettings implements ISimplificationSettings {
  65093. /** expected quality */
  65094. quality: number;
  65095. /** distance when this optimized version should be used */
  65096. distance: number;
  65097. /** already optimized mesh */
  65098. optimizeMesh?: boolean | undefined;
  65099. /**
  65100. * Creates a SimplificationSettings
  65101. * @param quality expected quality
  65102. * @param distance distance when this optimized version should be used
  65103. * @param optimizeMesh already optimized mesh
  65104. */
  65105. constructor(
  65106. /** expected quality */
  65107. quality: number,
  65108. /** distance when this optimized version should be used */
  65109. distance: number,
  65110. /** already optimized mesh */
  65111. optimizeMesh?: boolean | undefined);
  65112. }
  65113. /**
  65114. * Interface used to define a simplification task
  65115. */
  65116. export interface ISimplificationTask {
  65117. /**
  65118. * Array of settings
  65119. */
  65120. settings: Array<ISimplificationSettings>;
  65121. /**
  65122. * Simplification type
  65123. */
  65124. simplificationType: SimplificationType;
  65125. /**
  65126. * Mesh to simplify
  65127. */
  65128. mesh: Mesh;
  65129. /**
  65130. * Callback called on success
  65131. */
  65132. successCallback?: () => void;
  65133. /**
  65134. * Defines if parallel processing can be used
  65135. */
  65136. parallelProcessing: boolean;
  65137. }
  65138. /**
  65139. * Queue used to order the simplification tasks
  65140. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65141. */
  65142. export class SimplificationQueue {
  65143. private _simplificationArray;
  65144. /**
  65145. * Gets a boolean indicating that the process is still running
  65146. */
  65147. running: boolean;
  65148. /**
  65149. * Creates a new queue
  65150. */
  65151. constructor();
  65152. /**
  65153. * Adds a new simplification task
  65154. * @param task defines a task to add
  65155. */
  65156. addTask(task: ISimplificationTask): void;
  65157. /**
  65158. * Execute next task
  65159. */
  65160. executeNext(): void;
  65161. /**
  65162. * Execute a simplification task
  65163. * @param task defines the task to run
  65164. */
  65165. runSimplification(task: ISimplificationTask): void;
  65166. private getSimplifier;
  65167. }
  65168. /**
  65169. * The implemented types of simplification
  65170. * At the moment only Quadratic Error Decimation is implemented
  65171. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65172. */
  65173. export enum SimplificationType {
  65174. /** Quadratic error decimation */
  65175. QUADRATIC = 0
  65176. }
  65177. /**
  65178. * An implementation of the Quadratic Error simplification algorithm.
  65179. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65180. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65181. * @author RaananW
  65182. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65183. */
  65184. export class QuadraticErrorSimplification implements ISimplifier {
  65185. private _mesh;
  65186. private triangles;
  65187. private vertices;
  65188. private references;
  65189. private _reconstructedMesh;
  65190. /** Gets or sets the number pf sync interations */
  65191. syncIterations: number;
  65192. /** Gets or sets the aggressiveness of the simplifier */
  65193. aggressiveness: number;
  65194. /** Gets or sets the number of allowed iterations for decimation */
  65195. decimationIterations: number;
  65196. /** Gets or sets the espilon to use for bounding box computation */
  65197. boundingBoxEpsilon: number;
  65198. /**
  65199. * Creates a new QuadraticErrorSimplification
  65200. * @param _mesh defines the target mesh
  65201. */
  65202. constructor(_mesh: Mesh);
  65203. /**
  65204. * Simplification of a given mesh according to the given settings.
  65205. * Since this requires computation, it is assumed that the function runs async.
  65206. * @param settings The settings of the simplification, including quality and distance
  65207. * @param successCallback A callback that will be called after the mesh was simplified.
  65208. */
  65209. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65210. private runDecimation;
  65211. private initWithMesh;
  65212. private init;
  65213. private reconstructMesh;
  65214. private initDecimatedMesh;
  65215. private isFlipped;
  65216. private updateTriangles;
  65217. private identifyBorder;
  65218. private updateMesh;
  65219. private vertexError;
  65220. private calculateError;
  65221. }
  65222. }
  65223. declare module BABYLON {
  65224. interface Scene {
  65225. /** @hidden (Backing field) */
  65226. _simplificationQueue: SimplificationQueue;
  65227. /**
  65228. * Gets or sets the simplification queue attached to the scene
  65229. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65230. */
  65231. simplificationQueue: SimplificationQueue;
  65232. }
  65233. interface Mesh {
  65234. /**
  65235. * Simplify the mesh according to the given array of settings.
  65236. * Function will return immediately and will simplify async
  65237. * @param settings a collection of simplification settings
  65238. * @param parallelProcessing should all levels calculate parallel or one after the other
  65239. * @param simplificationType the type of simplification to run
  65240. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65241. * @returns the current mesh
  65242. */
  65243. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65244. }
  65245. /**
  65246. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65247. * created in a scene
  65248. */
  65249. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65250. /**
  65251. * The component name helpfull to identify the component in the list of scene components.
  65252. */
  65253. readonly name: string;
  65254. /**
  65255. * The scene the component belongs to.
  65256. */
  65257. scene: Scene;
  65258. /**
  65259. * Creates a new instance of the component for the given scene
  65260. * @param scene Defines the scene to register the component in
  65261. */
  65262. constructor(scene: Scene);
  65263. /**
  65264. * Registers the component in a given scene
  65265. */
  65266. register(): void;
  65267. /**
  65268. * Rebuilds the elements related to this component in case of
  65269. * context lost for instance.
  65270. */
  65271. rebuild(): void;
  65272. /**
  65273. * Disposes the component and the associated ressources
  65274. */
  65275. dispose(): void;
  65276. private _beforeCameraUpdate;
  65277. }
  65278. }
  65279. declare module BABYLON {
  65280. interface Mesh {
  65281. /**
  65282. * Creates a new thin instance
  65283. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65284. * @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
  65285. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65286. */
  65287. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65288. /**
  65289. * Adds the transformation (matrix) of the current mesh as a thin instance
  65290. * @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
  65291. * @returns the thin instance index number
  65292. */
  65293. thinInstanceAddSelf(refresh: boolean): number;
  65294. /**
  65295. * Registers a custom attribute to be used with thin instances
  65296. * @param kind name of the attribute
  65297. * @param stride size in floats of the attribute
  65298. */
  65299. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65300. /**
  65301. * Sets the matrix of a thin instance
  65302. * @param index index of the thin instance
  65303. * @param matrix matrix to set
  65304. * @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
  65305. */
  65306. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65307. /**
  65308. * Sets the value of a custom attribute for a thin instance
  65309. * @param kind name of the attribute
  65310. * @param index index of the thin instance
  65311. * @param value value to set
  65312. * @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
  65313. */
  65314. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65315. /**
  65316. * 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.
  65317. */
  65318. thinInstanceCount: number;
  65319. /**
  65320. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65321. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65322. * @param buffer buffer to set
  65323. * @param stride size in floats of each value of the buffer
  65324. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65325. */
  65326. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65327. /**
  65328. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65329. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65330. */
  65331. thinInstanceBufferUpdated(kind: string): void;
  65332. /**
  65333. * Refreshes the bounding info, taking into account all the thin instances defined
  65334. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65335. */
  65336. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65337. /** @hidden */
  65338. _thinInstanceInitializeUserStorage(): void;
  65339. /** @hidden */
  65340. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65341. /** @hidden */
  65342. _userThinInstanceBuffersStorage: {
  65343. data: {
  65344. [key: string]: Float32Array;
  65345. };
  65346. sizes: {
  65347. [key: string]: number;
  65348. };
  65349. vertexBuffers: {
  65350. [key: string]: Nullable<VertexBuffer>;
  65351. };
  65352. strides: {
  65353. [key: string]: number;
  65354. };
  65355. };
  65356. }
  65357. }
  65358. declare module BABYLON {
  65359. /**
  65360. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65361. */
  65362. export interface INavigationEnginePlugin {
  65363. /**
  65364. * plugin name
  65365. */
  65366. name: string;
  65367. /**
  65368. * Creates a navigation mesh
  65369. * @param meshes array of all the geometry used to compute the navigatio mesh
  65370. * @param parameters bunch of parameters used to filter geometry
  65371. */
  65372. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65373. /**
  65374. * Create a navigation mesh debug mesh
  65375. * @param scene is where the mesh will be added
  65376. * @returns debug display mesh
  65377. */
  65378. createDebugNavMesh(scene: Scene): Mesh;
  65379. /**
  65380. * Get a navigation mesh constrained position, closest to the parameter position
  65381. * @param position world position
  65382. * @returns the closest point to position constrained by the navigation mesh
  65383. */
  65384. getClosestPoint(position: Vector3): Vector3;
  65385. /**
  65386. * Get a navigation mesh constrained position, closest to the parameter position
  65387. * @param position world position
  65388. * @param result output the closest point to position constrained by the navigation mesh
  65389. */
  65390. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65391. /**
  65392. * Get a navigation mesh constrained position, within a particular radius
  65393. * @param position world position
  65394. * @param maxRadius the maximum distance to the constrained world position
  65395. * @returns the closest point to position constrained by the navigation mesh
  65396. */
  65397. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65398. /**
  65399. * Get a navigation mesh constrained position, within a particular radius
  65400. * @param position world position
  65401. * @param maxRadius the maximum distance to the constrained world position
  65402. * @param result output the closest point to position constrained by the navigation mesh
  65403. */
  65404. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65405. /**
  65406. * Compute the final position from a segment made of destination-position
  65407. * @param position world position
  65408. * @param destination world position
  65409. * @returns the resulting point along the navmesh
  65410. */
  65411. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65412. /**
  65413. * Compute the final position from a segment made of destination-position
  65414. * @param position world position
  65415. * @param destination world position
  65416. * @param result output the resulting point along the navmesh
  65417. */
  65418. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65419. /**
  65420. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65421. * @param start world position
  65422. * @param end world position
  65423. * @returns array containing world position composing the path
  65424. */
  65425. computePath(start: Vector3, end: Vector3): Vector3[];
  65426. /**
  65427. * If this plugin is supported
  65428. * @returns true if plugin is supported
  65429. */
  65430. isSupported(): boolean;
  65431. /**
  65432. * Create a new Crowd so you can add agents
  65433. * @param maxAgents the maximum agent count in the crowd
  65434. * @param maxAgentRadius the maximum radius an agent can have
  65435. * @param scene to attach the crowd to
  65436. * @returns the crowd you can add agents to
  65437. */
  65438. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65439. /**
  65440. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65441. * The queries will try to find a solution within those bounds
  65442. * default is (1,1,1)
  65443. * @param extent x,y,z value that define the extent around the queries point of reference
  65444. */
  65445. setDefaultQueryExtent(extent: Vector3): void;
  65446. /**
  65447. * Get the Bounding box extent specified by setDefaultQueryExtent
  65448. * @returns the box extent values
  65449. */
  65450. getDefaultQueryExtent(): Vector3;
  65451. /**
  65452. * build the navmesh from a previously saved state using getNavmeshData
  65453. * @param data the Uint8Array returned by getNavmeshData
  65454. */
  65455. buildFromNavmeshData(data: Uint8Array): void;
  65456. /**
  65457. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65458. * @returns data the Uint8Array that can be saved and reused
  65459. */
  65460. getNavmeshData(): Uint8Array;
  65461. /**
  65462. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65463. * @param result output the box extent values
  65464. */
  65465. getDefaultQueryExtentToRef(result: Vector3): void;
  65466. /**
  65467. * Release all resources
  65468. */
  65469. dispose(): void;
  65470. }
  65471. /**
  65472. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65473. */
  65474. export interface ICrowd {
  65475. /**
  65476. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65477. * You can attach anything to that node. The node position is updated in the scene update tick.
  65478. * @param pos world position that will be constrained by the navigation mesh
  65479. * @param parameters agent parameters
  65480. * @param transform hooked to the agent that will be update by the scene
  65481. * @returns agent index
  65482. */
  65483. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65484. /**
  65485. * Returns the agent position in world space
  65486. * @param index agent index returned by addAgent
  65487. * @returns world space position
  65488. */
  65489. getAgentPosition(index: number): Vector3;
  65490. /**
  65491. * Gets the agent position result in world space
  65492. * @param index agent index returned by addAgent
  65493. * @param result output world space position
  65494. */
  65495. getAgentPositionToRef(index: number, result: Vector3): void;
  65496. /**
  65497. * Gets the agent velocity in world space
  65498. * @param index agent index returned by addAgent
  65499. * @returns world space velocity
  65500. */
  65501. getAgentVelocity(index: number): Vector3;
  65502. /**
  65503. * Gets the agent velocity result in world space
  65504. * @param index agent index returned by addAgent
  65505. * @param result output world space velocity
  65506. */
  65507. getAgentVelocityToRef(index: number, result: Vector3): void;
  65508. /**
  65509. * remove a particular agent previously created
  65510. * @param index agent index returned by addAgent
  65511. */
  65512. removeAgent(index: number): void;
  65513. /**
  65514. * get the list of all agents attached to this crowd
  65515. * @returns list of agent indices
  65516. */
  65517. getAgents(): number[];
  65518. /**
  65519. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65520. * @param deltaTime in seconds
  65521. */
  65522. update(deltaTime: number): void;
  65523. /**
  65524. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65525. * @param index agent index returned by addAgent
  65526. * @param destination targeted world position
  65527. */
  65528. agentGoto(index: number, destination: Vector3): void;
  65529. /**
  65530. * Teleport the agent to a new position
  65531. * @param index agent index returned by addAgent
  65532. * @param destination targeted world position
  65533. */
  65534. agentTeleport(index: number, destination: Vector3): void;
  65535. /**
  65536. * Update agent parameters
  65537. * @param index agent index returned by addAgent
  65538. * @param parameters agent parameters
  65539. */
  65540. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65541. /**
  65542. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65543. * The queries will try to find a solution within those bounds
  65544. * default is (1,1,1)
  65545. * @param extent x,y,z value that define the extent around the queries point of reference
  65546. */
  65547. setDefaultQueryExtent(extent: Vector3): void;
  65548. /**
  65549. * Get the Bounding box extent specified by setDefaultQueryExtent
  65550. * @returns the box extent values
  65551. */
  65552. getDefaultQueryExtent(): Vector3;
  65553. /**
  65554. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65555. * @param result output the box extent values
  65556. */
  65557. getDefaultQueryExtentToRef(result: Vector3): void;
  65558. /**
  65559. * Release all resources
  65560. */
  65561. dispose(): void;
  65562. }
  65563. /**
  65564. * Configures an agent
  65565. */
  65566. export interface IAgentParameters {
  65567. /**
  65568. * Agent radius. [Limit: >= 0]
  65569. */
  65570. radius: number;
  65571. /**
  65572. * Agent height. [Limit: > 0]
  65573. */
  65574. height: number;
  65575. /**
  65576. * Maximum allowed acceleration. [Limit: >= 0]
  65577. */
  65578. maxAcceleration: number;
  65579. /**
  65580. * Maximum allowed speed. [Limit: >= 0]
  65581. */
  65582. maxSpeed: number;
  65583. /**
  65584. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65585. */
  65586. collisionQueryRange: number;
  65587. /**
  65588. * The path visibility optimization range. [Limit: > 0]
  65589. */
  65590. pathOptimizationRange: number;
  65591. /**
  65592. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65593. */
  65594. separationWeight: number;
  65595. }
  65596. /**
  65597. * Configures the navigation mesh creation
  65598. */
  65599. export interface INavMeshParameters {
  65600. /**
  65601. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65602. */
  65603. cs: number;
  65604. /**
  65605. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65606. */
  65607. ch: number;
  65608. /**
  65609. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65610. */
  65611. walkableSlopeAngle: number;
  65612. /**
  65613. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65614. * be considered walkable. [Limit: >= 3] [Units: vx]
  65615. */
  65616. walkableHeight: number;
  65617. /**
  65618. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65619. */
  65620. walkableClimb: number;
  65621. /**
  65622. * The distance to erode/shrink the walkable area of the heightfield away from
  65623. * obstructions. [Limit: >=0] [Units: vx]
  65624. */
  65625. walkableRadius: number;
  65626. /**
  65627. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65628. */
  65629. maxEdgeLen: number;
  65630. /**
  65631. * The maximum distance a simplfied contour's border edges should deviate
  65632. * the original raw contour. [Limit: >=0] [Units: vx]
  65633. */
  65634. maxSimplificationError: number;
  65635. /**
  65636. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65637. */
  65638. minRegionArea: number;
  65639. /**
  65640. * Any regions with a span count smaller than this value will, if possible,
  65641. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65642. */
  65643. mergeRegionArea: number;
  65644. /**
  65645. * The maximum number of vertices allowed for polygons generated during the
  65646. * contour to polygon conversion process. [Limit: >= 3]
  65647. */
  65648. maxVertsPerPoly: number;
  65649. /**
  65650. * Sets the sampling distance to use when generating the detail mesh.
  65651. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65652. */
  65653. detailSampleDist: number;
  65654. /**
  65655. * The maximum distance the detail mesh surface should deviate from heightfield
  65656. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65657. */
  65658. detailSampleMaxError: number;
  65659. }
  65660. }
  65661. declare module BABYLON {
  65662. /**
  65663. * RecastJS navigation plugin
  65664. */
  65665. export class RecastJSPlugin implements INavigationEnginePlugin {
  65666. /**
  65667. * Reference to the Recast library
  65668. */
  65669. bjsRECAST: any;
  65670. /**
  65671. * plugin name
  65672. */
  65673. name: string;
  65674. /**
  65675. * the first navmesh created. We might extend this to support multiple navmeshes
  65676. */
  65677. navMesh: any;
  65678. /**
  65679. * Initializes the recastJS plugin
  65680. * @param recastInjection can be used to inject your own recast reference
  65681. */
  65682. constructor(recastInjection?: any);
  65683. /**
  65684. * Creates a navigation mesh
  65685. * @param meshes array of all the geometry used to compute the navigatio mesh
  65686. * @param parameters bunch of parameters used to filter geometry
  65687. */
  65688. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65689. /**
  65690. * Create a navigation mesh debug mesh
  65691. * @param scene is where the mesh will be added
  65692. * @returns debug display mesh
  65693. */
  65694. createDebugNavMesh(scene: Scene): Mesh;
  65695. /**
  65696. * Get a navigation mesh constrained position, closest to the parameter position
  65697. * @param position world position
  65698. * @returns the closest point to position constrained by the navigation mesh
  65699. */
  65700. getClosestPoint(position: Vector3): Vector3;
  65701. /**
  65702. * Get a navigation mesh constrained position, closest to the parameter position
  65703. * @param position world position
  65704. * @param result output the closest point to position constrained by the navigation mesh
  65705. */
  65706. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65707. /**
  65708. * Get a navigation mesh constrained position, within a particular radius
  65709. * @param position world position
  65710. * @param maxRadius the maximum distance to the constrained world position
  65711. * @returns the closest point to position constrained by the navigation mesh
  65712. */
  65713. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65714. /**
  65715. * Get a navigation mesh constrained position, within a particular radius
  65716. * @param position world position
  65717. * @param maxRadius the maximum distance to the constrained world position
  65718. * @param result output the closest point to position constrained by the navigation mesh
  65719. */
  65720. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65721. /**
  65722. * Compute the final position from a segment made of destination-position
  65723. * @param position world position
  65724. * @param destination world position
  65725. * @returns the resulting point along the navmesh
  65726. */
  65727. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65728. /**
  65729. * Compute the final position from a segment made of destination-position
  65730. * @param position world position
  65731. * @param destination world position
  65732. * @param result output the resulting point along the navmesh
  65733. */
  65734. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65735. /**
  65736. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65737. * @param start world position
  65738. * @param end world position
  65739. * @returns array containing world position composing the path
  65740. */
  65741. computePath(start: Vector3, end: Vector3): Vector3[];
  65742. /**
  65743. * Create a new Crowd so you can add agents
  65744. * @param maxAgents the maximum agent count in the crowd
  65745. * @param maxAgentRadius the maximum radius an agent can have
  65746. * @param scene to attach the crowd to
  65747. * @returns the crowd you can add agents to
  65748. */
  65749. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65750. /**
  65751. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65752. * The queries will try to find a solution within those bounds
  65753. * default is (1,1,1)
  65754. * @param extent x,y,z value that define the extent around the queries point of reference
  65755. */
  65756. setDefaultQueryExtent(extent: Vector3): void;
  65757. /**
  65758. * Get the Bounding box extent specified by setDefaultQueryExtent
  65759. * @returns the box extent values
  65760. */
  65761. getDefaultQueryExtent(): Vector3;
  65762. /**
  65763. * build the navmesh from a previously saved state using getNavmeshData
  65764. * @param data the Uint8Array returned by getNavmeshData
  65765. */
  65766. buildFromNavmeshData(data: Uint8Array): void;
  65767. /**
  65768. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65769. * @returns data the Uint8Array that can be saved and reused
  65770. */
  65771. getNavmeshData(): Uint8Array;
  65772. /**
  65773. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65774. * @param result output the box extent values
  65775. */
  65776. getDefaultQueryExtentToRef(result: Vector3): void;
  65777. /**
  65778. * Disposes
  65779. */
  65780. dispose(): void;
  65781. /**
  65782. * If this plugin is supported
  65783. * @returns true if plugin is supported
  65784. */
  65785. isSupported(): boolean;
  65786. }
  65787. /**
  65788. * Recast detour crowd implementation
  65789. */
  65790. export class RecastJSCrowd implements ICrowd {
  65791. /**
  65792. * Recast/detour plugin
  65793. */
  65794. bjsRECASTPlugin: RecastJSPlugin;
  65795. /**
  65796. * Link to the detour crowd
  65797. */
  65798. recastCrowd: any;
  65799. /**
  65800. * One transform per agent
  65801. */
  65802. transforms: TransformNode[];
  65803. /**
  65804. * All agents created
  65805. */
  65806. agents: number[];
  65807. /**
  65808. * Link to the scene is kept to unregister the crowd from the scene
  65809. */
  65810. private _scene;
  65811. /**
  65812. * Observer for crowd updates
  65813. */
  65814. private _onBeforeAnimationsObserver;
  65815. /**
  65816. * Constructor
  65817. * @param plugin recastJS plugin
  65818. * @param maxAgents the maximum agent count in the crowd
  65819. * @param maxAgentRadius the maximum radius an agent can have
  65820. * @param scene to attach the crowd to
  65821. * @returns the crowd you can add agents to
  65822. */
  65823. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65824. /**
  65825. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65826. * You can attach anything to that node. The node position is updated in the scene update tick.
  65827. * @param pos world position that will be constrained by the navigation mesh
  65828. * @param parameters agent parameters
  65829. * @param transform hooked to the agent that will be update by the scene
  65830. * @returns agent index
  65831. */
  65832. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65833. /**
  65834. * Returns the agent position in world space
  65835. * @param index agent index returned by addAgent
  65836. * @returns world space position
  65837. */
  65838. getAgentPosition(index: number): Vector3;
  65839. /**
  65840. * Returns the agent position result in world space
  65841. * @param index agent index returned by addAgent
  65842. * @param result output world space position
  65843. */
  65844. getAgentPositionToRef(index: number, result: Vector3): void;
  65845. /**
  65846. * Returns the agent velocity in world space
  65847. * @param index agent index returned by addAgent
  65848. * @returns world space velocity
  65849. */
  65850. getAgentVelocity(index: number): Vector3;
  65851. /**
  65852. * Returns the agent velocity result in world space
  65853. * @param index agent index returned by addAgent
  65854. * @param result output world space velocity
  65855. */
  65856. getAgentVelocityToRef(index: number, result: Vector3): void;
  65857. /**
  65858. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65859. * @param index agent index returned by addAgent
  65860. * @param destination targeted world position
  65861. */
  65862. agentGoto(index: number, destination: Vector3): void;
  65863. /**
  65864. * Teleport the agent to a new position
  65865. * @param index agent index returned by addAgent
  65866. * @param destination targeted world position
  65867. */
  65868. agentTeleport(index: number, destination: Vector3): void;
  65869. /**
  65870. * Update agent parameters
  65871. * @param index agent index returned by addAgent
  65872. * @param parameters agent parameters
  65873. */
  65874. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65875. /**
  65876. * remove a particular agent previously created
  65877. * @param index agent index returned by addAgent
  65878. */
  65879. removeAgent(index: number): void;
  65880. /**
  65881. * get the list of all agents attached to this crowd
  65882. * @returns list of agent indices
  65883. */
  65884. getAgents(): number[];
  65885. /**
  65886. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65887. * @param deltaTime in seconds
  65888. */
  65889. update(deltaTime: number): void;
  65890. /**
  65891. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65892. * The queries will try to find a solution within those bounds
  65893. * default is (1,1,1)
  65894. * @param extent x,y,z value that define the extent around the queries point of reference
  65895. */
  65896. setDefaultQueryExtent(extent: Vector3): void;
  65897. /**
  65898. * Get the Bounding box extent specified by setDefaultQueryExtent
  65899. * @returns the box extent values
  65900. */
  65901. getDefaultQueryExtent(): Vector3;
  65902. /**
  65903. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65904. * @param result output the box extent values
  65905. */
  65906. getDefaultQueryExtentToRef(result: Vector3): void;
  65907. /**
  65908. * Release all resources
  65909. */
  65910. dispose(): void;
  65911. }
  65912. }
  65913. declare module BABYLON {
  65914. /**
  65915. * Class used to enable access to IndexedDB
  65916. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65917. */
  65918. export class Database implements IOfflineProvider {
  65919. private _callbackManifestChecked;
  65920. private _currentSceneUrl;
  65921. private _db;
  65922. private _enableSceneOffline;
  65923. private _enableTexturesOffline;
  65924. private _manifestVersionFound;
  65925. private _mustUpdateRessources;
  65926. private _hasReachedQuota;
  65927. private _isSupported;
  65928. private _idbFactory;
  65929. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65930. private static IsUASupportingBlobStorage;
  65931. /**
  65932. * Gets a boolean indicating if Database storate is enabled (off by default)
  65933. */
  65934. static IDBStorageEnabled: boolean;
  65935. /**
  65936. * Gets a boolean indicating if scene must be saved in the database
  65937. */
  65938. get enableSceneOffline(): boolean;
  65939. /**
  65940. * Gets a boolean indicating if textures must be saved in the database
  65941. */
  65942. get enableTexturesOffline(): boolean;
  65943. /**
  65944. * Creates a new Database
  65945. * @param urlToScene defines the url to load the scene
  65946. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65947. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65948. */
  65949. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65950. private static _ParseURL;
  65951. private static _ReturnFullUrlLocation;
  65952. private _checkManifestFile;
  65953. /**
  65954. * Open the database and make it available
  65955. * @param successCallback defines the callback to call on success
  65956. * @param errorCallback defines the callback to call on error
  65957. */
  65958. open(successCallback: () => void, errorCallback: () => void): void;
  65959. /**
  65960. * Loads an image from the database
  65961. * @param url defines the url to load from
  65962. * @param image defines the target DOM image
  65963. */
  65964. loadImage(url: string, image: HTMLImageElement): void;
  65965. private _loadImageFromDBAsync;
  65966. private _saveImageIntoDBAsync;
  65967. private _checkVersionFromDB;
  65968. private _loadVersionFromDBAsync;
  65969. private _saveVersionIntoDBAsync;
  65970. /**
  65971. * Loads a file from database
  65972. * @param url defines the URL to load from
  65973. * @param sceneLoaded defines a callback to call on success
  65974. * @param progressCallBack defines a callback to call when progress changed
  65975. * @param errorCallback defines a callback to call on error
  65976. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65977. */
  65978. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65979. private _loadFileAsync;
  65980. private _saveFileAsync;
  65981. /**
  65982. * Validates if xhr data is correct
  65983. * @param xhr defines the request to validate
  65984. * @param dataType defines the expected data type
  65985. * @returns true if data is correct
  65986. */
  65987. private static _ValidateXHRData;
  65988. }
  65989. }
  65990. declare module BABYLON {
  65991. /** @hidden */
  65992. export var gpuUpdateParticlesPixelShader: {
  65993. name: string;
  65994. shader: string;
  65995. };
  65996. }
  65997. declare module BABYLON {
  65998. /** @hidden */
  65999. export var gpuUpdateParticlesVertexShader: {
  66000. name: string;
  66001. shader: string;
  66002. };
  66003. }
  66004. declare module BABYLON {
  66005. /** @hidden */
  66006. export var clipPlaneFragmentDeclaration2: {
  66007. name: string;
  66008. shader: string;
  66009. };
  66010. }
  66011. declare module BABYLON {
  66012. /** @hidden */
  66013. export var gpuRenderParticlesPixelShader: {
  66014. name: string;
  66015. shader: string;
  66016. };
  66017. }
  66018. declare module BABYLON {
  66019. /** @hidden */
  66020. export var clipPlaneVertexDeclaration2: {
  66021. name: string;
  66022. shader: string;
  66023. };
  66024. }
  66025. declare module BABYLON {
  66026. /** @hidden */
  66027. export var gpuRenderParticlesVertexShader: {
  66028. name: string;
  66029. shader: string;
  66030. };
  66031. }
  66032. declare module BABYLON {
  66033. /**
  66034. * This represents a GPU particle system in Babylon
  66035. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66036. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66037. */
  66038. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66039. /**
  66040. * The layer mask we are rendering the particles through.
  66041. */
  66042. layerMask: number;
  66043. private _capacity;
  66044. private _activeCount;
  66045. private _currentActiveCount;
  66046. private _accumulatedCount;
  66047. private _renderEffect;
  66048. private _updateEffect;
  66049. private _buffer0;
  66050. private _buffer1;
  66051. private _spriteBuffer;
  66052. private _updateVAO;
  66053. private _renderVAO;
  66054. private _targetIndex;
  66055. private _sourceBuffer;
  66056. private _targetBuffer;
  66057. private _engine;
  66058. private _currentRenderId;
  66059. private _started;
  66060. private _stopped;
  66061. private _timeDelta;
  66062. private _randomTexture;
  66063. private _randomTexture2;
  66064. private _attributesStrideSize;
  66065. private _updateEffectOptions;
  66066. private _randomTextureSize;
  66067. private _actualFrame;
  66068. private _customEffect;
  66069. private readonly _rawTextureWidth;
  66070. /**
  66071. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66072. */
  66073. static get IsSupported(): boolean;
  66074. /**
  66075. * An event triggered when the system is disposed.
  66076. */
  66077. onDisposeObservable: Observable<IParticleSystem>;
  66078. /**
  66079. * Gets the maximum number of particles active at the same time.
  66080. * @returns The max number of active particles.
  66081. */
  66082. getCapacity(): number;
  66083. /**
  66084. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66085. * to override the particles.
  66086. */
  66087. forceDepthWrite: boolean;
  66088. /**
  66089. * Gets or set the number of active particles
  66090. */
  66091. get activeParticleCount(): number;
  66092. set activeParticleCount(value: number);
  66093. private _preWarmDone;
  66094. /**
  66095. * Specifies if the particles are updated in emitter local space or world space.
  66096. */
  66097. isLocal: boolean;
  66098. /**
  66099. * Is this system ready to be used/rendered
  66100. * @return true if the system is ready
  66101. */
  66102. isReady(): boolean;
  66103. /**
  66104. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66105. * @returns True if it has been started, otherwise false.
  66106. */
  66107. isStarted(): boolean;
  66108. /**
  66109. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66110. * @returns True if it has been stopped, otherwise false.
  66111. */
  66112. isStopped(): boolean;
  66113. /**
  66114. * Gets a boolean indicating that the system is stopping
  66115. * @returns true if the system is currently stopping
  66116. */
  66117. isStopping(): boolean;
  66118. /**
  66119. * Gets the number of particles active at the same time.
  66120. * @returns The number of active particles.
  66121. */
  66122. getActiveCount(): number;
  66123. /**
  66124. * Starts the particle system and begins to emit
  66125. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66126. */
  66127. start(delay?: number): void;
  66128. /**
  66129. * Stops the particle system.
  66130. */
  66131. stop(): void;
  66132. /**
  66133. * Remove all active particles
  66134. */
  66135. reset(): void;
  66136. /**
  66137. * Returns the string "GPUParticleSystem"
  66138. * @returns a string containing the class name
  66139. */
  66140. getClassName(): string;
  66141. /**
  66142. * Gets the custom effect used to render the particles
  66143. * @param blendMode Blend mode for which the effect should be retrieved
  66144. * @returns The effect
  66145. */
  66146. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66147. /**
  66148. * Sets the custom effect used to render the particles
  66149. * @param effect The effect to set
  66150. * @param blendMode Blend mode for which the effect should be set
  66151. */
  66152. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66153. /** @hidden */
  66154. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66155. /**
  66156. * Observable that will be called just before the particles are drawn
  66157. */
  66158. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66159. /**
  66160. * Gets the name of the particle vertex shader
  66161. */
  66162. get vertexShaderName(): string;
  66163. private _colorGradientsTexture;
  66164. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66165. /**
  66166. * Adds a new color gradient
  66167. * @param gradient defines the gradient to use (between 0 and 1)
  66168. * @param color1 defines the color to affect to the specified gradient
  66169. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66170. * @returns the current particle system
  66171. */
  66172. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66173. private _refreshColorGradient;
  66174. /** Force the system to rebuild all gradients that need to be resync */
  66175. forceRefreshGradients(): void;
  66176. /**
  66177. * Remove a specific color gradient
  66178. * @param gradient defines the gradient to remove
  66179. * @returns the current particle system
  66180. */
  66181. removeColorGradient(gradient: number): GPUParticleSystem;
  66182. private _angularSpeedGradientsTexture;
  66183. private _sizeGradientsTexture;
  66184. private _velocityGradientsTexture;
  66185. private _limitVelocityGradientsTexture;
  66186. private _dragGradientsTexture;
  66187. private _addFactorGradient;
  66188. /**
  66189. * Adds a new size gradient
  66190. * @param gradient defines the gradient to use (between 0 and 1)
  66191. * @param factor defines the size factor to affect to the specified gradient
  66192. * @returns the current particle system
  66193. */
  66194. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66195. /**
  66196. * Remove a specific size gradient
  66197. * @param gradient defines the gradient to remove
  66198. * @returns the current particle system
  66199. */
  66200. removeSizeGradient(gradient: number): GPUParticleSystem;
  66201. private _refreshFactorGradient;
  66202. /**
  66203. * Adds a new angular speed gradient
  66204. * @param gradient defines the gradient to use (between 0 and 1)
  66205. * @param factor defines the angular speed to affect to the specified gradient
  66206. * @returns the current particle system
  66207. */
  66208. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66209. /**
  66210. * Remove a specific angular speed gradient
  66211. * @param gradient defines the gradient to remove
  66212. * @returns the current particle system
  66213. */
  66214. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66215. /**
  66216. * Adds a new velocity gradient
  66217. * @param gradient defines the gradient to use (between 0 and 1)
  66218. * @param factor defines the velocity to affect to the specified gradient
  66219. * @returns the current particle system
  66220. */
  66221. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66222. /**
  66223. * Remove a specific velocity gradient
  66224. * @param gradient defines the gradient to remove
  66225. * @returns the current particle system
  66226. */
  66227. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66228. /**
  66229. * Adds a new limit velocity gradient
  66230. * @param gradient defines the gradient to use (between 0 and 1)
  66231. * @param factor defines the limit velocity value to affect to the specified gradient
  66232. * @returns the current particle system
  66233. */
  66234. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66235. /**
  66236. * Remove a specific limit velocity gradient
  66237. * @param gradient defines the gradient to remove
  66238. * @returns the current particle system
  66239. */
  66240. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66241. /**
  66242. * Adds a new drag gradient
  66243. * @param gradient defines the gradient to use (between 0 and 1)
  66244. * @param factor defines the drag value to affect to the specified gradient
  66245. * @returns the current particle system
  66246. */
  66247. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66248. /**
  66249. * Remove a specific drag gradient
  66250. * @param gradient defines the gradient to remove
  66251. * @returns the current particle system
  66252. */
  66253. removeDragGradient(gradient: number): GPUParticleSystem;
  66254. /**
  66255. * Not supported by GPUParticleSystem
  66256. * @param gradient defines the gradient to use (between 0 and 1)
  66257. * @param factor defines the emit rate value to affect to the specified gradient
  66258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66259. * @returns the current particle system
  66260. */
  66261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66262. /**
  66263. * Not supported by GPUParticleSystem
  66264. * @param gradient defines the gradient to remove
  66265. * @returns the current particle system
  66266. */
  66267. removeEmitRateGradient(gradient: number): IParticleSystem;
  66268. /**
  66269. * Not supported by GPUParticleSystem
  66270. * @param gradient defines the gradient to use (between 0 and 1)
  66271. * @param factor defines the start size value to affect to the specified gradient
  66272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66273. * @returns the current particle system
  66274. */
  66275. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66276. /**
  66277. * Not supported by GPUParticleSystem
  66278. * @param gradient defines the gradient to remove
  66279. * @returns the current particle system
  66280. */
  66281. removeStartSizeGradient(gradient: number): IParticleSystem;
  66282. /**
  66283. * Not supported by GPUParticleSystem
  66284. * @param gradient defines the gradient to use (between 0 and 1)
  66285. * @param min defines the color remap minimal range
  66286. * @param max defines the color remap maximal range
  66287. * @returns the current particle system
  66288. */
  66289. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66290. /**
  66291. * Not supported by GPUParticleSystem
  66292. * @param gradient defines the gradient to remove
  66293. * @returns the current particle system
  66294. */
  66295. removeColorRemapGradient(): IParticleSystem;
  66296. /**
  66297. * Not supported by GPUParticleSystem
  66298. * @param gradient defines the gradient to use (between 0 and 1)
  66299. * @param min defines the alpha remap minimal range
  66300. * @param max defines the alpha remap maximal range
  66301. * @returns the current particle system
  66302. */
  66303. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66304. /**
  66305. * Not supported by GPUParticleSystem
  66306. * @param gradient defines the gradient to remove
  66307. * @returns the current particle system
  66308. */
  66309. removeAlphaRemapGradient(): IParticleSystem;
  66310. /**
  66311. * Not supported by GPUParticleSystem
  66312. * @param gradient defines the gradient to use (between 0 and 1)
  66313. * @param color defines the color to affect to the specified gradient
  66314. * @returns the current particle system
  66315. */
  66316. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66317. /**
  66318. * Not supported by GPUParticleSystem
  66319. * @param gradient defines the gradient to remove
  66320. * @returns the current particle system
  66321. */
  66322. removeRampGradient(): IParticleSystem;
  66323. /**
  66324. * Not supported by GPUParticleSystem
  66325. * @returns the list of ramp gradients
  66326. */
  66327. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66328. /**
  66329. * Not supported by GPUParticleSystem
  66330. * Gets or sets a boolean indicating that ramp gradients must be used
  66331. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66332. */
  66333. get useRampGradients(): boolean;
  66334. set useRampGradients(value: boolean);
  66335. /**
  66336. * Not supported by GPUParticleSystem
  66337. * @param gradient defines the gradient to use (between 0 and 1)
  66338. * @param factor defines the life time factor to affect to the specified gradient
  66339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66340. * @returns the current particle system
  66341. */
  66342. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66343. /**
  66344. * Not supported by GPUParticleSystem
  66345. * @param gradient defines the gradient to remove
  66346. * @returns the current particle system
  66347. */
  66348. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66349. /**
  66350. * Instantiates a GPU particle system.
  66351. * 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.
  66352. * @param name The name of the particle system
  66353. * @param options The options used to create the system
  66354. * @param scene The scene the particle system belongs to
  66355. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66356. * @param customEffect a custom effect used to change the way particles are rendered by default
  66357. */
  66358. constructor(name: string, options: Partial<{
  66359. capacity: number;
  66360. randomTextureSize: number;
  66361. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66362. protected _reset(): void;
  66363. private _createUpdateVAO;
  66364. private _createRenderVAO;
  66365. private _initialize;
  66366. /** @hidden */
  66367. _recreateUpdateEffect(): void;
  66368. private _getEffect;
  66369. /**
  66370. * Fill the defines array according to the current settings of the particle system
  66371. * @param defines Array to be updated
  66372. * @param blendMode blend mode to take into account when updating the array
  66373. */
  66374. fillDefines(defines: Array<string>, blendMode?: number): void;
  66375. /**
  66376. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66377. * @param uniforms Uniforms array to fill
  66378. * @param attributes Attributes array to fill
  66379. * @param samplers Samplers array to fill
  66380. */
  66381. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66382. /** @hidden */
  66383. _recreateRenderEffect(): Effect;
  66384. /**
  66385. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66386. * @param preWarm defines if we are in the pre-warmimg phase
  66387. */
  66388. animate(preWarm?: boolean): void;
  66389. private _createFactorGradientTexture;
  66390. private _createSizeGradientTexture;
  66391. private _createAngularSpeedGradientTexture;
  66392. private _createVelocityGradientTexture;
  66393. private _createLimitVelocityGradientTexture;
  66394. private _createDragGradientTexture;
  66395. private _createColorGradientTexture;
  66396. /**
  66397. * Renders the particle system in its current state
  66398. * @param preWarm defines if the system should only update the particles but not render them
  66399. * @returns the current number of particles
  66400. */
  66401. render(preWarm?: boolean): number;
  66402. /**
  66403. * Rebuilds the particle system
  66404. */
  66405. rebuild(): void;
  66406. private _releaseBuffers;
  66407. private _releaseVAOs;
  66408. /**
  66409. * Disposes the particle system and free the associated resources
  66410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66411. */
  66412. dispose(disposeTexture?: boolean): void;
  66413. /**
  66414. * Clones the particle system.
  66415. * @param name The name of the cloned object
  66416. * @param newEmitter The new emitter to use
  66417. * @returns the cloned particle system
  66418. */
  66419. clone(name: string, newEmitter: any): GPUParticleSystem;
  66420. /**
  66421. * Serializes the particle system to a JSON object
  66422. * @param serializeTexture defines if the texture must be serialized as well
  66423. * @returns the JSON object
  66424. */
  66425. serialize(serializeTexture?: boolean): any;
  66426. /**
  66427. * Parses a JSON object to create a GPU particle system.
  66428. * @param parsedParticleSystem The JSON object to parse
  66429. * @param scene The scene to create the particle system in
  66430. * @param rootUrl The root url to use to load external dependencies like texture
  66431. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66432. * @returns the parsed GPU particle system
  66433. */
  66434. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66435. }
  66436. }
  66437. declare module BABYLON {
  66438. /**
  66439. * Represents a set of particle systems working together to create a specific effect
  66440. */
  66441. export class ParticleSystemSet implements IDisposable {
  66442. /**
  66443. * Gets or sets base Assets URL
  66444. */
  66445. static BaseAssetsUrl: string;
  66446. private _emitterCreationOptions;
  66447. private _emitterNode;
  66448. /**
  66449. * Gets the particle system list
  66450. */
  66451. systems: IParticleSystem[];
  66452. /**
  66453. * Gets the emitter node used with this set
  66454. */
  66455. get emitterNode(): Nullable<TransformNode>;
  66456. /**
  66457. * Creates a new emitter mesh as a sphere
  66458. * @param options defines the options used to create the sphere
  66459. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66460. * @param scene defines the hosting scene
  66461. */
  66462. setEmitterAsSphere(options: {
  66463. diameter: number;
  66464. segments: number;
  66465. color: Color3;
  66466. }, renderingGroupId: number, scene: Scene): void;
  66467. /**
  66468. * Starts all particle systems of the set
  66469. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66470. */
  66471. start(emitter?: AbstractMesh): void;
  66472. /**
  66473. * Release all associated resources
  66474. */
  66475. dispose(): void;
  66476. /**
  66477. * Serialize the set into a JSON compatible object
  66478. * @param serializeTexture defines if the texture must be serialized as well
  66479. * @returns a JSON compatible representation of the set
  66480. */
  66481. serialize(serializeTexture?: boolean): any;
  66482. /**
  66483. * Parse a new ParticleSystemSet from a serialized source
  66484. * @param data defines a JSON compatible representation of the set
  66485. * @param scene defines the hosting scene
  66486. * @param gpu defines if we want GPU particles or CPU particles
  66487. * @returns a new ParticleSystemSet
  66488. */
  66489. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66490. }
  66491. }
  66492. declare module BABYLON {
  66493. /**
  66494. * This class is made for on one-liner static method to help creating particle system set.
  66495. */
  66496. export class ParticleHelper {
  66497. /**
  66498. * Gets or sets base Assets URL
  66499. */
  66500. static BaseAssetsUrl: string;
  66501. /** Define the Url to load snippets */
  66502. static SnippetUrl: string;
  66503. /**
  66504. * Create a default particle system that you can tweak
  66505. * @param emitter defines the emitter to use
  66506. * @param capacity defines the system capacity (default is 500 particles)
  66507. * @param scene defines the hosting scene
  66508. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66509. * @returns the new Particle system
  66510. */
  66511. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66512. /**
  66513. * This is the main static method (one-liner) of this helper to create different particle systems
  66514. * @param type This string represents the type to the particle system to create
  66515. * @param scene The scene where the particle system should live
  66516. * @param gpu If the system will use gpu
  66517. * @returns the ParticleSystemSet created
  66518. */
  66519. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66520. /**
  66521. * Static function used to export a particle system to a ParticleSystemSet variable.
  66522. * Please note that the emitter shape is not exported
  66523. * @param systems defines the particle systems to export
  66524. * @returns the created particle system set
  66525. */
  66526. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66527. /**
  66528. * Creates a particle system from a snippet saved in a remote file
  66529. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66530. * @param url defines the url to load from
  66531. * @param scene defines the hosting scene
  66532. * @param gpu If the system will use gpu
  66533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66534. * @returns a promise that will resolve to the new particle system
  66535. */
  66536. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66537. /**
  66538. * Creates a particle system from a snippet saved by the particle system editor
  66539. * @param snippetId defines the snippet to load
  66540. * @param scene defines the hosting scene
  66541. * @param gpu If the system will use gpu
  66542. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66543. * @returns a promise that will resolve to the new particle system
  66544. */
  66545. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66546. }
  66547. }
  66548. declare module BABYLON {
  66549. interface Engine {
  66550. /**
  66551. * Create an effect to use with particle systems.
  66552. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66553. * the particle system for which you want to create a custom effect in the last parameter
  66554. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66555. * @param uniformsNames defines a list of attribute names
  66556. * @param samplers defines an array of string used to represent textures
  66557. * @param defines defines the string containing the defines to use to compile the shaders
  66558. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66559. * @param onCompiled defines a function to call when the effect creation is successful
  66560. * @param onError defines a function to call when the effect creation has failed
  66561. * @param particleSystem the particle system you want to create the effect for
  66562. * @returns the new Effect
  66563. */
  66564. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66565. }
  66566. interface Mesh {
  66567. /**
  66568. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66569. * @returns an array of IParticleSystem
  66570. */
  66571. getEmittedParticleSystems(): IParticleSystem[];
  66572. /**
  66573. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66574. * @returns an array of IParticleSystem
  66575. */
  66576. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66577. }
  66578. }
  66579. declare module BABYLON {
  66580. /** Defines the 4 color options */
  66581. export enum PointColor {
  66582. /** color value */
  66583. Color = 2,
  66584. /** uv value */
  66585. UV = 1,
  66586. /** random value */
  66587. Random = 0,
  66588. /** stated value */
  66589. Stated = 3
  66590. }
  66591. /**
  66592. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66593. * 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.
  66594. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66595. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66596. *
  66597. * Full documentation here : TO BE ENTERED
  66598. */
  66599. export class PointsCloudSystem implements IDisposable {
  66600. /**
  66601. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66602. * Example : var p = SPS.particles[i];
  66603. */
  66604. particles: CloudPoint[];
  66605. /**
  66606. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66607. */
  66608. nbParticles: number;
  66609. /**
  66610. * This a counter for your own usage. It's not set by any SPS functions.
  66611. */
  66612. counter: number;
  66613. /**
  66614. * The PCS name. This name is also given to the underlying mesh.
  66615. */
  66616. name: string;
  66617. /**
  66618. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66619. */
  66620. mesh: Mesh;
  66621. /**
  66622. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66623. * Please read :
  66624. */
  66625. vars: any;
  66626. /**
  66627. * @hidden
  66628. */
  66629. _size: number;
  66630. private _scene;
  66631. private _promises;
  66632. private _positions;
  66633. private _indices;
  66634. private _normals;
  66635. private _colors;
  66636. private _uvs;
  66637. private _indices32;
  66638. private _positions32;
  66639. private _colors32;
  66640. private _uvs32;
  66641. private _updatable;
  66642. private _isVisibilityBoxLocked;
  66643. private _alwaysVisible;
  66644. private _groups;
  66645. private _groupCounter;
  66646. private _computeParticleColor;
  66647. private _computeParticleTexture;
  66648. private _computeParticleRotation;
  66649. private _computeBoundingBox;
  66650. private _isReady;
  66651. /**
  66652. * Creates a PCS (Points Cloud System) object
  66653. * @param name (String) is the PCS name, this will be the underlying mesh name
  66654. * @param pointSize (number) is the size for each point
  66655. * @param scene (Scene) is the scene in which the PCS is added
  66656. * @param options defines the options of the PCS e.g.
  66657. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66658. */
  66659. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66660. updatable?: boolean;
  66661. });
  66662. /**
  66663. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66664. * If no points were added to the PCS, the returned mesh is just a single point.
  66665. * @returns a promise for the created mesh
  66666. */
  66667. buildMeshAsync(): Promise<Mesh>;
  66668. /**
  66669. * @hidden
  66670. */
  66671. private _buildMesh;
  66672. private _addParticle;
  66673. private _randomUnitVector;
  66674. private _getColorIndicesForCoord;
  66675. private _setPointsColorOrUV;
  66676. private _colorFromTexture;
  66677. private _calculateDensity;
  66678. /**
  66679. * Adds points to the PCS in random positions within a unit sphere
  66680. * @param nb (positive integer) the number of particles to be created from this model
  66681. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66682. * @returns the number of groups in the system
  66683. */
  66684. addPoints(nb: number, pointFunction?: any): number;
  66685. /**
  66686. * Adds points to the PCS from the surface of the model shape
  66687. * @param mesh is any Mesh object that will be used as a surface model for the points
  66688. * @param nb (positive integer) the number of particles to be created from this model
  66689. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66690. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66691. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66692. * @returns the number of groups in the system
  66693. */
  66694. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66695. /**
  66696. * Adds points to the PCS inside the model shape
  66697. * @param mesh is any Mesh object that will be used as a surface model for the points
  66698. * @param nb (positive integer) the number of particles to be created from this model
  66699. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66700. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66701. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66702. * @returns the number of groups in the system
  66703. */
  66704. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66705. /**
  66706. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66707. * This method calls `updateParticle()` for each particle of the SPS.
  66708. * For an animated SPS, it is usually called within the render loop.
  66709. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66710. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66711. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66712. * @returns the PCS.
  66713. */
  66714. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66715. /**
  66716. * Disposes the PCS.
  66717. */
  66718. dispose(): void;
  66719. /**
  66720. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66721. * doc :
  66722. * @returns the PCS.
  66723. */
  66724. refreshVisibleSize(): PointsCloudSystem;
  66725. /**
  66726. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66727. * @param size the size (float) of the visibility box
  66728. * note : this doesn't lock the PCS mesh bounding box.
  66729. * doc :
  66730. */
  66731. setVisibilityBox(size: number): void;
  66732. /**
  66733. * Gets whether the PCS is always visible or not
  66734. * doc :
  66735. */
  66736. get isAlwaysVisible(): boolean;
  66737. /**
  66738. * Sets the PCS as always visible or not
  66739. * doc :
  66740. */
  66741. set isAlwaysVisible(val: boolean);
  66742. /**
  66743. * Tells to `setParticles()` to compute the particle rotations or not
  66744. * Default value : false. The PCS is faster when it's set to false
  66745. * Note : particle rotations are only applied to parent particles
  66746. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66747. */
  66748. set computeParticleRotation(val: boolean);
  66749. /**
  66750. * Tells to `setParticles()` to compute the particle colors or not.
  66751. * Default value : true. The PCS is faster when it's set to false.
  66752. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66753. */
  66754. set computeParticleColor(val: boolean);
  66755. set computeParticleTexture(val: boolean);
  66756. /**
  66757. * Gets if `setParticles()` computes the particle colors or not.
  66758. * Default value : false. The PCS is faster when it's set to false.
  66759. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66760. */
  66761. get computeParticleColor(): boolean;
  66762. /**
  66763. * Gets if `setParticles()` computes the particle textures or not.
  66764. * Default value : false. The PCS is faster when it's set to false.
  66765. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66766. */
  66767. get computeParticleTexture(): boolean;
  66768. /**
  66769. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66770. */
  66771. set computeBoundingBox(val: boolean);
  66772. /**
  66773. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66774. */
  66775. get computeBoundingBox(): boolean;
  66776. /**
  66777. * This function does nothing. It may be overwritten to set all the particle first values.
  66778. * The PCS doesn't call this function, you may have to call it by your own.
  66779. * doc :
  66780. */
  66781. initParticles(): void;
  66782. /**
  66783. * This function does nothing. It may be overwritten to recycle a particle
  66784. * The PCS doesn't call this function, you can to call it
  66785. * doc :
  66786. * @param particle The particle to recycle
  66787. * @returns the recycled particle
  66788. */
  66789. recycleParticle(particle: CloudPoint): CloudPoint;
  66790. /**
  66791. * Updates a particle : this function should be overwritten by the user.
  66792. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66793. * doc :
  66794. * @example : just set a particle position or velocity and recycle conditions
  66795. * @param particle The particle to update
  66796. * @returns the updated particle
  66797. */
  66798. updateParticle(particle: CloudPoint): CloudPoint;
  66799. /**
  66800. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66801. * This does nothing and may be overwritten by the user.
  66802. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66803. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66804. * @param update the boolean update value actually passed to setParticles()
  66805. */
  66806. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66807. /**
  66808. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66809. * This will be passed three parameters.
  66810. * This does nothing and may be overwritten by the user.
  66811. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66812. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66813. * @param update the boolean update value actually passed to setParticles()
  66814. */
  66815. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66816. }
  66817. }
  66818. declare module BABYLON {
  66819. /**
  66820. * Represents one particle of a points cloud system.
  66821. */
  66822. export class CloudPoint {
  66823. /**
  66824. * particle global index
  66825. */
  66826. idx: number;
  66827. /**
  66828. * The color of the particle
  66829. */
  66830. color: Nullable<Color4>;
  66831. /**
  66832. * The world space position of the particle.
  66833. */
  66834. position: Vector3;
  66835. /**
  66836. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66837. */
  66838. rotation: Vector3;
  66839. /**
  66840. * The world space rotation quaternion of the particle.
  66841. */
  66842. rotationQuaternion: Nullable<Quaternion>;
  66843. /**
  66844. * The uv of the particle.
  66845. */
  66846. uv: Nullable<Vector2>;
  66847. /**
  66848. * The current speed of the particle.
  66849. */
  66850. velocity: Vector3;
  66851. /**
  66852. * The pivot point in the particle local space.
  66853. */
  66854. pivot: Vector3;
  66855. /**
  66856. * Must the particle be translated from its pivot point in its local space ?
  66857. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66858. * Default : false
  66859. */
  66860. translateFromPivot: boolean;
  66861. /**
  66862. * Index of this particle in the global "positions" array (Internal use)
  66863. * @hidden
  66864. */
  66865. _pos: number;
  66866. /**
  66867. * @hidden Index of this particle in the global "indices" array (Internal use)
  66868. */
  66869. _ind: number;
  66870. /**
  66871. * Group this particle belongs to
  66872. */
  66873. _group: PointsGroup;
  66874. /**
  66875. * Group id of this particle
  66876. */
  66877. groupId: number;
  66878. /**
  66879. * Index of the particle in its group id (Internal use)
  66880. */
  66881. idxInGroup: number;
  66882. /**
  66883. * @hidden Particle BoundingInfo object (Internal use)
  66884. */
  66885. _boundingInfo: BoundingInfo;
  66886. /**
  66887. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66888. */
  66889. _pcs: PointsCloudSystem;
  66890. /**
  66891. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66892. */
  66893. _stillInvisible: boolean;
  66894. /**
  66895. * @hidden Last computed particle rotation matrix
  66896. */
  66897. _rotationMatrix: number[];
  66898. /**
  66899. * Parent particle Id, if any.
  66900. * Default null.
  66901. */
  66902. parentId: Nullable<number>;
  66903. /**
  66904. * @hidden Internal global position in the PCS.
  66905. */
  66906. _globalPosition: Vector3;
  66907. /**
  66908. * Creates a Point Cloud object.
  66909. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66910. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66911. * @param group (PointsGroup) is the group the particle belongs to
  66912. * @param groupId (integer) is the group identifier in the PCS.
  66913. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66914. * @param pcs defines the PCS it is associated to
  66915. */
  66916. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66917. /**
  66918. * get point size
  66919. */
  66920. get size(): Vector3;
  66921. /**
  66922. * Set point size
  66923. */
  66924. set size(scale: Vector3);
  66925. /**
  66926. * Legacy support, changed quaternion to rotationQuaternion
  66927. */
  66928. get quaternion(): Nullable<Quaternion>;
  66929. /**
  66930. * Legacy support, changed quaternion to rotationQuaternion
  66931. */
  66932. set quaternion(q: Nullable<Quaternion>);
  66933. /**
  66934. * Returns a boolean. True if the particle intersects a mesh, else false
  66935. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66936. * @param target is the object (point or mesh) what the intersection is computed against
  66937. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66938. * @returns true if it intersects
  66939. */
  66940. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66941. /**
  66942. * get the rotation matrix of the particle
  66943. * @hidden
  66944. */
  66945. getRotationMatrix(m: Matrix): void;
  66946. }
  66947. /**
  66948. * Represents a group of points in a points cloud system
  66949. * * PCS internal tool, don't use it manually.
  66950. */
  66951. export class PointsGroup {
  66952. /**
  66953. * The group id
  66954. * @hidden
  66955. */
  66956. groupID: number;
  66957. /**
  66958. * image data for group (internal use)
  66959. * @hidden
  66960. */
  66961. _groupImageData: Nullable<ArrayBufferView>;
  66962. /**
  66963. * Image Width (internal use)
  66964. * @hidden
  66965. */
  66966. _groupImgWidth: number;
  66967. /**
  66968. * Image Height (internal use)
  66969. * @hidden
  66970. */
  66971. _groupImgHeight: number;
  66972. /**
  66973. * Custom position function (internal use)
  66974. * @hidden
  66975. */
  66976. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66977. /**
  66978. * density per facet for surface points
  66979. * @hidden
  66980. */
  66981. _groupDensity: number[];
  66982. /**
  66983. * Only when points are colored by texture carries pointer to texture list array
  66984. * @hidden
  66985. */
  66986. _textureNb: number;
  66987. /**
  66988. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66989. * PCS internal tool, don't use it manually.
  66990. * @hidden
  66991. */
  66992. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66993. }
  66994. }
  66995. declare module BABYLON {
  66996. interface Scene {
  66997. /** @hidden (Backing field) */
  66998. _physicsEngine: Nullable<IPhysicsEngine>;
  66999. /** @hidden */
  67000. _physicsTimeAccumulator: number;
  67001. /**
  67002. * Gets the current physics engine
  67003. * @returns a IPhysicsEngine or null if none attached
  67004. */
  67005. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67006. /**
  67007. * Enables physics to the current scene
  67008. * @param gravity defines the scene's gravity for the physics engine
  67009. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67010. * @return a boolean indicating if the physics engine was initialized
  67011. */
  67012. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67013. /**
  67014. * Disables and disposes the physics engine associated with the scene
  67015. */
  67016. disablePhysicsEngine(): void;
  67017. /**
  67018. * Gets a boolean indicating if there is an active physics engine
  67019. * @returns a boolean indicating if there is an active physics engine
  67020. */
  67021. isPhysicsEnabled(): boolean;
  67022. /**
  67023. * Deletes a physics compound impostor
  67024. * @param compound defines the compound to delete
  67025. */
  67026. deleteCompoundImpostor(compound: any): void;
  67027. /**
  67028. * An event triggered when physic simulation is about to be run
  67029. */
  67030. onBeforePhysicsObservable: Observable<Scene>;
  67031. /**
  67032. * An event triggered when physic simulation has been done
  67033. */
  67034. onAfterPhysicsObservable: Observable<Scene>;
  67035. }
  67036. interface AbstractMesh {
  67037. /** @hidden */
  67038. _physicsImpostor: Nullable<PhysicsImpostor>;
  67039. /**
  67040. * Gets or sets impostor used for physic simulation
  67041. * @see http://doc.babylonjs.com/features/physics_engine
  67042. */
  67043. physicsImpostor: Nullable<PhysicsImpostor>;
  67044. /**
  67045. * Gets the current physics impostor
  67046. * @see http://doc.babylonjs.com/features/physics_engine
  67047. * @returns a physics impostor or null
  67048. */
  67049. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67050. /** Apply a physic impulse to the mesh
  67051. * @param force defines the force to apply
  67052. * @param contactPoint defines where to apply the force
  67053. * @returns the current mesh
  67054. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67055. */
  67056. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67057. /**
  67058. * Creates a physic joint between two meshes
  67059. * @param otherMesh defines the other mesh to use
  67060. * @param pivot1 defines the pivot to use on this mesh
  67061. * @param pivot2 defines the pivot to use on the other mesh
  67062. * @param options defines additional options (can be plugin dependent)
  67063. * @returns the current mesh
  67064. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67065. */
  67066. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67067. /** @hidden */
  67068. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67069. }
  67070. /**
  67071. * Defines the physics engine scene component responsible to manage a physics engine
  67072. */
  67073. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67074. /**
  67075. * The component name helpful to identify the component in the list of scene components.
  67076. */
  67077. readonly name: string;
  67078. /**
  67079. * The scene the component belongs to.
  67080. */
  67081. scene: Scene;
  67082. /**
  67083. * Creates a new instance of the component for the given scene
  67084. * @param scene Defines the scene to register the component in
  67085. */
  67086. constructor(scene: Scene);
  67087. /**
  67088. * Registers the component in a given scene
  67089. */
  67090. register(): void;
  67091. /**
  67092. * Rebuilds the elements related to this component in case of
  67093. * context lost for instance.
  67094. */
  67095. rebuild(): void;
  67096. /**
  67097. * Disposes the component and the associated ressources
  67098. */
  67099. dispose(): void;
  67100. }
  67101. }
  67102. declare module BABYLON {
  67103. /**
  67104. * A helper for physics simulations
  67105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67106. */
  67107. export class PhysicsHelper {
  67108. private _scene;
  67109. private _physicsEngine;
  67110. /**
  67111. * Initializes the Physics helper
  67112. * @param scene Babylon.js scene
  67113. */
  67114. constructor(scene: Scene);
  67115. /**
  67116. * Applies a radial explosion impulse
  67117. * @param origin the origin of the explosion
  67118. * @param radiusOrEventOptions the radius or the options of radial explosion
  67119. * @param strength the explosion strength
  67120. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67121. * @returns A physics radial explosion event, or null
  67122. */
  67123. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67124. /**
  67125. * Applies a radial explosion force
  67126. * @param origin the origin of the explosion
  67127. * @param radiusOrEventOptions the radius or the options of radial explosion
  67128. * @param strength the explosion strength
  67129. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67130. * @returns A physics radial explosion event, or null
  67131. */
  67132. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67133. /**
  67134. * Creates a gravitational field
  67135. * @param origin the origin of the explosion
  67136. * @param radiusOrEventOptions the radius or the options of radial explosion
  67137. * @param strength the explosion strength
  67138. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67139. * @returns A physics gravitational field event, or null
  67140. */
  67141. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67142. /**
  67143. * Creates a physics updraft event
  67144. * @param origin the origin of the updraft
  67145. * @param radiusOrEventOptions the radius or the options of the updraft
  67146. * @param strength the strength of the updraft
  67147. * @param height the height of the updraft
  67148. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67149. * @returns A physics updraft event, or null
  67150. */
  67151. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67152. /**
  67153. * Creates a physics vortex event
  67154. * @param origin the of the vortex
  67155. * @param radiusOrEventOptions the radius or the options of the vortex
  67156. * @param strength the strength of the vortex
  67157. * @param height the height of the vortex
  67158. * @returns a Physics vortex event, or null
  67159. * A physics vortex event or null
  67160. */
  67161. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67162. }
  67163. /**
  67164. * Represents a physics radial explosion event
  67165. */
  67166. class PhysicsRadialExplosionEvent {
  67167. private _scene;
  67168. private _options;
  67169. private _sphere;
  67170. private _dataFetched;
  67171. /**
  67172. * Initializes a radial explosioin event
  67173. * @param _scene BabylonJS scene
  67174. * @param _options The options for the vortex event
  67175. */
  67176. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67177. /**
  67178. * Returns the data related to the radial explosion event (sphere).
  67179. * @returns The radial explosion event data
  67180. */
  67181. getData(): PhysicsRadialExplosionEventData;
  67182. /**
  67183. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67184. * @param impostor A physics imposter
  67185. * @param origin the origin of the explosion
  67186. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67187. */
  67188. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67189. /**
  67190. * Triggers affecterd impostors callbacks
  67191. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67192. */
  67193. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67194. /**
  67195. * Disposes the sphere.
  67196. * @param force Specifies if the sphere should be disposed by force
  67197. */
  67198. dispose(force?: boolean): void;
  67199. /*** Helpers ***/
  67200. private _prepareSphere;
  67201. private _intersectsWithSphere;
  67202. }
  67203. /**
  67204. * Represents a gravitational field event
  67205. */
  67206. class PhysicsGravitationalFieldEvent {
  67207. private _physicsHelper;
  67208. private _scene;
  67209. private _origin;
  67210. private _options;
  67211. private _tickCallback;
  67212. private _sphere;
  67213. private _dataFetched;
  67214. /**
  67215. * Initializes the physics gravitational field event
  67216. * @param _physicsHelper A physics helper
  67217. * @param _scene BabylonJS scene
  67218. * @param _origin The origin position of the gravitational field event
  67219. * @param _options The options for the vortex event
  67220. */
  67221. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67222. /**
  67223. * Returns the data related to the gravitational field event (sphere).
  67224. * @returns A gravitational field event
  67225. */
  67226. getData(): PhysicsGravitationalFieldEventData;
  67227. /**
  67228. * Enables the gravitational field.
  67229. */
  67230. enable(): void;
  67231. /**
  67232. * Disables the gravitational field.
  67233. */
  67234. disable(): void;
  67235. /**
  67236. * Disposes the sphere.
  67237. * @param force The force to dispose from the gravitational field event
  67238. */
  67239. dispose(force?: boolean): void;
  67240. private _tick;
  67241. }
  67242. /**
  67243. * Represents a physics updraft event
  67244. */
  67245. class PhysicsUpdraftEvent {
  67246. private _scene;
  67247. private _origin;
  67248. private _options;
  67249. private _physicsEngine;
  67250. private _originTop;
  67251. private _originDirection;
  67252. private _tickCallback;
  67253. private _cylinder;
  67254. private _cylinderPosition;
  67255. private _dataFetched;
  67256. /**
  67257. * Initializes the physics updraft event
  67258. * @param _scene BabylonJS scene
  67259. * @param _origin The origin position of the updraft
  67260. * @param _options The options for the updraft event
  67261. */
  67262. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67263. /**
  67264. * Returns the data related to the updraft event (cylinder).
  67265. * @returns A physics updraft event
  67266. */
  67267. getData(): PhysicsUpdraftEventData;
  67268. /**
  67269. * Enables the updraft.
  67270. */
  67271. enable(): void;
  67272. /**
  67273. * Disables the updraft.
  67274. */
  67275. disable(): void;
  67276. /**
  67277. * Disposes the cylinder.
  67278. * @param force Specifies if the updraft should be disposed by force
  67279. */
  67280. dispose(force?: boolean): void;
  67281. private getImpostorHitData;
  67282. private _tick;
  67283. /*** Helpers ***/
  67284. private _prepareCylinder;
  67285. private _intersectsWithCylinder;
  67286. }
  67287. /**
  67288. * Represents a physics vortex event
  67289. */
  67290. class PhysicsVortexEvent {
  67291. private _scene;
  67292. private _origin;
  67293. private _options;
  67294. private _physicsEngine;
  67295. private _originTop;
  67296. private _tickCallback;
  67297. private _cylinder;
  67298. private _cylinderPosition;
  67299. private _dataFetched;
  67300. /**
  67301. * Initializes the physics vortex event
  67302. * @param _scene The BabylonJS scene
  67303. * @param _origin The origin position of the vortex
  67304. * @param _options The options for the vortex event
  67305. */
  67306. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67307. /**
  67308. * Returns the data related to the vortex event (cylinder).
  67309. * @returns The physics vortex event data
  67310. */
  67311. getData(): PhysicsVortexEventData;
  67312. /**
  67313. * Enables the vortex.
  67314. */
  67315. enable(): void;
  67316. /**
  67317. * Disables the cortex.
  67318. */
  67319. disable(): void;
  67320. /**
  67321. * Disposes the sphere.
  67322. * @param force
  67323. */
  67324. dispose(force?: boolean): void;
  67325. private getImpostorHitData;
  67326. private _tick;
  67327. /*** Helpers ***/
  67328. private _prepareCylinder;
  67329. private _intersectsWithCylinder;
  67330. }
  67331. /**
  67332. * Options fot the radial explosion event
  67333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67334. */
  67335. export class PhysicsRadialExplosionEventOptions {
  67336. /**
  67337. * The radius of the sphere for the radial explosion.
  67338. */
  67339. radius: number;
  67340. /**
  67341. * The strenth of the explosion.
  67342. */
  67343. strength: number;
  67344. /**
  67345. * The strenght of the force in correspondence to the distance of the affected object
  67346. */
  67347. falloff: PhysicsRadialImpulseFalloff;
  67348. /**
  67349. * Sphere options for the radial explosion.
  67350. */
  67351. sphere: {
  67352. segments: number;
  67353. diameter: number;
  67354. };
  67355. /**
  67356. * Sphere options for the radial explosion.
  67357. */
  67358. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67359. }
  67360. /**
  67361. * Options fot the updraft event
  67362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67363. */
  67364. export class PhysicsUpdraftEventOptions {
  67365. /**
  67366. * The radius of the cylinder for the vortex
  67367. */
  67368. radius: number;
  67369. /**
  67370. * The strenth of the updraft.
  67371. */
  67372. strength: number;
  67373. /**
  67374. * The height of the cylinder for the updraft.
  67375. */
  67376. height: number;
  67377. /**
  67378. * The mode for the the updraft.
  67379. */
  67380. updraftMode: PhysicsUpdraftMode;
  67381. }
  67382. /**
  67383. * Options fot the vortex event
  67384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67385. */
  67386. export class PhysicsVortexEventOptions {
  67387. /**
  67388. * The radius of the cylinder for the vortex
  67389. */
  67390. radius: number;
  67391. /**
  67392. * The strenth of the vortex.
  67393. */
  67394. strength: number;
  67395. /**
  67396. * The height of the cylinder for the vortex.
  67397. */
  67398. height: number;
  67399. /**
  67400. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67401. */
  67402. centripetalForceThreshold: number;
  67403. /**
  67404. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67405. */
  67406. centripetalForceMultiplier: number;
  67407. /**
  67408. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67409. */
  67410. centrifugalForceMultiplier: number;
  67411. /**
  67412. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67413. */
  67414. updraftForceMultiplier: number;
  67415. }
  67416. /**
  67417. * The strenght of the force in correspondence to the distance of the affected object
  67418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67419. */
  67420. export enum PhysicsRadialImpulseFalloff {
  67421. /** Defines that impulse is constant in strength across it's whole radius */
  67422. Constant = 0,
  67423. /** Defines that impulse gets weaker if it's further from the origin */
  67424. Linear = 1
  67425. }
  67426. /**
  67427. * The strength of the force in correspondence to the distance of the affected object
  67428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67429. */
  67430. export enum PhysicsUpdraftMode {
  67431. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67432. Center = 0,
  67433. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67434. Perpendicular = 1
  67435. }
  67436. /**
  67437. * Interface for a physics hit data
  67438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67439. */
  67440. export interface PhysicsHitData {
  67441. /**
  67442. * The force applied at the contact point
  67443. */
  67444. force: Vector3;
  67445. /**
  67446. * The contact point
  67447. */
  67448. contactPoint: Vector3;
  67449. /**
  67450. * The distance from the origin to the contact point
  67451. */
  67452. distanceFromOrigin: number;
  67453. }
  67454. /**
  67455. * Interface for radial explosion event data
  67456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67457. */
  67458. export interface PhysicsRadialExplosionEventData {
  67459. /**
  67460. * A sphere used for the radial explosion event
  67461. */
  67462. sphere: Mesh;
  67463. }
  67464. /**
  67465. * Interface for gravitational field event data
  67466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67467. */
  67468. export interface PhysicsGravitationalFieldEventData {
  67469. /**
  67470. * A sphere mesh used for the gravitational field event
  67471. */
  67472. sphere: Mesh;
  67473. }
  67474. /**
  67475. * Interface for updraft event data
  67476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67477. */
  67478. export interface PhysicsUpdraftEventData {
  67479. /**
  67480. * A cylinder used for the updraft event
  67481. */
  67482. cylinder: Mesh;
  67483. }
  67484. /**
  67485. * Interface for vortex event data
  67486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67487. */
  67488. export interface PhysicsVortexEventData {
  67489. /**
  67490. * A cylinder used for the vortex event
  67491. */
  67492. cylinder: Mesh;
  67493. }
  67494. /**
  67495. * Interface for an affected physics impostor
  67496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67497. */
  67498. export interface PhysicsAffectedImpostorWithData {
  67499. /**
  67500. * The impostor affected by the effect
  67501. */
  67502. impostor: PhysicsImpostor;
  67503. /**
  67504. * The data about the hit/horce from the explosion
  67505. */
  67506. hitData: PhysicsHitData;
  67507. }
  67508. }
  67509. declare module BABYLON {
  67510. /** @hidden */
  67511. export var blackAndWhitePixelShader: {
  67512. name: string;
  67513. shader: string;
  67514. };
  67515. }
  67516. declare module BABYLON {
  67517. /**
  67518. * Post process used to render in black and white
  67519. */
  67520. export class BlackAndWhitePostProcess extends PostProcess {
  67521. /**
  67522. * Linear about to convert he result to black and white (default: 1)
  67523. */
  67524. degree: number;
  67525. /**
  67526. * Creates a black and white post process
  67527. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67528. * @param name The name of the effect.
  67529. * @param options The required width/height ratio to downsize to before computing the render pass.
  67530. * @param camera The camera to apply the render pass to.
  67531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67532. * @param engine The engine which the post process will be applied. (default: current engine)
  67533. * @param reusable If the post process can be reused on the same frame. (default: false)
  67534. */
  67535. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67536. }
  67537. }
  67538. declare module BABYLON {
  67539. /**
  67540. * This represents a set of one or more post processes in Babylon.
  67541. * A post process can be used to apply a shader to a texture after it is rendered.
  67542. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67543. */
  67544. export class PostProcessRenderEffect {
  67545. private _postProcesses;
  67546. private _getPostProcesses;
  67547. private _singleInstance;
  67548. private _cameras;
  67549. private _indicesForCamera;
  67550. /**
  67551. * Name of the effect
  67552. * @hidden
  67553. */
  67554. _name: string;
  67555. /**
  67556. * Instantiates a post process render effect.
  67557. * A post process can be used to apply a shader to a texture after it is rendered.
  67558. * @param engine The engine the effect is tied to
  67559. * @param name The name of the effect
  67560. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67561. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67562. */
  67563. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67564. /**
  67565. * Checks if all the post processes in the effect are supported.
  67566. */
  67567. get isSupported(): boolean;
  67568. /**
  67569. * Updates the current state of the effect
  67570. * @hidden
  67571. */
  67572. _update(): void;
  67573. /**
  67574. * Attaches the effect on cameras
  67575. * @param cameras The camera to attach to.
  67576. * @hidden
  67577. */
  67578. _attachCameras(cameras: Camera): void;
  67579. /**
  67580. * Attaches the effect on cameras
  67581. * @param cameras The camera to attach to.
  67582. * @hidden
  67583. */
  67584. _attachCameras(cameras: Camera[]): void;
  67585. /**
  67586. * Detaches the effect on cameras
  67587. * @param cameras The camera to detatch from.
  67588. * @hidden
  67589. */
  67590. _detachCameras(cameras: Camera): void;
  67591. /**
  67592. * Detatches the effect on cameras
  67593. * @param cameras The camera to detatch from.
  67594. * @hidden
  67595. */
  67596. _detachCameras(cameras: Camera[]): void;
  67597. /**
  67598. * Enables the effect on given cameras
  67599. * @param cameras The camera to enable.
  67600. * @hidden
  67601. */
  67602. _enable(cameras: Camera): void;
  67603. /**
  67604. * Enables the effect on given cameras
  67605. * @param cameras The camera to enable.
  67606. * @hidden
  67607. */
  67608. _enable(cameras: Nullable<Camera[]>): void;
  67609. /**
  67610. * Disables the effect on the given cameras
  67611. * @param cameras The camera to disable.
  67612. * @hidden
  67613. */
  67614. _disable(cameras: Camera): void;
  67615. /**
  67616. * Disables the effect on the given cameras
  67617. * @param cameras The camera to disable.
  67618. * @hidden
  67619. */
  67620. _disable(cameras: Nullable<Camera[]>): void;
  67621. /**
  67622. * Gets a list of the post processes contained in the effect.
  67623. * @param camera The camera to get the post processes on.
  67624. * @returns The list of the post processes in the effect.
  67625. */
  67626. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67627. }
  67628. }
  67629. declare module BABYLON {
  67630. /** @hidden */
  67631. export var extractHighlightsPixelShader: {
  67632. name: string;
  67633. shader: string;
  67634. };
  67635. }
  67636. declare module BABYLON {
  67637. /**
  67638. * 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.
  67639. */
  67640. export class ExtractHighlightsPostProcess extends PostProcess {
  67641. /**
  67642. * The luminance threshold, pixels below this value will be set to black.
  67643. */
  67644. threshold: number;
  67645. /** @hidden */
  67646. _exposure: number;
  67647. /**
  67648. * Post process which has the input texture to be used when performing highlight extraction
  67649. * @hidden
  67650. */
  67651. _inputPostProcess: Nullable<PostProcess>;
  67652. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67653. }
  67654. }
  67655. declare module BABYLON {
  67656. /** @hidden */
  67657. export var bloomMergePixelShader: {
  67658. name: string;
  67659. shader: string;
  67660. };
  67661. }
  67662. declare module BABYLON {
  67663. /**
  67664. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67665. */
  67666. export class BloomMergePostProcess extends PostProcess {
  67667. /** Weight of the bloom to be added to the original input. */
  67668. weight: number;
  67669. /**
  67670. * Creates a new instance of @see BloomMergePostProcess
  67671. * @param name The name of the effect.
  67672. * @param originalFromInput Post process which's input will be used for the merge.
  67673. * @param blurred Blurred highlights post process which's output will be used.
  67674. * @param weight Weight of the bloom to be added to the original input.
  67675. * @param options The required width/height ratio to downsize to before computing the render pass.
  67676. * @param camera The camera to apply the render pass to.
  67677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67678. * @param engine The engine which the post process will be applied. (default: current engine)
  67679. * @param reusable If the post process can be reused on the same frame. (default: false)
  67680. * @param textureType Type of textures used when performing the post process. (default: 0)
  67681. * @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)
  67682. */
  67683. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67684. /** Weight of the bloom to be added to the original input. */
  67685. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67686. }
  67687. }
  67688. declare module BABYLON {
  67689. /**
  67690. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67691. */
  67692. export class BloomEffect extends PostProcessRenderEffect {
  67693. private bloomScale;
  67694. /**
  67695. * @hidden Internal
  67696. */
  67697. _effects: Array<PostProcess>;
  67698. /**
  67699. * @hidden Internal
  67700. */
  67701. _downscale: ExtractHighlightsPostProcess;
  67702. private _blurX;
  67703. private _blurY;
  67704. private _merge;
  67705. /**
  67706. * The luminance threshold to find bright areas of the image to bloom.
  67707. */
  67708. get threshold(): number;
  67709. set threshold(value: number);
  67710. /**
  67711. * The strength of the bloom.
  67712. */
  67713. get weight(): number;
  67714. set weight(value: number);
  67715. /**
  67716. * Specifies the size of the bloom blur kernel, relative to the final output size
  67717. */
  67718. get kernel(): number;
  67719. set kernel(value: number);
  67720. /**
  67721. * Creates a new instance of @see BloomEffect
  67722. * @param scene The scene the effect belongs to.
  67723. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67724. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67725. * @param bloomWeight The the strength of bloom.
  67726. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67727. * @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)
  67728. */
  67729. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67730. /**
  67731. * Disposes each of the internal effects for a given camera.
  67732. * @param camera The camera to dispose the effect on.
  67733. */
  67734. disposeEffects(camera: Camera): void;
  67735. /**
  67736. * @hidden Internal
  67737. */
  67738. _updateEffects(): void;
  67739. /**
  67740. * Internal
  67741. * @returns if all the contained post processes are ready.
  67742. * @hidden
  67743. */
  67744. _isReady(): boolean;
  67745. }
  67746. }
  67747. declare module BABYLON {
  67748. /** @hidden */
  67749. export var chromaticAberrationPixelShader: {
  67750. name: string;
  67751. shader: string;
  67752. };
  67753. }
  67754. declare module BABYLON {
  67755. /**
  67756. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67757. */
  67758. export class ChromaticAberrationPostProcess extends PostProcess {
  67759. /**
  67760. * The amount of seperation of rgb channels (default: 30)
  67761. */
  67762. aberrationAmount: number;
  67763. /**
  67764. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67765. */
  67766. radialIntensity: number;
  67767. /**
  67768. * 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))
  67769. */
  67770. direction: Vector2;
  67771. /**
  67772. * 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))
  67773. */
  67774. centerPosition: Vector2;
  67775. /**
  67776. * Creates a new instance ChromaticAberrationPostProcess
  67777. * @param name The name of the effect.
  67778. * @param screenWidth The width of the screen to apply the effect on.
  67779. * @param screenHeight The height of the screen to apply the effect on.
  67780. * @param options The required width/height ratio to downsize to before computing the render pass.
  67781. * @param camera The camera to apply the render pass to.
  67782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67783. * @param engine The engine which the post process will be applied. (default: current engine)
  67784. * @param reusable If the post process can be reused on the same frame. (default: false)
  67785. * @param textureType Type of textures used when performing the post process. (default: 0)
  67786. * @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)
  67787. */
  67788. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67789. }
  67790. }
  67791. declare module BABYLON {
  67792. /** @hidden */
  67793. export var circleOfConfusionPixelShader: {
  67794. name: string;
  67795. shader: string;
  67796. };
  67797. }
  67798. declare module BABYLON {
  67799. /**
  67800. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67801. */
  67802. export class CircleOfConfusionPostProcess extends PostProcess {
  67803. /**
  67804. * 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.
  67805. */
  67806. lensSize: number;
  67807. /**
  67808. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67809. */
  67810. fStop: number;
  67811. /**
  67812. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67813. */
  67814. focusDistance: number;
  67815. /**
  67816. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67817. */
  67818. focalLength: number;
  67819. private _depthTexture;
  67820. /**
  67821. * Creates a new instance CircleOfConfusionPostProcess
  67822. * @param name The name of the effect.
  67823. * @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.
  67824. * @param options The required width/height ratio to downsize to before computing the render pass.
  67825. * @param camera The camera to apply the render pass to.
  67826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67827. * @param engine The engine which the post process will be applied. (default: current engine)
  67828. * @param reusable If the post process can be reused on the same frame. (default: false)
  67829. * @param textureType Type of textures used when performing the post process. (default: 0)
  67830. * @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)
  67831. */
  67832. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67833. /**
  67834. * 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.
  67835. */
  67836. set depthTexture(value: RenderTargetTexture);
  67837. }
  67838. }
  67839. declare module BABYLON {
  67840. /** @hidden */
  67841. export var colorCorrectionPixelShader: {
  67842. name: string;
  67843. shader: string;
  67844. };
  67845. }
  67846. declare module BABYLON {
  67847. /**
  67848. *
  67849. * This post-process allows the modification of rendered colors by using
  67850. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67851. *
  67852. * The object needs to be provided an url to a texture containing the color
  67853. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67854. * Use an image editing software to tweak the LUT to match your needs.
  67855. *
  67856. * For an example of a color LUT, see here:
  67857. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67858. * For explanations on color grading, see here:
  67859. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67860. *
  67861. */
  67862. export class ColorCorrectionPostProcess extends PostProcess {
  67863. private _colorTableTexture;
  67864. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67865. }
  67866. }
  67867. declare module BABYLON {
  67868. /** @hidden */
  67869. export var convolutionPixelShader: {
  67870. name: string;
  67871. shader: string;
  67872. };
  67873. }
  67874. declare module BABYLON {
  67875. /**
  67876. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67877. * input texture to perform effects such as edge detection or sharpening
  67878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67879. */
  67880. export class ConvolutionPostProcess extends PostProcess {
  67881. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67882. kernel: number[];
  67883. /**
  67884. * Creates a new instance ConvolutionPostProcess
  67885. * @param name The name of the effect.
  67886. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67887. * @param options The required width/height ratio to downsize to before computing the render pass.
  67888. * @param camera The camera to apply the render pass to.
  67889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67890. * @param engine The engine which the post process will be applied. (default: current engine)
  67891. * @param reusable If the post process can be reused on the same frame. (default: false)
  67892. * @param textureType Type of textures used when performing the post process. (default: 0)
  67893. */
  67894. constructor(name: string,
  67895. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67896. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67897. /**
  67898. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67899. */
  67900. static EdgeDetect0Kernel: number[];
  67901. /**
  67902. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67903. */
  67904. static EdgeDetect1Kernel: number[];
  67905. /**
  67906. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67907. */
  67908. static EdgeDetect2Kernel: number[];
  67909. /**
  67910. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67911. */
  67912. static SharpenKernel: number[];
  67913. /**
  67914. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67915. */
  67916. static EmbossKernel: number[];
  67917. /**
  67918. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67919. */
  67920. static GaussianKernel: number[];
  67921. }
  67922. }
  67923. declare module BABYLON {
  67924. /**
  67925. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67926. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67927. * based on samples that have a large difference in distance than the center pixel.
  67928. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67929. */
  67930. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67931. direction: Vector2;
  67932. /**
  67933. * Creates a new instance CircleOfConfusionPostProcess
  67934. * @param name The name of the effect.
  67935. * @param scene The scene the effect belongs to.
  67936. * @param direction The direction the blur should be applied.
  67937. * @param kernel The size of the kernel used to blur.
  67938. * @param options The required width/height ratio to downsize to before computing the render pass.
  67939. * @param camera The camera to apply the render pass to.
  67940. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67941. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67943. * @param engine The engine which the post process will be applied. (default: current engine)
  67944. * @param reusable If the post process can be reused on the same frame. (default: false)
  67945. * @param textureType Type of textures used when performing the post process. (default: 0)
  67946. * @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)
  67947. */
  67948. 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);
  67949. }
  67950. }
  67951. declare module BABYLON {
  67952. /** @hidden */
  67953. export var depthOfFieldMergePixelShader: {
  67954. name: string;
  67955. shader: string;
  67956. };
  67957. }
  67958. declare module BABYLON {
  67959. /**
  67960. * Options to be set when merging outputs from the default pipeline.
  67961. */
  67962. export class DepthOfFieldMergePostProcessOptions {
  67963. /**
  67964. * The original image to merge on top of
  67965. */
  67966. originalFromInput: PostProcess;
  67967. /**
  67968. * Parameters to perform the merge of the depth of field effect
  67969. */
  67970. depthOfField?: {
  67971. circleOfConfusion: PostProcess;
  67972. blurSteps: Array<PostProcess>;
  67973. };
  67974. /**
  67975. * Parameters to perform the merge of bloom effect
  67976. */
  67977. bloom?: {
  67978. blurred: PostProcess;
  67979. weight: number;
  67980. };
  67981. }
  67982. /**
  67983. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67984. */
  67985. export class DepthOfFieldMergePostProcess extends PostProcess {
  67986. private blurSteps;
  67987. /**
  67988. * Creates a new instance of DepthOfFieldMergePostProcess
  67989. * @param name The name of the effect.
  67990. * @param originalFromInput Post process which's input will be used for the merge.
  67991. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67992. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67993. * @param options The required width/height ratio to downsize to before computing the render pass.
  67994. * @param camera The camera to apply the render pass to.
  67995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67996. * @param engine The engine which the post process will be applied. (default: current engine)
  67997. * @param reusable If the post process can be reused on the same frame. (default: false)
  67998. * @param textureType Type of textures used when performing the post process. (default: 0)
  67999. * @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)
  68000. */
  68001. 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);
  68002. /**
  68003. * Updates the effect with the current post process compile time values and recompiles the shader.
  68004. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68005. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68006. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68007. * @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
  68008. * @param onCompiled Called when the shader has been compiled.
  68009. * @param onError Called if there is an error when compiling a shader.
  68010. */
  68011. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68012. }
  68013. }
  68014. declare module BABYLON {
  68015. /**
  68016. * Specifies the level of max blur that should be applied when using the depth of field effect
  68017. */
  68018. export enum DepthOfFieldEffectBlurLevel {
  68019. /**
  68020. * Subtle blur
  68021. */
  68022. Low = 0,
  68023. /**
  68024. * Medium blur
  68025. */
  68026. Medium = 1,
  68027. /**
  68028. * Large blur
  68029. */
  68030. High = 2
  68031. }
  68032. /**
  68033. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68034. */
  68035. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68036. private _circleOfConfusion;
  68037. /**
  68038. * @hidden Internal, blurs from high to low
  68039. */
  68040. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68041. private _depthOfFieldBlurY;
  68042. private _dofMerge;
  68043. /**
  68044. * @hidden Internal post processes in depth of field effect
  68045. */
  68046. _effects: Array<PostProcess>;
  68047. /**
  68048. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68049. */
  68050. set focalLength(value: number);
  68051. get focalLength(): number;
  68052. /**
  68053. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68054. */
  68055. set fStop(value: number);
  68056. get fStop(): number;
  68057. /**
  68058. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68059. */
  68060. set focusDistance(value: number);
  68061. get focusDistance(): number;
  68062. /**
  68063. * 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.
  68064. */
  68065. set lensSize(value: number);
  68066. get lensSize(): number;
  68067. /**
  68068. * Creates a new instance DepthOfFieldEffect
  68069. * @param scene The scene the effect belongs to.
  68070. * @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.
  68071. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68072. * @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)
  68073. */
  68074. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68075. /**
  68076. * Get the current class name of the current effet
  68077. * @returns "DepthOfFieldEffect"
  68078. */
  68079. getClassName(): string;
  68080. /**
  68081. * 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.
  68082. */
  68083. set depthTexture(value: RenderTargetTexture);
  68084. /**
  68085. * Disposes each of the internal effects for a given camera.
  68086. * @param camera The camera to dispose the effect on.
  68087. */
  68088. disposeEffects(camera: Camera): void;
  68089. /**
  68090. * @hidden Internal
  68091. */
  68092. _updateEffects(): void;
  68093. /**
  68094. * Internal
  68095. * @returns if all the contained post processes are ready.
  68096. * @hidden
  68097. */
  68098. _isReady(): boolean;
  68099. }
  68100. }
  68101. declare module BABYLON {
  68102. /** @hidden */
  68103. export var displayPassPixelShader: {
  68104. name: string;
  68105. shader: string;
  68106. };
  68107. }
  68108. declare module BABYLON {
  68109. /**
  68110. * DisplayPassPostProcess which produces an output the same as it's input
  68111. */
  68112. export class DisplayPassPostProcess extends PostProcess {
  68113. /**
  68114. * Creates the DisplayPassPostProcess
  68115. * @param name The name of the effect.
  68116. * @param options The required width/height ratio to downsize to before computing the render pass.
  68117. * @param camera The camera to apply the render pass to.
  68118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68119. * @param engine The engine which the post process will be applied. (default: current engine)
  68120. * @param reusable If the post process can be reused on the same frame. (default: false)
  68121. */
  68122. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68123. }
  68124. }
  68125. declare module BABYLON {
  68126. /** @hidden */
  68127. export var filterPixelShader: {
  68128. name: string;
  68129. shader: string;
  68130. };
  68131. }
  68132. declare module BABYLON {
  68133. /**
  68134. * Applies a kernel filter to the image
  68135. */
  68136. export class FilterPostProcess extends PostProcess {
  68137. /** The matrix to be applied to the image */
  68138. kernelMatrix: Matrix;
  68139. /**
  68140. *
  68141. * @param name The name of the effect.
  68142. * @param kernelMatrix The matrix to be applied to the image
  68143. * @param options The required width/height ratio to downsize to before computing the render pass.
  68144. * @param camera The camera to apply the render pass to.
  68145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68146. * @param engine The engine which the post process will be applied. (default: current engine)
  68147. * @param reusable If the post process can be reused on the same frame. (default: false)
  68148. */
  68149. constructor(name: string,
  68150. /** The matrix to be applied to the image */
  68151. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68152. }
  68153. }
  68154. declare module BABYLON {
  68155. /** @hidden */
  68156. export var fxaaPixelShader: {
  68157. name: string;
  68158. shader: string;
  68159. };
  68160. }
  68161. declare module BABYLON {
  68162. /** @hidden */
  68163. export var fxaaVertexShader: {
  68164. name: string;
  68165. shader: string;
  68166. };
  68167. }
  68168. declare module BABYLON {
  68169. /**
  68170. * Fxaa post process
  68171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68172. */
  68173. export class FxaaPostProcess extends PostProcess {
  68174. /** @hidden */
  68175. texelWidth: number;
  68176. /** @hidden */
  68177. texelHeight: number;
  68178. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68179. private _getDefines;
  68180. }
  68181. }
  68182. declare module BABYLON {
  68183. /** @hidden */
  68184. export var grainPixelShader: {
  68185. name: string;
  68186. shader: string;
  68187. };
  68188. }
  68189. declare module BABYLON {
  68190. /**
  68191. * The GrainPostProcess adds noise to the image at mid luminance levels
  68192. */
  68193. export class GrainPostProcess extends PostProcess {
  68194. /**
  68195. * The intensity of the grain added (default: 30)
  68196. */
  68197. intensity: number;
  68198. /**
  68199. * If the grain should be randomized on every frame
  68200. */
  68201. animated: boolean;
  68202. /**
  68203. * Creates a new instance of @see GrainPostProcess
  68204. * @param name The name of the effect.
  68205. * @param options The required width/height ratio to downsize to before computing the render pass.
  68206. * @param camera The camera to apply the render pass to.
  68207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68208. * @param engine The engine which the post process will be applied. (default: current engine)
  68209. * @param reusable If the post process can be reused on the same frame. (default: false)
  68210. * @param textureType Type of textures used when performing the post process. (default: 0)
  68211. * @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)
  68212. */
  68213. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68214. }
  68215. }
  68216. declare module BABYLON {
  68217. /** @hidden */
  68218. export var highlightsPixelShader: {
  68219. name: string;
  68220. shader: string;
  68221. };
  68222. }
  68223. declare module BABYLON {
  68224. /**
  68225. * Extracts highlights from the image
  68226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68227. */
  68228. export class HighlightsPostProcess extends PostProcess {
  68229. /**
  68230. * Extracts highlights from the image
  68231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68232. * @param name The name of the effect.
  68233. * @param options The required width/height ratio to downsize to before computing the render pass.
  68234. * @param camera The camera to apply the render pass to.
  68235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68236. * @param engine The engine which the post process will be applied. (default: current engine)
  68237. * @param reusable If the post process can be reused on the same frame. (default: false)
  68238. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68239. */
  68240. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68241. }
  68242. }
  68243. declare module BABYLON {
  68244. /** @hidden */
  68245. export var mrtFragmentDeclaration: {
  68246. name: string;
  68247. shader: string;
  68248. };
  68249. }
  68250. declare module BABYLON {
  68251. /** @hidden */
  68252. export var geometryPixelShader: {
  68253. name: string;
  68254. shader: string;
  68255. };
  68256. }
  68257. declare module BABYLON {
  68258. /** @hidden */
  68259. export var geometryVertexShader: {
  68260. name: string;
  68261. shader: string;
  68262. };
  68263. }
  68264. declare module BABYLON {
  68265. /** @hidden */
  68266. interface ISavedTransformationMatrix {
  68267. world: Matrix;
  68268. viewProjection: Matrix;
  68269. }
  68270. /**
  68271. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68272. */
  68273. export class GeometryBufferRenderer {
  68274. /**
  68275. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68276. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68277. */
  68278. static readonly POSITION_TEXTURE_TYPE: number;
  68279. /**
  68280. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68281. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68282. */
  68283. static readonly VELOCITY_TEXTURE_TYPE: number;
  68284. /**
  68285. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68286. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68287. */
  68288. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68289. /**
  68290. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68291. * in order to compute objects velocities when enableVelocity is set to "true"
  68292. * @hidden
  68293. */
  68294. _previousTransformationMatrices: {
  68295. [index: number]: ISavedTransformationMatrix;
  68296. };
  68297. /**
  68298. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68299. * in order to compute objects velocities when enableVelocity is set to "true"
  68300. * @hidden
  68301. */
  68302. _previousBonesTransformationMatrices: {
  68303. [index: number]: Float32Array;
  68304. };
  68305. /**
  68306. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68307. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68308. */
  68309. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68310. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68311. renderTransparentMeshes: boolean;
  68312. private _scene;
  68313. private _multiRenderTarget;
  68314. private _ratio;
  68315. private _enablePosition;
  68316. private _enableVelocity;
  68317. private _enableReflectivity;
  68318. private _positionIndex;
  68319. private _velocityIndex;
  68320. private _reflectivityIndex;
  68321. protected _effect: Effect;
  68322. protected _cachedDefines: string;
  68323. /**
  68324. * Set the render list (meshes to be rendered) used in the G buffer.
  68325. */
  68326. set renderList(meshes: Mesh[]);
  68327. /**
  68328. * Gets wether or not G buffer are supported by the running hardware.
  68329. * This requires draw buffer supports
  68330. */
  68331. get isSupported(): boolean;
  68332. /**
  68333. * Returns the index of the given texture type in the G-Buffer textures array
  68334. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68335. * @returns the index of the given texture type in the G-Buffer textures array
  68336. */
  68337. getTextureIndex(textureType: number): number;
  68338. /**
  68339. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68340. */
  68341. get enablePosition(): boolean;
  68342. /**
  68343. * Sets whether or not objects positions are enabled for the G buffer.
  68344. */
  68345. set enablePosition(enable: boolean);
  68346. /**
  68347. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68348. */
  68349. get enableVelocity(): boolean;
  68350. /**
  68351. * Sets wether or not objects velocities are enabled for the G buffer.
  68352. */
  68353. set enableVelocity(enable: boolean);
  68354. /**
  68355. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68356. */
  68357. get enableReflectivity(): boolean;
  68358. /**
  68359. * Sets wether or not objects roughness are enabled for the G buffer.
  68360. */
  68361. set enableReflectivity(enable: boolean);
  68362. /**
  68363. * Gets the scene associated with the buffer.
  68364. */
  68365. get scene(): Scene;
  68366. /**
  68367. * Gets the ratio used by the buffer during its creation.
  68368. * How big is the buffer related to the main canvas.
  68369. */
  68370. get ratio(): number;
  68371. /** @hidden */
  68372. static _SceneComponentInitialization: (scene: Scene) => void;
  68373. /**
  68374. * Creates a new G Buffer for the scene
  68375. * @param scene The scene the buffer belongs to
  68376. * @param ratio How big is the buffer related to the main canvas.
  68377. */
  68378. constructor(scene: Scene, ratio?: number);
  68379. /**
  68380. * Checks wether everything is ready to render a submesh to the G buffer.
  68381. * @param subMesh the submesh to check readiness for
  68382. * @param useInstances is the mesh drawn using instance or not
  68383. * @returns true if ready otherwise false
  68384. */
  68385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68386. /**
  68387. * Gets the current underlying G Buffer.
  68388. * @returns the buffer
  68389. */
  68390. getGBuffer(): MultiRenderTarget;
  68391. /**
  68392. * Gets the number of samples used to render the buffer (anti aliasing).
  68393. */
  68394. get samples(): number;
  68395. /**
  68396. * Sets the number of samples used to render the buffer (anti aliasing).
  68397. */
  68398. set samples(value: number);
  68399. /**
  68400. * Disposes the renderer and frees up associated resources.
  68401. */
  68402. dispose(): void;
  68403. protected _createRenderTargets(): void;
  68404. private _copyBonesTransformationMatrices;
  68405. }
  68406. }
  68407. declare module BABYLON {
  68408. interface Scene {
  68409. /** @hidden (Backing field) */
  68410. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68411. /**
  68412. * Gets or Sets the current geometry buffer associated to the scene.
  68413. */
  68414. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68415. /**
  68416. * Enables a GeometryBufferRender and associates it with the scene
  68417. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68418. * @returns the GeometryBufferRenderer
  68419. */
  68420. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68421. /**
  68422. * Disables the GeometryBufferRender associated with the scene
  68423. */
  68424. disableGeometryBufferRenderer(): void;
  68425. }
  68426. /**
  68427. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68428. * in several rendering techniques.
  68429. */
  68430. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68431. /**
  68432. * The component name helpful to identify the component in the list of scene components.
  68433. */
  68434. readonly name: string;
  68435. /**
  68436. * The scene the component belongs to.
  68437. */
  68438. scene: Scene;
  68439. /**
  68440. * Creates a new instance of the component for the given scene
  68441. * @param scene Defines the scene to register the component in
  68442. */
  68443. constructor(scene: Scene);
  68444. /**
  68445. * Registers the component in a given scene
  68446. */
  68447. register(): void;
  68448. /**
  68449. * Rebuilds the elements related to this component in case of
  68450. * context lost for instance.
  68451. */
  68452. rebuild(): void;
  68453. /**
  68454. * Disposes the component and the associated ressources
  68455. */
  68456. dispose(): void;
  68457. private _gatherRenderTargets;
  68458. }
  68459. }
  68460. declare module BABYLON {
  68461. /** @hidden */
  68462. export var motionBlurPixelShader: {
  68463. name: string;
  68464. shader: string;
  68465. };
  68466. }
  68467. declare module BABYLON {
  68468. /**
  68469. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68470. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68471. * As an example, all you have to do is to create the post-process:
  68472. * var mb = new BABYLON.MotionBlurPostProcess(
  68473. * 'mb', // The name of the effect.
  68474. * scene, // The scene containing the objects to blur according to their velocity.
  68475. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68476. * camera // The camera to apply the render pass to.
  68477. * );
  68478. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68479. */
  68480. export class MotionBlurPostProcess extends PostProcess {
  68481. /**
  68482. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68483. */
  68484. motionStrength: number;
  68485. /**
  68486. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68487. */
  68488. get motionBlurSamples(): number;
  68489. /**
  68490. * Sets the number of iterations to be used for motion blur quality
  68491. */
  68492. set motionBlurSamples(samples: number);
  68493. private _motionBlurSamples;
  68494. private _geometryBufferRenderer;
  68495. /**
  68496. * Creates a new instance MotionBlurPostProcess
  68497. * @param name The name of the effect.
  68498. * @param scene The scene containing the objects to blur according to their velocity.
  68499. * @param options The required width/height ratio to downsize to before computing the render pass.
  68500. * @param camera The camera to apply the render pass to.
  68501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68502. * @param engine The engine which the post process will be applied. (default: current engine)
  68503. * @param reusable If the post process can be reused on the same frame. (default: false)
  68504. * @param textureType Type of textures used when performing the post process. (default: 0)
  68505. * @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)
  68506. */
  68507. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68508. /**
  68509. * Excludes the given skinned mesh from computing bones velocities.
  68510. * 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.
  68511. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68512. */
  68513. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68514. /**
  68515. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68516. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68517. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68518. */
  68519. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68520. /**
  68521. * Disposes the post process.
  68522. * @param camera The camera to dispose the post process on.
  68523. */
  68524. dispose(camera?: Camera): void;
  68525. }
  68526. }
  68527. declare module BABYLON {
  68528. /** @hidden */
  68529. export var refractionPixelShader: {
  68530. name: string;
  68531. shader: string;
  68532. };
  68533. }
  68534. declare module BABYLON {
  68535. /**
  68536. * Post process which applies a refractin texture
  68537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68538. */
  68539. export class RefractionPostProcess extends PostProcess {
  68540. /** the base color of the refraction (used to taint the rendering) */
  68541. color: Color3;
  68542. /** simulated refraction depth */
  68543. depth: number;
  68544. /** the coefficient of the base color (0 to remove base color tainting) */
  68545. colorLevel: number;
  68546. private _refTexture;
  68547. private _ownRefractionTexture;
  68548. /**
  68549. * Gets or sets the refraction texture
  68550. * Please note that you are responsible for disposing the texture if you set it manually
  68551. */
  68552. get refractionTexture(): Texture;
  68553. set refractionTexture(value: Texture);
  68554. /**
  68555. * Initializes the RefractionPostProcess
  68556. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68557. * @param name The name of the effect.
  68558. * @param refractionTextureUrl Url of the refraction texture to use
  68559. * @param color the base color of the refraction (used to taint the rendering)
  68560. * @param depth simulated refraction depth
  68561. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68562. * @param camera The camera to apply the render pass to.
  68563. * @param options The required width/height ratio to downsize to before computing the render pass.
  68564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68565. * @param engine The engine which the post process will be applied. (default: current engine)
  68566. * @param reusable If the post process can be reused on the same frame. (default: false)
  68567. */
  68568. constructor(name: string, refractionTextureUrl: string,
  68569. /** the base color of the refraction (used to taint the rendering) */
  68570. color: Color3,
  68571. /** simulated refraction depth */
  68572. depth: number,
  68573. /** the coefficient of the base color (0 to remove base color tainting) */
  68574. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68575. /**
  68576. * Disposes of the post process
  68577. * @param camera Camera to dispose post process on
  68578. */
  68579. dispose(camera: Camera): void;
  68580. }
  68581. }
  68582. declare module BABYLON {
  68583. /** @hidden */
  68584. export var sharpenPixelShader: {
  68585. name: string;
  68586. shader: string;
  68587. };
  68588. }
  68589. declare module BABYLON {
  68590. /**
  68591. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68592. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68593. */
  68594. export class SharpenPostProcess extends PostProcess {
  68595. /**
  68596. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68597. */
  68598. colorAmount: number;
  68599. /**
  68600. * How much sharpness should be applied (default: 0.3)
  68601. */
  68602. edgeAmount: number;
  68603. /**
  68604. * Creates a new instance ConvolutionPostProcess
  68605. * @param name The name of the effect.
  68606. * @param options The required width/height ratio to downsize to before computing the render pass.
  68607. * @param camera The camera to apply the render pass to.
  68608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68609. * @param engine The engine which the post process will be applied. (default: current engine)
  68610. * @param reusable If the post process can be reused on the same frame. (default: false)
  68611. * @param textureType Type of textures used when performing the post process. (default: 0)
  68612. * @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)
  68613. */
  68614. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68615. }
  68616. }
  68617. declare module BABYLON {
  68618. /**
  68619. * PostProcessRenderPipeline
  68620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68621. */
  68622. export class PostProcessRenderPipeline {
  68623. private engine;
  68624. private _renderEffects;
  68625. private _renderEffectsForIsolatedPass;
  68626. /**
  68627. * List of inspectable custom properties (used by the Inspector)
  68628. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68629. */
  68630. inspectableCustomProperties: IInspectable[];
  68631. /**
  68632. * @hidden
  68633. */
  68634. protected _cameras: Camera[];
  68635. /** @hidden */
  68636. _name: string;
  68637. /**
  68638. * Gets pipeline name
  68639. */
  68640. get name(): string;
  68641. /** Gets the list of attached cameras */
  68642. get cameras(): Camera[];
  68643. /**
  68644. * Initializes a PostProcessRenderPipeline
  68645. * @param engine engine to add the pipeline to
  68646. * @param name name of the pipeline
  68647. */
  68648. constructor(engine: Engine, name: string);
  68649. /**
  68650. * Gets the class name
  68651. * @returns "PostProcessRenderPipeline"
  68652. */
  68653. getClassName(): string;
  68654. /**
  68655. * If all the render effects in the pipeline are supported
  68656. */
  68657. get isSupported(): boolean;
  68658. /**
  68659. * Adds an effect to the pipeline
  68660. * @param renderEffect the effect to add
  68661. */
  68662. addEffect(renderEffect: PostProcessRenderEffect): void;
  68663. /** @hidden */
  68664. _rebuild(): void;
  68665. /** @hidden */
  68666. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68667. /** @hidden */
  68668. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68669. /** @hidden */
  68670. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68671. /** @hidden */
  68672. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68673. /** @hidden */
  68674. _attachCameras(cameras: Camera, unique: boolean): void;
  68675. /** @hidden */
  68676. _attachCameras(cameras: Camera[], unique: boolean): void;
  68677. /** @hidden */
  68678. _detachCameras(cameras: Camera): void;
  68679. /** @hidden */
  68680. _detachCameras(cameras: Nullable<Camera[]>): void;
  68681. /** @hidden */
  68682. _update(): void;
  68683. /** @hidden */
  68684. _reset(): void;
  68685. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68686. /**
  68687. * Disposes of the pipeline
  68688. */
  68689. dispose(): void;
  68690. }
  68691. }
  68692. declare module BABYLON {
  68693. /**
  68694. * PostProcessRenderPipelineManager class
  68695. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68696. */
  68697. export class PostProcessRenderPipelineManager {
  68698. private _renderPipelines;
  68699. /**
  68700. * Initializes a PostProcessRenderPipelineManager
  68701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68702. */
  68703. constructor();
  68704. /**
  68705. * Gets the list of supported render pipelines
  68706. */
  68707. get supportedPipelines(): PostProcessRenderPipeline[];
  68708. /**
  68709. * Adds a pipeline to the manager
  68710. * @param renderPipeline The pipeline to add
  68711. */
  68712. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68713. /**
  68714. * Attaches a camera to the pipeline
  68715. * @param renderPipelineName The name of the pipeline to attach to
  68716. * @param cameras the camera to attach
  68717. * @param unique if the camera can be attached multiple times to the pipeline
  68718. */
  68719. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68720. /**
  68721. * Detaches a camera from the pipeline
  68722. * @param renderPipelineName The name of the pipeline to detach from
  68723. * @param cameras the camera to detach
  68724. */
  68725. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68726. /**
  68727. * Enables an effect by name on a pipeline
  68728. * @param renderPipelineName the name of the pipeline to enable the effect in
  68729. * @param renderEffectName the name of the effect to enable
  68730. * @param cameras the cameras that the effect should be enabled on
  68731. */
  68732. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68733. /**
  68734. * Disables an effect by name on a pipeline
  68735. * @param renderPipelineName the name of the pipeline to disable the effect in
  68736. * @param renderEffectName the name of the effect to disable
  68737. * @param cameras the cameras that the effect should be disabled on
  68738. */
  68739. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68740. /**
  68741. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68742. */
  68743. update(): void;
  68744. /** @hidden */
  68745. _rebuild(): void;
  68746. /**
  68747. * Disposes of the manager and pipelines
  68748. */
  68749. dispose(): void;
  68750. }
  68751. }
  68752. declare module BABYLON {
  68753. interface Scene {
  68754. /** @hidden (Backing field) */
  68755. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68756. /**
  68757. * Gets the postprocess render pipeline manager
  68758. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68759. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68760. */
  68761. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68762. }
  68763. /**
  68764. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68765. */
  68766. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68767. /**
  68768. * The component name helpfull to identify the component in the list of scene components.
  68769. */
  68770. readonly name: string;
  68771. /**
  68772. * The scene the component belongs to.
  68773. */
  68774. scene: Scene;
  68775. /**
  68776. * Creates a new instance of the component for the given scene
  68777. * @param scene Defines the scene to register the component in
  68778. */
  68779. constructor(scene: Scene);
  68780. /**
  68781. * Registers the component in a given scene
  68782. */
  68783. register(): void;
  68784. /**
  68785. * Rebuilds the elements related to this component in case of
  68786. * context lost for instance.
  68787. */
  68788. rebuild(): void;
  68789. /**
  68790. * Disposes the component and the associated ressources
  68791. */
  68792. dispose(): void;
  68793. private _gatherRenderTargets;
  68794. }
  68795. }
  68796. declare module BABYLON {
  68797. /**
  68798. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68799. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68800. */
  68801. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68802. private _scene;
  68803. private _camerasToBeAttached;
  68804. /**
  68805. * ID of the sharpen post process,
  68806. */
  68807. private readonly SharpenPostProcessId;
  68808. /**
  68809. * @ignore
  68810. * ID of the image processing post process;
  68811. */
  68812. readonly ImageProcessingPostProcessId: string;
  68813. /**
  68814. * @ignore
  68815. * ID of the Fast Approximate Anti-Aliasing post process;
  68816. */
  68817. readonly FxaaPostProcessId: string;
  68818. /**
  68819. * ID of the chromatic aberration post process,
  68820. */
  68821. private readonly ChromaticAberrationPostProcessId;
  68822. /**
  68823. * ID of the grain post process
  68824. */
  68825. private readonly GrainPostProcessId;
  68826. /**
  68827. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68828. */
  68829. sharpen: SharpenPostProcess;
  68830. private _sharpenEffect;
  68831. private bloom;
  68832. /**
  68833. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68834. */
  68835. depthOfField: DepthOfFieldEffect;
  68836. /**
  68837. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68838. */
  68839. fxaa: FxaaPostProcess;
  68840. /**
  68841. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68842. */
  68843. imageProcessing: ImageProcessingPostProcess;
  68844. /**
  68845. * Chromatic aberration post process which will shift rgb colors in the image
  68846. */
  68847. chromaticAberration: ChromaticAberrationPostProcess;
  68848. private _chromaticAberrationEffect;
  68849. /**
  68850. * Grain post process which add noise to the image
  68851. */
  68852. grain: GrainPostProcess;
  68853. private _grainEffect;
  68854. /**
  68855. * Glow post process which adds a glow to emissive areas of the image
  68856. */
  68857. private _glowLayer;
  68858. /**
  68859. * Animations which can be used to tweak settings over a period of time
  68860. */
  68861. animations: Animation[];
  68862. private _imageProcessingConfigurationObserver;
  68863. private _sharpenEnabled;
  68864. private _bloomEnabled;
  68865. private _depthOfFieldEnabled;
  68866. private _depthOfFieldBlurLevel;
  68867. private _fxaaEnabled;
  68868. private _imageProcessingEnabled;
  68869. private _defaultPipelineTextureType;
  68870. private _bloomScale;
  68871. private _chromaticAberrationEnabled;
  68872. private _grainEnabled;
  68873. private _buildAllowed;
  68874. /**
  68875. * Gets active scene
  68876. */
  68877. get scene(): Scene;
  68878. /**
  68879. * Enable or disable the sharpen process from the pipeline
  68880. */
  68881. set sharpenEnabled(enabled: boolean);
  68882. get sharpenEnabled(): boolean;
  68883. private _resizeObserver;
  68884. private _hardwareScaleLevel;
  68885. private _bloomKernel;
  68886. /**
  68887. * Specifies the size of the bloom blur kernel, relative to the final output size
  68888. */
  68889. get bloomKernel(): number;
  68890. set bloomKernel(value: number);
  68891. /**
  68892. * Specifies the weight of the bloom in the final rendering
  68893. */
  68894. private _bloomWeight;
  68895. /**
  68896. * Specifies the luma threshold for the area that will be blurred by the bloom
  68897. */
  68898. private _bloomThreshold;
  68899. private _hdr;
  68900. /**
  68901. * The strength of the bloom.
  68902. */
  68903. set bloomWeight(value: number);
  68904. get bloomWeight(): number;
  68905. /**
  68906. * The strength of the bloom.
  68907. */
  68908. set bloomThreshold(value: number);
  68909. get bloomThreshold(): number;
  68910. /**
  68911. * The scale of the bloom, lower value will provide better performance.
  68912. */
  68913. set bloomScale(value: number);
  68914. get bloomScale(): number;
  68915. /**
  68916. * Enable or disable the bloom from the pipeline
  68917. */
  68918. set bloomEnabled(enabled: boolean);
  68919. get bloomEnabled(): boolean;
  68920. private _rebuildBloom;
  68921. /**
  68922. * If the depth of field is enabled.
  68923. */
  68924. get depthOfFieldEnabled(): boolean;
  68925. set depthOfFieldEnabled(enabled: boolean);
  68926. /**
  68927. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68928. */
  68929. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68930. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68931. /**
  68932. * If the anti aliasing is enabled.
  68933. */
  68934. set fxaaEnabled(enabled: boolean);
  68935. get fxaaEnabled(): boolean;
  68936. private _samples;
  68937. /**
  68938. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68939. */
  68940. set samples(sampleCount: number);
  68941. get samples(): number;
  68942. /**
  68943. * If image processing is enabled.
  68944. */
  68945. set imageProcessingEnabled(enabled: boolean);
  68946. get imageProcessingEnabled(): boolean;
  68947. /**
  68948. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68949. */
  68950. set glowLayerEnabled(enabled: boolean);
  68951. get glowLayerEnabled(): boolean;
  68952. /**
  68953. * Gets the glow layer (or null if not defined)
  68954. */
  68955. get glowLayer(): Nullable<GlowLayer>;
  68956. /**
  68957. * Enable or disable the chromaticAberration process from the pipeline
  68958. */
  68959. set chromaticAberrationEnabled(enabled: boolean);
  68960. get chromaticAberrationEnabled(): boolean;
  68961. /**
  68962. * Enable or disable the grain process from the pipeline
  68963. */
  68964. set grainEnabled(enabled: boolean);
  68965. get grainEnabled(): boolean;
  68966. /**
  68967. * @constructor
  68968. * @param name - The rendering pipeline name (default: "")
  68969. * @param hdr - If high dynamic range textures should be used (default: true)
  68970. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68971. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68972. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68973. */
  68974. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68975. /**
  68976. * Get the class name
  68977. * @returns "DefaultRenderingPipeline"
  68978. */
  68979. getClassName(): string;
  68980. /**
  68981. * Force the compilation of the entire pipeline.
  68982. */
  68983. prepare(): void;
  68984. private _hasCleared;
  68985. private _prevPostProcess;
  68986. private _prevPrevPostProcess;
  68987. private _setAutoClearAndTextureSharing;
  68988. private _depthOfFieldSceneObserver;
  68989. private _buildPipeline;
  68990. private _disposePostProcesses;
  68991. /**
  68992. * Adds a camera to the pipeline
  68993. * @param camera the camera to be added
  68994. */
  68995. addCamera(camera: Camera): void;
  68996. /**
  68997. * Removes a camera from the pipeline
  68998. * @param camera the camera to remove
  68999. */
  69000. removeCamera(camera: Camera): void;
  69001. /**
  69002. * Dispose of the pipeline and stop all post processes
  69003. */
  69004. dispose(): void;
  69005. /**
  69006. * Serialize the rendering pipeline (Used when exporting)
  69007. * @returns the serialized object
  69008. */
  69009. serialize(): any;
  69010. /**
  69011. * Parse the serialized pipeline
  69012. * @param source Source pipeline.
  69013. * @param scene The scene to load the pipeline to.
  69014. * @param rootUrl The URL of the serialized pipeline.
  69015. * @returns An instantiated pipeline from the serialized object.
  69016. */
  69017. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69018. }
  69019. }
  69020. declare module BABYLON {
  69021. /** @hidden */
  69022. export var lensHighlightsPixelShader: {
  69023. name: string;
  69024. shader: string;
  69025. };
  69026. }
  69027. declare module BABYLON {
  69028. /** @hidden */
  69029. export var depthOfFieldPixelShader: {
  69030. name: string;
  69031. shader: string;
  69032. };
  69033. }
  69034. declare module BABYLON {
  69035. /**
  69036. * BABYLON.JS Chromatic Aberration GLSL Shader
  69037. * Author: Olivier Guyot
  69038. * Separates very slightly R, G and B colors on the edges of the screen
  69039. * Inspired by Francois Tarlier & Martins Upitis
  69040. */
  69041. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69042. /**
  69043. * @ignore
  69044. * The chromatic aberration PostProcess id in the pipeline
  69045. */
  69046. LensChromaticAberrationEffect: string;
  69047. /**
  69048. * @ignore
  69049. * The highlights enhancing PostProcess id in the pipeline
  69050. */
  69051. HighlightsEnhancingEffect: string;
  69052. /**
  69053. * @ignore
  69054. * The depth-of-field PostProcess id in the pipeline
  69055. */
  69056. LensDepthOfFieldEffect: string;
  69057. private _scene;
  69058. private _depthTexture;
  69059. private _grainTexture;
  69060. private _chromaticAberrationPostProcess;
  69061. private _highlightsPostProcess;
  69062. private _depthOfFieldPostProcess;
  69063. private _edgeBlur;
  69064. private _grainAmount;
  69065. private _chromaticAberration;
  69066. private _distortion;
  69067. private _highlightsGain;
  69068. private _highlightsThreshold;
  69069. private _dofDistance;
  69070. private _dofAperture;
  69071. private _dofDarken;
  69072. private _dofPentagon;
  69073. private _blurNoise;
  69074. /**
  69075. * @constructor
  69076. *
  69077. * Effect parameters are as follow:
  69078. * {
  69079. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69080. * edge_blur: number; // from 0 to x (1 for realism)
  69081. * distortion: number; // from 0 to x (1 for realism)
  69082. * grain_amount: number; // from 0 to 1
  69083. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69084. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69085. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69086. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69087. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69088. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69089. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69090. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69091. * }
  69092. * Note: if an effect parameter is unset, effect is disabled
  69093. *
  69094. * @param name The rendering pipeline name
  69095. * @param parameters - An object containing all parameters (see above)
  69096. * @param scene The scene linked to this pipeline
  69097. * @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)
  69098. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69099. */
  69100. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69101. /**
  69102. * Get the class name
  69103. * @returns "LensRenderingPipeline"
  69104. */
  69105. getClassName(): string;
  69106. /**
  69107. * Gets associated scene
  69108. */
  69109. get scene(): Scene;
  69110. /**
  69111. * Gets or sets the edge blur
  69112. */
  69113. get edgeBlur(): number;
  69114. set edgeBlur(value: number);
  69115. /**
  69116. * Gets or sets the grain amount
  69117. */
  69118. get grainAmount(): number;
  69119. set grainAmount(value: number);
  69120. /**
  69121. * Gets or sets the chromatic aberration amount
  69122. */
  69123. get chromaticAberration(): number;
  69124. set chromaticAberration(value: number);
  69125. /**
  69126. * Gets or sets the depth of field aperture
  69127. */
  69128. get dofAperture(): number;
  69129. set dofAperture(value: number);
  69130. /**
  69131. * Gets or sets the edge distortion
  69132. */
  69133. get edgeDistortion(): number;
  69134. set edgeDistortion(value: number);
  69135. /**
  69136. * Gets or sets the depth of field distortion
  69137. */
  69138. get dofDistortion(): number;
  69139. set dofDistortion(value: number);
  69140. /**
  69141. * Gets or sets the darken out of focus amount
  69142. */
  69143. get darkenOutOfFocus(): number;
  69144. set darkenOutOfFocus(value: number);
  69145. /**
  69146. * Gets or sets a boolean indicating if blur noise is enabled
  69147. */
  69148. get blurNoise(): boolean;
  69149. set blurNoise(value: boolean);
  69150. /**
  69151. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69152. */
  69153. get pentagonBokeh(): boolean;
  69154. set pentagonBokeh(value: boolean);
  69155. /**
  69156. * Gets or sets the highlight grain amount
  69157. */
  69158. get highlightsGain(): number;
  69159. set highlightsGain(value: number);
  69160. /**
  69161. * Gets or sets the highlight threshold
  69162. */
  69163. get highlightsThreshold(): number;
  69164. set highlightsThreshold(value: number);
  69165. /**
  69166. * Sets the amount of blur at the edges
  69167. * @param amount blur amount
  69168. */
  69169. setEdgeBlur(amount: number): void;
  69170. /**
  69171. * Sets edge blur to 0
  69172. */
  69173. disableEdgeBlur(): void;
  69174. /**
  69175. * Sets the amout of grain
  69176. * @param amount Amount of grain
  69177. */
  69178. setGrainAmount(amount: number): void;
  69179. /**
  69180. * Set grain amount to 0
  69181. */
  69182. disableGrain(): void;
  69183. /**
  69184. * Sets the chromatic aberration amount
  69185. * @param amount amount of chromatic aberration
  69186. */
  69187. setChromaticAberration(amount: number): void;
  69188. /**
  69189. * Sets chromatic aberration amount to 0
  69190. */
  69191. disableChromaticAberration(): void;
  69192. /**
  69193. * Sets the EdgeDistortion amount
  69194. * @param amount amount of EdgeDistortion
  69195. */
  69196. setEdgeDistortion(amount: number): void;
  69197. /**
  69198. * Sets edge distortion to 0
  69199. */
  69200. disableEdgeDistortion(): void;
  69201. /**
  69202. * Sets the FocusDistance amount
  69203. * @param amount amount of FocusDistance
  69204. */
  69205. setFocusDistance(amount: number): void;
  69206. /**
  69207. * Disables depth of field
  69208. */
  69209. disableDepthOfField(): void;
  69210. /**
  69211. * Sets the Aperture amount
  69212. * @param amount amount of Aperture
  69213. */
  69214. setAperture(amount: number): void;
  69215. /**
  69216. * Sets the DarkenOutOfFocus amount
  69217. * @param amount amount of DarkenOutOfFocus
  69218. */
  69219. setDarkenOutOfFocus(amount: number): void;
  69220. private _pentagonBokehIsEnabled;
  69221. /**
  69222. * Creates a pentagon bokeh effect
  69223. */
  69224. enablePentagonBokeh(): void;
  69225. /**
  69226. * Disables the pentagon bokeh effect
  69227. */
  69228. disablePentagonBokeh(): void;
  69229. /**
  69230. * Enables noise blur
  69231. */
  69232. enableNoiseBlur(): void;
  69233. /**
  69234. * Disables noise blur
  69235. */
  69236. disableNoiseBlur(): void;
  69237. /**
  69238. * Sets the HighlightsGain amount
  69239. * @param amount amount of HighlightsGain
  69240. */
  69241. setHighlightsGain(amount: number): void;
  69242. /**
  69243. * Sets the HighlightsThreshold amount
  69244. * @param amount amount of HighlightsThreshold
  69245. */
  69246. setHighlightsThreshold(amount: number): void;
  69247. /**
  69248. * Disables highlights
  69249. */
  69250. disableHighlights(): void;
  69251. /**
  69252. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69253. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69254. */
  69255. dispose(disableDepthRender?: boolean): void;
  69256. private _createChromaticAberrationPostProcess;
  69257. private _createHighlightsPostProcess;
  69258. private _createDepthOfFieldPostProcess;
  69259. private _createGrainTexture;
  69260. }
  69261. }
  69262. declare module BABYLON {
  69263. /** @hidden */
  69264. export var ssao2PixelShader: {
  69265. name: string;
  69266. shader: string;
  69267. };
  69268. }
  69269. declare module BABYLON {
  69270. /** @hidden */
  69271. export var ssaoCombinePixelShader: {
  69272. name: string;
  69273. shader: string;
  69274. };
  69275. }
  69276. declare module BABYLON {
  69277. /**
  69278. * Render pipeline to produce ssao effect
  69279. */
  69280. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69281. /**
  69282. * @ignore
  69283. * The PassPostProcess id in the pipeline that contains the original scene color
  69284. */
  69285. SSAOOriginalSceneColorEffect: string;
  69286. /**
  69287. * @ignore
  69288. * The SSAO PostProcess id in the pipeline
  69289. */
  69290. SSAORenderEffect: string;
  69291. /**
  69292. * @ignore
  69293. * The horizontal blur PostProcess id in the pipeline
  69294. */
  69295. SSAOBlurHRenderEffect: string;
  69296. /**
  69297. * @ignore
  69298. * The vertical blur PostProcess id in the pipeline
  69299. */
  69300. SSAOBlurVRenderEffect: string;
  69301. /**
  69302. * @ignore
  69303. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69304. */
  69305. SSAOCombineRenderEffect: string;
  69306. /**
  69307. * The output strength of the SSAO post-process. Default value is 1.0.
  69308. */
  69309. totalStrength: number;
  69310. /**
  69311. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69312. */
  69313. maxZ: number;
  69314. /**
  69315. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69316. */
  69317. minZAspect: number;
  69318. private _samples;
  69319. /**
  69320. * Number of samples used for the SSAO calculations. Default value is 8
  69321. */
  69322. set samples(n: number);
  69323. get samples(): number;
  69324. private _textureSamples;
  69325. /**
  69326. * Number of samples to use for antialiasing
  69327. */
  69328. set textureSamples(n: number);
  69329. get textureSamples(): number;
  69330. /**
  69331. * Ratio object used for SSAO ratio and blur ratio
  69332. */
  69333. private _ratio;
  69334. /**
  69335. * Dynamically generated sphere sampler.
  69336. */
  69337. private _sampleSphere;
  69338. /**
  69339. * Blur filter offsets
  69340. */
  69341. private _samplerOffsets;
  69342. private _expensiveBlur;
  69343. /**
  69344. * If bilateral blur should be used
  69345. */
  69346. set expensiveBlur(b: boolean);
  69347. get expensiveBlur(): boolean;
  69348. /**
  69349. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69350. */
  69351. radius: number;
  69352. /**
  69353. * The base color of the SSAO post-process
  69354. * The final result is "base + ssao" between [0, 1]
  69355. */
  69356. base: number;
  69357. /**
  69358. * Support test.
  69359. */
  69360. static get IsSupported(): boolean;
  69361. private _scene;
  69362. private _depthTexture;
  69363. private _normalTexture;
  69364. private _randomTexture;
  69365. private _originalColorPostProcess;
  69366. private _ssaoPostProcess;
  69367. private _blurHPostProcess;
  69368. private _blurVPostProcess;
  69369. private _ssaoCombinePostProcess;
  69370. /**
  69371. * Gets active scene
  69372. */
  69373. get scene(): Scene;
  69374. /**
  69375. * @constructor
  69376. * @param name The rendering pipeline name
  69377. * @param scene The scene linked to this pipeline
  69378. * @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 }
  69379. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69380. */
  69381. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69382. /**
  69383. * Get the class name
  69384. * @returns "SSAO2RenderingPipeline"
  69385. */
  69386. getClassName(): string;
  69387. /**
  69388. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69389. */
  69390. dispose(disableGeometryBufferRenderer?: boolean): void;
  69391. private _createBlurPostProcess;
  69392. /** @hidden */
  69393. _rebuild(): void;
  69394. private _bits;
  69395. private _radicalInverse_VdC;
  69396. private _hammersley;
  69397. private _hemisphereSample_uniform;
  69398. private _generateHemisphere;
  69399. private _createSSAOPostProcess;
  69400. private _createSSAOCombinePostProcess;
  69401. private _createRandomTexture;
  69402. /**
  69403. * Serialize the rendering pipeline (Used when exporting)
  69404. * @returns the serialized object
  69405. */
  69406. serialize(): any;
  69407. /**
  69408. * Parse the serialized pipeline
  69409. * @param source Source pipeline.
  69410. * @param scene The scene to load the pipeline to.
  69411. * @param rootUrl The URL of the serialized pipeline.
  69412. * @returns An instantiated pipeline from the serialized object.
  69413. */
  69414. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69415. }
  69416. }
  69417. declare module BABYLON {
  69418. /** @hidden */
  69419. export var ssaoPixelShader: {
  69420. name: string;
  69421. shader: string;
  69422. };
  69423. }
  69424. declare module BABYLON {
  69425. /**
  69426. * Render pipeline to produce ssao effect
  69427. */
  69428. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69429. /**
  69430. * @ignore
  69431. * The PassPostProcess id in the pipeline that contains the original scene color
  69432. */
  69433. SSAOOriginalSceneColorEffect: string;
  69434. /**
  69435. * @ignore
  69436. * The SSAO PostProcess id in the pipeline
  69437. */
  69438. SSAORenderEffect: string;
  69439. /**
  69440. * @ignore
  69441. * The horizontal blur PostProcess id in the pipeline
  69442. */
  69443. SSAOBlurHRenderEffect: string;
  69444. /**
  69445. * @ignore
  69446. * The vertical blur PostProcess id in the pipeline
  69447. */
  69448. SSAOBlurVRenderEffect: string;
  69449. /**
  69450. * @ignore
  69451. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69452. */
  69453. SSAOCombineRenderEffect: string;
  69454. /**
  69455. * The output strength of the SSAO post-process. Default value is 1.0.
  69456. */
  69457. totalStrength: number;
  69458. /**
  69459. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69460. */
  69461. radius: number;
  69462. /**
  69463. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69464. * Must not be equal to fallOff and superior to fallOff.
  69465. * Default value is 0.0075
  69466. */
  69467. area: number;
  69468. /**
  69469. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69470. * Must not be equal to area and inferior to area.
  69471. * Default value is 0.000001
  69472. */
  69473. fallOff: number;
  69474. /**
  69475. * The base color of the SSAO post-process
  69476. * The final result is "base + ssao" between [0, 1]
  69477. */
  69478. base: number;
  69479. private _scene;
  69480. private _depthTexture;
  69481. private _randomTexture;
  69482. private _originalColorPostProcess;
  69483. private _ssaoPostProcess;
  69484. private _blurHPostProcess;
  69485. private _blurVPostProcess;
  69486. private _ssaoCombinePostProcess;
  69487. private _firstUpdate;
  69488. /**
  69489. * Gets active scene
  69490. */
  69491. get scene(): Scene;
  69492. /**
  69493. * @constructor
  69494. * @param name - The rendering pipeline name
  69495. * @param scene - The scene linked to this pipeline
  69496. * @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 }
  69497. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69498. */
  69499. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69500. /**
  69501. * Get the class name
  69502. * @returns "SSAORenderingPipeline"
  69503. */
  69504. getClassName(): string;
  69505. /**
  69506. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69507. */
  69508. dispose(disableDepthRender?: boolean): void;
  69509. private _createBlurPostProcess;
  69510. /** @hidden */
  69511. _rebuild(): void;
  69512. private _createSSAOPostProcess;
  69513. private _createSSAOCombinePostProcess;
  69514. private _createRandomTexture;
  69515. }
  69516. }
  69517. declare module BABYLON {
  69518. /** @hidden */
  69519. export var screenSpaceReflectionPixelShader: {
  69520. name: string;
  69521. shader: string;
  69522. };
  69523. }
  69524. declare module BABYLON {
  69525. /**
  69526. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69527. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69528. */
  69529. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69530. /**
  69531. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69532. */
  69533. threshold: number;
  69534. /**
  69535. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69536. */
  69537. strength: number;
  69538. /**
  69539. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69540. */
  69541. reflectionSpecularFalloffExponent: number;
  69542. /**
  69543. * 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]
  69544. */
  69545. step: number;
  69546. /**
  69547. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69548. */
  69549. roughnessFactor: number;
  69550. private _geometryBufferRenderer;
  69551. private _enableSmoothReflections;
  69552. private _reflectionSamples;
  69553. private _smoothSteps;
  69554. /**
  69555. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69556. * @param name The name of the effect.
  69557. * @param scene The scene containing the objects to calculate reflections.
  69558. * @param options The required width/height ratio to downsize to before computing the render pass.
  69559. * @param camera The camera to apply the render pass to.
  69560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69561. * @param engine The engine which the post process will be applied. (default: current engine)
  69562. * @param reusable If the post process can be reused on the same frame. (default: false)
  69563. * @param textureType Type of textures used when performing the post process. (default: 0)
  69564. * @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)
  69565. */
  69566. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69567. /**
  69568. * Gets wether or not smoothing reflections is enabled.
  69569. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69570. */
  69571. get enableSmoothReflections(): boolean;
  69572. /**
  69573. * Sets wether or not smoothing reflections is enabled.
  69574. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69575. */
  69576. set enableSmoothReflections(enabled: boolean);
  69577. /**
  69578. * Gets the number of samples taken while computing reflections. More samples count is high,
  69579. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69580. */
  69581. get reflectionSamples(): number;
  69582. /**
  69583. * Sets the number of samples taken while computing reflections. More samples count is high,
  69584. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69585. */
  69586. set reflectionSamples(samples: number);
  69587. /**
  69588. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69589. * more the post-process will require GPU power and can generate a drop in FPS.
  69590. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69591. */
  69592. get smoothSteps(): number;
  69593. set smoothSteps(steps: number);
  69594. private _updateEffectDefines;
  69595. }
  69596. }
  69597. declare module BABYLON {
  69598. /** @hidden */
  69599. export var standardPixelShader: {
  69600. name: string;
  69601. shader: string;
  69602. };
  69603. }
  69604. declare module BABYLON {
  69605. /**
  69606. * Standard rendering pipeline
  69607. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69608. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69609. */
  69610. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69611. /**
  69612. * Public members
  69613. */
  69614. /**
  69615. * Post-process which contains the original scene color before the pipeline applies all the effects
  69616. */
  69617. originalPostProcess: Nullable<PostProcess>;
  69618. /**
  69619. * Post-process used to down scale an image x4
  69620. */
  69621. downSampleX4PostProcess: Nullable<PostProcess>;
  69622. /**
  69623. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69624. */
  69625. brightPassPostProcess: Nullable<PostProcess>;
  69626. /**
  69627. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69628. */
  69629. blurHPostProcesses: PostProcess[];
  69630. /**
  69631. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69632. */
  69633. blurVPostProcesses: PostProcess[];
  69634. /**
  69635. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69636. */
  69637. textureAdderPostProcess: Nullable<PostProcess>;
  69638. /**
  69639. * Post-process used to create volumetric lighting effect
  69640. */
  69641. volumetricLightPostProcess: Nullable<PostProcess>;
  69642. /**
  69643. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69644. */
  69645. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69646. /**
  69647. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69648. */
  69649. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69650. /**
  69651. * Post-process used to merge the volumetric light effect and the real scene color
  69652. */
  69653. volumetricLightMergePostProces: Nullable<PostProcess>;
  69654. /**
  69655. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69656. */
  69657. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69658. /**
  69659. * Base post-process used to calculate the average luminance of the final image for HDR
  69660. */
  69661. luminancePostProcess: Nullable<PostProcess>;
  69662. /**
  69663. * Post-processes used to create down sample post-processes in order to get
  69664. * the average luminance of the final image for HDR
  69665. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69666. */
  69667. luminanceDownSamplePostProcesses: PostProcess[];
  69668. /**
  69669. * Post-process used to create a HDR effect (light adaptation)
  69670. */
  69671. hdrPostProcess: Nullable<PostProcess>;
  69672. /**
  69673. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69674. */
  69675. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69676. /**
  69677. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69678. */
  69679. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69680. /**
  69681. * Post-process used to merge the final HDR post-process and the real scene color
  69682. */
  69683. hdrFinalPostProcess: Nullable<PostProcess>;
  69684. /**
  69685. * Post-process used to create a lens flare effect
  69686. */
  69687. lensFlarePostProcess: Nullable<PostProcess>;
  69688. /**
  69689. * Post-process that merges the result of the lens flare post-process and the real scene color
  69690. */
  69691. lensFlareComposePostProcess: Nullable<PostProcess>;
  69692. /**
  69693. * Post-process used to create a motion blur effect
  69694. */
  69695. motionBlurPostProcess: Nullable<PostProcess>;
  69696. /**
  69697. * Post-process used to create a depth of field effect
  69698. */
  69699. depthOfFieldPostProcess: Nullable<PostProcess>;
  69700. /**
  69701. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69702. */
  69703. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69704. /**
  69705. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69706. */
  69707. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69708. /**
  69709. * Represents the brightness threshold in order to configure the illuminated surfaces
  69710. */
  69711. brightThreshold: number;
  69712. /**
  69713. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69714. */
  69715. blurWidth: number;
  69716. /**
  69717. * Sets if the blur for highlighted surfaces must be only horizontal
  69718. */
  69719. horizontalBlur: boolean;
  69720. /**
  69721. * Gets the overall exposure used by the pipeline
  69722. */
  69723. get exposure(): number;
  69724. /**
  69725. * Sets the overall exposure used by the pipeline
  69726. */
  69727. set exposure(value: number);
  69728. /**
  69729. * Texture used typically to simulate "dirty" on camera lens
  69730. */
  69731. lensTexture: Nullable<Texture>;
  69732. /**
  69733. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69734. */
  69735. volumetricLightCoefficient: number;
  69736. /**
  69737. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69738. */
  69739. volumetricLightPower: number;
  69740. /**
  69741. * Used the set the blur intensity to smooth the volumetric lights
  69742. */
  69743. volumetricLightBlurScale: number;
  69744. /**
  69745. * Light (spot or directional) used to generate the volumetric lights rays
  69746. * The source light must have a shadow generate so the pipeline can get its
  69747. * depth map
  69748. */
  69749. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69750. /**
  69751. * For eye adaptation, represents the minimum luminance the eye can see
  69752. */
  69753. hdrMinimumLuminance: number;
  69754. /**
  69755. * For eye adaptation, represents the decrease luminance speed
  69756. */
  69757. hdrDecreaseRate: number;
  69758. /**
  69759. * For eye adaptation, represents the increase luminance speed
  69760. */
  69761. hdrIncreaseRate: number;
  69762. /**
  69763. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69764. */
  69765. get hdrAutoExposure(): boolean;
  69766. /**
  69767. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69768. */
  69769. set hdrAutoExposure(value: boolean);
  69770. /**
  69771. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69772. */
  69773. lensColorTexture: Nullable<Texture>;
  69774. /**
  69775. * The overall strengh for the lens flare effect
  69776. */
  69777. lensFlareStrength: number;
  69778. /**
  69779. * Dispersion coefficient for lens flare ghosts
  69780. */
  69781. lensFlareGhostDispersal: number;
  69782. /**
  69783. * Main lens flare halo width
  69784. */
  69785. lensFlareHaloWidth: number;
  69786. /**
  69787. * Based on the lens distortion effect, defines how much the lens flare result
  69788. * is distorted
  69789. */
  69790. lensFlareDistortionStrength: number;
  69791. /**
  69792. * Configures the blur intensity used for for lens flare (halo)
  69793. */
  69794. lensFlareBlurWidth: number;
  69795. /**
  69796. * Lens star texture must be used to simulate rays on the flares and is available
  69797. * in the documentation
  69798. */
  69799. lensStarTexture: Nullable<Texture>;
  69800. /**
  69801. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69802. * flare effect by taking account of the dirt texture
  69803. */
  69804. lensFlareDirtTexture: Nullable<Texture>;
  69805. /**
  69806. * Represents the focal length for the depth of field effect
  69807. */
  69808. depthOfFieldDistance: number;
  69809. /**
  69810. * Represents the blur intensity for the blurred part of the depth of field effect
  69811. */
  69812. depthOfFieldBlurWidth: number;
  69813. /**
  69814. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69815. */
  69816. get motionStrength(): number;
  69817. /**
  69818. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69819. */
  69820. set motionStrength(strength: number);
  69821. /**
  69822. * Gets wether or not the motion blur post-process is object based or screen based.
  69823. */
  69824. get objectBasedMotionBlur(): boolean;
  69825. /**
  69826. * Sets wether or not the motion blur post-process should be object based or screen based
  69827. */
  69828. set objectBasedMotionBlur(value: boolean);
  69829. /**
  69830. * List of animations for the pipeline (IAnimatable implementation)
  69831. */
  69832. animations: Animation[];
  69833. /**
  69834. * Private members
  69835. */
  69836. private _scene;
  69837. private _currentDepthOfFieldSource;
  69838. private _basePostProcess;
  69839. private _fixedExposure;
  69840. private _currentExposure;
  69841. private _hdrAutoExposure;
  69842. private _hdrCurrentLuminance;
  69843. private _motionStrength;
  69844. private _isObjectBasedMotionBlur;
  69845. private _floatTextureType;
  69846. private _camerasToBeAttached;
  69847. private _ratio;
  69848. private _bloomEnabled;
  69849. private _depthOfFieldEnabled;
  69850. private _vlsEnabled;
  69851. private _lensFlareEnabled;
  69852. private _hdrEnabled;
  69853. private _motionBlurEnabled;
  69854. private _fxaaEnabled;
  69855. private _screenSpaceReflectionsEnabled;
  69856. private _motionBlurSamples;
  69857. private _volumetricLightStepsCount;
  69858. private _samples;
  69859. /**
  69860. * @ignore
  69861. * Specifies if the bloom pipeline is enabled
  69862. */
  69863. get BloomEnabled(): boolean;
  69864. set BloomEnabled(enabled: boolean);
  69865. /**
  69866. * @ignore
  69867. * Specifies if the depth of field pipeline is enabed
  69868. */
  69869. get DepthOfFieldEnabled(): boolean;
  69870. set DepthOfFieldEnabled(enabled: boolean);
  69871. /**
  69872. * @ignore
  69873. * Specifies if the lens flare pipeline is enabed
  69874. */
  69875. get LensFlareEnabled(): boolean;
  69876. set LensFlareEnabled(enabled: boolean);
  69877. /**
  69878. * @ignore
  69879. * Specifies if the HDR pipeline is enabled
  69880. */
  69881. get HDREnabled(): boolean;
  69882. set HDREnabled(enabled: boolean);
  69883. /**
  69884. * @ignore
  69885. * Specifies if the volumetric lights scattering effect is enabled
  69886. */
  69887. get VLSEnabled(): boolean;
  69888. set VLSEnabled(enabled: boolean);
  69889. /**
  69890. * @ignore
  69891. * Specifies if the motion blur effect is enabled
  69892. */
  69893. get MotionBlurEnabled(): boolean;
  69894. set MotionBlurEnabled(enabled: boolean);
  69895. /**
  69896. * Specifies if anti-aliasing is enabled
  69897. */
  69898. get fxaaEnabled(): boolean;
  69899. set fxaaEnabled(enabled: boolean);
  69900. /**
  69901. * Specifies if screen space reflections are enabled.
  69902. */
  69903. get screenSpaceReflectionsEnabled(): boolean;
  69904. set screenSpaceReflectionsEnabled(enabled: boolean);
  69905. /**
  69906. * Specifies the number of steps used to calculate the volumetric lights
  69907. * Typically in interval [50, 200]
  69908. */
  69909. get volumetricLightStepsCount(): number;
  69910. set volumetricLightStepsCount(count: number);
  69911. /**
  69912. * Specifies the number of samples used for the motion blur effect
  69913. * Typically in interval [16, 64]
  69914. */
  69915. get motionBlurSamples(): number;
  69916. set motionBlurSamples(samples: number);
  69917. /**
  69918. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69919. */
  69920. get samples(): number;
  69921. set samples(sampleCount: number);
  69922. /**
  69923. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69924. * @constructor
  69925. * @param name The rendering pipeline name
  69926. * @param scene The scene linked to this pipeline
  69927. * @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)
  69928. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69929. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69930. */
  69931. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69932. private _buildPipeline;
  69933. private _createDownSampleX4PostProcess;
  69934. private _createBrightPassPostProcess;
  69935. private _createBlurPostProcesses;
  69936. private _createTextureAdderPostProcess;
  69937. private _createVolumetricLightPostProcess;
  69938. private _createLuminancePostProcesses;
  69939. private _createHdrPostProcess;
  69940. private _createLensFlarePostProcess;
  69941. private _createDepthOfFieldPostProcess;
  69942. private _createMotionBlurPostProcess;
  69943. private _getDepthTexture;
  69944. private _disposePostProcesses;
  69945. /**
  69946. * Dispose of the pipeline and stop all post processes
  69947. */
  69948. dispose(): void;
  69949. /**
  69950. * Serialize the rendering pipeline (Used when exporting)
  69951. * @returns the serialized object
  69952. */
  69953. serialize(): any;
  69954. /**
  69955. * Parse the serialized pipeline
  69956. * @param source Source pipeline.
  69957. * @param scene The scene to load the pipeline to.
  69958. * @param rootUrl The URL of the serialized pipeline.
  69959. * @returns An instantiated pipeline from the serialized object.
  69960. */
  69961. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69962. /**
  69963. * Luminance steps
  69964. */
  69965. static LuminanceSteps: number;
  69966. }
  69967. }
  69968. declare module BABYLON {
  69969. /** @hidden */
  69970. export var stereoscopicInterlacePixelShader: {
  69971. name: string;
  69972. shader: string;
  69973. };
  69974. }
  69975. declare module BABYLON {
  69976. /**
  69977. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69978. */
  69979. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69980. private _stepSize;
  69981. private _passedProcess;
  69982. /**
  69983. * Initializes a StereoscopicInterlacePostProcessI
  69984. * @param name The name of the effect.
  69985. * @param rigCameras The rig cameras to be appled to the post process
  69986. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69987. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69989. * @param engine The engine which the post process will be applied. (default: current engine)
  69990. * @param reusable If the post process can be reused on the same frame. (default: false)
  69991. */
  69992. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69993. }
  69994. /**
  69995. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69996. */
  69997. export class StereoscopicInterlacePostProcess extends PostProcess {
  69998. private _stepSize;
  69999. private _passedProcess;
  70000. /**
  70001. * Initializes a StereoscopicInterlacePostProcess
  70002. * @param name The name of the effect.
  70003. * @param rigCameras The rig cameras to be appled to the post process
  70004. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70006. * @param engine The engine which the post process will be applied. (default: current engine)
  70007. * @param reusable If the post process can be reused on the same frame. (default: false)
  70008. */
  70009. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70010. }
  70011. }
  70012. declare module BABYLON {
  70013. /** @hidden */
  70014. export var tonemapPixelShader: {
  70015. name: string;
  70016. shader: string;
  70017. };
  70018. }
  70019. declare module BABYLON {
  70020. /** Defines operator used for tonemapping */
  70021. export enum TonemappingOperator {
  70022. /** Hable */
  70023. Hable = 0,
  70024. /** Reinhard */
  70025. Reinhard = 1,
  70026. /** HejiDawson */
  70027. HejiDawson = 2,
  70028. /** Photographic */
  70029. Photographic = 3
  70030. }
  70031. /**
  70032. * Defines a post process to apply tone mapping
  70033. */
  70034. export class TonemapPostProcess extends PostProcess {
  70035. private _operator;
  70036. /** Defines the required exposure adjustement */
  70037. exposureAdjustment: number;
  70038. /**
  70039. * Creates a new TonemapPostProcess
  70040. * @param name defines the name of the postprocess
  70041. * @param _operator defines the operator to use
  70042. * @param exposureAdjustment defines the required exposure adjustement
  70043. * @param camera defines the camera to use (can be null)
  70044. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70045. * @param engine defines the hosting engine (can be ignore if camera is set)
  70046. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70047. */
  70048. constructor(name: string, _operator: TonemappingOperator,
  70049. /** Defines the required exposure adjustement */
  70050. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70051. }
  70052. }
  70053. declare module BABYLON {
  70054. /** @hidden */
  70055. export var volumetricLightScatteringPixelShader: {
  70056. name: string;
  70057. shader: string;
  70058. };
  70059. }
  70060. declare module BABYLON {
  70061. /** @hidden */
  70062. export var volumetricLightScatteringPassVertexShader: {
  70063. name: string;
  70064. shader: string;
  70065. };
  70066. }
  70067. declare module BABYLON {
  70068. /** @hidden */
  70069. export var volumetricLightScatteringPassPixelShader: {
  70070. name: string;
  70071. shader: string;
  70072. };
  70073. }
  70074. declare module BABYLON {
  70075. /**
  70076. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70077. */
  70078. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70079. private _volumetricLightScatteringPass;
  70080. private _volumetricLightScatteringRTT;
  70081. private _viewPort;
  70082. private _screenCoordinates;
  70083. private _cachedDefines;
  70084. /**
  70085. * If not undefined, the mesh position is computed from the attached node position
  70086. */
  70087. attachedNode: {
  70088. position: Vector3;
  70089. };
  70090. /**
  70091. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70092. */
  70093. customMeshPosition: Vector3;
  70094. /**
  70095. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70096. */
  70097. useCustomMeshPosition: boolean;
  70098. /**
  70099. * If the post-process should inverse the light scattering direction
  70100. */
  70101. invert: boolean;
  70102. /**
  70103. * The internal mesh used by the post-process
  70104. */
  70105. mesh: Mesh;
  70106. /**
  70107. * @hidden
  70108. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70109. */
  70110. get useDiffuseColor(): boolean;
  70111. set useDiffuseColor(useDiffuseColor: boolean);
  70112. /**
  70113. * Array containing the excluded meshes not rendered in the internal pass
  70114. */
  70115. excludedMeshes: AbstractMesh[];
  70116. /**
  70117. * Controls the overall intensity of the post-process
  70118. */
  70119. exposure: number;
  70120. /**
  70121. * Dissipates each sample's contribution in range [0, 1]
  70122. */
  70123. decay: number;
  70124. /**
  70125. * Controls the overall intensity of each sample
  70126. */
  70127. weight: number;
  70128. /**
  70129. * Controls the density of each sample
  70130. */
  70131. density: number;
  70132. /**
  70133. * @constructor
  70134. * @param name The post-process name
  70135. * @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)
  70136. * @param camera The camera that the post-process will be attached to
  70137. * @param mesh The mesh used to create the light scattering
  70138. * @param samples The post-process quality, default 100
  70139. * @param samplingModeThe post-process filtering mode
  70140. * @param engine The babylon engine
  70141. * @param reusable If the post-process is reusable
  70142. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70143. */
  70144. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70145. /**
  70146. * Returns the string "VolumetricLightScatteringPostProcess"
  70147. * @returns "VolumetricLightScatteringPostProcess"
  70148. */
  70149. getClassName(): string;
  70150. private _isReady;
  70151. /**
  70152. * Sets the new light position for light scattering effect
  70153. * @param position The new custom light position
  70154. */
  70155. setCustomMeshPosition(position: Vector3): void;
  70156. /**
  70157. * Returns the light position for light scattering effect
  70158. * @return Vector3 The custom light position
  70159. */
  70160. getCustomMeshPosition(): Vector3;
  70161. /**
  70162. * Disposes the internal assets and detaches the post-process from the camera
  70163. */
  70164. dispose(camera: Camera): void;
  70165. /**
  70166. * Returns the render target texture used by the post-process
  70167. * @return the render target texture used by the post-process
  70168. */
  70169. getPass(): RenderTargetTexture;
  70170. private _meshExcluded;
  70171. private _createPass;
  70172. private _updateMeshScreenCoordinates;
  70173. /**
  70174. * Creates a default mesh for the Volumeric Light Scattering post-process
  70175. * @param name The mesh name
  70176. * @param scene The scene where to create the mesh
  70177. * @return the default mesh
  70178. */
  70179. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70180. }
  70181. }
  70182. declare module BABYLON {
  70183. interface Scene {
  70184. /** @hidden (Backing field) */
  70185. _boundingBoxRenderer: BoundingBoxRenderer;
  70186. /** @hidden (Backing field) */
  70187. _forceShowBoundingBoxes: boolean;
  70188. /**
  70189. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70190. */
  70191. forceShowBoundingBoxes: boolean;
  70192. /**
  70193. * Gets the bounding box renderer associated with the scene
  70194. * @returns a BoundingBoxRenderer
  70195. */
  70196. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70197. }
  70198. interface AbstractMesh {
  70199. /** @hidden (Backing field) */
  70200. _showBoundingBox: boolean;
  70201. /**
  70202. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70203. */
  70204. showBoundingBox: boolean;
  70205. }
  70206. /**
  70207. * Component responsible of rendering the bounding box of the meshes in a scene.
  70208. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70209. */
  70210. export class BoundingBoxRenderer implements ISceneComponent {
  70211. /**
  70212. * The component name helpfull to identify the component in the list of scene components.
  70213. */
  70214. readonly name: string;
  70215. /**
  70216. * The scene the component belongs to.
  70217. */
  70218. scene: Scene;
  70219. /**
  70220. * Color of the bounding box lines placed in front of an object
  70221. */
  70222. frontColor: Color3;
  70223. /**
  70224. * Color of the bounding box lines placed behind an object
  70225. */
  70226. backColor: Color3;
  70227. /**
  70228. * Defines if the renderer should show the back lines or not
  70229. */
  70230. showBackLines: boolean;
  70231. /**
  70232. * Observable raised before rendering a bounding box
  70233. */
  70234. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70235. /**
  70236. * Observable raised after rendering a bounding box
  70237. */
  70238. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70239. /**
  70240. * @hidden
  70241. */
  70242. renderList: SmartArray<BoundingBox>;
  70243. private _colorShader;
  70244. private _vertexBuffers;
  70245. private _indexBuffer;
  70246. private _fillIndexBuffer;
  70247. private _fillIndexData;
  70248. /**
  70249. * Instantiates a new bounding box renderer in a scene.
  70250. * @param scene the scene the renderer renders in
  70251. */
  70252. constructor(scene: Scene);
  70253. /**
  70254. * Registers the component in a given scene
  70255. */
  70256. register(): void;
  70257. private _evaluateSubMesh;
  70258. private _activeMesh;
  70259. private _prepareRessources;
  70260. private _createIndexBuffer;
  70261. /**
  70262. * Rebuilds the elements related to this component in case of
  70263. * context lost for instance.
  70264. */
  70265. rebuild(): void;
  70266. /**
  70267. * @hidden
  70268. */
  70269. reset(): void;
  70270. /**
  70271. * Render the bounding boxes of a specific rendering group
  70272. * @param renderingGroupId defines the rendering group to render
  70273. */
  70274. render(renderingGroupId: number): void;
  70275. /**
  70276. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70277. * @param mesh Define the mesh to render the occlusion bounding box for
  70278. */
  70279. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70280. /**
  70281. * Dispose and release the resources attached to this renderer.
  70282. */
  70283. dispose(): void;
  70284. }
  70285. }
  70286. declare module BABYLON {
  70287. interface Scene {
  70288. /** @hidden (Backing field) */
  70289. _depthRenderer: {
  70290. [id: string]: DepthRenderer;
  70291. };
  70292. /**
  70293. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70294. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70295. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70296. * @returns the created depth renderer
  70297. */
  70298. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70299. /**
  70300. * Disables a depth renderer for a given camera
  70301. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70302. */
  70303. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70304. }
  70305. /**
  70306. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70307. * in several rendering techniques.
  70308. */
  70309. export class DepthRendererSceneComponent implements ISceneComponent {
  70310. /**
  70311. * The component name helpfull to identify the component in the list of scene components.
  70312. */
  70313. readonly name: string;
  70314. /**
  70315. * The scene the component belongs to.
  70316. */
  70317. scene: Scene;
  70318. /**
  70319. * Creates a new instance of the component for the given scene
  70320. * @param scene Defines the scene to register the component in
  70321. */
  70322. constructor(scene: Scene);
  70323. /**
  70324. * Registers the component in a given scene
  70325. */
  70326. register(): void;
  70327. /**
  70328. * Rebuilds the elements related to this component in case of
  70329. * context lost for instance.
  70330. */
  70331. rebuild(): void;
  70332. /**
  70333. * Disposes the component and the associated ressources
  70334. */
  70335. dispose(): void;
  70336. private _gatherRenderTargets;
  70337. private _gatherActiveCameraRenderTargets;
  70338. }
  70339. }
  70340. declare module BABYLON {
  70341. /** @hidden */
  70342. export var outlinePixelShader: {
  70343. name: string;
  70344. shader: string;
  70345. };
  70346. }
  70347. declare module BABYLON {
  70348. /** @hidden */
  70349. export var outlineVertexShader: {
  70350. name: string;
  70351. shader: string;
  70352. };
  70353. }
  70354. declare module BABYLON {
  70355. interface Scene {
  70356. /** @hidden */
  70357. _outlineRenderer: OutlineRenderer;
  70358. /**
  70359. * Gets the outline renderer associated with the scene
  70360. * @returns a OutlineRenderer
  70361. */
  70362. getOutlineRenderer(): OutlineRenderer;
  70363. }
  70364. interface AbstractMesh {
  70365. /** @hidden (Backing field) */
  70366. _renderOutline: boolean;
  70367. /**
  70368. * Gets or sets a boolean indicating if the outline must be rendered as well
  70369. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70370. */
  70371. renderOutline: boolean;
  70372. /** @hidden (Backing field) */
  70373. _renderOverlay: boolean;
  70374. /**
  70375. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70376. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70377. */
  70378. renderOverlay: boolean;
  70379. }
  70380. /**
  70381. * This class is responsible to draw bothe outline/overlay of meshes.
  70382. * It should not be used directly but through the available method on mesh.
  70383. */
  70384. export class OutlineRenderer implements ISceneComponent {
  70385. /**
  70386. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70387. */
  70388. private static _StencilReference;
  70389. /**
  70390. * The name of the component. Each component must have a unique name.
  70391. */
  70392. name: string;
  70393. /**
  70394. * The scene the component belongs to.
  70395. */
  70396. scene: Scene;
  70397. /**
  70398. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70399. */
  70400. zOffset: number;
  70401. private _engine;
  70402. private _effect;
  70403. private _cachedDefines;
  70404. private _savedDepthWrite;
  70405. /**
  70406. * Instantiates a new outline renderer. (There could be only one per scene).
  70407. * @param scene Defines the scene it belongs to
  70408. */
  70409. constructor(scene: Scene);
  70410. /**
  70411. * Register the component to one instance of a scene.
  70412. */
  70413. register(): void;
  70414. /**
  70415. * Rebuilds the elements related to this component in case of
  70416. * context lost for instance.
  70417. */
  70418. rebuild(): void;
  70419. /**
  70420. * Disposes the component and the associated ressources.
  70421. */
  70422. dispose(): void;
  70423. /**
  70424. * Renders the outline in the canvas.
  70425. * @param subMesh Defines the sumesh to render
  70426. * @param batch Defines the batch of meshes in case of instances
  70427. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70428. */
  70429. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70430. /**
  70431. * Returns whether or not the outline renderer is ready for a given submesh.
  70432. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70433. * @param subMesh Defines the submesh to check readyness for
  70434. * @param useInstances Defines wheter wee are trying to render instances or not
  70435. * @returns true if ready otherwise false
  70436. */
  70437. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70438. private _beforeRenderingMesh;
  70439. private _afterRenderingMesh;
  70440. }
  70441. }
  70442. declare module BABYLON {
  70443. /**
  70444. * Defines the basic options interface of a Sprite Frame Source Size.
  70445. */
  70446. export interface ISpriteJSONSpriteSourceSize {
  70447. /**
  70448. * number of the original width of the Frame
  70449. */
  70450. w: number;
  70451. /**
  70452. * number of the original height of the Frame
  70453. */
  70454. h: number;
  70455. }
  70456. /**
  70457. * Defines the basic options interface of a Sprite Frame Data.
  70458. */
  70459. export interface ISpriteJSONSpriteFrameData {
  70460. /**
  70461. * number of the x offset of the Frame
  70462. */
  70463. x: number;
  70464. /**
  70465. * number of the y offset of the Frame
  70466. */
  70467. y: number;
  70468. /**
  70469. * number of the width of the Frame
  70470. */
  70471. w: number;
  70472. /**
  70473. * number of the height of the Frame
  70474. */
  70475. h: number;
  70476. }
  70477. /**
  70478. * Defines the basic options interface of a JSON Sprite.
  70479. */
  70480. export interface ISpriteJSONSprite {
  70481. /**
  70482. * string name of the Frame
  70483. */
  70484. filename: string;
  70485. /**
  70486. * ISpriteJSONSpriteFrame basic object of the frame data
  70487. */
  70488. frame: ISpriteJSONSpriteFrameData;
  70489. /**
  70490. * boolean to flag is the frame was rotated.
  70491. */
  70492. rotated: boolean;
  70493. /**
  70494. * boolean to flag is the frame was trimmed.
  70495. */
  70496. trimmed: boolean;
  70497. /**
  70498. * ISpriteJSONSpriteFrame basic object of the source data
  70499. */
  70500. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70501. /**
  70502. * ISpriteJSONSpriteFrame basic object of the source data
  70503. */
  70504. sourceSize: ISpriteJSONSpriteSourceSize;
  70505. }
  70506. /**
  70507. * Defines the basic options interface of a JSON atlas.
  70508. */
  70509. export interface ISpriteJSONAtlas {
  70510. /**
  70511. * Array of objects that contain the frame data.
  70512. */
  70513. frames: Array<ISpriteJSONSprite>;
  70514. /**
  70515. * object basic object containing the sprite meta data.
  70516. */
  70517. meta?: object;
  70518. }
  70519. }
  70520. declare module BABYLON {
  70521. /** @hidden */
  70522. export var spriteMapPixelShader: {
  70523. name: string;
  70524. shader: string;
  70525. };
  70526. }
  70527. declare module BABYLON {
  70528. /** @hidden */
  70529. export var spriteMapVertexShader: {
  70530. name: string;
  70531. shader: string;
  70532. };
  70533. }
  70534. declare module BABYLON {
  70535. /**
  70536. * Defines the basic options interface of a SpriteMap
  70537. */
  70538. export interface ISpriteMapOptions {
  70539. /**
  70540. * Vector2 of the number of cells in the grid.
  70541. */
  70542. stageSize?: Vector2;
  70543. /**
  70544. * Vector2 of the size of the output plane in World Units.
  70545. */
  70546. outputSize?: Vector2;
  70547. /**
  70548. * Vector3 of the position of the output plane in World Units.
  70549. */
  70550. outputPosition?: Vector3;
  70551. /**
  70552. * Vector3 of the rotation of the output plane.
  70553. */
  70554. outputRotation?: Vector3;
  70555. /**
  70556. * number of layers that the system will reserve in resources.
  70557. */
  70558. layerCount?: number;
  70559. /**
  70560. * number of max animation frames a single cell will reserve in resources.
  70561. */
  70562. maxAnimationFrames?: number;
  70563. /**
  70564. * number cell index of the base tile when the system compiles.
  70565. */
  70566. baseTile?: number;
  70567. /**
  70568. * boolean flip the sprite after its been repositioned by the framing data.
  70569. */
  70570. flipU?: boolean;
  70571. /**
  70572. * Vector3 scalar of the global RGB values of the SpriteMap.
  70573. */
  70574. colorMultiply?: Vector3;
  70575. }
  70576. /**
  70577. * Defines the IDisposable interface in order to be cleanable from resources.
  70578. */
  70579. export interface ISpriteMap extends IDisposable {
  70580. /**
  70581. * String name of the SpriteMap.
  70582. */
  70583. name: string;
  70584. /**
  70585. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70586. */
  70587. atlasJSON: ISpriteJSONAtlas;
  70588. /**
  70589. * Texture of the SpriteMap.
  70590. */
  70591. spriteSheet: Texture;
  70592. /**
  70593. * The parameters to initialize the SpriteMap with.
  70594. */
  70595. options: ISpriteMapOptions;
  70596. }
  70597. /**
  70598. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70599. */
  70600. export class SpriteMap implements ISpriteMap {
  70601. /** The Name of the spriteMap */
  70602. name: string;
  70603. /** The JSON file with the frame and meta data */
  70604. atlasJSON: ISpriteJSONAtlas;
  70605. /** The systems Sprite Sheet Texture */
  70606. spriteSheet: Texture;
  70607. /** Arguments passed with the Constructor */
  70608. options: ISpriteMapOptions;
  70609. /** Public Sprite Storage array, parsed from atlasJSON */
  70610. sprites: Array<ISpriteJSONSprite>;
  70611. /** Returns the Number of Sprites in the System */
  70612. get spriteCount(): number;
  70613. /** Returns the Position of Output Plane*/
  70614. get position(): Vector3;
  70615. /** Returns the Position of Output Plane*/
  70616. set position(v: Vector3);
  70617. /** Returns the Rotation of Output Plane*/
  70618. get rotation(): Vector3;
  70619. /** Returns the Rotation of Output Plane*/
  70620. set rotation(v: Vector3);
  70621. /** Sets the AnimationMap*/
  70622. get animationMap(): RawTexture;
  70623. /** Sets the AnimationMap*/
  70624. set animationMap(v: RawTexture);
  70625. /** Scene that the SpriteMap was created in */
  70626. private _scene;
  70627. /** Texture Buffer of Float32 that holds tile frame data*/
  70628. private _frameMap;
  70629. /** Texture Buffers of Float32 that holds tileMap data*/
  70630. private _tileMaps;
  70631. /** Texture Buffer of Float32 that holds Animation Data*/
  70632. private _animationMap;
  70633. /** Custom ShaderMaterial Central to the System*/
  70634. private _material;
  70635. /** Custom ShaderMaterial Central to the System*/
  70636. private _output;
  70637. /** Systems Time Ticker*/
  70638. private _time;
  70639. /**
  70640. * Creates a new SpriteMap
  70641. * @param name defines the SpriteMaps Name
  70642. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70643. * @param spriteSheet is the Texture that the Sprites are on.
  70644. * @param options a basic deployment configuration
  70645. * @param scene The Scene that the map is deployed on
  70646. */
  70647. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70648. /**
  70649. * Returns tileID location
  70650. * @returns Vector2 the cell position ID
  70651. */
  70652. getTileID(): Vector2;
  70653. /**
  70654. * Gets the UV location of the mouse over the SpriteMap.
  70655. * @returns Vector2 the UV position of the mouse interaction
  70656. */
  70657. getMousePosition(): Vector2;
  70658. /**
  70659. * Creates the "frame" texture Buffer
  70660. * -------------------------------------
  70661. * Structure of frames
  70662. * "filename": "Falling-Water-2.png",
  70663. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70664. * "rotated": true,
  70665. * "trimmed": true,
  70666. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70667. * "sourceSize": {"w":32,"h":32}
  70668. * @returns RawTexture of the frameMap
  70669. */
  70670. private _createFrameBuffer;
  70671. /**
  70672. * Creates the tileMap texture Buffer
  70673. * @param buffer normally and array of numbers, or a false to generate from scratch
  70674. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70675. * @returns RawTexture of the tileMap
  70676. */
  70677. private _createTileBuffer;
  70678. /**
  70679. * Modifies the data of the tileMaps
  70680. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70681. * @param pos is the iVector2 Coordinates of the Tile
  70682. * @param tile The SpriteIndex of the new Tile
  70683. */
  70684. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70685. /**
  70686. * Creates the animationMap texture Buffer
  70687. * @param buffer normally and array of numbers, or a false to generate from scratch
  70688. * @returns RawTexture of the animationMap
  70689. */
  70690. private _createTileAnimationBuffer;
  70691. /**
  70692. * Modifies the data of the animationMap
  70693. * @param cellID is the Index of the Sprite
  70694. * @param _frame is the target Animation frame
  70695. * @param toCell is the Target Index of the next frame of the animation
  70696. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70697. * @param speed is a global scalar of the time variable on the map.
  70698. */
  70699. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70700. /**
  70701. * Exports the .tilemaps file
  70702. */
  70703. saveTileMaps(): void;
  70704. /**
  70705. * Imports the .tilemaps file
  70706. * @param url of the .tilemaps file
  70707. */
  70708. loadTileMaps(url: string): void;
  70709. /**
  70710. * Release associated resources
  70711. */
  70712. dispose(): void;
  70713. }
  70714. }
  70715. declare module BABYLON {
  70716. /**
  70717. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70718. * @see http://doc.babylonjs.com/babylon101/sprites
  70719. */
  70720. export class SpritePackedManager extends SpriteManager {
  70721. /** defines the packed manager's name */
  70722. name: string;
  70723. /**
  70724. * Creates a new sprite manager from a packed sprite sheet
  70725. * @param name defines the manager's name
  70726. * @param imgUrl defines the sprite sheet url
  70727. * @param capacity defines the maximum allowed number of sprites
  70728. * @param scene defines the hosting scene
  70729. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70730. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70731. * @param samplingMode defines the smapling mode to use with spritesheet
  70732. * @param fromPacked set to true; do not alter
  70733. */
  70734. constructor(
  70735. /** defines the packed manager's name */
  70736. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70737. }
  70738. }
  70739. declare module BABYLON {
  70740. /**
  70741. * Defines the list of states available for a task inside a AssetsManager
  70742. */
  70743. export enum AssetTaskState {
  70744. /**
  70745. * Initialization
  70746. */
  70747. INIT = 0,
  70748. /**
  70749. * Running
  70750. */
  70751. RUNNING = 1,
  70752. /**
  70753. * Done
  70754. */
  70755. DONE = 2,
  70756. /**
  70757. * Error
  70758. */
  70759. ERROR = 3
  70760. }
  70761. /**
  70762. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70763. */
  70764. export abstract class AbstractAssetTask {
  70765. /**
  70766. * Task name
  70767. */ name: string;
  70768. /**
  70769. * Callback called when the task is successful
  70770. */
  70771. onSuccess: (task: any) => void;
  70772. /**
  70773. * Callback called when the task is not successful
  70774. */
  70775. onError: (task: any, message?: string, exception?: any) => void;
  70776. /**
  70777. * Creates a new AssetsManager
  70778. * @param name defines the name of the task
  70779. */
  70780. constructor(
  70781. /**
  70782. * Task name
  70783. */ name: string);
  70784. private _isCompleted;
  70785. private _taskState;
  70786. private _errorObject;
  70787. /**
  70788. * Get if the task is completed
  70789. */
  70790. get isCompleted(): boolean;
  70791. /**
  70792. * Gets the current state of the task
  70793. */
  70794. get taskState(): AssetTaskState;
  70795. /**
  70796. * Gets the current error object (if task is in error)
  70797. */
  70798. get errorObject(): {
  70799. message?: string;
  70800. exception?: any;
  70801. };
  70802. /**
  70803. * Internal only
  70804. * @hidden
  70805. */
  70806. _setErrorObject(message?: string, exception?: any): void;
  70807. /**
  70808. * Execute the current task
  70809. * @param scene defines the scene where you want your assets to be loaded
  70810. * @param onSuccess is a callback called when the task is successfully executed
  70811. * @param onError is a callback called if an error occurs
  70812. */
  70813. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70814. /**
  70815. * Execute the current task
  70816. * @param scene defines the scene where you want your assets to be loaded
  70817. * @param onSuccess is a callback called when the task is successfully executed
  70818. * @param onError is a callback called if an error occurs
  70819. */
  70820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70821. /**
  70822. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70823. * This can be used with failed tasks that have the reason for failure fixed.
  70824. */
  70825. reset(): void;
  70826. private onErrorCallback;
  70827. private onDoneCallback;
  70828. }
  70829. /**
  70830. * Define the interface used by progress events raised during assets loading
  70831. */
  70832. export interface IAssetsProgressEvent {
  70833. /**
  70834. * Defines the number of remaining tasks to process
  70835. */
  70836. remainingCount: number;
  70837. /**
  70838. * Defines the total number of tasks
  70839. */
  70840. totalCount: number;
  70841. /**
  70842. * Defines the task that was just processed
  70843. */
  70844. task: AbstractAssetTask;
  70845. }
  70846. /**
  70847. * Class used to share progress information about assets loading
  70848. */
  70849. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70850. /**
  70851. * Defines the number of remaining tasks to process
  70852. */
  70853. remainingCount: number;
  70854. /**
  70855. * Defines the total number of tasks
  70856. */
  70857. totalCount: number;
  70858. /**
  70859. * Defines the task that was just processed
  70860. */
  70861. task: AbstractAssetTask;
  70862. /**
  70863. * Creates a AssetsProgressEvent
  70864. * @param remainingCount defines the number of remaining tasks to process
  70865. * @param totalCount defines the total number of tasks
  70866. * @param task defines the task that was just processed
  70867. */
  70868. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70869. }
  70870. /**
  70871. * Define a task used by AssetsManager to load meshes
  70872. */
  70873. export class MeshAssetTask extends AbstractAssetTask {
  70874. /**
  70875. * Defines the name of the task
  70876. */
  70877. name: string;
  70878. /**
  70879. * Defines the list of mesh's names you want to load
  70880. */
  70881. meshesNames: any;
  70882. /**
  70883. * Defines the root url to use as a base to load your meshes and associated resources
  70884. */
  70885. rootUrl: string;
  70886. /**
  70887. * Defines the filename or File of the scene to load from
  70888. */
  70889. sceneFilename: string | File;
  70890. /**
  70891. * Gets the list of loaded meshes
  70892. */
  70893. loadedMeshes: Array<AbstractMesh>;
  70894. /**
  70895. * Gets the list of loaded particle systems
  70896. */
  70897. loadedParticleSystems: Array<IParticleSystem>;
  70898. /**
  70899. * Gets the list of loaded skeletons
  70900. */
  70901. loadedSkeletons: Array<Skeleton>;
  70902. /**
  70903. * Gets the list of loaded animation groups
  70904. */
  70905. loadedAnimationGroups: Array<AnimationGroup>;
  70906. /**
  70907. * Callback called when the task is successful
  70908. */
  70909. onSuccess: (task: MeshAssetTask) => void;
  70910. /**
  70911. * Callback called when the task is successful
  70912. */
  70913. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70914. /**
  70915. * Creates a new MeshAssetTask
  70916. * @param name defines the name of the task
  70917. * @param meshesNames defines the list of mesh's names you want to load
  70918. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70919. * @param sceneFilename defines the filename or File of the scene to load from
  70920. */
  70921. constructor(
  70922. /**
  70923. * Defines the name of the task
  70924. */
  70925. name: string,
  70926. /**
  70927. * Defines the list of mesh's names you want to load
  70928. */
  70929. meshesNames: any,
  70930. /**
  70931. * Defines the root url to use as a base to load your meshes and associated resources
  70932. */
  70933. rootUrl: string,
  70934. /**
  70935. * Defines the filename or File of the scene to load from
  70936. */
  70937. sceneFilename: string | File);
  70938. /**
  70939. * Execute the current task
  70940. * @param scene defines the scene where you want your assets to be loaded
  70941. * @param onSuccess is a callback called when the task is successfully executed
  70942. * @param onError is a callback called if an error occurs
  70943. */
  70944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70945. }
  70946. /**
  70947. * Define a task used by AssetsManager to load text content
  70948. */
  70949. export class TextFileAssetTask extends AbstractAssetTask {
  70950. /**
  70951. * Defines the name of the task
  70952. */
  70953. name: string;
  70954. /**
  70955. * Defines the location of the file to load
  70956. */
  70957. url: string;
  70958. /**
  70959. * Gets the loaded text string
  70960. */
  70961. text: string;
  70962. /**
  70963. * Callback called when the task is successful
  70964. */
  70965. onSuccess: (task: TextFileAssetTask) => void;
  70966. /**
  70967. * Callback called when the task is successful
  70968. */
  70969. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70970. /**
  70971. * Creates a new TextFileAssetTask object
  70972. * @param name defines the name of the task
  70973. * @param url defines the location of the file to load
  70974. */
  70975. constructor(
  70976. /**
  70977. * Defines the name of the task
  70978. */
  70979. name: string,
  70980. /**
  70981. * Defines the location of the file to load
  70982. */
  70983. url: string);
  70984. /**
  70985. * Execute the current task
  70986. * @param scene defines the scene where you want your assets to be loaded
  70987. * @param onSuccess is a callback called when the task is successfully executed
  70988. * @param onError is a callback called if an error occurs
  70989. */
  70990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70991. }
  70992. /**
  70993. * Define a task used by AssetsManager to load binary data
  70994. */
  70995. export class BinaryFileAssetTask extends AbstractAssetTask {
  70996. /**
  70997. * Defines the name of the task
  70998. */
  70999. name: string;
  71000. /**
  71001. * Defines the location of the file to load
  71002. */
  71003. url: string;
  71004. /**
  71005. * Gets the lodaded data (as an array buffer)
  71006. */
  71007. data: ArrayBuffer;
  71008. /**
  71009. * Callback called when the task is successful
  71010. */
  71011. onSuccess: (task: BinaryFileAssetTask) => void;
  71012. /**
  71013. * Callback called when the task is successful
  71014. */
  71015. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71016. /**
  71017. * Creates a new BinaryFileAssetTask object
  71018. * @param name defines the name of the new task
  71019. * @param url defines the location of the file to load
  71020. */
  71021. constructor(
  71022. /**
  71023. * Defines the name of the task
  71024. */
  71025. name: string,
  71026. /**
  71027. * Defines the location of the file to load
  71028. */
  71029. url: string);
  71030. /**
  71031. * Execute the current task
  71032. * @param scene defines the scene where you want your assets to be loaded
  71033. * @param onSuccess is a callback called when the task is successfully executed
  71034. * @param onError is a callback called if an error occurs
  71035. */
  71036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71037. }
  71038. /**
  71039. * Define a task used by AssetsManager to load images
  71040. */
  71041. export class ImageAssetTask extends AbstractAssetTask {
  71042. /**
  71043. * Defines the name of the task
  71044. */
  71045. name: string;
  71046. /**
  71047. * Defines the location of the image to load
  71048. */
  71049. url: string;
  71050. /**
  71051. * Gets the loaded images
  71052. */
  71053. image: HTMLImageElement;
  71054. /**
  71055. * Callback called when the task is successful
  71056. */
  71057. onSuccess: (task: ImageAssetTask) => void;
  71058. /**
  71059. * Callback called when the task is successful
  71060. */
  71061. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71062. /**
  71063. * Creates a new ImageAssetTask
  71064. * @param name defines the name of the task
  71065. * @param url defines the location of the image to load
  71066. */
  71067. constructor(
  71068. /**
  71069. * Defines the name of the task
  71070. */
  71071. name: string,
  71072. /**
  71073. * Defines the location of the image to load
  71074. */
  71075. url: string);
  71076. /**
  71077. * Execute the current task
  71078. * @param scene defines the scene where you want your assets to be loaded
  71079. * @param onSuccess is a callback called when the task is successfully executed
  71080. * @param onError is a callback called if an error occurs
  71081. */
  71082. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71083. }
  71084. /**
  71085. * Defines the interface used by texture loading tasks
  71086. */
  71087. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71088. /**
  71089. * Gets the loaded texture
  71090. */
  71091. texture: TEX;
  71092. }
  71093. /**
  71094. * Define a task used by AssetsManager to load 2D textures
  71095. */
  71096. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71097. /**
  71098. * Defines the name of the task
  71099. */
  71100. name: string;
  71101. /**
  71102. * Defines the location of the file to load
  71103. */
  71104. url: string;
  71105. /**
  71106. * Defines if mipmap should not be generated (default is false)
  71107. */
  71108. noMipmap?: boolean | undefined;
  71109. /**
  71110. * Defines if texture must be inverted on Y axis (default is true)
  71111. */
  71112. invertY: boolean;
  71113. /**
  71114. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71115. */
  71116. samplingMode: number;
  71117. /**
  71118. * Gets the loaded texture
  71119. */
  71120. texture: Texture;
  71121. /**
  71122. * Callback called when the task is successful
  71123. */
  71124. onSuccess: (task: TextureAssetTask) => void;
  71125. /**
  71126. * Callback called when the task is successful
  71127. */
  71128. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71129. /**
  71130. * Creates a new TextureAssetTask object
  71131. * @param name defines the name of the task
  71132. * @param url defines the location of the file to load
  71133. * @param noMipmap defines if mipmap should not be generated (default is false)
  71134. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71135. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71136. */
  71137. constructor(
  71138. /**
  71139. * Defines the name of the task
  71140. */
  71141. name: string,
  71142. /**
  71143. * Defines the location of the file to load
  71144. */
  71145. url: string,
  71146. /**
  71147. * Defines if mipmap should not be generated (default is false)
  71148. */
  71149. noMipmap?: boolean | undefined,
  71150. /**
  71151. * Defines if texture must be inverted on Y axis (default is true)
  71152. */
  71153. invertY?: boolean,
  71154. /**
  71155. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71156. */
  71157. samplingMode?: number);
  71158. /**
  71159. * Execute the current task
  71160. * @param scene defines the scene where you want your assets to be loaded
  71161. * @param onSuccess is a callback called when the task is successfully executed
  71162. * @param onError is a callback called if an error occurs
  71163. */
  71164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71165. }
  71166. /**
  71167. * Define a task used by AssetsManager to load cube textures
  71168. */
  71169. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71170. /**
  71171. * Defines the name of the task
  71172. */
  71173. name: string;
  71174. /**
  71175. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71176. */
  71177. url: string;
  71178. /**
  71179. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71180. */
  71181. extensions?: string[] | undefined;
  71182. /**
  71183. * Defines if mipmaps should not be generated (default is false)
  71184. */
  71185. noMipmap?: boolean | undefined;
  71186. /**
  71187. * Defines the explicit list of files (undefined by default)
  71188. */
  71189. files?: string[] | undefined;
  71190. /**
  71191. * Gets the loaded texture
  71192. */
  71193. texture: CubeTexture;
  71194. /**
  71195. * Callback called when the task is successful
  71196. */
  71197. onSuccess: (task: CubeTextureAssetTask) => void;
  71198. /**
  71199. * Callback called when the task is successful
  71200. */
  71201. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71202. /**
  71203. * Creates a new CubeTextureAssetTask
  71204. * @param name defines the name of the task
  71205. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71206. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71207. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71208. * @param files defines the explicit list of files (undefined by default)
  71209. */
  71210. constructor(
  71211. /**
  71212. * Defines the name of the task
  71213. */
  71214. name: string,
  71215. /**
  71216. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71217. */
  71218. url: string,
  71219. /**
  71220. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71221. */
  71222. extensions?: string[] | undefined,
  71223. /**
  71224. * Defines if mipmaps should not be generated (default is false)
  71225. */
  71226. noMipmap?: boolean | undefined,
  71227. /**
  71228. * Defines the explicit list of files (undefined by default)
  71229. */
  71230. files?: string[] | undefined);
  71231. /**
  71232. * Execute the current task
  71233. * @param scene defines the scene where you want your assets to be loaded
  71234. * @param onSuccess is a callback called when the task is successfully executed
  71235. * @param onError is a callback called if an error occurs
  71236. */
  71237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71238. }
  71239. /**
  71240. * Define a task used by AssetsManager to load HDR cube textures
  71241. */
  71242. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71243. /**
  71244. * Defines the name of the task
  71245. */
  71246. name: string;
  71247. /**
  71248. * Defines the location of the file to load
  71249. */
  71250. url: string;
  71251. /**
  71252. * Defines the desired size (the more it increases the longer the generation will be)
  71253. */
  71254. size: number;
  71255. /**
  71256. * Defines if mipmaps should not be generated (default is false)
  71257. */
  71258. noMipmap: boolean;
  71259. /**
  71260. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71261. */
  71262. generateHarmonics: boolean;
  71263. /**
  71264. * 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)
  71265. */
  71266. gammaSpace: boolean;
  71267. /**
  71268. * Internal Use Only
  71269. */
  71270. reserved: boolean;
  71271. /**
  71272. * Gets the loaded texture
  71273. */
  71274. texture: HDRCubeTexture;
  71275. /**
  71276. * Callback called when the task is successful
  71277. */
  71278. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71279. /**
  71280. * Callback called when the task is successful
  71281. */
  71282. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71283. /**
  71284. * Creates a new HDRCubeTextureAssetTask object
  71285. * @param name defines the name of the task
  71286. * @param url defines the location of the file to load
  71287. * @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.
  71288. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71289. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71290. * @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)
  71291. * @param reserved Internal use only
  71292. */
  71293. constructor(
  71294. /**
  71295. * Defines the name of the task
  71296. */
  71297. name: string,
  71298. /**
  71299. * Defines the location of the file to load
  71300. */
  71301. url: string,
  71302. /**
  71303. * Defines the desired size (the more it increases the longer the generation will be)
  71304. */
  71305. size: number,
  71306. /**
  71307. * Defines if mipmaps should not be generated (default is false)
  71308. */
  71309. noMipmap?: boolean,
  71310. /**
  71311. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71312. */
  71313. generateHarmonics?: boolean,
  71314. /**
  71315. * 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)
  71316. */
  71317. gammaSpace?: boolean,
  71318. /**
  71319. * Internal Use Only
  71320. */
  71321. reserved?: boolean);
  71322. /**
  71323. * Execute the current task
  71324. * @param scene defines the scene where you want your assets to be loaded
  71325. * @param onSuccess is a callback called when the task is successfully executed
  71326. * @param onError is a callback called if an error occurs
  71327. */
  71328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71329. }
  71330. /**
  71331. * Define a task used by AssetsManager to load Equirectangular cube textures
  71332. */
  71333. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71334. /**
  71335. * Defines the name of the task
  71336. */
  71337. name: string;
  71338. /**
  71339. * Defines the location of the file to load
  71340. */
  71341. url: string;
  71342. /**
  71343. * Defines the desired size (the more it increases the longer the generation will be)
  71344. */
  71345. size: number;
  71346. /**
  71347. * Defines if mipmaps should not be generated (default is false)
  71348. */
  71349. noMipmap: boolean;
  71350. /**
  71351. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71352. * but the standard material would require them in Gamma space) (default is true)
  71353. */
  71354. gammaSpace: boolean;
  71355. /**
  71356. * Gets the loaded texture
  71357. */
  71358. texture: EquiRectangularCubeTexture;
  71359. /**
  71360. * Callback called when the task is successful
  71361. */
  71362. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71363. /**
  71364. * Callback called when the task is successful
  71365. */
  71366. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71367. /**
  71368. * Creates a new EquiRectangularCubeTextureAssetTask object
  71369. * @param name defines the name of the task
  71370. * @param url defines the location of the file to load
  71371. * @param size defines the desired size (the more it increases the longer the generation will be)
  71372. * If the size is omitted this implies you are using a preprocessed cubemap.
  71373. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71374. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71375. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71376. * (default is true)
  71377. */
  71378. constructor(
  71379. /**
  71380. * Defines the name of the task
  71381. */
  71382. name: string,
  71383. /**
  71384. * Defines the location of the file to load
  71385. */
  71386. url: string,
  71387. /**
  71388. * Defines the desired size (the more it increases the longer the generation will be)
  71389. */
  71390. size: number,
  71391. /**
  71392. * Defines if mipmaps should not be generated (default is false)
  71393. */
  71394. noMipmap?: boolean,
  71395. /**
  71396. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71397. * but the standard material would require them in Gamma space) (default is true)
  71398. */
  71399. gammaSpace?: boolean);
  71400. /**
  71401. * Execute the current task
  71402. * @param scene defines the scene where you want your assets to be loaded
  71403. * @param onSuccess is a callback called when the task is successfully executed
  71404. * @param onError is a callback called if an error occurs
  71405. */
  71406. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71407. }
  71408. /**
  71409. * This class can be used to easily import assets into a scene
  71410. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71411. */
  71412. export class AssetsManager {
  71413. private _scene;
  71414. private _isLoading;
  71415. protected _tasks: AbstractAssetTask[];
  71416. protected _waitingTasksCount: number;
  71417. protected _totalTasksCount: number;
  71418. /**
  71419. * Callback called when all tasks are processed
  71420. */
  71421. onFinish: (tasks: AbstractAssetTask[]) => void;
  71422. /**
  71423. * Callback called when a task is successful
  71424. */
  71425. onTaskSuccess: (task: AbstractAssetTask) => void;
  71426. /**
  71427. * Callback called when a task had an error
  71428. */
  71429. onTaskError: (task: AbstractAssetTask) => void;
  71430. /**
  71431. * Callback called when a task is done (whatever the result is)
  71432. */
  71433. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71434. /**
  71435. * Observable called when all tasks are processed
  71436. */
  71437. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71438. /**
  71439. * Observable called when a task had an error
  71440. */
  71441. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71442. /**
  71443. * Observable called when all tasks were executed
  71444. */
  71445. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71446. /**
  71447. * Observable called when a task is done (whatever the result is)
  71448. */
  71449. onProgressObservable: Observable<IAssetsProgressEvent>;
  71450. /**
  71451. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71453. */
  71454. useDefaultLoadingScreen: boolean;
  71455. /**
  71456. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71457. * when all assets have been downloaded.
  71458. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71459. */
  71460. autoHideLoadingUI: boolean;
  71461. /**
  71462. * Creates a new AssetsManager
  71463. * @param scene defines the scene to work on
  71464. */
  71465. constructor(scene: Scene);
  71466. /**
  71467. * Add a MeshAssetTask to the list of active tasks
  71468. * @param taskName defines the name of the new task
  71469. * @param meshesNames defines the name of meshes to load
  71470. * @param rootUrl defines the root url to use to locate files
  71471. * @param sceneFilename defines the filename of the scene file
  71472. * @returns a new MeshAssetTask object
  71473. */
  71474. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71475. /**
  71476. * Add a TextFileAssetTask to the list of active tasks
  71477. * @param taskName defines the name of the new task
  71478. * @param url defines the url of the file to load
  71479. * @returns a new TextFileAssetTask object
  71480. */
  71481. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71482. /**
  71483. * Add a BinaryFileAssetTask to the list of active tasks
  71484. * @param taskName defines the name of the new task
  71485. * @param url defines the url of the file to load
  71486. * @returns a new BinaryFileAssetTask object
  71487. */
  71488. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71489. /**
  71490. * Add a ImageAssetTask to the list of active tasks
  71491. * @param taskName defines the name of the new task
  71492. * @param url defines the url of the file to load
  71493. * @returns a new ImageAssetTask object
  71494. */
  71495. addImageTask(taskName: string, url: string): ImageAssetTask;
  71496. /**
  71497. * Add a TextureAssetTask to the list of active tasks
  71498. * @param taskName defines the name of the new task
  71499. * @param url defines the url of the file to load
  71500. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71501. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71502. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71503. * @returns a new TextureAssetTask object
  71504. */
  71505. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71506. /**
  71507. * Add a CubeTextureAssetTask to the list of active tasks
  71508. * @param taskName defines the name of the new task
  71509. * @param url defines the url of the file to load
  71510. * @param extensions defines the extension to use to load the cube map (can be null)
  71511. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71512. * @param files defines the list of files to load (can be null)
  71513. * @returns a new CubeTextureAssetTask object
  71514. */
  71515. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71516. /**
  71517. *
  71518. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71519. * @param taskName defines the name of the new task
  71520. * @param url defines the url of the file to load
  71521. * @param size defines the size you want for the cubemap (can be null)
  71522. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71523. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71524. * @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)
  71525. * @param reserved Internal use only
  71526. * @returns a new HDRCubeTextureAssetTask object
  71527. */
  71528. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71529. /**
  71530. *
  71531. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71532. * @param taskName defines the name of the new task
  71533. * @param url defines the url of the file to load
  71534. * @param size defines the size you want for the cubemap (can be null)
  71535. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71536. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71537. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71538. * @returns a new EquiRectangularCubeTextureAssetTask object
  71539. */
  71540. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71541. /**
  71542. * Remove a task from the assets manager.
  71543. * @param task the task to remove
  71544. */
  71545. removeTask(task: AbstractAssetTask): void;
  71546. private _decreaseWaitingTasksCount;
  71547. private _runTask;
  71548. /**
  71549. * Reset the AssetsManager and remove all tasks
  71550. * @return the current instance of the AssetsManager
  71551. */
  71552. reset(): AssetsManager;
  71553. /**
  71554. * Start the loading process
  71555. * @return the current instance of the AssetsManager
  71556. */
  71557. load(): AssetsManager;
  71558. /**
  71559. * Start the loading process as an async operation
  71560. * @return a promise returning the list of failed tasks
  71561. */
  71562. loadAsync(): Promise<void>;
  71563. }
  71564. }
  71565. declare module BABYLON {
  71566. /**
  71567. * Wrapper class for promise with external resolve and reject.
  71568. */
  71569. export class Deferred<T> {
  71570. /**
  71571. * The promise associated with this deferred object.
  71572. */
  71573. readonly promise: Promise<T>;
  71574. private _resolve;
  71575. private _reject;
  71576. /**
  71577. * The resolve method of the promise associated with this deferred object.
  71578. */
  71579. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71580. /**
  71581. * The reject method of the promise associated with this deferred object.
  71582. */
  71583. get reject(): (reason?: any) => void;
  71584. /**
  71585. * Constructor for this deferred object.
  71586. */
  71587. constructor();
  71588. }
  71589. }
  71590. declare module BABYLON {
  71591. /**
  71592. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71593. */
  71594. export class MeshExploder {
  71595. private _centerMesh;
  71596. private _meshes;
  71597. private _meshesOrigins;
  71598. private _toCenterVectors;
  71599. private _scaledDirection;
  71600. private _newPosition;
  71601. private _centerPosition;
  71602. /**
  71603. * Explodes meshes from a center mesh.
  71604. * @param meshes The meshes to explode.
  71605. * @param centerMesh The mesh to be center of explosion.
  71606. */
  71607. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71608. private _setCenterMesh;
  71609. /**
  71610. * Get class name
  71611. * @returns "MeshExploder"
  71612. */
  71613. getClassName(): string;
  71614. /**
  71615. * "Exploded meshes"
  71616. * @returns Array of meshes with the centerMesh at index 0.
  71617. */
  71618. getMeshes(): Array<Mesh>;
  71619. /**
  71620. * Explodes meshes giving a specific direction
  71621. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71622. */
  71623. explode(direction?: number): void;
  71624. }
  71625. }
  71626. declare module BABYLON {
  71627. /**
  71628. * Class used to help managing file picking and drag'n'drop
  71629. */
  71630. export class FilesInput {
  71631. /**
  71632. * List of files ready to be loaded
  71633. */
  71634. static get FilesToLoad(): {
  71635. [key: string]: File;
  71636. };
  71637. /**
  71638. * Callback called when a file is processed
  71639. */
  71640. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71641. private _engine;
  71642. private _currentScene;
  71643. private _sceneLoadedCallback;
  71644. private _progressCallback;
  71645. private _additionalRenderLoopLogicCallback;
  71646. private _textureLoadingCallback;
  71647. private _startingProcessingFilesCallback;
  71648. private _onReloadCallback;
  71649. private _errorCallback;
  71650. private _elementToMonitor;
  71651. private _sceneFileToLoad;
  71652. private _filesToLoad;
  71653. /**
  71654. * Creates a new FilesInput
  71655. * @param engine defines the rendering engine
  71656. * @param scene defines the hosting scene
  71657. * @param sceneLoadedCallback callback called when scene is loaded
  71658. * @param progressCallback callback called to track progress
  71659. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71660. * @param textureLoadingCallback callback called when a texture is loading
  71661. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71662. * @param onReloadCallback callback called when a reload is requested
  71663. * @param errorCallback callback call if an error occurs
  71664. */
  71665. 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);
  71666. private _dragEnterHandler;
  71667. private _dragOverHandler;
  71668. private _dropHandler;
  71669. /**
  71670. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71671. * @param elementToMonitor defines the DOM element to track
  71672. */
  71673. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71674. /**
  71675. * Release all associated resources
  71676. */
  71677. dispose(): void;
  71678. private renderFunction;
  71679. private drag;
  71680. private drop;
  71681. private _traverseFolder;
  71682. private _processFiles;
  71683. /**
  71684. * Load files from a drop event
  71685. * @param event defines the drop event to use as source
  71686. */
  71687. loadFiles(event: any): void;
  71688. private _processReload;
  71689. /**
  71690. * Reload the current scene from the loaded files
  71691. */
  71692. reload(): void;
  71693. }
  71694. }
  71695. declare module BABYLON {
  71696. /**
  71697. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71699. */
  71700. export class SceneOptimization {
  71701. /**
  71702. * Defines the priority of this optimization (0 by default which means first in the list)
  71703. */
  71704. priority: number;
  71705. /**
  71706. * Gets a string describing the action executed by the current optimization
  71707. * @returns description string
  71708. */
  71709. getDescription(): string;
  71710. /**
  71711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71712. * @param scene defines the current scene where to apply this optimization
  71713. * @param optimizer defines the current optimizer
  71714. * @returns true if everything that can be done was applied
  71715. */
  71716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71717. /**
  71718. * Creates the SceneOptimization object
  71719. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71720. * @param desc defines the description associated with the optimization
  71721. */
  71722. constructor(
  71723. /**
  71724. * Defines the priority of this optimization (0 by default which means first in the list)
  71725. */
  71726. priority?: number);
  71727. }
  71728. /**
  71729. * Defines an optimization used to reduce the size of render target textures
  71730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71731. */
  71732. export class TextureOptimization extends SceneOptimization {
  71733. /**
  71734. * Defines the priority of this optimization (0 by default which means first in the list)
  71735. */
  71736. priority: number;
  71737. /**
  71738. * 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
  71739. */
  71740. maximumSize: number;
  71741. /**
  71742. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71743. */
  71744. step: number;
  71745. /**
  71746. * Gets a string describing the action executed by the current optimization
  71747. * @returns description string
  71748. */
  71749. getDescription(): string;
  71750. /**
  71751. * Creates the TextureOptimization object
  71752. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71753. * @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
  71754. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71755. */
  71756. constructor(
  71757. /**
  71758. * Defines the priority of this optimization (0 by default which means first in the list)
  71759. */
  71760. priority?: number,
  71761. /**
  71762. * 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
  71763. */
  71764. maximumSize?: number,
  71765. /**
  71766. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71767. */
  71768. step?: number);
  71769. /**
  71770. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71771. * @param scene defines the current scene where to apply this optimization
  71772. * @param optimizer defines the current optimizer
  71773. * @returns true if everything that can be done was applied
  71774. */
  71775. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71776. }
  71777. /**
  71778. * Defines an optimization used to increase or decrease the rendering resolution
  71779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71780. */
  71781. export class HardwareScalingOptimization extends SceneOptimization {
  71782. /**
  71783. * Defines the priority of this optimization (0 by default which means first in the list)
  71784. */
  71785. priority: number;
  71786. /**
  71787. * Defines the maximum scale to use (2 by default)
  71788. */
  71789. maximumScale: number;
  71790. /**
  71791. * Defines the step to use between two passes (0.5 by default)
  71792. */
  71793. step: number;
  71794. private _currentScale;
  71795. private _directionOffset;
  71796. /**
  71797. * Gets a string describing the action executed by the current optimization
  71798. * @return description string
  71799. */
  71800. getDescription(): string;
  71801. /**
  71802. * Creates the HardwareScalingOptimization object
  71803. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71804. * @param maximumScale defines the maximum scale to use (2 by default)
  71805. * @param step defines the step to use between two passes (0.5 by default)
  71806. */
  71807. constructor(
  71808. /**
  71809. * Defines the priority of this optimization (0 by default which means first in the list)
  71810. */
  71811. priority?: number,
  71812. /**
  71813. * Defines the maximum scale to use (2 by default)
  71814. */
  71815. maximumScale?: number,
  71816. /**
  71817. * Defines the step to use between two passes (0.5 by default)
  71818. */
  71819. step?: number);
  71820. /**
  71821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71822. * @param scene defines the current scene where to apply this optimization
  71823. * @param optimizer defines the current optimizer
  71824. * @returns true if everything that can be done was applied
  71825. */
  71826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71827. }
  71828. /**
  71829. * Defines an optimization used to remove shadows
  71830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71831. */
  71832. export class ShadowsOptimization extends SceneOptimization {
  71833. /**
  71834. * Gets a string describing the action executed by the current optimization
  71835. * @return description string
  71836. */
  71837. getDescription(): string;
  71838. /**
  71839. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71840. * @param scene defines the current scene where to apply this optimization
  71841. * @param optimizer defines the current optimizer
  71842. * @returns true if everything that can be done was applied
  71843. */
  71844. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71845. }
  71846. /**
  71847. * Defines an optimization used to turn post-processes off
  71848. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71849. */
  71850. export class PostProcessesOptimization extends SceneOptimization {
  71851. /**
  71852. * Gets a string describing the action executed by the current optimization
  71853. * @return description string
  71854. */
  71855. getDescription(): string;
  71856. /**
  71857. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71858. * @param scene defines the current scene where to apply this optimization
  71859. * @param optimizer defines the current optimizer
  71860. * @returns true if everything that can be done was applied
  71861. */
  71862. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71863. }
  71864. /**
  71865. * Defines an optimization used to turn lens flares off
  71866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71867. */
  71868. export class LensFlaresOptimization extends SceneOptimization {
  71869. /**
  71870. * Gets a string describing the action executed by the current optimization
  71871. * @return description string
  71872. */
  71873. getDescription(): string;
  71874. /**
  71875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71876. * @param scene defines the current scene where to apply this optimization
  71877. * @param optimizer defines the current optimizer
  71878. * @returns true if everything that can be done was applied
  71879. */
  71880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71881. }
  71882. /**
  71883. * Defines an optimization based on user defined callback.
  71884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71885. */
  71886. export class CustomOptimization extends SceneOptimization {
  71887. /**
  71888. * Callback called to apply the custom optimization.
  71889. */
  71890. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71891. /**
  71892. * Callback called to get custom description
  71893. */
  71894. onGetDescription: () => string;
  71895. /**
  71896. * Gets a string describing the action executed by the current optimization
  71897. * @returns description string
  71898. */
  71899. getDescription(): string;
  71900. /**
  71901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71902. * @param scene defines the current scene where to apply this optimization
  71903. * @param optimizer defines the current optimizer
  71904. * @returns true if everything that can be done was applied
  71905. */
  71906. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71907. }
  71908. /**
  71909. * Defines an optimization used to turn particles off
  71910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71911. */
  71912. export class ParticlesOptimization extends SceneOptimization {
  71913. /**
  71914. * Gets a string describing the action executed by the current optimization
  71915. * @return description string
  71916. */
  71917. getDescription(): string;
  71918. /**
  71919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71920. * @param scene defines the current scene where to apply this optimization
  71921. * @param optimizer defines the current optimizer
  71922. * @returns true if everything that can be done was applied
  71923. */
  71924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71925. }
  71926. /**
  71927. * Defines an optimization used to turn render targets off
  71928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71929. */
  71930. export class RenderTargetsOptimization extends SceneOptimization {
  71931. /**
  71932. * Gets a string describing the action executed by the current optimization
  71933. * @return description string
  71934. */
  71935. getDescription(): string;
  71936. /**
  71937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71938. * @param scene defines the current scene where to apply this optimization
  71939. * @param optimizer defines the current optimizer
  71940. * @returns true if everything that can be done was applied
  71941. */
  71942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71943. }
  71944. /**
  71945. * Defines an optimization used to merge meshes with compatible materials
  71946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71947. */
  71948. export class MergeMeshesOptimization extends SceneOptimization {
  71949. private static _UpdateSelectionTree;
  71950. /**
  71951. * Gets or sets a boolean which defines if optimization octree has to be updated
  71952. */
  71953. static get UpdateSelectionTree(): boolean;
  71954. /**
  71955. * Gets or sets a boolean which defines if optimization octree has to be updated
  71956. */
  71957. static set UpdateSelectionTree(value: boolean);
  71958. /**
  71959. * Gets a string describing the action executed by the current optimization
  71960. * @return description string
  71961. */
  71962. getDescription(): string;
  71963. private _canBeMerged;
  71964. /**
  71965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71966. * @param scene defines the current scene where to apply this optimization
  71967. * @param optimizer defines the current optimizer
  71968. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71969. * @returns true if everything that can be done was applied
  71970. */
  71971. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71972. }
  71973. /**
  71974. * Defines a list of options used by SceneOptimizer
  71975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71976. */
  71977. export class SceneOptimizerOptions {
  71978. /**
  71979. * Defines the target frame rate to reach (60 by default)
  71980. */
  71981. targetFrameRate: number;
  71982. /**
  71983. * Defines the interval between two checkes (2000ms by default)
  71984. */
  71985. trackerDuration: number;
  71986. /**
  71987. * Gets the list of optimizations to apply
  71988. */
  71989. optimizations: SceneOptimization[];
  71990. /**
  71991. * Creates a new list of options used by SceneOptimizer
  71992. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71993. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71994. */
  71995. constructor(
  71996. /**
  71997. * Defines the target frame rate to reach (60 by default)
  71998. */
  71999. targetFrameRate?: number,
  72000. /**
  72001. * Defines the interval between two checkes (2000ms by default)
  72002. */
  72003. trackerDuration?: number);
  72004. /**
  72005. * Add a new optimization
  72006. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72007. * @returns the current SceneOptimizerOptions
  72008. */
  72009. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72010. /**
  72011. * Add a new custom optimization
  72012. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72013. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72014. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72015. * @returns the current SceneOptimizerOptions
  72016. */
  72017. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72018. /**
  72019. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72020. * @param targetFrameRate defines the target frame rate (60 by default)
  72021. * @returns a SceneOptimizerOptions object
  72022. */
  72023. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72024. /**
  72025. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72026. * @param targetFrameRate defines the target frame rate (60 by default)
  72027. * @returns a SceneOptimizerOptions object
  72028. */
  72029. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72030. /**
  72031. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72032. * @param targetFrameRate defines the target frame rate (60 by default)
  72033. * @returns a SceneOptimizerOptions object
  72034. */
  72035. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72036. }
  72037. /**
  72038. * Class used to run optimizations in order to reach a target frame rate
  72039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72040. */
  72041. export class SceneOptimizer implements IDisposable {
  72042. private _isRunning;
  72043. private _options;
  72044. private _scene;
  72045. private _currentPriorityLevel;
  72046. private _targetFrameRate;
  72047. private _trackerDuration;
  72048. private _currentFrameRate;
  72049. private _sceneDisposeObserver;
  72050. private _improvementMode;
  72051. /**
  72052. * Defines an observable called when the optimizer reaches the target frame rate
  72053. */
  72054. onSuccessObservable: Observable<SceneOptimizer>;
  72055. /**
  72056. * Defines an observable called when the optimizer enables an optimization
  72057. */
  72058. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72059. /**
  72060. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72061. */
  72062. onFailureObservable: Observable<SceneOptimizer>;
  72063. /**
  72064. * Gets a boolean indicating if the optimizer is in improvement mode
  72065. */
  72066. get isInImprovementMode(): boolean;
  72067. /**
  72068. * Gets the current priority level (0 at start)
  72069. */
  72070. get currentPriorityLevel(): number;
  72071. /**
  72072. * Gets the current frame rate checked by the SceneOptimizer
  72073. */
  72074. get currentFrameRate(): number;
  72075. /**
  72076. * Gets or sets the current target frame rate (60 by default)
  72077. */
  72078. get targetFrameRate(): number;
  72079. /**
  72080. * Gets or sets the current target frame rate (60 by default)
  72081. */
  72082. set targetFrameRate(value: number);
  72083. /**
  72084. * Gets or sets the current interval between two checks (every 2000ms by default)
  72085. */
  72086. get trackerDuration(): number;
  72087. /**
  72088. * Gets or sets the current interval between two checks (every 2000ms by default)
  72089. */
  72090. set trackerDuration(value: number);
  72091. /**
  72092. * Gets the list of active optimizations
  72093. */
  72094. get optimizations(): SceneOptimization[];
  72095. /**
  72096. * Creates a new SceneOptimizer
  72097. * @param scene defines the scene to work on
  72098. * @param options defines the options to use with the SceneOptimizer
  72099. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72100. * @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)
  72101. */
  72102. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72103. /**
  72104. * Stops the current optimizer
  72105. */
  72106. stop(): void;
  72107. /**
  72108. * Reset the optimizer to initial step (current priority level = 0)
  72109. */
  72110. reset(): void;
  72111. /**
  72112. * Start the optimizer. By default it will try to reach a specific framerate
  72113. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72114. */
  72115. start(): void;
  72116. private _checkCurrentState;
  72117. /**
  72118. * Release all resources
  72119. */
  72120. dispose(): void;
  72121. /**
  72122. * Helper function to create a SceneOptimizer with one single line of code
  72123. * @param scene defines the scene to work on
  72124. * @param options defines the options to use with the SceneOptimizer
  72125. * @param onSuccess defines a callback to call on success
  72126. * @param onFailure defines a callback to call on failure
  72127. * @returns the new SceneOptimizer object
  72128. */
  72129. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72130. }
  72131. }
  72132. declare module BABYLON {
  72133. /**
  72134. * Class used to serialize a scene into a string
  72135. */
  72136. export class SceneSerializer {
  72137. /**
  72138. * Clear cache used by a previous serialization
  72139. */
  72140. static ClearCache(): void;
  72141. /**
  72142. * Serialize a scene into a JSON compatible object
  72143. * @param scene defines the scene to serialize
  72144. * @returns a JSON compatible object
  72145. */
  72146. static Serialize(scene: Scene): any;
  72147. /**
  72148. * Serialize a mesh into a JSON compatible object
  72149. * @param toSerialize defines the mesh to serialize
  72150. * @param withParents defines if parents must be serialized as well
  72151. * @param withChildren defines if children must be serialized as well
  72152. * @returns a JSON compatible object
  72153. */
  72154. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72155. }
  72156. }
  72157. declare module BABYLON {
  72158. /**
  72159. * Class used to host texture specific utilities
  72160. */
  72161. export class TextureTools {
  72162. /**
  72163. * Uses the GPU to create a copy texture rescaled at a given size
  72164. * @param texture Texture to copy from
  72165. * @param width defines the desired width
  72166. * @param height defines the desired height
  72167. * @param useBilinearMode defines if bilinear mode has to be used
  72168. * @return the generated texture
  72169. */
  72170. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72171. }
  72172. }
  72173. declare module BABYLON {
  72174. /**
  72175. * This represents the different options available for the video capture.
  72176. */
  72177. export interface VideoRecorderOptions {
  72178. /** Defines the mime type of the video. */
  72179. mimeType: string;
  72180. /** Defines the FPS the video should be recorded at. */
  72181. fps: number;
  72182. /** Defines the chunk size for the recording data. */
  72183. recordChunckSize: number;
  72184. /** The audio tracks to attach to the recording. */
  72185. audioTracks?: MediaStreamTrack[];
  72186. }
  72187. /**
  72188. * This can help with recording videos from BabylonJS.
  72189. * This is based on the available WebRTC functionalities of the browser.
  72190. *
  72191. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72192. */
  72193. export class VideoRecorder {
  72194. private static readonly _defaultOptions;
  72195. /**
  72196. * Returns whether or not the VideoRecorder is available in your browser.
  72197. * @param engine Defines the Babylon Engine.
  72198. * @returns true if supported otherwise false.
  72199. */
  72200. static IsSupported(engine: Engine): boolean;
  72201. private readonly _options;
  72202. private _canvas;
  72203. private _mediaRecorder;
  72204. private _recordedChunks;
  72205. private _fileName;
  72206. private _resolve;
  72207. private _reject;
  72208. /**
  72209. * True when a recording is already in progress.
  72210. */
  72211. get isRecording(): boolean;
  72212. /**
  72213. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72214. * @param engine Defines the BabylonJS Engine you wish to record.
  72215. * @param options Defines options that can be used to customize the capture.
  72216. */
  72217. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72218. /**
  72219. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72220. */
  72221. stopRecording(): void;
  72222. /**
  72223. * Starts recording the canvas for a max duration specified in parameters.
  72224. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72225. * If null no automatic download will start and you can rely on the promise to get the data back.
  72226. * @param maxDuration Defines the maximum recording time in seconds.
  72227. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72228. * @return A promise callback at the end of the recording with the video data in Blob.
  72229. */
  72230. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72231. /**
  72232. * Releases internal resources used during the recording.
  72233. */
  72234. dispose(): void;
  72235. private _handleDataAvailable;
  72236. private _handleError;
  72237. private _handleStop;
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. /**
  72242. * Class containing a set of static utilities functions for screenshots
  72243. */
  72244. export class ScreenshotTools {
  72245. /**
  72246. * Captures a screenshot of the current rendering
  72247. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72248. * @param engine defines the rendering engine
  72249. * @param camera defines the source camera
  72250. * @param size This parameter can be set to a single number or to an object with the
  72251. * following (optional) properties: precision, width, height. If a single number is passed,
  72252. * it will be used for both width and height. If an object is passed, the screenshot size
  72253. * will be derived from the parameters. The precision property is a multiplier allowing
  72254. * rendering at a higher or lower resolution
  72255. * @param successCallback defines the callback receives a single parameter which contains the
  72256. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72257. * src parameter of an <img> to display it
  72258. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72259. * Check your browser for supported MIME types
  72260. */
  72261. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72262. /**
  72263. * Captures a screenshot of the current rendering
  72264. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72265. * @param engine defines the rendering engine
  72266. * @param camera defines the source camera
  72267. * @param size This parameter can be set to a single number or to an object with the
  72268. * following (optional) properties: precision, width, height. If a single number is passed,
  72269. * it will be used for both width and height. If an object is passed, the screenshot size
  72270. * will be derived from the parameters. The precision property is a multiplier allowing
  72271. * rendering at a higher or lower resolution
  72272. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72273. * Check your browser for supported MIME types
  72274. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72275. * to the src parameter of an <img> to display it
  72276. */
  72277. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72278. /**
  72279. * Generates an image screenshot from the specified camera.
  72280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72281. * @param engine The engine to use for rendering
  72282. * @param camera The camera to use for rendering
  72283. * @param size This parameter can be set to a single number or to an object with the
  72284. * following (optional) properties: precision, width, height. If a single number is passed,
  72285. * it will be used for both width and height. If an object is passed, the screenshot size
  72286. * will be derived from the parameters. The precision property is a multiplier allowing
  72287. * rendering at a higher or lower resolution
  72288. * @param successCallback The callback receives a single parameter which contains the
  72289. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72290. * src parameter of an <img> to display it
  72291. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72292. * Check your browser for supported MIME types
  72293. * @param samples Texture samples (default: 1)
  72294. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72295. * @param fileName A name for for the downloaded file.
  72296. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72297. */
  72298. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72299. /**
  72300. * Generates an image screenshot from the specified camera.
  72301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72302. * @param engine The engine to use for rendering
  72303. * @param camera The camera to use for rendering
  72304. * @param size This parameter can be set to a single number or to an object with the
  72305. * following (optional) properties: precision, width, height. If a single number is passed,
  72306. * it will be used for both width and height. If an object is passed, the screenshot size
  72307. * will be derived from the parameters. The precision property is a multiplier allowing
  72308. * rendering at a higher or lower resolution
  72309. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72310. * Check your browser for supported MIME types
  72311. * @param samples Texture samples (default: 1)
  72312. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72313. * @param fileName A name for for the downloaded file.
  72314. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72315. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72316. * to the src parameter of an <img> to display it
  72317. */
  72318. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72319. /**
  72320. * Gets height and width for screenshot size
  72321. * @private
  72322. */
  72323. private static _getScreenshotSize;
  72324. }
  72325. }
  72326. declare module BABYLON {
  72327. /**
  72328. * Interface for a data buffer
  72329. */
  72330. export interface IDataBuffer {
  72331. /**
  72332. * Reads bytes from the data buffer.
  72333. * @param byteOffset The byte offset to read
  72334. * @param byteLength The byte length to read
  72335. * @returns A promise that resolves when the bytes are read
  72336. */
  72337. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72338. /**
  72339. * The byte length of the buffer.
  72340. */
  72341. readonly byteLength: number;
  72342. }
  72343. /**
  72344. * Utility class for reading from a data buffer
  72345. */
  72346. export class DataReader {
  72347. /**
  72348. * The data buffer associated with this data reader.
  72349. */
  72350. readonly buffer: IDataBuffer;
  72351. /**
  72352. * The current byte offset from the beginning of the data buffer.
  72353. */
  72354. byteOffset: number;
  72355. private _dataView;
  72356. private _dataByteOffset;
  72357. /**
  72358. * Constructor
  72359. * @param buffer The buffer to read
  72360. */
  72361. constructor(buffer: IDataBuffer);
  72362. /**
  72363. * Loads the given byte length.
  72364. * @param byteLength The byte length to load
  72365. * @returns A promise that resolves when the load is complete
  72366. */
  72367. loadAsync(byteLength: number): Promise<void>;
  72368. /**
  72369. * Read a unsigned 32-bit integer from the currently loaded data range.
  72370. * @returns The 32-bit integer read
  72371. */
  72372. readUint32(): number;
  72373. /**
  72374. * Read a byte array from the currently loaded data range.
  72375. * @param byteLength The byte length to read
  72376. * @returns The byte array read
  72377. */
  72378. readUint8Array(byteLength: number): Uint8Array;
  72379. /**
  72380. * Read a string from the currently loaded data range.
  72381. * @param byteLength The byte length to read
  72382. * @returns The string read
  72383. */
  72384. readString(byteLength: number): string;
  72385. /**
  72386. * Skips the given byte length the currently loaded data range.
  72387. * @param byteLength The byte length to skip
  72388. */
  72389. skipBytes(byteLength: number): void;
  72390. }
  72391. }
  72392. declare module BABYLON {
  72393. /**
  72394. * Class for storing data to local storage if available or in-memory storage otherwise
  72395. */
  72396. export class DataStorage {
  72397. private static _Storage;
  72398. private static _GetStorage;
  72399. /**
  72400. * Reads a string from the data storage
  72401. * @param key The key to read
  72402. * @param defaultValue The value if the key doesn't exist
  72403. * @returns The string value
  72404. */
  72405. static ReadString(key: string, defaultValue: string): string;
  72406. /**
  72407. * Writes a string to the data storage
  72408. * @param key The key to write
  72409. * @param value The value to write
  72410. */
  72411. static WriteString(key: string, value: string): void;
  72412. /**
  72413. * Reads a boolean from the data storage
  72414. * @param key The key to read
  72415. * @param defaultValue The value if the key doesn't exist
  72416. * @returns The boolean value
  72417. */
  72418. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72419. /**
  72420. * Writes a boolean to the data storage
  72421. * @param key The key to write
  72422. * @param value The value to write
  72423. */
  72424. static WriteBoolean(key: string, value: boolean): void;
  72425. /**
  72426. * Reads a number from the data storage
  72427. * @param key The key to read
  72428. * @param defaultValue The value if the key doesn't exist
  72429. * @returns The number value
  72430. */
  72431. static ReadNumber(key: string, defaultValue: number): number;
  72432. /**
  72433. * Writes a number to the data storage
  72434. * @param key The key to write
  72435. * @param value The value to write
  72436. */
  72437. static WriteNumber(key: string, value: number): void;
  72438. }
  72439. }
  72440. declare module BABYLON {
  72441. /**
  72442. * An interface for all Hit test features
  72443. */
  72444. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72445. /**
  72446. * Triggered when new babylon (transformed) hit test results are available
  72447. */
  72448. onHitTestResultObservable: Observable<T[]>;
  72449. }
  72450. /**
  72451. * Options used for hit testing
  72452. */
  72453. export interface IWebXRLegacyHitTestOptions {
  72454. /**
  72455. * Only test when user interacted with the scene. Default - hit test every frame
  72456. */
  72457. testOnPointerDownOnly?: boolean;
  72458. /**
  72459. * The node to use to transform the local results to world coordinates
  72460. */
  72461. worldParentNode?: TransformNode;
  72462. }
  72463. /**
  72464. * Interface defining the babylon result of raycasting/hit-test
  72465. */
  72466. export interface IWebXRLegacyHitResult {
  72467. /**
  72468. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72469. */
  72470. transformationMatrix: Matrix;
  72471. /**
  72472. * The native hit test result
  72473. */
  72474. xrHitResult: XRHitResult | XRHitTestResult;
  72475. }
  72476. /**
  72477. * The currently-working hit-test module.
  72478. * Hit test (or Ray-casting) is used to interact with the real world.
  72479. * For further information read here - https://github.com/immersive-web/hit-test
  72480. */
  72481. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72482. /**
  72483. * options to use when constructing this feature
  72484. */
  72485. readonly options: IWebXRLegacyHitTestOptions;
  72486. private _direction;
  72487. private _mat;
  72488. private _onSelectEnabled;
  72489. private _origin;
  72490. /**
  72491. * The module's name
  72492. */
  72493. static readonly Name: string;
  72494. /**
  72495. * The (Babylon) version of this module.
  72496. * This is an integer representing the implementation version.
  72497. * This number does not correspond to the WebXR specs version
  72498. */
  72499. static readonly Version: number;
  72500. /**
  72501. * Populated with the last native XR Hit Results
  72502. */
  72503. lastNativeXRHitResults: XRHitResult[];
  72504. /**
  72505. * Triggered when new babylon (transformed) hit test results are available
  72506. */
  72507. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72508. /**
  72509. * Creates a new instance of the (legacy version) hit test feature
  72510. * @param _xrSessionManager an instance of WebXRSessionManager
  72511. * @param options options to use when constructing this feature
  72512. */
  72513. constructor(_xrSessionManager: WebXRSessionManager,
  72514. /**
  72515. * options to use when constructing this feature
  72516. */
  72517. options?: IWebXRLegacyHitTestOptions);
  72518. /**
  72519. * execute a hit test with an XR Ray
  72520. *
  72521. * @param xrSession a native xrSession that will execute this hit test
  72522. * @param xrRay the ray (position and direction) to use for ray-casting
  72523. * @param referenceSpace native XR reference space to use for the hit-test
  72524. * @param filter filter function that will filter the results
  72525. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72526. */
  72527. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72528. /**
  72529. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72530. * @param event the (select) event to use to select with
  72531. * @param referenceSpace the reference space to use for this hit test
  72532. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72533. */
  72534. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72535. /**
  72536. * attach this feature
  72537. * Will usually be called by the features manager
  72538. *
  72539. * @returns true if successful.
  72540. */
  72541. attach(): boolean;
  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. private _onHitTestResults;
  72555. private _onSelect;
  72556. }
  72557. }
  72558. declare module BABYLON {
  72559. /**
  72560. * Options used for hit testing (version 2)
  72561. */
  72562. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72563. /**
  72564. * Do not create a permanent hit test. Will usually be used when only
  72565. * transient inputs are needed.
  72566. */
  72567. disablePermanentHitTest?: boolean;
  72568. /**
  72569. * Enable transient (for example touch-based) hit test inspections
  72570. */
  72571. enableTransientHitTest?: boolean;
  72572. /**
  72573. * Offset ray for the permanent hit test
  72574. */
  72575. offsetRay?: Vector3;
  72576. /**
  72577. * Offset ray for the transient hit test
  72578. */
  72579. transientOffsetRay?: Vector3;
  72580. /**
  72581. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72582. */
  72583. useReferenceSpace?: boolean;
  72584. }
  72585. /**
  72586. * Interface defining the babylon result of hit-test
  72587. */
  72588. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72589. /**
  72590. * The input source that generated this hit test (if transient)
  72591. */
  72592. inputSource?: XRInputSource;
  72593. /**
  72594. * Is this a transient hit test
  72595. */
  72596. isTransient?: boolean;
  72597. /**
  72598. * Position of the hit test result
  72599. */
  72600. position: Vector3;
  72601. /**
  72602. * Rotation of the hit test result
  72603. */
  72604. rotationQuaternion: Quaternion;
  72605. /**
  72606. * The native hit test result
  72607. */
  72608. xrHitResult: XRHitTestResult;
  72609. }
  72610. /**
  72611. * The currently-working hit-test module.
  72612. * Hit test (or Ray-casting) is used to interact with the real world.
  72613. * For further information read here - https://github.com/immersive-web/hit-test
  72614. *
  72615. * Tested on chrome (mobile) 80.
  72616. */
  72617. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72618. /**
  72619. * options to use when constructing this feature
  72620. */
  72621. readonly options: IWebXRHitTestOptions;
  72622. private _tmpMat;
  72623. private _tmpPos;
  72624. private _tmpQuat;
  72625. private _transientXrHitTestSource;
  72626. private _xrHitTestSource;
  72627. private initHitTestSource;
  72628. /**
  72629. * The module's name
  72630. */
  72631. static readonly Name: string;
  72632. /**
  72633. * The (Babylon) version of this module.
  72634. * This is an integer representing the implementation version.
  72635. * This number does not correspond to the WebXR specs version
  72636. */
  72637. static readonly Version: number;
  72638. /**
  72639. * When set to true, each hit test will have its own position/rotation objects
  72640. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72641. * the developers will clone them or copy them as they see fit.
  72642. */
  72643. autoCloneTransformation: boolean;
  72644. /**
  72645. * Triggered when new babylon (transformed) hit test results are available
  72646. */
  72647. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72648. /**
  72649. * Use this to temporarily pause hit test checks.
  72650. */
  72651. paused: boolean;
  72652. /**
  72653. * Creates a new instance of the hit test feature
  72654. * @param _xrSessionManager an instance of WebXRSessionManager
  72655. * @param options options to use when constructing this feature
  72656. */
  72657. constructor(_xrSessionManager: WebXRSessionManager,
  72658. /**
  72659. * options to use when constructing this feature
  72660. */
  72661. options?: IWebXRHitTestOptions);
  72662. /**
  72663. * attach this feature
  72664. * Will usually be called by the features manager
  72665. *
  72666. * @returns true if successful.
  72667. */
  72668. attach(): boolean;
  72669. /**
  72670. * detach this feature.
  72671. * Will usually be called by the features manager
  72672. *
  72673. * @returns true if successful.
  72674. */
  72675. detach(): boolean;
  72676. /**
  72677. * Dispose this feature and all of the resources attached
  72678. */
  72679. dispose(): void;
  72680. protected _onXRFrame(frame: XRFrame): void;
  72681. private _processWebXRHitTestResult;
  72682. }
  72683. }
  72684. declare module BABYLON {
  72685. /**
  72686. * Configuration options of the anchor system
  72687. */
  72688. export interface IWebXRAnchorSystemOptions {
  72689. /**
  72690. * a node that will be used to convert local to world coordinates
  72691. */
  72692. worldParentNode?: TransformNode;
  72693. /**
  72694. * If set to true a reference of the created anchors will be kept until the next session starts
  72695. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72696. */
  72697. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72698. }
  72699. /**
  72700. * A babylon container for an XR Anchor
  72701. */
  72702. export interface IWebXRAnchor {
  72703. /**
  72704. * A babylon-assigned ID for this anchor
  72705. */
  72706. id: number;
  72707. /**
  72708. * Transformation matrix to apply to an object attached to this anchor
  72709. */
  72710. transformationMatrix: Matrix;
  72711. /**
  72712. * The native anchor object
  72713. */
  72714. xrAnchor: XRAnchor;
  72715. /**
  72716. * if defined, this object will be constantly updated by the anchor's position and rotation
  72717. */
  72718. attachedNode?: TransformNode;
  72719. }
  72720. /**
  72721. * An implementation of the anchor system for WebXR.
  72722. * For further information see https://github.com/immersive-web/anchors/
  72723. */
  72724. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72725. private _options;
  72726. private _lastFrameDetected;
  72727. private _trackedAnchors;
  72728. private _referenceSpaceForFrameAnchors;
  72729. private _futureAnchors;
  72730. /**
  72731. * The module's name
  72732. */
  72733. static readonly Name: string;
  72734. /**
  72735. * The (Babylon) version of this module.
  72736. * This is an integer representing the implementation version.
  72737. * This number does not correspond to the WebXR specs version
  72738. */
  72739. static readonly Version: number;
  72740. /**
  72741. * Observers registered here will be executed when a new anchor was added to the session
  72742. */
  72743. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72744. /**
  72745. * Observers registered here will be executed when an anchor was removed from the session
  72746. */
  72747. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72748. /**
  72749. * Observers registered here will be executed when an existing anchor updates
  72750. * This can execute N times every frame
  72751. */
  72752. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72753. /**
  72754. * Set the reference space to use for anchor creation, when not using a hit test.
  72755. * Will default to the session's reference space if not defined
  72756. */
  72757. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72758. /**
  72759. * constructs a new anchor system
  72760. * @param _xrSessionManager an instance of WebXRSessionManager
  72761. * @param _options configuration object for this feature
  72762. */
  72763. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72764. private _tmpVector;
  72765. private _tmpQuaternion;
  72766. private _populateTmpTransformation;
  72767. /**
  72768. * Create a new anchor point using a hit test result at a specific point in the scene
  72769. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72770. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72771. *
  72772. * @param hitTestResult The hit test result to use for this anchor creation
  72773. * @param position an optional position offset for this anchor
  72774. * @param rotationQuaternion an optional rotation offset for this anchor
  72775. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72776. */
  72777. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72778. /**
  72779. * Add a new anchor at a specific position and rotation
  72780. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72781. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72782. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72783. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72784. *
  72785. * @param position the position in which to add an anchor
  72786. * @param rotationQuaternion an optional rotation for the anchor transformation
  72787. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72788. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72789. */
  72790. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72791. /**
  72792. * detach this feature.
  72793. * Will usually be called by the features manager
  72794. *
  72795. * @returns true if successful.
  72796. */
  72797. detach(): boolean;
  72798. /**
  72799. * Dispose this feature and all of the resources attached
  72800. */
  72801. dispose(): void;
  72802. protected _onXRFrame(frame: XRFrame): void;
  72803. /**
  72804. * avoiding using Array.find for global support.
  72805. * @param xrAnchor the plane to find in the array
  72806. */
  72807. private _findIndexInAnchorArray;
  72808. private _updateAnchorWithXRFrame;
  72809. private _createAnchorAtTransformation;
  72810. }
  72811. }
  72812. declare module BABYLON {
  72813. /**
  72814. * Options used in the plane detector module
  72815. */
  72816. export interface IWebXRPlaneDetectorOptions {
  72817. /**
  72818. * The node to use to transform the local results to world coordinates
  72819. */
  72820. worldParentNode?: TransformNode;
  72821. /**
  72822. * If set to true a reference of the created planes will be kept until the next session starts
  72823. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72824. */
  72825. doNotRemovePlanesOnSessionEnded?: boolean;
  72826. }
  72827. /**
  72828. * A babylon interface for a WebXR plane.
  72829. * A Plane is actually a polygon, built from N points in space
  72830. *
  72831. * Supported in chrome 79, not supported in canary 81 ATM
  72832. */
  72833. export interface IWebXRPlane {
  72834. /**
  72835. * a babylon-assigned ID for this polygon
  72836. */
  72837. id: number;
  72838. /**
  72839. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72840. */
  72841. polygonDefinition: Array<Vector3>;
  72842. /**
  72843. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72844. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72845. */
  72846. transformationMatrix: Matrix;
  72847. /**
  72848. * the native xr-plane object
  72849. */
  72850. xrPlane: XRPlane;
  72851. }
  72852. /**
  72853. * The plane detector is used to detect planes in the real world when in AR
  72854. * For more information see https://github.com/immersive-web/real-world-geometry/
  72855. */
  72856. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72857. private _options;
  72858. private _detectedPlanes;
  72859. private _enabled;
  72860. private _lastFrameDetected;
  72861. /**
  72862. * The module's name
  72863. */
  72864. static readonly Name: string;
  72865. /**
  72866. * The (Babylon) version of this module.
  72867. * This is an integer representing the implementation version.
  72868. * This number does not correspond to the WebXR specs version
  72869. */
  72870. static readonly Version: number;
  72871. /**
  72872. * Observers registered here will be executed when a new plane was added to the session
  72873. */
  72874. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72875. /**
  72876. * Observers registered here will be executed when a plane is no longer detected in the session
  72877. */
  72878. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72879. /**
  72880. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72881. * This can execute N times every frame
  72882. */
  72883. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72884. /**
  72885. * construct a new Plane Detector
  72886. * @param _xrSessionManager an instance of xr Session manager
  72887. * @param _options configuration to use when constructing this feature
  72888. */
  72889. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72890. /**
  72891. * detach this feature.
  72892. * Will usually be called by the features manager
  72893. *
  72894. * @returns true if successful.
  72895. */
  72896. detach(): boolean;
  72897. /**
  72898. * Dispose this feature and all of the resources attached
  72899. */
  72900. dispose(): void;
  72901. protected _onXRFrame(frame: XRFrame): void;
  72902. private _init;
  72903. private _updatePlaneWithXRPlane;
  72904. /**
  72905. * avoiding using Array.find for global support.
  72906. * @param xrPlane the plane to find in the array
  72907. */
  72908. private findIndexInPlaneArray;
  72909. }
  72910. }
  72911. declare module BABYLON {
  72912. /**
  72913. * Options interface for the background remover plugin
  72914. */
  72915. export interface IWebXRBackgroundRemoverOptions {
  72916. /**
  72917. * Further background meshes to disable when entering AR
  72918. */
  72919. backgroundMeshes?: AbstractMesh[];
  72920. /**
  72921. * flags to configure the removal of the environment helper.
  72922. * If not set, the entire background will be removed. If set, flags should be set as well.
  72923. */
  72924. environmentHelperRemovalFlags?: {
  72925. /**
  72926. * Should the skybox be removed (default false)
  72927. */
  72928. skyBox?: boolean;
  72929. /**
  72930. * Should the ground be removed (default false)
  72931. */
  72932. ground?: boolean;
  72933. };
  72934. /**
  72935. * don't disable the environment helper
  72936. */
  72937. ignoreEnvironmentHelper?: boolean;
  72938. }
  72939. /**
  72940. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72941. */
  72942. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72943. /**
  72944. * read-only options to be used in this module
  72945. */
  72946. readonly options: IWebXRBackgroundRemoverOptions;
  72947. /**
  72948. * The module's name
  72949. */
  72950. static readonly Name: string;
  72951. /**
  72952. * The (Babylon) version of this module.
  72953. * This is an integer representing the implementation version.
  72954. * This number does not correspond to the WebXR specs version
  72955. */
  72956. static readonly Version: number;
  72957. /**
  72958. * registered observers will be triggered when the background state changes
  72959. */
  72960. onBackgroundStateChangedObservable: Observable<boolean>;
  72961. /**
  72962. * constructs a new background remover module
  72963. * @param _xrSessionManager the session manager for this module
  72964. * @param options read-only options to be used in this module
  72965. */
  72966. constructor(_xrSessionManager: WebXRSessionManager,
  72967. /**
  72968. * read-only options to be used in this module
  72969. */
  72970. options?: IWebXRBackgroundRemoverOptions);
  72971. /**
  72972. * attach this feature
  72973. * Will usually be called by the features manager
  72974. *
  72975. * @returns true if successful.
  72976. */
  72977. attach(): boolean;
  72978. /**
  72979. * detach this feature.
  72980. * Will usually be called by the features manager
  72981. *
  72982. * @returns true if successful.
  72983. */
  72984. detach(): boolean;
  72985. /**
  72986. * Dispose this feature and all of the resources attached
  72987. */
  72988. dispose(): void;
  72989. protected _onXRFrame(_xrFrame: XRFrame): void;
  72990. private _setBackgroundState;
  72991. }
  72992. }
  72993. declare module BABYLON {
  72994. /**
  72995. * Options for the controller physics feature
  72996. */
  72997. export class IWebXRControllerPhysicsOptions {
  72998. /**
  72999. * Should the headset get its own impostor
  73000. */
  73001. enableHeadsetImpostor?: boolean;
  73002. /**
  73003. * Optional parameters for the headset impostor
  73004. */
  73005. headsetImpostorParams?: {
  73006. /**
  73007. * The type of impostor to create. Default is sphere
  73008. */
  73009. impostorType: number;
  73010. /**
  73011. * the size of the impostor. Defaults to 10cm
  73012. */
  73013. impostorSize?: number | {
  73014. width: number;
  73015. height: number;
  73016. depth: number;
  73017. };
  73018. /**
  73019. * Friction definitions
  73020. */
  73021. friction?: number;
  73022. /**
  73023. * Restitution
  73024. */
  73025. restitution?: number;
  73026. };
  73027. /**
  73028. * The physics properties of the future impostors
  73029. */
  73030. physicsProperties?: {
  73031. /**
  73032. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73033. * Note that this requires a physics engine that supports mesh impostors!
  73034. */
  73035. useControllerMesh?: boolean;
  73036. /**
  73037. * The type of impostor to create. Default is sphere
  73038. */
  73039. impostorType?: number;
  73040. /**
  73041. * the size of the impostor. Defaults to 10cm
  73042. */
  73043. impostorSize?: number | {
  73044. width: number;
  73045. height: number;
  73046. depth: number;
  73047. };
  73048. /**
  73049. * Friction definitions
  73050. */
  73051. friction?: number;
  73052. /**
  73053. * Restitution
  73054. */
  73055. restitution?: number;
  73056. };
  73057. /**
  73058. * the xr input to use with this pointer selection
  73059. */
  73060. xrInput: WebXRInput;
  73061. }
  73062. /**
  73063. * Add physics impostor to your webxr controllers,
  73064. * including naive calculation of their linear and angular velocity
  73065. */
  73066. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73067. private readonly _options;
  73068. private _attachController;
  73069. private _controllers;
  73070. private _debugMode;
  73071. private _delta;
  73072. private _headsetImpostor?;
  73073. private _headsetMesh?;
  73074. private _lastTimestamp;
  73075. private _tmpQuaternion;
  73076. private _tmpVector;
  73077. /**
  73078. * The module's name
  73079. */
  73080. static readonly Name: string;
  73081. /**
  73082. * The (Babylon) version of this module.
  73083. * This is an integer representing the implementation version.
  73084. * This number does not correspond to the webxr specs version
  73085. */
  73086. static readonly Version: number;
  73087. /**
  73088. * Construct a new Controller Physics Feature
  73089. * @param _xrSessionManager the corresponding xr session manager
  73090. * @param _options options to create this feature with
  73091. */
  73092. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73093. /**
  73094. * @hidden
  73095. * enable debugging - will show console outputs and the impostor mesh
  73096. */
  73097. _enablePhysicsDebug(): void;
  73098. /**
  73099. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73100. * @param xrController the controller to add
  73101. */
  73102. addController(xrController: WebXRInputSource): void;
  73103. /**
  73104. * attach this feature
  73105. * Will usually be called by the features manager
  73106. *
  73107. * @returns true if successful.
  73108. */
  73109. attach(): boolean;
  73110. /**
  73111. * detach this feature.
  73112. * Will usually be called by the features manager
  73113. *
  73114. * @returns true if successful.
  73115. */
  73116. detach(): boolean;
  73117. /**
  73118. * Get the headset impostor, if enabled
  73119. * @returns the impostor
  73120. */
  73121. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73122. /**
  73123. * Get the physics impostor of a specific controller.
  73124. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73125. * @param controller the controller or the controller id of which to get the impostor
  73126. * @returns the impostor or null
  73127. */
  73128. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73129. /**
  73130. * Update the physics properties provided in the constructor
  73131. * @param newProperties the new properties object
  73132. */
  73133. setPhysicsProperties(newProperties: {
  73134. impostorType?: number;
  73135. impostorSize?: number | {
  73136. width: number;
  73137. height: number;
  73138. depth: number;
  73139. };
  73140. friction?: number;
  73141. restitution?: number;
  73142. }): void;
  73143. protected _onXRFrame(_xrFrame: any): void;
  73144. private _detachController;
  73145. }
  73146. }
  73147. declare module BABYLON {
  73148. /**
  73149. * The motion controller class for all microsoft mixed reality controllers
  73150. */
  73151. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73152. protected readonly _mapping: {
  73153. defaultButton: {
  73154. valueNodeName: string;
  73155. unpressedNodeName: string;
  73156. pressedNodeName: string;
  73157. };
  73158. defaultAxis: {
  73159. valueNodeName: string;
  73160. minNodeName: string;
  73161. maxNodeName: string;
  73162. };
  73163. buttons: {
  73164. "xr-standard-trigger": {
  73165. rootNodeName: string;
  73166. componentProperty: string;
  73167. states: string[];
  73168. };
  73169. "xr-standard-squeeze": {
  73170. rootNodeName: string;
  73171. componentProperty: string;
  73172. states: string[];
  73173. };
  73174. "xr-standard-touchpad": {
  73175. rootNodeName: string;
  73176. labelAnchorNodeName: string;
  73177. touchPointNodeName: string;
  73178. };
  73179. "xr-standard-thumbstick": {
  73180. rootNodeName: string;
  73181. componentProperty: string;
  73182. states: string[];
  73183. };
  73184. };
  73185. axes: {
  73186. "xr-standard-touchpad": {
  73187. "x-axis": {
  73188. rootNodeName: string;
  73189. };
  73190. "y-axis": {
  73191. rootNodeName: string;
  73192. };
  73193. };
  73194. "xr-standard-thumbstick": {
  73195. "x-axis": {
  73196. rootNodeName: string;
  73197. };
  73198. "y-axis": {
  73199. rootNodeName: string;
  73200. };
  73201. };
  73202. };
  73203. };
  73204. /**
  73205. * The base url used to load the left and right controller models
  73206. */
  73207. static MODEL_BASE_URL: string;
  73208. /**
  73209. * The name of the left controller model file
  73210. */
  73211. static MODEL_LEFT_FILENAME: string;
  73212. /**
  73213. * The name of the right controller model file
  73214. */
  73215. static MODEL_RIGHT_FILENAME: string;
  73216. profileId: string;
  73217. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73218. protected _getFilenameAndPath(): {
  73219. filename: string;
  73220. path: string;
  73221. };
  73222. protected _getModelLoadingConstraints(): boolean;
  73223. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73224. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73225. protected _updateModel(): void;
  73226. }
  73227. }
  73228. declare module BABYLON {
  73229. /**
  73230. * The motion controller class for oculus touch (quest, rift).
  73231. * This class supports legacy mapping as well the standard xr mapping
  73232. */
  73233. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73234. private _forceLegacyControllers;
  73235. private _modelRootNode;
  73236. /**
  73237. * The base url used to load the left and right controller models
  73238. */
  73239. static MODEL_BASE_URL: string;
  73240. /**
  73241. * The name of the left controller model file
  73242. */
  73243. static MODEL_LEFT_FILENAME: string;
  73244. /**
  73245. * The name of the right controller model file
  73246. */
  73247. static MODEL_RIGHT_FILENAME: string;
  73248. /**
  73249. * Base Url for the Quest controller model.
  73250. */
  73251. static QUEST_MODEL_BASE_URL: string;
  73252. profileId: string;
  73253. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73254. protected _getFilenameAndPath(): {
  73255. filename: string;
  73256. path: string;
  73257. };
  73258. protected _getModelLoadingConstraints(): boolean;
  73259. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73260. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73261. protected _updateModel(): void;
  73262. /**
  73263. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73264. * between the touch and touch 2.
  73265. */
  73266. private _isQuest;
  73267. }
  73268. }
  73269. declare module BABYLON {
  73270. /**
  73271. * The motion controller class for the standard HTC-Vive controllers
  73272. */
  73273. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73274. private _modelRootNode;
  73275. /**
  73276. * The base url used to load the left and right controller models
  73277. */
  73278. static MODEL_BASE_URL: string;
  73279. /**
  73280. * File name for the controller model.
  73281. */
  73282. static MODEL_FILENAME: string;
  73283. profileId: string;
  73284. /**
  73285. * Create a new Vive motion controller object
  73286. * @param scene the scene to use to create this controller
  73287. * @param gamepadObject the corresponding gamepad object
  73288. * @param handedness the handedness of the controller
  73289. */
  73290. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73291. protected _getFilenameAndPath(): {
  73292. filename: string;
  73293. path: string;
  73294. };
  73295. protected _getModelLoadingConstraints(): boolean;
  73296. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73297. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73298. protected _updateModel(): void;
  73299. }
  73300. }
  73301. declare module BABYLON {
  73302. /**
  73303. * A cursor which tracks a point on a path
  73304. */
  73305. export class PathCursor {
  73306. private path;
  73307. /**
  73308. * Stores path cursor callbacks for when an onchange event is triggered
  73309. */
  73310. private _onchange;
  73311. /**
  73312. * The value of the path cursor
  73313. */
  73314. value: number;
  73315. /**
  73316. * The animation array of the path cursor
  73317. */
  73318. animations: Animation[];
  73319. /**
  73320. * Initializes the path cursor
  73321. * @param path The path to track
  73322. */
  73323. constructor(path: Path2);
  73324. /**
  73325. * Gets the cursor point on the path
  73326. * @returns A point on the path cursor at the cursor location
  73327. */
  73328. getPoint(): Vector3;
  73329. /**
  73330. * Moves the cursor ahead by the step amount
  73331. * @param step The amount to move the cursor forward
  73332. * @returns This path cursor
  73333. */
  73334. moveAhead(step?: number): PathCursor;
  73335. /**
  73336. * Moves the cursor behind by the step amount
  73337. * @param step The amount to move the cursor back
  73338. * @returns This path cursor
  73339. */
  73340. moveBack(step?: number): PathCursor;
  73341. /**
  73342. * Moves the cursor by the step amount
  73343. * If the step amount is greater than one, an exception is thrown
  73344. * @param step The amount to move the cursor
  73345. * @returns This path cursor
  73346. */
  73347. move(step: number): PathCursor;
  73348. /**
  73349. * Ensures that the value is limited between zero and one
  73350. * @returns This path cursor
  73351. */
  73352. private ensureLimits;
  73353. /**
  73354. * Runs onchange callbacks on change (used by the animation engine)
  73355. * @returns This path cursor
  73356. */
  73357. private raiseOnChange;
  73358. /**
  73359. * Executes a function on change
  73360. * @param f A path cursor onchange callback
  73361. * @returns This path cursor
  73362. */
  73363. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73364. }
  73365. }
  73366. declare module BABYLON {
  73367. /** @hidden */
  73368. export var blurPixelShader: {
  73369. name: string;
  73370. shader: string;
  73371. };
  73372. }
  73373. declare module BABYLON {
  73374. /** @hidden */
  73375. export var pointCloudVertexDeclaration: {
  73376. name: string;
  73377. shader: string;
  73378. };
  73379. }
  73380. // Mixins
  73381. interface Window {
  73382. mozIndexedDB: IDBFactory;
  73383. webkitIndexedDB: IDBFactory;
  73384. msIndexedDB: IDBFactory;
  73385. webkitURL: typeof URL;
  73386. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73387. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73388. WebGLRenderingContext: WebGLRenderingContext;
  73389. MSGesture: MSGesture;
  73390. CANNON: any;
  73391. AudioContext: AudioContext;
  73392. webkitAudioContext: AudioContext;
  73393. PointerEvent: any;
  73394. Math: Math;
  73395. Uint8Array: Uint8ArrayConstructor;
  73396. Float32Array: Float32ArrayConstructor;
  73397. mozURL: typeof URL;
  73398. msURL: typeof URL;
  73399. VRFrameData: any; // WebVR, from specs 1.1
  73400. DracoDecoderModule: any;
  73401. setImmediate(handler: (...args: any[]) => void): number;
  73402. }
  73403. interface HTMLCanvasElement {
  73404. requestPointerLock(): void;
  73405. msRequestPointerLock?(): void;
  73406. mozRequestPointerLock?(): void;
  73407. webkitRequestPointerLock?(): void;
  73408. /** Track wether a record is in progress */
  73409. isRecording: boolean;
  73410. /** Capture Stream method defined by some browsers */
  73411. captureStream(fps?: number): MediaStream;
  73412. }
  73413. interface CanvasRenderingContext2D {
  73414. msImageSmoothingEnabled: boolean;
  73415. }
  73416. interface MouseEvent {
  73417. mozMovementX: number;
  73418. mozMovementY: number;
  73419. webkitMovementX: number;
  73420. webkitMovementY: number;
  73421. msMovementX: number;
  73422. msMovementY: number;
  73423. }
  73424. interface Navigator {
  73425. mozGetVRDevices: (any: any) => any;
  73426. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73427. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73428. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73429. webkitGetGamepads(): Gamepad[];
  73430. msGetGamepads(): Gamepad[];
  73431. webkitGamepads(): Gamepad[];
  73432. }
  73433. interface HTMLVideoElement {
  73434. mozSrcObject: any;
  73435. }
  73436. interface Math {
  73437. fround(x: number): number;
  73438. imul(a: number, b: number): number;
  73439. }
  73440. interface WebGLRenderingContext {
  73441. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73442. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73443. vertexAttribDivisor(index: number, divisor: number): void;
  73444. createVertexArray(): any;
  73445. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73446. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73447. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73448. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73449. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73450. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73451. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73452. // Queries
  73453. createQuery(): WebGLQuery;
  73454. deleteQuery(query: WebGLQuery): void;
  73455. beginQuery(target: number, query: WebGLQuery): void;
  73456. endQuery(target: number): void;
  73457. getQueryParameter(query: WebGLQuery, pname: number): any;
  73458. getQuery(target: number, pname: number): any;
  73459. MAX_SAMPLES: number;
  73460. RGBA8: number;
  73461. READ_FRAMEBUFFER: number;
  73462. DRAW_FRAMEBUFFER: number;
  73463. UNIFORM_BUFFER: number;
  73464. HALF_FLOAT_OES: number;
  73465. RGBA16F: number;
  73466. RGBA32F: number;
  73467. R32F: number;
  73468. RG32F: number;
  73469. RGB32F: number;
  73470. R16F: number;
  73471. RG16F: number;
  73472. RGB16F: number;
  73473. RED: number;
  73474. RG: number;
  73475. R8: number;
  73476. RG8: number;
  73477. UNSIGNED_INT_24_8: number;
  73478. DEPTH24_STENCIL8: number;
  73479. MIN: number;
  73480. MAX: number;
  73481. /* Multiple Render Targets */
  73482. drawBuffers(buffers: number[]): void;
  73483. readBuffer(src: number): void;
  73484. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73485. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73486. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73487. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73488. // Occlusion Query
  73489. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73490. ANY_SAMPLES_PASSED: number;
  73491. QUERY_RESULT_AVAILABLE: number;
  73492. QUERY_RESULT: number;
  73493. }
  73494. interface WebGLProgram {
  73495. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73496. }
  73497. interface EXT_disjoint_timer_query {
  73498. QUERY_COUNTER_BITS_EXT: number;
  73499. TIME_ELAPSED_EXT: number;
  73500. TIMESTAMP_EXT: number;
  73501. GPU_DISJOINT_EXT: number;
  73502. QUERY_RESULT_EXT: number;
  73503. QUERY_RESULT_AVAILABLE_EXT: number;
  73504. queryCounterEXT(query: WebGLQuery, target: number): void;
  73505. createQueryEXT(): WebGLQuery;
  73506. beginQueryEXT(target: number, query: WebGLQuery): void;
  73507. endQueryEXT(target: number): void;
  73508. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73509. deleteQueryEXT(query: WebGLQuery): void;
  73510. }
  73511. interface WebGLUniformLocation {
  73512. _currentState: any;
  73513. }
  73514. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73515. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73516. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73517. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73518. interface WebGLRenderingContext {
  73519. readonly RASTERIZER_DISCARD: number;
  73520. readonly DEPTH_COMPONENT24: number;
  73521. readonly TEXTURE_3D: number;
  73522. readonly TEXTURE_2D_ARRAY: number;
  73523. readonly TEXTURE_COMPARE_FUNC: number;
  73524. readonly TEXTURE_COMPARE_MODE: number;
  73525. readonly COMPARE_REF_TO_TEXTURE: number;
  73526. readonly TEXTURE_WRAP_R: number;
  73527. readonly HALF_FLOAT: number;
  73528. readonly RGB8: number;
  73529. readonly RED_INTEGER: number;
  73530. readonly RG_INTEGER: number;
  73531. readonly RGB_INTEGER: number;
  73532. readonly RGBA_INTEGER: number;
  73533. readonly R8_SNORM: number;
  73534. readonly RG8_SNORM: number;
  73535. readonly RGB8_SNORM: number;
  73536. readonly RGBA8_SNORM: number;
  73537. readonly R8I: number;
  73538. readonly RG8I: number;
  73539. readonly RGB8I: number;
  73540. readonly RGBA8I: number;
  73541. readonly R8UI: number;
  73542. readonly RG8UI: number;
  73543. readonly RGB8UI: number;
  73544. readonly RGBA8UI: number;
  73545. readonly R16I: number;
  73546. readonly RG16I: number;
  73547. readonly RGB16I: number;
  73548. readonly RGBA16I: number;
  73549. readonly R16UI: number;
  73550. readonly RG16UI: number;
  73551. readonly RGB16UI: number;
  73552. readonly RGBA16UI: number;
  73553. readonly R32I: number;
  73554. readonly RG32I: number;
  73555. readonly RGB32I: number;
  73556. readonly RGBA32I: number;
  73557. readonly R32UI: number;
  73558. readonly RG32UI: number;
  73559. readonly RGB32UI: number;
  73560. readonly RGBA32UI: number;
  73561. readonly RGB10_A2UI: number;
  73562. readonly R11F_G11F_B10F: number;
  73563. readonly RGB9_E5: number;
  73564. readonly RGB10_A2: number;
  73565. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73566. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73567. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73568. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73569. readonly DEPTH_COMPONENT32F: number;
  73570. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73571. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73572. 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;
  73573. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73574. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73575. readonly TRANSFORM_FEEDBACK: number;
  73576. readonly INTERLEAVED_ATTRIBS: number;
  73577. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73578. createTransformFeedback(): WebGLTransformFeedback;
  73579. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73580. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73581. beginTransformFeedback(primitiveMode: number): void;
  73582. endTransformFeedback(): void;
  73583. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73584. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73585. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73586. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73587. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73588. }
  73589. interface ImageBitmap {
  73590. readonly width: number;
  73591. readonly height: number;
  73592. close(): void;
  73593. }
  73594. interface WebGLQuery extends WebGLObject {
  73595. }
  73596. declare var WebGLQuery: {
  73597. prototype: WebGLQuery;
  73598. new(): WebGLQuery;
  73599. };
  73600. interface WebGLSampler extends WebGLObject {
  73601. }
  73602. declare var WebGLSampler: {
  73603. prototype: WebGLSampler;
  73604. new(): WebGLSampler;
  73605. };
  73606. interface WebGLSync extends WebGLObject {
  73607. }
  73608. declare var WebGLSync: {
  73609. prototype: WebGLSync;
  73610. new(): WebGLSync;
  73611. };
  73612. interface WebGLTransformFeedback extends WebGLObject {
  73613. }
  73614. declare var WebGLTransformFeedback: {
  73615. prototype: WebGLTransformFeedback;
  73616. new(): WebGLTransformFeedback;
  73617. };
  73618. interface WebGLVertexArrayObject extends WebGLObject {
  73619. }
  73620. declare var WebGLVertexArrayObject: {
  73621. prototype: WebGLVertexArrayObject;
  73622. new(): WebGLVertexArrayObject;
  73623. };
  73624. // Type definitions for WebVR API
  73625. // Project: https://w3c.github.io/webvr/
  73626. // Definitions by: six a <https://github.com/lostfictions>
  73627. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73628. interface VRDisplay extends EventTarget {
  73629. /**
  73630. * Dictionary of capabilities describing the VRDisplay.
  73631. */
  73632. readonly capabilities: VRDisplayCapabilities;
  73633. /**
  73634. * z-depth defining the far plane of the eye view frustum
  73635. * enables mapping of values in the render target depth
  73636. * attachment to scene coordinates. Initially set to 10000.0.
  73637. */
  73638. depthFar: number;
  73639. /**
  73640. * z-depth defining the near plane of the eye view frustum
  73641. * enables mapping of values in the render target depth
  73642. * attachment to scene coordinates. Initially set to 0.01.
  73643. */
  73644. depthNear: number;
  73645. /**
  73646. * An identifier for this distinct VRDisplay. Used as an
  73647. * association point in the Gamepad API.
  73648. */
  73649. readonly displayId: number;
  73650. /**
  73651. * A display name, a user-readable name identifying it.
  73652. */
  73653. readonly displayName: string;
  73654. readonly isConnected: boolean;
  73655. readonly isPresenting: boolean;
  73656. /**
  73657. * If this VRDisplay supports room-scale experiences, the optional
  73658. * stage attribute contains details on the room-scale parameters.
  73659. */
  73660. readonly stageParameters: VRStageParameters | null;
  73661. /**
  73662. * Passing the value returned by `requestAnimationFrame` to
  73663. * `cancelAnimationFrame` will unregister the callback.
  73664. * @param handle Define the hanle of the request to cancel
  73665. */
  73666. cancelAnimationFrame(handle: number): void;
  73667. /**
  73668. * Stops presenting to the VRDisplay.
  73669. * @returns a promise to know when it stopped
  73670. */
  73671. exitPresent(): Promise<void>;
  73672. /**
  73673. * Return the current VREyeParameters for the given eye.
  73674. * @param whichEye Define the eye we want the parameter for
  73675. * @returns the eye parameters
  73676. */
  73677. getEyeParameters(whichEye: string): VREyeParameters;
  73678. /**
  73679. * Populates the passed VRFrameData with the information required to render
  73680. * the current frame.
  73681. * @param frameData Define the data structure to populate
  73682. * @returns true if ok otherwise false
  73683. */
  73684. getFrameData(frameData: VRFrameData): boolean;
  73685. /**
  73686. * Get the layers currently being presented.
  73687. * @returns the list of VR layers
  73688. */
  73689. getLayers(): VRLayer[];
  73690. /**
  73691. * Return a VRPose containing the future predicted pose of the VRDisplay
  73692. * when the current frame will be presented. The value returned will not
  73693. * change until JavaScript has returned control to the browser.
  73694. *
  73695. * The VRPose will contain the position, orientation, velocity,
  73696. * and acceleration of each of these properties.
  73697. * @returns the pose object
  73698. */
  73699. getPose(): VRPose;
  73700. /**
  73701. * Return the current instantaneous pose of the VRDisplay, with no
  73702. * prediction applied.
  73703. * @returns the current instantaneous pose
  73704. */
  73705. getImmediatePose(): VRPose;
  73706. /**
  73707. * The callback passed to `requestAnimationFrame` will be called
  73708. * any time a new frame should be rendered. When the VRDisplay is
  73709. * presenting the callback will be called at the native refresh
  73710. * rate of the HMD. When not presenting this function acts
  73711. * identically to how window.requestAnimationFrame acts. Content should
  73712. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73713. * asynchronously from other displays and at differing refresh rates.
  73714. * @param callback Define the eaction to run next frame
  73715. * @returns the request handle it
  73716. */
  73717. requestAnimationFrame(callback: FrameRequestCallback): number;
  73718. /**
  73719. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73720. * Repeat calls while already presenting will update the VRLayers being displayed.
  73721. * @param layers Define the list of layer to present
  73722. * @returns a promise to know when the request has been fulfilled
  73723. */
  73724. requestPresent(layers: VRLayer[]): Promise<void>;
  73725. /**
  73726. * Reset the pose for this display, treating its current position and
  73727. * orientation as the "origin/zero" values. VRPose.position,
  73728. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73729. * updated when calling resetPose(). This should be called in only
  73730. * sitting-space experiences.
  73731. */
  73732. resetPose(): void;
  73733. /**
  73734. * The VRLayer provided to the VRDisplay will be captured and presented
  73735. * in the HMD. Calling this function has the same effect on the source
  73736. * canvas as any other operation that uses its source image, and canvases
  73737. * created without preserveDrawingBuffer set to true will be cleared.
  73738. * @param pose Define the pose to submit
  73739. */
  73740. submitFrame(pose?: VRPose): void;
  73741. }
  73742. declare var VRDisplay: {
  73743. prototype: VRDisplay;
  73744. new(): VRDisplay;
  73745. };
  73746. interface VRLayer {
  73747. leftBounds?: number[] | Float32Array | null;
  73748. rightBounds?: number[] | Float32Array | null;
  73749. source?: HTMLCanvasElement | null;
  73750. }
  73751. interface VRDisplayCapabilities {
  73752. readonly canPresent: boolean;
  73753. readonly hasExternalDisplay: boolean;
  73754. readonly hasOrientation: boolean;
  73755. readonly hasPosition: boolean;
  73756. readonly maxLayers: number;
  73757. }
  73758. interface VREyeParameters {
  73759. /** @deprecated */
  73760. readonly fieldOfView: VRFieldOfView;
  73761. readonly offset: Float32Array;
  73762. readonly renderHeight: number;
  73763. readonly renderWidth: number;
  73764. }
  73765. interface VRFieldOfView {
  73766. readonly downDegrees: number;
  73767. readonly leftDegrees: number;
  73768. readonly rightDegrees: number;
  73769. readonly upDegrees: number;
  73770. }
  73771. interface VRFrameData {
  73772. readonly leftProjectionMatrix: Float32Array;
  73773. readonly leftViewMatrix: Float32Array;
  73774. readonly pose: VRPose;
  73775. readonly rightProjectionMatrix: Float32Array;
  73776. readonly rightViewMatrix: Float32Array;
  73777. readonly timestamp: number;
  73778. }
  73779. interface VRPose {
  73780. readonly angularAcceleration: Float32Array | null;
  73781. readonly angularVelocity: Float32Array | null;
  73782. readonly linearAcceleration: Float32Array | null;
  73783. readonly linearVelocity: Float32Array | null;
  73784. readonly orientation: Float32Array | null;
  73785. readonly position: Float32Array | null;
  73786. readonly timestamp: number;
  73787. }
  73788. interface VRStageParameters {
  73789. sittingToStandingTransform?: Float32Array;
  73790. sizeX?: number;
  73791. sizeY?: number;
  73792. }
  73793. interface Navigator {
  73794. getVRDisplays(): Promise<VRDisplay[]>;
  73795. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73796. }
  73797. interface Window {
  73798. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73799. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73800. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73801. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73802. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73803. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73804. }
  73805. interface Gamepad {
  73806. readonly displayId: number;
  73807. }
  73808. type XRSessionMode =
  73809. | "inline"
  73810. | "immersive-vr"
  73811. | "immersive-ar";
  73812. type XRReferenceSpaceType =
  73813. | "viewer"
  73814. | "local"
  73815. | "local-floor"
  73816. | "bounded-floor"
  73817. | "unbounded";
  73818. type XREnvironmentBlendMode =
  73819. | "opaque"
  73820. | "additive"
  73821. | "alpha-blend";
  73822. type XRVisibilityState =
  73823. | "visible"
  73824. | "visible-blurred"
  73825. | "hidden";
  73826. type XRHandedness =
  73827. | "none"
  73828. | "left"
  73829. | "right";
  73830. type XRTargetRayMode =
  73831. | "gaze"
  73832. | "tracked-pointer"
  73833. | "screen";
  73834. type XREye =
  73835. | "none"
  73836. | "left"
  73837. | "right";
  73838. type XREventType =
  73839. | "devicechange"
  73840. | "visibilitychange"
  73841. | "end"
  73842. | "inputsourceschange"
  73843. | "select"
  73844. | "selectstart"
  73845. | "selectend"
  73846. | "squeeze"
  73847. | "squeezestart"
  73848. | "squeezeend"
  73849. | "reset";
  73850. interface XRSpace extends EventTarget {
  73851. }
  73852. interface XRRenderState {
  73853. depthNear?: number;
  73854. depthFar?: number;
  73855. inlineVerticalFieldOfView?: number;
  73856. baseLayer?: XRWebGLLayer;
  73857. }
  73858. interface XRInputSource {
  73859. handedness: XRHandedness;
  73860. targetRayMode: XRTargetRayMode;
  73861. targetRaySpace: XRSpace;
  73862. gripSpace: XRSpace | undefined;
  73863. gamepad: Gamepad | undefined;
  73864. profiles: Array<string>;
  73865. }
  73866. interface XRSessionInit {
  73867. optionalFeatures?: string[];
  73868. requiredFeatures?: string[];
  73869. }
  73870. interface XRSession {
  73871. addEventListener: Function;
  73872. removeEventListener: Function;
  73873. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73874. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73875. requestAnimationFrame: Function;
  73876. end(): Promise<void>;
  73877. renderState: XRRenderState;
  73878. inputSources: Array<XRInputSource>;
  73879. // hit test
  73880. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73881. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73882. // legacy AR hit test
  73883. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73884. // legacy plane detection
  73885. updateWorldTrackingState(options: {
  73886. planeDetectionState?: { enabled: boolean; }
  73887. }): void;
  73888. }
  73889. interface XRReferenceSpace extends XRSpace {
  73890. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73891. onreset: any;
  73892. }
  73893. type XRPlaneSet = Set<XRPlane>;
  73894. type XRAnchorSet = Set<XRAnchor>;
  73895. interface XRFrame {
  73896. session: XRSession;
  73897. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73898. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73899. // AR
  73900. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73901. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73902. // Anchors
  73903. trackedAnchors?: XRAnchorSet;
  73904. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  73905. // Planes
  73906. worldInformation: {
  73907. detectedPlanes?: XRPlaneSet;
  73908. };
  73909. }
  73910. interface XRViewerPose extends XRPose {
  73911. views: Array<XRView>;
  73912. }
  73913. interface XRPose {
  73914. transform: XRRigidTransform;
  73915. emulatedPosition: boolean;
  73916. }
  73917. interface XRWebGLLayerOptions {
  73918. antialias?: boolean;
  73919. depth?: boolean;
  73920. stencil?: boolean;
  73921. alpha?: boolean;
  73922. multiview?: boolean;
  73923. framebufferScaleFactor?: number;
  73924. }
  73925. declare var XRWebGLLayer: {
  73926. prototype: XRWebGLLayer;
  73927. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73928. };
  73929. interface XRWebGLLayer {
  73930. framebuffer: WebGLFramebuffer;
  73931. framebufferWidth: number;
  73932. framebufferHeight: number;
  73933. getViewport: Function;
  73934. }
  73935. declare class XRRigidTransform {
  73936. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73937. position: DOMPointReadOnly;
  73938. orientation: DOMPointReadOnly;
  73939. matrix: Float32Array;
  73940. inverse: XRRigidTransform;
  73941. }
  73942. interface XRView {
  73943. eye: XREye;
  73944. projectionMatrix: Float32Array;
  73945. transform: XRRigidTransform;
  73946. }
  73947. interface XRInputSourceChangeEvent {
  73948. session: XRSession;
  73949. removed: Array<XRInputSource>;
  73950. added: Array<XRInputSource>;
  73951. }
  73952. interface XRInputSourceEvent extends Event {
  73953. readonly frame: XRFrame;
  73954. readonly inputSource: XRInputSource;
  73955. }
  73956. // Experimental(er) features
  73957. declare class XRRay {
  73958. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73959. origin: DOMPointReadOnly;
  73960. direction: DOMPointReadOnly;
  73961. matrix: Float32Array;
  73962. }
  73963. declare enum XRHitTestTrackableType {
  73964. "point",
  73965. "plane"
  73966. }
  73967. interface XRHitResult {
  73968. hitMatrix: Float32Array;
  73969. }
  73970. interface XRTransientInputHitTestResult {
  73971. readonly inputSource: XRInputSource;
  73972. readonly results: Array<XRHitTestResult>;
  73973. }
  73974. interface XRHitTestResult {
  73975. getPose(baseSpace: XRSpace): XRPose | undefined;
  73976. // When anchor system is enabled
  73977. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  73978. }
  73979. interface XRHitTestSource {
  73980. cancel(): void;
  73981. }
  73982. interface XRTransientInputHitTestSource {
  73983. cancel(): void;
  73984. }
  73985. interface XRHitTestOptionsInit {
  73986. space: XRSpace;
  73987. entityTypes?: Array<XRHitTestTrackableType>;
  73988. offsetRay?: XRRay;
  73989. }
  73990. interface XRTransientInputHitTestOptionsInit {
  73991. profile: string;
  73992. entityTypes?: Array<XRHitTestTrackableType>;
  73993. offsetRay?: XRRay;
  73994. }
  73995. interface XRAnchor {
  73996. anchorSpace: XRSpace;
  73997. delete(): void;
  73998. }
  73999. interface XRPlane {
  74000. orientation: "Horizontal" | "Vertical";
  74001. planeSpace: XRSpace;
  74002. polygon: Array<DOMPointReadOnly>;
  74003. lastChangedTime: number;
  74004. }
  74005. /**
  74006. * @ignore
  74007. */
  74008. declare module BABYLON.GLTF2.Exporter {
  74009. }
  74010. /**
  74011. * @ignore
  74012. */
  74013. declare module BABYLON.GLTF1 {
  74014. }
  74015. declare module BABYLON.GUI {
  74016. /**
  74017. * Class used to specific a value and its associated unit
  74018. */
  74019. export class ValueAndUnit {
  74020. /** defines the unit to store */
  74021. unit: number;
  74022. /** defines a boolean indicating if the value can be negative */
  74023. negativeValueAllowed: boolean;
  74024. private _value;
  74025. private _originalUnit;
  74026. /**
  74027. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74028. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74029. */
  74030. ignoreAdaptiveScaling: boolean;
  74031. /**
  74032. * Creates a new ValueAndUnit
  74033. * @param value defines the value to store
  74034. * @param unit defines the unit to store
  74035. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74036. */
  74037. constructor(value: number,
  74038. /** defines the unit to store */
  74039. unit?: number,
  74040. /** defines a boolean indicating if the value can be negative */
  74041. negativeValueAllowed?: boolean);
  74042. /** Gets a boolean indicating if the value is a percentage */
  74043. get isPercentage(): boolean;
  74044. /** Gets a boolean indicating if the value is store as pixel */
  74045. get isPixel(): boolean;
  74046. /** Gets direct internal value */
  74047. get internalValue(): number;
  74048. /**
  74049. * Gets value as pixel
  74050. * @param host defines the root host
  74051. * @param refValue defines the reference value for percentages
  74052. * @returns the value as pixel
  74053. */
  74054. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74055. /**
  74056. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74057. * @param value defines the value to store
  74058. * @param unit defines the unit to store
  74059. * @returns the current ValueAndUnit
  74060. */
  74061. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74062. /**
  74063. * Gets the value accordingly to its unit
  74064. * @param host defines the root host
  74065. * @returns the value
  74066. */
  74067. getValue(host: AdvancedDynamicTexture): number;
  74068. /**
  74069. * Gets a string representation of the value
  74070. * @param host defines the root host
  74071. * @param decimals defines an optional number of decimals to display
  74072. * @returns a string
  74073. */
  74074. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74075. /**
  74076. * Store a value parsed from a string
  74077. * @param source defines the source string
  74078. * @returns true if the value was successfully parsed
  74079. */
  74080. fromString(source: string | number): boolean;
  74081. private static _Regex;
  74082. private static _UNITMODE_PERCENTAGE;
  74083. private static _UNITMODE_PIXEL;
  74084. /** UNITMODE_PERCENTAGE */
  74085. static get UNITMODE_PERCENTAGE(): number;
  74086. /** UNITMODE_PIXEL */
  74087. static get UNITMODE_PIXEL(): number;
  74088. }
  74089. }
  74090. declare module BABYLON.GUI {
  74091. /**
  74092. * Define a style used by control to automatically setup properties based on a template.
  74093. * Only support font related properties so far
  74094. */
  74095. export class Style implements BABYLON.IDisposable {
  74096. private _fontFamily;
  74097. private _fontStyle;
  74098. private _fontWeight;
  74099. /** @hidden */
  74100. _host: AdvancedDynamicTexture;
  74101. /** @hidden */
  74102. _fontSize: ValueAndUnit;
  74103. /**
  74104. * BABYLON.Observable raised when the style values are changed
  74105. */
  74106. onChangedObservable: BABYLON.Observable<Style>;
  74107. /**
  74108. * Creates a new style object
  74109. * @param host defines the AdvancedDynamicTexture which hosts this style
  74110. */
  74111. constructor(host: AdvancedDynamicTexture);
  74112. /**
  74113. * Gets or sets the font size
  74114. */
  74115. get fontSize(): string | number;
  74116. set fontSize(value: string | number);
  74117. /**
  74118. * Gets or sets the font family
  74119. */
  74120. get fontFamily(): string;
  74121. set fontFamily(value: string);
  74122. /**
  74123. * Gets or sets the font style
  74124. */
  74125. get fontStyle(): string;
  74126. set fontStyle(value: string);
  74127. /** Gets or sets font weight */
  74128. get fontWeight(): string;
  74129. set fontWeight(value: string);
  74130. /** Dispose all associated resources */
  74131. dispose(): void;
  74132. }
  74133. }
  74134. declare module BABYLON.GUI {
  74135. /**
  74136. * Class used to transport BABYLON.Vector2 information for pointer events
  74137. */
  74138. export class Vector2WithInfo extends BABYLON.Vector2 {
  74139. /** defines the current mouse button index */
  74140. buttonIndex: number;
  74141. /**
  74142. * Creates a new Vector2WithInfo
  74143. * @param source defines the vector2 data to transport
  74144. * @param buttonIndex defines the current mouse button index
  74145. */
  74146. constructor(source: BABYLON.Vector2,
  74147. /** defines the current mouse button index */
  74148. buttonIndex?: number);
  74149. }
  74150. /** Class used to provide 2D matrix features */
  74151. export class Matrix2D {
  74152. /** Gets the internal array of 6 floats used to store matrix data */
  74153. m: Float32Array;
  74154. /**
  74155. * Creates a new matrix
  74156. * @param m00 defines value for (0, 0)
  74157. * @param m01 defines value for (0, 1)
  74158. * @param m10 defines value for (1, 0)
  74159. * @param m11 defines value for (1, 1)
  74160. * @param m20 defines value for (2, 0)
  74161. * @param m21 defines value for (2, 1)
  74162. */
  74163. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74164. /**
  74165. * Fills the matrix from direct values
  74166. * @param m00 defines value for (0, 0)
  74167. * @param m01 defines value for (0, 1)
  74168. * @param m10 defines value for (1, 0)
  74169. * @param m11 defines value for (1, 1)
  74170. * @param m20 defines value for (2, 0)
  74171. * @param m21 defines value for (2, 1)
  74172. * @returns the current modified matrix
  74173. */
  74174. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74175. /**
  74176. * Gets matrix determinant
  74177. * @returns the determinant
  74178. */
  74179. determinant(): number;
  74180. /**
  74181. * Inverses the matrix and stores it in a target matrix
  74182. * @param result defines the target matrix
  74183. * @returns the current matrix
  74184. */
  74185. invertToRef(result: Matrix2D): Matrix2D;
  74186. /**
  74187. * Multiplies the current matrix with another one
  74188. * @param other defines the second operand
  74189. * @param result defines the target matrix
  74190. * @returns the current matrix
  74191. */
  74192. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74193. /**
  74194. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74195. * @param x defines the x coordinate to transform
  74196. * @param y defines the x coordinate to transform
  74197. * @param result defines the target vector2
  74198. * @returns the current matrix
  74199. */
  74200. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74201. /**
  74202. * Creates an identity matrix
  74203. * @returns a new matrix
  74204. */
  74205. static Identity(): Matrix2D;
  74206. /**
  74207. * Creates a translation matrix and stores it in a target matrix
  74208. * @param x defines the x coordinate of the translation
  74209. * @param y defines the y coordinate of the translation
  74210. * @param result defines the target matrix
  74211. */
  74212. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74213. /**
  74214. * Creates a scaling matrix and stores it in a target matrix
  74215. * @param x defines the x coordinate of the scaling
  74216. * @param y defines the y coordinate of the scaling
  74217. * @param result defines the target matrix
  74218. */
  74219. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74220. /**
  74221. * Creates a rotation matrix and stores it in a target matrix
  74222. * @param angle defines the rotation angle
  74223. * @param result defines the target matrix
  74224. */
  74225. static RotationToRef(angle: number, result: Matrix2D): void;
  74226. private static _TempPreTranslationMatrix;
  74227. private static _TempPostTranslationMatrix;
  74228. private static _TempRotationMatrix;
  74229. private static _TempScalingMatrix;
  74230. private static _TempCompose0;
  74231. private static _TempCompose1;
  74232. private static _TempCompose2;
  74233. /**
  74234. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74235. * @param tx defines the x coordinate of the translation
  74236. * @param ty defines the y coordinate of the translation
  74237. * @param angle defines the rotation angle
  74238. * @param scaleX defines the x coordinate of the scaling
  74239. * @param scaleY defines the y coordinate of the scaling
  74240. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74241. * @param result defines the target matrix
  74242. */
  74243. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74244. }
  74245. }
  74246. declare module BABYLON.GUI {
  74247. /**
  74248. * Class used to store 2D control sizes
  74249. */
  74250. export class Measure {
  74251. /** defines left coordinate */
  74252. left: number;
  74253. /** defines top coordinate */
  74254. top: number;
  74255. /** defines width dimension */
  74256. width: number;
  74257. /** defines height dimension */
  74258. height: number;
  74259. /**
  74260. * Creates a new measure
  74261. * @param left defines left coordinate
  74262. * @param top defines top coordinate
  74263. * @param width defines width dimension
  74264. * @param height defines height dimension
  74265. */
  74266. constructor(
  74267. /** defines left coordinate */
  74268. left: number,
  74269. /** defines top coordinate */
  74270. top: number,
  74271. /** defines width dimension */
  74272. width: number,
  74273. /** defines height dimension */
  74274. height: number);
  74275. /**
  74276. * Copy from another measure
  74277. * @param other defines the other measure to copy from
  74278. */
  74279. copyFrom(other: Measure): void;
  74280. /**
  74281. * Copy from a group of 4 floats
  74282. * @param left defines left coordinate
  74283. * @param top defines top coordinate
  74284. * @param width defines width dimension
  74285. * @param height defines height dimension
  74286. */
  74287. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74288. /**
  74289. * Computes the axis aligned bounding box measure for two given measures
  74290. * @param a Input measure
  74291. * @param b Input measure
  74292. * @param result the resulting bounding measure
  74293. */
  74294. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74295. /**
  74296. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74297. * @param transform the matrix to transform the measure before computing the AABB
  74298. * @param result the resulting AABB
  74299. */
  74300. transformToRef(transform: Matrix2D, result: Measure): void;
  74301. /**
  74302. * Check equality between this measure and another one
  74303. * @param other defines the other measures
  74304. * @returns true if both measures are equals
  74305. */
  74306. isEqualsTo(other: Measure): boolean;
  74307. /**
  74308. * Creates an empty measure
  74309. * @returns a new measure
  74310. */
  74311. static Empty(): Measure;
  74312. }
  74313. }
  74314. declare module BABYLON.GUI {
  74315. /**
  74316. * Interface used to define a control that can receive focus
  74317. */
  74318. export interface IFocusableControl {
  74319. /**
  74320. * Function called when the control receives the focus
  74321. */
  74322. onFocus(): void;
  74323. /**
  74324. * Function called when the control loses the focus
  74325. */
  74326. onBlur(): void;
  74327. /**
  74328. * Function called to let the control handle keyboard events
  74329. * @param evt defines the current keyboard event
  74330. */
  74331. processKeyboard(evt: KeyboardEvent): void;
  74332. /**
  74333. * Function called to get the list of controls that should not steal the focus from this control
  74334. * @returns an array of controls
  74335. */
  74336. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74337. }
  74338. /**
  74339. * Class used to create texture to support 2D GUI elements
  74340. * @see http://doc.babylonjs.com/how_to/gui
  74341. */
  74342. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74343. private _isDirty;
  74344. private _renderObserver;
  74345. private _resizeObserver;
  74346. private _preKeyboardObserver;
  74347. private _pointerMoveObserver;
  74348. private _pointerObserver;
  74349. private _canvasPointerOutObserver;
  74350. private _background;
  74351. /** @hidden */
  74352. _rootContainer: Container;
  74353. /** @hidden */
  74354. _lastPickedControl: Control;
  74355. /** @hidden */
  74356. _lastControlOver: {
  74357. [pointerId: number]: Control;
  74358. };
  74359. /** @hidden */
  74360. _lastControlDown: {
  74361. [pointerId: number]: Control;
  74362. };
  74363. /** @hidden */
  74364. _capturingControl: {
  74365. [pointerId: number]: Control;
  74366. };
  74367. /** @hidden */
  74368. _shouldBlockPointer: boolean;
  74369. /** @hidden */
  74370. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74371. /** @hidden */
  74372. _linkedControls: Control[];
  74373. private _isFullscreen;
  74374. private _fullscreenViewport;
  74375. private _idealWidth;
  74376. private _idealHeight;
  74377. private _useSmallestIdeal;
  74378. private _renderAtIdealSize;
  74379. private _focusedControl;
  74380. private _blockNextFocusCheck;
  74381. private _renderScale;
  74382. private _rootElement;
  74383. private _cursorChanged;
  74384. private _defaultMousePointerId;
  74385. /** @hidden */
  74386. _numLayoutCalls: number;
  74387. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74388. get numLayoutCalls(): number;
  74389. /** @hidden */
  74390. _numRenderCalls: number;
  74391. /** Gets the number of render calls made the last time the ADT has been rendered */
  74392. get numRenderCalls(): number;
  74393. /**
  74394. * Define type to string to ensure compatibility across browsers
  74395. * Safari doesn't support DataTransfer constructor
  74396. */
  74397. private _clipboardData;
  74398. /**
  74399. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74400. */
  74401. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74402. /**
  74403. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74404. */
  74405. onControlPickedObservable: BABYLON.Observable<Control>;
  74406. /**
  74407. * BABYLON.Observable event triggered before layout is evaluated
  74408. */
  74409. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74410. /**
  74411. * BABYLON.Observable event triggered after the layout was evaluated
  74412. */
  74413. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74414. /**
  74415. * BABYLON.Observable event triggered before the texture is rendered
  74416. */
  74417. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74418. /**
  74419. * BABYLON.Observable event triggered after the texture was rendered
  74420. */
  74421. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74422. /**
  74423. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74424. */
  74425. premulAlpha: boolean;
  74426. /**
  74427. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74428. * Useful when you want more antialiasing
  74429. */
  74430. get renderScale(): number;
  74431. set renderScale(value: number);
  74432. /** Gets or sets the background color */
  74433. get background(): string;
  74434. set background(value: string);
  74435. /**
  74436. * Gets or sets the ideal width used to design controls.
  74437. * The GUI will then rescale everything accordingly
  74438. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74439. */
  74440. get idealWidth(): number;
  74441. set idealWidth(value: number);
  74442. /**
  74443. * Gets or sets the ideal height used to design controls.
  74444. * The GUI will then rescale everything accordingly
  74445. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74446. */
  74447. get idealHeight(): number;
  74448. set idealHeight(value: number);
  74449. /**
  74450. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74451. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74452. */
  74453. get useSmallestIdeal(): boolean;
  74454. set useSmallestIdeal(value: boolean);
  74455. /**
  74456. * Gets or sets a boolean indicating if adaptive scaling must be used
  74457. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74458. */
  74459. get renderAtIdealSize(): boolean;
  74460. set renderAtIdealSize(value: boolean);
  74461. /**
  74462. * Gets the ratio used when in "ideal mode"
  74463. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74464. * */
  74465. get idealRatio(): number;
  74466. /**
  74467. * Gets the underlying layer used to render the texture when in fullscreen mode
  74468. */
  74469. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74470. /**
  74471. * Gets the root container control
  74472. */
  74473. get rootContainer(): Container;
  74474. /**
  74475. * Returns an array containing the root container.
  74476. * This is mostly used to let the Inspector introspects the ADT
  74477. * @returns an array containing the rootContainer
  74478. */
  74479. getChildren(): Array<Container>;
  74480. /**
  74481. * Will return all controls that are inside this texture
  74482. * @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
  74483. * @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
  74484. * @return all child controls
  74485. */
  74486. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74487. /**
  74488. * Gets or sets the current focused control
  74489. */
  74490. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74491. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74492. /**
  74493. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74494. */
  74495. get isForeground(): boolean;
  74496. set isForeground(value: boolean);
  74497. /**
  74498. * Gets or set information about clipboardData
  74499. */
  74500. get clipboardData(): string;
  74501. set clipboardData(value: string);
  74502. /**
  74503. * Creates a new AdvancedDynamicTexture
  74504. * @param name defines the name of the texture
  74505. * @param width defines the width of the texture
  74506. * @param height defines the height of the texture
  74507. * @param scene defines the hosting scene
  74508. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74509. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74510. */
  74511. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74512. /**
  74513. * Get the current class name of the texture useful for serialization or dynamic coding.
  74514. * @returns "AdvancedDynamicTexture"
  74515. */
  74516. getClassName(): string;
  74517. /**
  74518. * Function used to execute a function on all controls
  74519. * @param func defines the function to execute
  74520. * @param container defines the container where controls belong. If null the root container will be used
  74521. */
  74522. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74523. private _useInvalidateRectOptimization;
  74524. /**
  74525. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74526. */
  74527. get useInvalidateRectOptimization(): boolean;
  74528. set useInvalidateRectOptimization(value: boolean);
  74529. private _invalidatedRectangle;
  74530. /**
  74531. * Invalidates a rectangle area on the gui texture
  74532. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74533. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74534. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74535. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74536. */
  74537. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74538. /**
  74539. * Marks the texture as dirty forcing a complete update
  74540. */
  74541. markAsDirty(): void;
  74542. /**
  74543. * Helper function used to create a new style
  74544. * @returns a new style
  74545. * @see http://doc.babylonjs.com/how_to/gui#styles
  74546. */
  74547. createStyle(): Style;
  74548. /**
  74549. * Adds a new control to the root container
  74550. * @param control defines the control to add
  74551. * @returns the current texture
  74552. */
  74553. addControl(control: Control): AdvancedDynamicTexture;
  74554. /**
  74555. * Removes a control from the root container
  74556. * @param control defines the control to remove
  74557. * @returns the current texture
  74558. */
  74559. removeControl(control: Control): AdvancedDynamicTexture;
  74560. /**
  74561. * Release all resources
  74562. */
  74563. dispose(): void;
  74564. private _onResize;
  74565. /** @hidden */
  74566. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74567. /**
  74568. * Get screen coordinates for a vector3
  74569. * @param position defines the position to project
  74570. * @param worldMatrix defines the world matrix to use
  74571. * @returns the projected position
  74572. */
  74573. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74574. private _checkUpdate;
  74575. private _clearMeasure;
  74576. private _render;
  74577. /** @hidden */
  74578. _changeCursor(cursor: string): void;
  74579. /** @hidden */
  74580. _registerLastControlDown(control: Control, pointerId: number): void;
  74581. private _doPicking;
  74582. /** @hidden */
  74583. _cleanControlAfterRemovalFromList(list: {
  74584. [pointerId: number]: Control;
  74585. }, control: Control): void;
  74586. /** @hidden */
  74587. _cleanControlAfterRemoval(control: Control): void;
  74588. /** Attach to all scene events required to support pointer events */
  74589. attach(): void;
  74590. /** @hidden */
  74591. private onClipboardCopy;
  74592. /** @hidden */
  74593. private onClipboardCut;
  74594. /** @hidden */
  74595. private onClipboardPaste;
  74596. /**
  74597. * Register the clipboard Events onto the canvas
  74598. */
  74599. registerClipboardEvents(): void;
  74600. /**
  74601. * Unregister the clipboard Events from the canvas
  74602. */
  74603. unRegisterClipboardEvents(): void;
  74604. /**
  74605. * Connect the texture to a hosting mesh to enable interactions
  74606. * @param mesh defines the mesh to attach to
  74607. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74608. */
  74609. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74610. /**
  74611. * Move the focus to a specific control
  74612. * @param control defines the control which will receive the focus
  74613. */
  74614. moveFocusToControl(control: IFocusableControl): void;
  74615. private _manageFocus;
  74616. private _attachToOnPointerOut;
  74617. /**
  74618. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74619. * @param mesh defines the mesh which will receive the texture
  74620. * @param width defines the texture width (1024 by default)
  74621. * @param height defines the texture height (1024 by default)
  74622. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74623. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74624. * @returns a new AdvancedDynamicTexture
  74625. */
  74626. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74627. /**
  74628. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74629. * In this mode the texture will rely on a layer for its rendering.
  74630. * This allows it to be treated like any other layer.
  74631. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74632. * LayerMask is set through advancedTexture.layer.layerMask
  74633. * @param name defines name for the texture
  74634. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74635. * @param scene defines the hsoting scene
  74636. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74637. * @returns a new AdvancedDynamicTexture
  74638. */
  74639. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74640. }
  74641. }
  74642. declare module BABYLON.GUI {
  74643. /**
  74644. * Root class used for all 2D controls
  74645. * @see http://doc.babylonjs.com/how_to/gui#controls
  74646. */
  74647. export class Control {
  74648. /** defines the name of the control */
  74649. name?: string | undefined;
  74650. /**
  74651. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74652. */
  74653. static AllowAlphaInheritance: boolean;
  74654. private _alpha;
  74655. private _alphaSet;
  74656. private _zIndex;
  74657. /** @hidden */
  74658. _host: AdvancedDynamicTexture;
  74659. /** Gets or sets the control parent */
  74660. parent: BABYLON.Nullable<Container>;
  74661. /** @hidden */
  74662. _currentMeasure: Measure;
  74663. private _fontFamily;
  74664. private _fontStyle;
  74665. private _fontWeight;
  74666. private _fontSize;
  74667. private _font;
  74668. /** @hidden */
  74669. _width: ValueAndUnit;
  74670. /** @hidden */
  74671. _height: ValueAndUnit;
  74672. /** @hidden */
  74673. protected _fontOffset: {
  74674. ascent: number;
  74675. height: number;
  74676. descent: number;
  74677. };
  74678. private _color;
  74679. private _style;
  74680. private _styleObserver;
  74681. /** @hidden */
  74682. protected _horizontalAlignment: number;
  74683. /** @hidden */
  74684. protected _verticalAlignment: number;
  74685. /** @hidden */
  74686. protected _isDirty: boolean;
  74687. /** @hidden */
  74688. protected _wasDirty: boolean;
  74689. /** @hidden */
  74690. _tempParentMeasure: Measure;
  74691. /** @hidden */
  74692. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74693. /** @hidden */
  74694. protected _cachedParentMeasure: Measure;
  74695. private _paddingLeft;
  74696. private _paddingRight;
  74697. private _paddingTop;
  74698. private _paddingBottom;
  74699. /** @hidden */
  74700. _left: ValueAndUnit;
  74701. /** @hidden */
  74702. _top: ValueAndUnit;
  74703. private _scaleX;
  74704. private _scaleY;
  74705. private _rotation;
  74706. private _transformCenterX;
  74707. private _transformCenterY;
  74708. /** @hidden */
  74709. _transformMatrix: Matrix2D;
  74710. /** @hidden */
  74711. protected _invertTransformMatrix: Matrix2D;
  74712. /** @hidden */
  74713. protected _transformedPosition: BABYLON.Vector2;
  74714. private _isMatrixDirty;
  74715. private _cachedOffsetX;
  74716. private _cachedOffsetY;
  74717. private _isVisible;
  74718. private _isHighlighted;
  74719. /** @hidden */
  74720. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74721. private _fontSet;
  74722. private _dummyVector2;
  74723. private _downCount;
  74724. private _enterCount;
  74725. private _doNotRender;
  74726. private _downPointerIds;
  74727. protected _isEnabled: boolean;
  74728. protected _disabledColor: string;
  74729. protected _disabledColorItem: string;
  74730. /** @hidden */
  74731. protected _rebuildLayout: boolean;
  74732. /** @hidden */
  74733. _customData: any;
  74734. /** @hidden */
  74735. _isClipped: boolean;
  74736. /** @hidden */
  74737. _automaticSize: boolean;
  74738. /** @hidden */
  74739. _tag: any;
  74740. /**
  74741. * 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
  74742. */
  74743. uniqueId: number;
  74744. /**
  74745. * Gets or sets an object used to store user defined information for the node
  74746. */
  74747. metadata: any;
  74748. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74749. isHitTestVisible: boolean;
  74750. /** Gets or sets a boolean indicating if the control can block pointer events */
  74751. isPointerBlocker: boolean;
  74752. /** Gets or sets a boolean indicating if the control can be focusable */
  74753. isFocusInvisible: boolean;
  74754. /**
  74755. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74756. * 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
  74757. */
  74758. clipChildren: boolean;
  74759. /**
  74760. * Gets or sets a boolean indicating that control content must be clipped
  74761. * 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
  74762. */
  74763. clipContent: boolean;
  74764. /**
  74765. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74766. */
  74767. useBitmapCache: boolean;
  74768. private _cacheData;
  74769. private _shadowOffsetX;
  74770. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74771. get shadowOffsetX(): number;
  74772. set shadowOffsetX(value: number);
  74773. private _shadowOffsetY;
  74774. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74775. get shadowOffsetY(): number;
  74776. set shadowOffsetY(value: number);
  74777. private _shadowBlur;
  74778. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74779. get shadowBlur(): number;
  74780. set shadowBlur(value: number);
  74781. private _shadowColor;
  74782. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74783. get shadowColor(): string;
  74784. set shadowColor(value: string);
  74785. /** Gets or sets the cursor to use when the control is hovered */
  74786. hoverCursor: string;
  74787. /** @hidden */
  74788. protected _linkOffsetX: ValueAndUnit;
  74789. /** @hidden */
  74790. protected _linkOffsetY: ValueAndUnit;
  74791. /** Gets the control type name */
  74792. get typeName(): string;
  74793. /**
  74794. * Get the current class name of the control.
  74795. * @returns current class name
  74796. */
  74797. getClassName(): string;
  74798. /**
  74799. * An event triggered when pointer wheel is scrolled
  74800. */
  74801. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74802. /**
  74803. * An event triggered when the pointer move over the control.
  74804. */
  74805. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74806. /**
  74807. * An event triggered when the pointer move out of the control.
  74808. */
  74809. onPointerOutObservable: BABYLON.Observable<Control>;
  74810. /**
  74811. * An event triggered when the pointer taps the control
  74812. */
  74813. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74814. /**
  74815. * An event triggered when pointer up
  74816. */
  74817. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74818. /**
  74819. * An event triggered when a control is clicked on
  74820. */
  74821. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74822. /**
  74823. * An event triggered when pointer enters the control
  74824. */
  74825. onPointerEnterObservable: BABYLON.Observable<Control>;
  74826. /**
  74827. * An event triggered when the control is marked as dirty
  74828. */
  74829. onDirtyObservable: BABYLON.Observable<Control>;
  74830. /**
  74831. * An event triggered before drawing the control
  74832. */
  74833. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74834. /**
  74835. * An event triggered after the control was drawn
  74836. */
  74837. onAfterDrawObservable: BABYLON.Observable<Control>;
  74838. /**
  74839. * An event triggered when the control has been disposed
  74840. */
  74841. onDisposeObservable: BABYLON.Observable<Control>;
  74842. /**
  74843. * Get the hosting AdvancedDynamicTexture
  74844. */
  74845. get host(): AdvancedDynamicTexture;
  74846. /** Gets or set information about font offsets (used to render and align text) */
  74847. get fontOffset(): {
  74848. ascent: number;
  74849. height: number;
  74850. descent: number;
  74851. };
  74852. set fontOffset(offset: {
  74853. ascent: number;
  74854. height: number;
  74855. descent: number;
  74856. });
  74857. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74858. get alpha(): number;
  74859. set alpha(value: number);
  74860. /**
  74861. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74862. */
  74863. get isHighlighted(): boolean;
  74864. set isHighlighted(value: boolean);
  74865. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74866. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74867. */
  74868. get scaleX(): number;
  74869. set scaleX(value: number);
  74870. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74871. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74872. */
  74873. get scaleY(): number;
  74874. set scaleY(value: number);
  74875. /** Gets or sets the rotation angle (0 by default)
  74876. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74877. */
  74878. get rotation(): number;
  74879. set rotation(value: number);
  74880. /** Gets or sets the transformation center on Y axis (0 by default)
  74881. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74882. */
  74883. get transformCenterY(): number;
  74884. set transformCenterY(value: number);
  74885. /** Gets or sets the transformation center on X axis (0 by default)
  74886. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74887. */
  74888. get transformCenterX(): number;
  74889. set transformCenterX(value: number);
  74890. /**
  74891. * Gets or sets the horizontal alignment
  74892. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74893. */
  74894. get horizontalAlignment(): number;
  74895. set horizontalAlignment(value: number);
  74896. /**
  74897. * Gets or sets the vertical alignment
  74898. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74899. */
  74900. get verticalAlignment(): number;
  74901. set verticalAlignment(value: number);
  74902. /**
  74903. * Gets or sets control width
  74904. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74905. */
  74906. get width(): string | number;
  74907. set width(value: string | number);
  74908. /**
  74909. * Gets or sets the control width in pixel
  74910. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74911. */
  74912. get widthInPixels(): number;
  74913. set widthInPixels(value: number);
  74914. /**
  74915. * Gets or sets control height
  74916. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74917. */
  74918. get height(): string | number;
  74919. set height(value: string | number);
  74920. /**
  74921. * Gets or sets control height in pixel
  74922. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74923. */
  74924. get heightInPixels(): number;
  74925. set heightInPixels(value: number);
  74926. /** Gets or set font family */
  74927. get fontFamily(): string;
  74928. set fontFamily(value: string);
  74929. /** Gets or sets font style */
  74930. get fontStyle(): string;
  74931. set fontStyle(value: string);
  74932. /** Gets or sets font weight */
  74933. get fontWeight(): string;
  74934. set fontWeight(value: string);
  74935. /**
  74936. * Gets or sets style
  74937. * @see http://doc.babylonjs.com/how_to/gui#styles
  74938. */
  74939. get style(): BABYLON.Nullable<Style>;
  74940. set style(value: BABYLON.Nullable<Style>);
  74941. /** @hidden */
  74942. get _isFontSizeInPercentage(): boolean;
  74943. /** Gets or sets font size in pixels */
  74944. get fontSizeInPixels(): number;
  74945. set fontSizeInPixels(value: number);
  74946. /** Gets or sets font size */
  74947. get fontSize(): string | number;
  74948. set fontSize(value: string | number);
  74949. /** Gets or sets foreground color */
  74950. get color(): string;
  74951. set color(value: string);
  74952. /** Gets or sets z index which is used to reorder controls on the z axis */
  74953. get zIndex(): number;
  74954. set zIndex(value: number);
  74955. /** Gets or sets a boolean indicating if the control can be rendered */
  74956. get notRenderable(): boolean;
  74957. set notRenderable(value: boolean);
  74958. /** Gets or sets a boolean indicating if the control is visible */
  74959. get isVisible(): boolean;
  74960. set isVisible(value: boolean);
  74961. /** Gets a boolean indicating that the control needs to update its rendering */
  74962. get isDirty(): boolean;
  74963. /**
  74964. * Gets the current linked mesh (or null if none)
  74965. */
  74966. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74967. /**
  74968. * Gets or sets a value indicating the padding to use on the left of the control
  74969. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74970. */
  74971. get paddingLeft(): string | number;
  74972. set paddingLeft(value: string | number);
  74973. /**
  74974. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74975. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74976. */
  74977. get paddingLeftInPixels(): number;
  74978. set paddingLeftInPixels(value: number);
  74979. /**
  74980. * Gets or sets a value indicating the padding to use on the right of the control
  74981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74982. */
  74983. get paddingRight(): string | number;
  74984. set paddingRight(value: string | number);
  74985. /**
  74986. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74987. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74988. */
  74989. get paddingRightInPixels(): number;
  74990. set paddingRightInPixels(value: number);
  74991. /**
  74992. * Gets or sets a value indicating the padding to use on the top of the control
  74993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74994. */
  74995. get paddingTop(): string | number;
  74996. set paddingTop(value: string | number);
  74997. /**
  74998. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74999. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75000. */
  75001. get paddingTopInPixels(): number;
  75002. set paddingTopInPixels(value: number);
  75003. /**
  75004. * Gets or sets a value indicating the padding to use on the bottom of the control
  75005. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75006. */
  75007. get paddingBottom(): string | number;
  75008. set paddingBottom(value: string | number);
  75009. /**
  75010. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75011. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75012. */
  75013. get paddingBottomInPixels(): number;
  75014. set paddingBottomInPixels(value: number);
  75015. /**
  75016. * Gets or sets a value indicating the left coordinate of the control
  75017. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75018. */
  75019. get left(): string | number;
  75020. set left(value: string | number);
  75021. /**
  75022. * Gets or sets a value indicating the left coordinate in pixels of the control
  75023. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75024. */
  75025. get leftInPixels(): number;
  75026. set leftInPixels(value: number);
  75027. /**
  75028. * Gets or sets a value indicating the top coordinate of the control
  75029. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75030. */
  75031. get top(): string | number;
  75032. set top(value: string | number);
  75033. /**
  75034. * Gets or sets a value indicating the top coordinate in pixels of the control
  75035. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75036. */
  75037. get topInPixels(): number;
  75038. set topInPixels(value: number);
  75039. /**
  75040. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75041. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75042. */
  75043. get linkOffsetX(): string | number;
  75044. set linkOffsetX(value: string | number);
  75045. /**
  75046. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75047. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75048. */
  75049. get linkOffsetXInPixels(): number;
  75050. set linkOffsetXInPixels(value: number);
  75051. /**
  75052. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75053. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75054. */
  75055. get linkOffsetY(): string | number;
  75056. set linkOffsetY(value: string | number);
  75057. /**
  75058. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75059. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75060. */
  75061. get linkOffsetYInPixels(): number;
  75062. set linkOffsetYInPixels(value: number);
  75063. /** Gets the center coordinate on X axis */
  75064. get centerX(): number;
  75065. /** Gets the center coordinate on Y axis */
  75066. get centerY(): number;
  75067. /** Gets or sets if control is Enabled*/
  75068. get isEnabled(): boolean;
  75069. set isEnabled(value: boolean);
  75070. /** Gets or sets background color of control if it's disabled*/
  75071. get disabledColor(): string;
  75072. set disabledColor(value: string);
  75073. /** Gets or sets front color of control if it's disabled*/
  75074. get disabledColorItem(): string;
  75075. set disabledColorItem(value: string);
  75076. /**
  75077. * Creates a new control
  75078. * @param name defines the name of the control
  75079. */
  75080. constructor(
  75081. /** defines the name of the control */
  75082. name?: string | undefined);
  75083. /** @hidden */
  75084. protected _getTypeName(): string;
  75085. /**
  75086. * Gets the first ascendant in the hierarchy of the given type
  75087. * @param className defines the required type
  75088. * @returns the ascendant or null if not found
  75089. */
  75090. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75091. /** @hidden */
  75092. _resetFontCache(): void;
  75093. /**
  75094. * Determines if a container is an ascendant of the current control
  75095. * @param container defines the container to look for
  75096. * @returns true if the container is one of the ascendant of the control
  75097. */
  75098. isAscendant(container: Control): boolean;
  75099. /**
  75100. * Gets coordinates in local control space
  75101. * @param globalCoordinates defines the coordinates to transform
  75102. * @returns the new coordinates in local space
  75103. */
  75104. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75105. /**
  75106. * Gets coordinates in local control space
  75107. * @param globalCoordinates defines the coordinates to transform
  75108. * @param result defines the target vector2 where to store the result
  75109. * @returns the current control
  75110. */
  75111. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75112. /**
  75113. * Gets coordinates in parent local control space
  75114. * @param globalCoordinates defines the coordinates to transform
  75115. * @returns the new coordinates in parent local space
  75116. */
  75117. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75118. /**
  75119. * Move the current control to a vector3 position projected onto the screen.
  75120. * @param position defines the target position
  75121. * @param scene defines the hosting scene
  75122. */
  75123. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75124. /**
  75125. * Will store all controls that have this control as ascendant in a given array
  75126. * @param results defines the array where to store the descendants
  75127. * @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
  75128. * @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
  75129. */
  75130. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75131. /**
  75132. * Will return all controls that have this control as ascendant
  75133. * @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
  75134. * @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
  75135. * @return all child controls
  75136. */
  75137. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75138. /**
  75139. * Link current control with a target mesh
  75140. * @param mesh defines the mesh to link with
  75141. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75142. */
  75143. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75144. /** @hidden */
  75145. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75146. /** @hidden */
  75147. _offsetLeft(offset: number): void;
  75148. /** @hidden */
  75149. _offsetTop(offset: number): void;
  75150. /** @hidden */
  75151. _markMatrixAsDirty(): void;
  75152. /** @hidden */
  75153. _flagDescendantsAsMatrixDirty(): void;
  75154. /** @hidden */
  75155. _intersectsRect(rect: Measure): boolean;
  75156. /** @hidden */
  75157. protected invalidateRect(): void;
  75158. /** @hidden */
  75159. _markAsDirty(force?: boolean): void;
  75160. /** @hidden */
  75161. _markAllAsDirty(): void;
  75162. /** @hidden */
  75163. _link(host: AdvancedDynamicTexture): void;
  75164. /** @hidden */
  75165. protected _transform(context?: CanvasRenderingContext2D): void;
  75166. /** @hidden */
  75167. _renderHighlight(context: CanvasRenderingContext2D): void;
  75168. /** @hidden */
  75169. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75170. /** @hidden */
  75171. protected _applyStates(context: CanvasRenderingContext2D): void;
  75172. /** @hidden */
  75173. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75174. /** @hidden */
  75175. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75176. protected _evaluateClippingState(parentMeasure: Measure): void;
  75177. /** @hidden */
  75178. _measure(): void;
  75179. /** @hidden */
  75180. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75181. /** @hidden */
  75182. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75183. /** @hidden */
  75184. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75185. /** @hidden */
  75186. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75187. private static _ClipMeasure;
  75188. private _tmpMeasureA;
  75189. private _clip;
  75190. /** @hidden */
  75191. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75192. /** @hidden */
  75193. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75194. /**
  75195. * Tests if a given coordinates belong to the current control
  75196. * @param x defines x coordinate to test
  75197. * @param y defines y coordinate to test
  75198. * @returns true if the coordinates are inside the control
  75199. */
  75200. contains(x: number, y: number): boolean;
  75201. /** @hidden */
  75202. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75203. /** @hidden */
  75204. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75205. /** @hidden */
  75206. _onPointerEnter(target: Control): boolean;
  75207. /** @hidden */
  75208. _onPointerOut(target: Control, force?: boolean): void;
  75209. /** @hidden */
  75210. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75211. /** @hidden */
  75212. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75213. /** @hidden */
  75214. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75215. /** @hidden */
  75216. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75217. /** @hidden */
  75218. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75219. private _prepareFont;
  75220. /** Releases associated resources */
  75221. dispose(): void;
  75222. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75223. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75224. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75225. private static _VERTICAL_ALIGNMENT_TOP;
  75226. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75227. private static _VERTICAL_ALIGNMENT_CENTER;
  75228. /** HORIZONTAL_ALIGNMENT_LEFT */
  75229. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75230. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75231. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75232. /** HORIZONTAL_ALIGNMENT_CENTER */
  75233. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75234. /** VERTICAL_ALIGNMENT_TOP */
  75235. static get VERTICAL_ALIGNMENT_TOP(): number;
  75236. /** VERTICAL_ALIGNMENT_BOTTOM */
  75237. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75238. /** VERTICAL_ALIGNMENT_CENTER */
  75239. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75240. private static _FontHeightSizes;
  75241. /** @hidden */
  75242. static _GetFontOffset(font: string): {
  75243. ascent: number;
  75244. height: number;
  75245. descent: number;
  75246. };
  75247. /**
  75248. * Creates a stack panel that can be used to render headers
  75249. * @param control defines the control to associate with the header
  75250. * @param text defines the text of the header
  75251. * @param size defines the size of the header
  75252. * @param options defines options used to configure the header
  75253. * @returns a new StackPanel
  75254. * @ignore
  75255. * @hidden
  75256. */
  75257. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75258. isHorizontal: boolean;
  75259. controlFirst: boolean;
  75260. }) => any;
  75261. /** @hidden */
  75262. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75263. }
  75264. }
  75265. declare module BABYLON.GUI {
  75266. /**
  75267. * Root class for 2D containers
  75268. * @see http://doc.babylonjs.com/how_to/gui#containers
  75269. */
  75270. export class Container extends Control {
  75271. name?: string | undefined;
  75272. /** @hidden */
  75273. _children: Control[];
  75274. /** @hidden */
  75275. protected _measureForChildren: Measure;
  75276. /** @hidden */
  75277. protected _background: string;
  75278. /** @hidden */
  75279. protected _adaptWidthToChildren: boolean;
  75280. /** @hidden */
  75281. protected _adaptHeightToChildren: boolean;
  75282. /**
  75283. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75284. */
  75285. logLayoutCycleErrors: boolean;
  75286. /**
  75287. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75288. */
  75289. maxLayoutCycle: number;
  75290. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75291. get adaptHeightToChildren(): boolean;
  75292. set adaptHeightToChildren(value: boolean);
  75293. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75294. get adaptWidthToChildren(): boolean;
  75295. set adaptWidthToChildren(value: boolean);
  75296. /** Gets or sets background color */
  75297. get background(): string;
  75298. set background(value: string);
  75299. /** Gets the list of children */
  75300. get children(): Control[];
  75301. /**
  75302. * Creates a new Container
  75303. * @param name defines the name of the container
  75304. */
  75305. constructor(name?: string | undefined);
  75306. protected _getTypeName(): string;
  75307. _flagDescendantsAsMatrixDirty(): void;
  75308. /**
  75309. * Gets a child using its name
  75310. * @param name defines the child name to look for
  75311. * @returns the child control if found
  75312. */
  75313. getChildByName(name: string): BABYLON.Nullable<Control>;
  75314. /**
  75315. * Gets a child using its type and its name
  75316. * @param name defines the child name to look for
  75317. * @param type defines the child type to look for
  75318. * @returns the child control if found
  75319. */
  75320. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75321. /**
  75322. * Search for a specific control in children
  75323. * @param control defines the control to look for
  75324. * @returns true if the control is in child list
  75325. */
  75326. containsControl(control: Control): boolean;
  75327. /**
  75328. * Adds a new control to the current container
  75329. * @param control defines the control to add
  75330. * @returns the current container
  75331. */
  75332. addControl(control: BABYLON.Nullable<Control>): Container;
  75333. /**
  75334. * Removes all controls from the current container
  75335. * @returns the current container
  75336. */
  75337. clearControls(): Container;
  75338. /**
  75339. * Removes a control from the current container
  75340. * @param control defines the control to remove
  75341. * @returns the current container
  75342. */
  75343. removeControl(control: Control): Container;
  75344. /** @hidden */
  75345. _reOrderControl(control: Control): void;
  75346. /** @hidden */
  75347. _offsetLeft(offset: number): void;
  75348. /** @hidden */
  75349. _offsetTop(offset: number): void;
  75350. /** @hidden */
  75351. _markAllAsDirty(): void;
  75352. /** @hidden */
  75353. protected _localDraw(context: CanvasRenderingContext2D): void;
  75354. /** @hidden */
  75355. _link(host: AdvancedDynamicTexture): void;
  75356. /** @hidden */
  75357. protected _beforeLayout(): void;
  75358. /** @hidden */
  75359. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75360. /** @hidden */
  75361. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75362. protected _postMeasure(): void;
  75363. /** @hidden */
  75364. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75365. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75366. /** @hidden */
  75367. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75368. /** @hidden */
  75369. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75370. /** Releases associated resources */
  75371. dispose(): void;
  75372. }
  75373. }
  75374. declare module BABYLON.GUI {
  75375. /** Class used to create rectangle container */
  75376. export class Rectangle extends Container {
  75377. name?: string | undefined;
  75378. private _thickness;
  75379. private _cornerRadius;
  75380. /** Gets or sets border thickness */
  75381. get thickness(): number;
  75382. set thickness(value: number);
  75383. /** Gets or sets the corner radius angle */
  75384. get cornerRadius(): number;
  75385. set cornerRadius(value: number);
  75386. /**
  75387. * Creates a new Rectangle
  75388. * @param name defines the control name
  75389. */
  75390. constructor(name?: string | undefined);
  75391. protected _getTypeName(): string;
  75392. protected _localDraw(context: CanvasRenderingContext2D): void;
  75393. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75394. private _drawRoundedRect;
  75395. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75396. }
  75397. }
  75398. declare module BABYLON.GUI {
  75399. /**
  75400. * Enum that determines the text-wrapping mode to use.
  75401. */
  75402. export enum TextWrapping {
  75403. /**
  75404. * Clip the text when it's larger than Control.width; this is the default mode.
  75405. */
  75406. Clip = 0,
  75407. /**
  75408. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75409. */
  75410. WordWrap = 1,
  75411. /**
  75412. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75413. */
  75414. Ellipsis = 2
  75415. }
  75416. /**
  75417. * Class used to create text block control
  75418. */
  75419. export class TextBlock extends Control {
  75420. /**
  75421. * Defines the name of the control
  75422. */
  75423. name?: string | undefined;
  75424. private _text;
  75425. private _textWrapping;
  75426. private _textHorizontalAlignment;
  75427. private _textVerticalAlignment;
  75428. private _lines;
  75429. private _resizeToFit;
  75430. private _lineSpacing;
  75431. private _outlineWidth;
  75432. private _outlineColor;
  75433. /**
  75434. * An event triggered after the text is changed
  75435. */
  75436. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75437. /**
  75438. * An event triggered after the text was broken up into lines
  75439. */
  75440. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75441. /**
  75442. * Function used to split a string into words. By default, a string is split at each space character found
  75443. */
  75444. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75445. /**
  75446. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75447. */
  75448. get lines(): any[];
  75449. /**
  75450. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75451. */
  75452. get resizeToFit(): boolean;
  75453. /**
  75454. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75455. */
  75456. set resizeToFit(value: boolean);
  75457. /**
  75458. * Gets or sets a boolean indicating if text must be wrapped
  75459. */
  75460. get textWrapping(): TextWrapping | boolean;
  75461. /**
  75462. * Gets or sets a boolean indicating if text must be wrapped
  75463. */
  75464. set textWrapping(value: TextWrapping | boolean);
  75465. /**
  75466. * Gets or sets text to display
  75467. */
  75468. get text(): string;
  75469. /**
  75470. * Gets or sets text to display
  75471. */
  75472. set text(value: string);
  75473. /**
  75474. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75475. */
  75476. get textHorizontalAlignment(): number;
  75477. /**
  75478. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75479. */
  75480. set textHorizontalAlignment(value: number);
  75481. /**
  75482. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75483. */
  75484. get textVerticalAlignment(): number;
  75485. /**
  75486. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75487. */
  75488. set textVerticalAlignment(value: number);
  75489. /**
  75490. * Gets or sets line spacing value
  75491. */
  75492. set lineSpacing(value: string | number);
  75493. /**
  75494. * Gets or sets line spacing value
  75495. */
  75496. get lineSpacing(): string | number;
  75497. /**
  75498. * Gets or sets outlineWidth of the text to display
  75499. */
  75500. get outlineWidth(): number;
  75501. /**
  75502. * Gets or sets outlineWidth of the text to display
  75503. */
  75504. set outlineWidth(value: number);
  75505. /**
  75506. * Gets or sets outlineColor of the text to display
  75507. */
  75508. get outlineColor(): string;
  75509. /**
  75510. * Gets or sets outlineColor of the text to display
  75511. */
  75512. set outlineColor(value: string);
  75513. /**
  75514. * Creates a new TextBlock object
  75515. * @param name defines the name of the control
  75516. * @param text defines the text to display (emptry string by default)
  75517. */
  75518. constructor(
  75519. /**
  75520. * Defines the name of the control
  75521. */
  75522. name?: string | undefined, text?: string);
  75523. protected _getTypeName(): string;
  75524. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75525. private _drawText;
  75526. /** @hidden */
  75527. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75528. protected _applyStates(context: CanvasRenderingContext2D): void;
  75529. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75530. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75531. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75532. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75533. protected _renderLines(context: CanvasRenderingContext2D): void;
  75534. /**
  75535. * Given a width constraint applied on the text block, find the expected height
  75536. * @returns expected height
  75537. */
  75538. computeExpectedHeight(): number;
  75539. dispose(): void;
  75540. }
  75541. }
  75542. declare module BABYLON.GUI {
  75543. /**
  75544. * Class used to create 2D images
  75545. */
  75546. export class Image extends Control {
  75547. name?: string | undefined;
  75548. private _workingCanvas;
  75549. private _domImage;
  75550. private _imageWidth;
  75551. private _imageHeight;
  75552. private _loaded;
  75553. private _stretch;
  75554. private _source;
  75555. private _autoScale;
  75556. private _sourceLeft;
  75557. private _sourceTop;
  75558. private _sourceWidth;
  75559. private _sourceHeight;
  75560. private _svgAttributesComputationCompleted;
  75561. private _isSVG;
  75562. private _cellWidth;
  75563. private _cellHeight;
  75564. private _cellId;
  75565. private _populateNinePatchSlicesFromImage;
  75566. private _sliceLeft;
  75567. private _sliceRight;
  75568. private _sliceTop;
  75569. private _sliceBottom;
  75570. private _detectPointerOnOpaqueOnly;
  75571. /**
  75572. * BABYLON.Observable notified when the content is loaded
  75573. */
  75574. onImageLoadedObservable: BABYLON.Observable<Image>;
  75575. /**
  75576. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75577. */
  75578. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75579. /**
  75580. * Gets a boolean indicating that the content is loaded
  75581. */
  75582. get isLoaded(): boolean;
  75583. /**
  75584. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75585. */
  75586. get populateNinePatchSlicesFromImage(): boolean;
  75587. set populateNinePatchSlicesFromImage(value: boolean);
  75588. /**
  75589. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75590. * Beware using this as this will comsume more memory as the image has to be stored twice
  75591. */
  75592. get detectPointerOnOpaqueOnly(): boolean;
  75593. set detectPointerOnOpaqueOnly(value: boolean);
  75594. /**
  75595. * Gets or sets the left value for slicing (9-patch)
  75596. */
  75597. get sliceLeft(): number;
  75598. set sliceLeft(value: number);
  75599. /**
  75600. * Gets or sets the right value for slicing (9-patch)
  75601. */
  75602. get sliceRight(): number;
  75603. set sliceRight(value: number);
  75604. /**
  75605. * Gets or sets the top value for slicing (9-patch)
  75606. */
  75607. get sliceTop(): number;
  75608. set sliceTop(value: number);
  75609. /**
  75610. * Gets or sets the bottom value for slicing (9-patch)
  75611. */
  75612. get sliceBottom(): number;
  75613. set sliceBottom(value: number);
  75614. /**
  75615. * Gets or sets the left coordinate in the source image
  75616. */
  75617. get sourceLeft(): number;
  75618. set sourceLeft(value: number);
  75619. /**
  75620. * Gets or sets the top coordinate in the source image
  75621. */
  75622. get sourceTop(): number;
  75623. set sourceTop(value: number);
  75624. /**
  75625. * Gets or sets the width to capture in the source image
  75626. */
  75627. get sourceWidth(): number;
  75628. set sourceWidth(value: number);
  75629. /**
  75630. * Gets or sets the height to capture in the source image
  75631. */
  75632. get sourceHeight(): number;
  75633. set sourceHeight(value: number);
  75634. /** Indicates if the format of the image is SVG */
  75635. get isSVG(): boolean;
  75636. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75637. get svgAttributesComputationCompleted(): boolean;
  75638. /**
  75639. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75640. * @see http://doc.babylonjs.com/how_to/gui#image
  75641. */
  75642. get autoScale(): boolean;
  75643. set autoScale(value: boolean);
  75644. /** Gets or sets the streching mode used by the image */
  75645. get stretch(): number;
  75646. set stretch(value: number);
  75647. /** @hidden */
  75648. _rotate90(n: number, preserveProperties?: boolean): Image;
  75649. private _handleRotationForSVGImage;
  75650. private _rotate90SourceProperties;
  75651. /**
  75652. * Gets or sets the internal DOM image used to render the control
  75653. */
  75654. set domImage(value: HTMLImageElement);
  75655. get domImage(): HTMLImageElement;
  75656. private _onImageLoaded;
  75657. private _extractNinePatchSliceDataFromImage;
  75658. /**
  75659. * Gets or sets image source url
  75660. */
  75661. set source(value: BABYLON.Nullable<string>);
  75662. /**
  75663. * Checks for svg document with icon id present
  75664. */
  75665. private _svgCheck;
  75666. /**
  75667. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75668. * given external svg file and icon id
  75669. */
  75670. private _getSVGAttribs;
  75671. /**
  75672. * Gets or sets the cell width to use when animation sheet is enabled
  75673. * @see http://doc.babylonjs.com/how_to/gui#image
  75674. */
  75675. get cellWidth(): number;
  75676. set cellWidth(value: number);
  75677. /**
  75678. * Gets or sets the cell height to use when animation sheet is enabled
  75679. * @see http://doc.babylonjs.com/how_to/gui#image
  75680. */
  75681. get cellHeight(): number;
  75682. set cellHeight(value: number);
  75683. /**
  75684. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75685. * @see http://doc.babylonjs.com/how_to/gui#image
  75686. */
  75687. get cellId(): number;
  75688. set cellId(value: number);
  75689. /**
  75690. * Creates a new Image
  75691. * @param name defines the control name
  75692. * @param url defines the image url
  75693. */
  75694. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75695. /**
  75696. * Tests if a given coordinates belong to the current control
  75697. * @param x defines x coordinate to test
  75698. * @param y defines y coordinate to test
  75699. * @returns true if the coordinates are inside the control
  75700. */
  75701. contains(x: number, y: number): boolean;
  75702. protected _getTypeName(): string;
  75703. /** Force the control to synchronize with its content */
  75704. synchronizeSizeWithContent(): void;
  75705. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75706. private _prepareWorkingCanvasForOpaqueDetection;
  75707. private _drawImage;
  75708. _draw(context: CanvasRenderingContext2D): void;
  75709. private _renderCornerPatch;
  75710. private _renderNinePatch;
  75711. dispose(): void;
  75712. /** STRETCH_NONE */
  75713. static readonly STRETCH_NONE: number;
  75714. /** STRETCH_FILL */
  75715. static readonly STRETCH_FILL: number;
  75716. /** STRETCH_UNIFORM */
  75717. static readonly STRETCH_UNIFORM: number;
  75718. /** STRETCH_EXTEND */
  75719. static readonly STRETCH_EXTEND: number;
  75720. /** NINE_PATCH */
  75721. static readonly STRETCH_NINE_PATCH: number;
  75722. }
  75723. }
  75724. declare module BABYLON.GUI {
  75725. /**
  75726. * Class used to create 2D buttons
  75727. */
  75728. export class Button extends Rectangle {
  75729. name?: string | undefined;
  75730. /**
  75731. * Function called to generate a pointer enter animation
  75732. */
  75733. pointerEnterAnimation: () => void;
  75734. /**
  75735. * Function called to generate a pointer out animation
  75736. */
  75737. pointerOutAnimation: () => void;
  75738. /**
  75739. * Function called to generate a pointer down animation
  75740. */
  75741. pointerDownAnimation: () => void;
  75742. /**
  75743. * Function called to generate a pointer up animation
  75744. */
  75745. pointerUpAnimation: () => void;
  75746. /**
  75747. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75748. */
  75749. delegatePickingToChildren: boolean;
  75750. private _image;
  75751. /**
  75752. * Returns the image part of the button (if any)
  75753. */
  75754. get image(): BABYLON.Nullable<Image>;
  75755. private _textBlock;
  75756. /**
  75757. * Returns the image part of the button (if any)
  75758. */
  75759. get textBlock(): BABYLON.Nullable<TextBlock>;
  75760. /**
  75761. * Creates a new Button
  75762. * @param name defines the name of the button
  75763. */
  75764. constructor(name?: string | undefined);
  75765. protected _getTypeName(): string;
  75766. /** @hidden */
  75767. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75768. /** @hidden */
  75769. _onPointerEnter(target: Control): boolean;
  75770. /** @hidden */
  75771. _onPointerOut(target: Control, force?: boolean): void;
  75772. /** @hidden */
  75773. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75774. /** @hidden */
  75775. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75776. /**
  75777. * Creates a new button made with an image and a text
  75778. * @param name defines the name of the button
  75779. * @param text defines the text of the button
  75780. * @param imageUrl defines the url of the image
  75781. * @returns a new Button
  75782. */
  75783. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75784. /**
  75785. * Creates a new button made with an image
  75786. * @param name defines the name of the button
  75787. * @param imageUrl defines the url of the image
  75788. * @returns a new Button
  75789. */
  75790. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75791. /**
  75792. * Creates a new button made with a text
  75793. * @param name defines the name of the button
  75794. * @param text defines the text of the button
  75795. * @returns a new Button
  75796. */
  75797. static CreateSimpleButton(name: string, text: string): Button;
  75798. /**
  75799. * Creates a new button made with an image and a centered text
  75800. * @param name defines the name of the button
  75801. * @param text defines the text of the button
  75802. * @param imageUrl defines the url of the image
  75803. * @returns a new Button
  75804. */
  75805. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75806. }
  75807. }
  75808. declare module BABYLON.GUI {
  75809. /**
  75810. * Class used to create a 2D stack panel container
  75811. */
  75812. export class StackPanel extends Container {
  75813. name?: string | undefined;
  75814. private _isVertical;
  75815. private _manualWidth;
  75816. private _manualHeight;
  75817. private _doNotTrackManualChanges;
  75818. /**
  75819. * Gets or sets a boolean indicating that layou warnings should be ignored
  75820. */
  75821. ignoreLayoutWarnings: boolean;
  75822. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75823. get isVertical(): boolean;
  75824. set isVertical(value: boolean);
  75825. /**
  75826. * Gets or sets panel width.
  75827. * This value should not be set when in horizontal mode as it will be computed automatically
  75828. */
  75829. set width(value: string | number);
  75830. get width(): string | number;
  75831. /**
  75832. * Gets or sets panel height.
  75833. * This value should not be set when in vertical mode as it will be computed automatically
  75834. */
  75835. set height(value: string | number);
  75836. get height(): string | number;
  75837. /**
  75838. * Creates a new StackPanel
  75839. * @param name defines control name
  75840. */
  75841. constructor(name?: string | undefined);
  75842. protected _getTypeName(): string;
  75843. /** @hidden */
  75844. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75845. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75846. protected _postMeasure(): void;
  75847. }
  75848. }
  75849. declare module BABYLON.GUI {
  75850. /**
  75851. * Class used to represent a 2D checkbox
  75852. */
  75853. export class Checkbox extends Control {
  75854. name?: string | undefined;
  75855. private _isChecked;
  75856. private _background;
  75857. private _checkSizeRatio;
  75858. private _thickness;
  75859. /** Gets or sets border thickness */
  75860. get thickness(): number;
  75861. set thickness(value: number);
  75862. /**
  75863. * BABYLON.Observable raised when isChecked property changes
  75864. */
  75865. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75866. /** Gets or sets a value indicating the ratio between overall size and check size */
  75867. get checkSizeRatio(): number;
  75868. set checkSizeRatio(value: number);
  75869. /** Gets or sets background color */
  75870. get background(): string;
  75871. set background(value: string);
  75872. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75873. get isChecked(): boolean;
  75874. set isChecked(value: boolean);
  75875. /**
  75876. * Creates a new CheckBox
  75877. * @param name defines the control name
  75878. */
  75879. constructor(name?: string | undefined);
  75880. protected _getTypeName(): string;
  75881. /** @hidden */
  75882. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75883. /** @hidden */
  75884. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75885. /**
  75886. * Utility function to easily create a checkbox with a header
  75887. * @param title defines the label to use for the header
  75888. * @param onValueChanged defines the callback to call when value changes
  75889. * @returns a StackPanel containing the checkbox and a textBlock
  75890. */
  75891. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75892. }
  75893. }
  75894. declare module BABYLON.GUI {
  75895. /**
  75896. * Class used to store key control properties
  75897. */
  75898. export class KeyPropertySet {
  75899. /** Width */
  75900. width?: string;
  75901. /** Height */
  75902. height?: string;
  75903. /** Left padding */
  75904. paddingLeft?: string;
  75905. /** Right padding */
  75906. paddingRight?: string;
  75907. /** Top padding */
  75908. paddingTop?: string;
  75909. /** Bottom padding */
  75910. paddingBottom?: string;
  75911. /** Foreground color */
  75912. color?: string;
  75913. /** Background color */
  75914. background?: string;
  75915. }
  75916. /**
  75917. * Class used to create virtual keyboard
  75918. */
  75919. export class VirtualKeyboard extends StackPanel {
  75920. /** BABYLON.Observable raised when a key is pressed */
  75921. onKeyPressObservable: BABYLON.Observable<string>;
  75922. /** Gets or sets default key button width */
  75923. defaultButtonWidth: string;
  75924. /** Gets or sets default key button height */
  75925. defaultButtonHeight: string;
  75926. /** Gets or sets default key button left padding */
  75927. defaultButtonPaddingLeft: string;
  75928. /** Gets or sets default key button right padding */
  75929. defaultButtonPaddingRight: string;
  75930. /** Gets or sets default key button top padding */
  75931. defaultButtonPaddingTop: string;
  75932. /** Gets or sets default key button bottom padding */
  75933. defaultButtonPaddingBottom: string;
  75934. /** Gets or sets default key button foreground color */
  75935. defaultButtonColor: string;
  75936. /** Gets or sets default key button background color */
  75937. defaultButtonBackground: string;
  75938. /** Gets or sets shift button foreground color */
  75939. shiftButtonColor: string;
  75940. /** Gets or sets shift button thickness*/
  75941. selectedShiftThickness: number;
  75942. /** Gets shift key state */
  75943. shiftState: number;
  75944. protected _getTypeName(): string;
  75945. private _createKey;
  75946. /**
  75947. * Adds a new row of keys
  75948. * @param keys defines the list of keys to add
  75949. * @param propertySets defines the associated property sets
  75950. */
  75951. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75952. /**
  75953. * Set the shift key to a specific state
  75954. * @param shiftState defines the new shift state
  75955. */
  75956. applyShiftState(shiftState: number): void;
  75957. private _currentlyConnectedInputText;
  75958. private _connectedInputTexts;
  75959. private _onKeyPressObserver;
  75960. /** Gets the input text control currently attached to the keyboard */
  75961. get connectedInputText(): BABYLON.Nullable<InputText>;
  75962. /**
  75963. * Connects the keyboard with an input text control
  75964. *
  75965. * @param input defines the target control
  75966. */
  75967. connect(input: InputText): void;
  75968. /**
  75969. * Disconnects the keyboard from connected InputText controls
  75970. *
  75971. * @param input optionally defines a target control, otherwise all are disconnected
  75972. */
  75973. disconnect(input?: InputText): void;
  75974. private _removeConnectedInputObservables;
  75975. /**
  75976. * Release all resources
  75977. */
  75978. dispose(): void;
  75979. /**
  75980. * Creates a new keyboard using a default layout
  75981. *
  75982. * @param name defines control name
  75983. * @returns a new VirtualKeyboard
  75984. */
  75985. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75986. }
  75987. }
  75988. declare module BABYLON.GUI {
  75989. /**
  75990. * Class used to create input text control
  75991. */
  75992. export class InputText extends Control implements IFocusableControl {
  75993. name?: string | undefined;
  75994. private _text;
  75995. private _placeholderText;
  75996. private _background;
  75997. private _focusedBackground;
  75998. private _focusedColor;
  75999. private _placeholderColor;
  76000. private _thickness;
  76001. private _margin;
  76002. private _autoStretchWidth;
  76003. private _maxWidth;
  76004. private _isFocused;
  76005. private _blinkTimeout;
  76006. private _blinkIsEven;
  76007. private _cursorOffset;
  76008. private _scrollLeft;
  76009. private _textWidth;
  76010. private _clickedCoordinate;
  76011. private _deadKey;
  76012. private _addKey;
  76013. private _currentKey;
  76014. private _isTextHighlightOn;
  76015. private _textHighlightColor;
  76016. private _highligherOpacity;
  76017. private _highlightedText;
  76018. private _startHighlightIndex;
  76019. private _endHighlightIndex;
  76020. private _cursorIndex;
  76021. private _onFocusSelectAll;
  76022. private _isPointerDown;
  76023. private _onClipboardObserver;
  76024. private _onPointerDblTapObserver;
  76025. /** @hidden */
  76026. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76027. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76028. promptMessage: string;
  76029. /** Force disable prompt on mobile device */
  76030. disableMobilePrompt: boolean;
  76031. /** BABYLON.Observable raised when the text changes */
  76032. onTextChangedObservable: BABYLON.Observable<InputText>;
  76033. /** BABYLON.Observable raised just before an entered character is to be added */
  76034. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76035. /** BABYLON.Observable raised when the control gets the focus */
  76036. onFocusObservable: BABYLON.Observable<InputText>;
  76037. /** BABYLON.Observable raised when the control loses the focus */
  76038. onBlurObservable: BABYLON.Observable<InputText>;
  76039. /**Observable raised when the text is highlighted */
  76040. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76041. /**Observable raised when copy event is triggered */
  76042. onTextCopyObservable: BABYLON.Observable<InputText>;
  76043. /** BABYLON.Observable raised when cut event is triggered */
  76044. onTextCutObservable: BABYLON.Observable<InputText>;
  76045. /** BABYLON.Observable raised when paste event is triggered */
  76046. onTextPasteObservable: BABYLON.Observable<InputText>;
  76047. /** BABYLON.Observable raised when a key event was processed */
  76048. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76049. /** Gets or sets the maximum width allowed by the control */
  76050. get maxWidth(): string | number;
  76051. /** Gets the maximum width allowed by the control in pixels */
  76052. get maxWidthInPixels(): number;
  76053. set maxWidth(value: string | number);
  76054. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76055. get highligherOpacity(): number;
  76056. set highligherOpacity(value: number);
  76057. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76058. get onFocusSelectAll(): boolean;
  76059. set onFocusSelectAll(value: boolean);
  76060. /** Gets or sets the text hightlight color */
  76061. get textHighlightColor(): string;
  76062. set textHighlightColor(value: string);
  76063. /** Gets or sets control margin */
  76064. get margin(): string;
  76065. /** Gets control margin in pixels */
  76066. get marginInPixels(): number;
  76067. set margin(value: string);
  76068. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76069. get autoStretchWidth(): boolean;
  76070. set autoStretchWidth(value: boolean);
  76071. /** Gets or sets border thickness */
  76072. get thickness(): number;
  76073. set thickness(value: number);
  76074. /** Gets or sets the background color when focused */
  76075. get focusedBackground(): string;
  76076. set focusedBackground(value: string);
  76077. /** Gets or sets the background color when focused */
  76078. get focusedColor(): string;
  76079. set focusedColor(value: string);
  76080. /** Gets or sets the background color */
  76081. get background(): string;
  76082. set background(value: string);
  76083. /** Gets or sets the placeholder color */
  76084. get placeholderColor(): string;
  76085. set placeholderColor(value: string);
  76086. /** Gets or sets the text displayed when the control is empty */
  76087. get placeholderText(): string;
  76088. set placeholderText(value: string);
  76089. /** Gets or sets the dead key flag */
  76090. get deadKey(): boolean;
  76091. set deadKey(flag: boolean);
  76092. /** Gets or sets the highlight text */
  76093. get highlightedText(): string;
  76094. set highlightedText(text: string);
  76095. /** Gets or sets if the current key should be added */
  76096. get addKey(): boolean;
  76097. set addKey(flag: boolean);
  76098. /** Gets or sets the value of the current key being entered */
  76099. get currentKey(): string;
  76100. set currentKey(key: string);
  76101. /** Gets or sets the text displayed in the control */
  76102. get text(): string;
  76103. set text(value: string);
  76104. /** Gets or sets control width */
  76105. get width(): string | number;
  76106. set width(value: string | number);
  76107. /**
  76108. * Creates a new InputText
  76109. * @param name defines the control name
  76110. * @param text defines the text of the control
  76111. */
  76112. constructor(name?: string | undefined, text?: string);
  76113. /** @hidden */
  76114. onBlur(): void;
  76115. /** @hidden */
  76116. onFocus(): void;
  76117. protected _getTypeName(): string;
  76118. /**
  76119. * Function called to get the list of controls that should not steal the focus from this control
  76120. * @returns an array of controls
  76121. */
  76122. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76123. /** @hidden */
  76124. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76125. /** @hidden */
  76126. private _updateValueFromCursorIndex;
  76127. /** @hidden */
  76128. private _processDblClick;
  76129. /** @hidden */
  76130. private _selectAllText;
  76131. /**
  76132. * Handles the keyboard event
  76133. * @param evt Defines the KeyboardEvent
  76134. */
  76135. processKeyboard(evt: KeyboardEvent): void;
  76136. /** @hidden */
  76137. private _onCopyText;
  76138. /** @hidden */
  76139. private _onCutText;
  76140. /** @hidden */
  76141. private _onPasteText;
  76142. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76143. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76144. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76145. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76146. protected _beforeRenderText(text: string): string;
  76147. dispose(): void;
  76148. }
  76149. }
  76150. declare module BABYLON.GUI {
  76151. /**
  76152. * Class used to create a 2D grid container
  76153. */
  76154. export class Grid extends Container {
  76155. name?: string | undefined;
  76156. private _rowDefinitions;
  76157. private _columnDefinitions;
  76158. private _cells;
  76159. private _childControls;
  76160. /**
  76161. * Gets the number of columns
  76162. */
  76163. get columnCount(): number;
  76164. /**
  76165. * Gets the number of rows
  76166. */
  76167. get rowCount(): number;
  76168. /** Gets the list of children */
  76169. get children(): Control[];
  76170. /** Gets the list of cells (e.g. the containers) */
  76171. get cells(): {
  76172. [key: string]: Container;
  76173. };
  76174. /**
  76175. * Gets the definition of a specific row
  76176. * @param index defines the index of the row
  76177. * @returns the row definition
  76178. */
  76179. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76180. /**
  76181. * Gets the definition of a specific column
  76182. * @param index defines the index of the column
  76183. * @returns the column definition
  76184. */
  76185. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76186. /**
  76187. * Adds a new row to the grid
  76188. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76189. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76190. * @returns the current grid
  76191. */
  76192. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76193. /**
  76194. * Adds a new column to the grid
  76195. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76196. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76197. * @returns the current grid
  76198. */
  76199. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76200. /**
  76201. * Update a row definition
  76202. * @param index defines the index of the row to update
  76203. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76204. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76205. * @returns the current grid
  76206. */
  76207. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76208. /**
  76209. * Update a column definition
  76210. * @param index defines the index of the column to update
  76211. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76212. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76213. * @returns the current grid
  76214. */
  76215. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76216. /**
  76217. * Gets the list of children stored in a specific cell
  76218. * @param row defines the row to check
  76219. * @param column defines the column to check
  76220. * @returns the list of controls
  76221. */
  76222. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76223. /**
  76224. * Gets a string representing the child cell info (row x column)
  76225. * @param child defines the control to get info from
  76226. * @returns a string containing the child cell info (row x column)
  76227. */
  76228. getChildCellInfo(child: Control): string;
  76229. private _removeCell;
  76230. private _offsetCell;
  76231. /**
  76232. * Remove a column definition at specified index
  76233. * @param index defines the index of the column to remove
  76234. * @returns the current grid
  76235. */
  76236. removeColumnDefinition(index: number): Grid;
  76237. /**
  76238. * Remove a row definition at specified index
  76239. * @param index defines the index of the row to remove
  76240. * @returns the current grid
  76241. */
  76242. removeRowDefinition(index: number): Grid;
  76243. /**
  76244. * Adds a new control to the current grid
  76245. * @param control defines the control to add
  76246. * @param row defines the row where to add the control (0 by default)
  76247. * @param column defines the column where to add the control (0 by default)
  76248. * @returns the current grid
  76249. */
  76250. addControl(control: Control, row?: number, column?: number): Grid;
  76251. /**
  76252. * Removes a control from the current container
  76253. * @param control defines the control to remove
  76254. * @returns the current container
  76255. */
  76256. removeControl(control: Control): Container;
  76257. /**
  76258. * Creates a new Grid
  76259. * @param name defines control name
  76260. */
  76261. constructor(name?: string | undefined);
  76262. protected _getTypeName(): string;
  76263. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76264. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76265. _flagDescendantsAsMatrixDirty(): void;
  76266. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76267. /** Releases associated resources */
  76268. dispose(): void;
  76269. }
  76270. }
  76271. declare module BABYLON.GUI {
  76272. /** Class used to create color pickers */
  76273. export class ColorPicker extends Control {
  76274. name?: string | undefined;
  76275. private static _Epsilon;
  76276. private _colorWheelCanvas;
  76277. private _value;
  76278. private _tmpColor;
  76279. private _pointerStartedOnSquare;
  76280. private _pointerStartedOnWheel;
  76281. private _squareLeft;
  76282. private _squareTop;
  76283. private _squareSize;
  76284. private _h;
  76285. private _s;
  76286. private _v;
  76287. private _lastPointerDownID;
  76288. /**
  76289. * BABYLON.Observable raised when the value changes
  76290. */
  76291. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76292. /** Gets or sets the color of the color picker */
  76293. get value(): BABYLON.Color3;
  76294. set value(value: BABYLON.Color3);
  76295. /**
  76296. * Gets or sets control width
  76297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76298. */
  76299. get width(): string | number;
  76300. set width(value: string | number);
  76301. /**
  76302. * Gets or sets control height
  76303. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76304. */
  76305. get height(): string | number;
  76306. /** Gets or sets control height */
  76307. set height(value: string | number);
  76308. /** Gets or sets control size */
  76309. get size(): string | number;
  76310. set size(value: string | number);
  76311. /**
  76312. * Creates a new ColorPicker
  76313. * @param name defines the control name
  76314. */
  76315. constructor(name?: string | undefined);
  76316. protected _getTypeName(): string;
  76317. /** @hidden */
  76318. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76319. private _updateSquareProps;
  76320. private _drawGradientSquare;
  76321. private _drawCircle;
  76322. private _createColorWheelCanvas;
  76323. /** @hidden */
  76324. _draw(context: CanvasRenderingContext2D): void;
  76325. private _pointerIsDown;
  76326. private _updateValueFromPointer;
  76327. private _isPointOnSquare;
  76328. private _isPointOnWheel;
  76329. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76330. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76331. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76332. /**
  76333. * This function expands the color picker by creating a color picker dialog with manual
  76334. * color value input and the ability to save colors into an array to be used later in
  76335. * subsequent launches of the dialogue.
  76336. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76337. * @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.
  76338. * @returns picked color as a hex string and the saved colors array as hex strings.
  76339. */
  76340. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76341. pickerWidth?: string;
  76342. pickerHeight?: string;
  76343. headerHeight?: string;
  76344. lastColor?: string;
  76345. swatchLimit?: number;
  76346. numSwatchesPerLine?: number;
  76347. savedColors?: Array<string>;
  76348. }): Promise<{
  76349. savedColors?: string[];
  76350. pickedColor: string;
  76351. }>;
  76352. }
  76353. }
  76354. declare module BABYLON.GUI {
  76355. /** Class used to create 2D ellipse containers */
  76356. export class Ellipse extends Container {
  76357. name?: string | undefined;
  76358. private _thickness;
  76359. /** Gets or sets border thickness */
  76360. get thickness(): number;
  76361. set thickness(value: number);
  76362. /**
  76363. * Creates a new Ellipse
  76364. * @param name defines the control name
  76365. */
  76366. constructor(name?: string | undefined);
  76367. protected _getTypeName(): string;
  76368. protected _localDraw(context: CanvasRenderingContext2D): void;
  76369. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76370. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76371. }
  76372. }
  76373. declare module BABYLON.GUI {
  76374. /**
  76375. * Class used to create a password control
  76376. */
  76377. export class InputPassword extends InputText {
  76378. protected _beforeRenderText(text: string): string;
  76379. }
  76380. }
  76381. declare module BABYLON.GUI {
  76382. /** Class used to render 2D lines */
  76383. export class Line extends Control {
  76384. name?: string | undefined;
  76385. private _lineWidth;
  76386. private _x1;
  76387. private _y1;
  76388. private _x2;
  76389. private _y2;
  76390. private _dash;
  76391. private _connectedControl;
  76392. private _connectedControlDirtyObserver;
  76393. /** Gets or sets the dash pattern */
  76394. get dash(): Array<number>;
  76395. set dash(value: Array<number>);
  76396. /** Gets or sets the control connected with the line end */
  76397. get connectedControl(): Control;
  76398. set connectedControl(value: Control);
  76399. /** Gets or sets start coordinates on X axis */
  76400. get x1(): string | number;
  76401. set x1(value: string | number);
  76402. /** Gets or sets start coordinates on Y axis */
  76403. get y1(): string | number;
  76404. set y1(value: string | number);
  76405. /** Gets or sets end coordinates on X axis */
  76406. get x2(): string | number;
  76407. set x2(value: string | number);
  76408. /** Gets or sets end coordinates on Y axis */
  76409. get y2(): string | number;
  76410. set y2(value: string | number);
  76411. /** Gets or sets line width */
  76412. get lineWidth(): number;
  76413. set lineWidth(value: number);
  76414. /** Gets or sets horizontal alignment */
  76415. set horizontalAlignment(value: number);
  76416. /** Gets or sets vertical alignment */
  76417. set verticalAlignment(value: number);
  76418. private get _effectiveX2();
  76419. private get _effectiveY2();
  76420. /**
  76421. * Creates a new Line
  76422. * @param name defines the control name
  76423. */
  76424. constructor(name?: string | undefined);
  76425. protected _getTypeName(): string;
  76426. _draw(context: CanvasRenderingContext2D): void;
  76427. _measure(): void;
  76428. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76429. /**
  76430. * Move one end of the line given 3D cartesian coordinates.
  76431. * @param position Targeted world position
  76432. * @param scene BABYLON.Scene
  76433. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76434. */
  76435. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76436. /**
  76437. * Move one end of the line to a position in screen absolute space.
  76438. * @param projectedPosition Position in screen absolute space (X, Y)
  76439. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76440. */
  76441. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76442. }
  76443. }
  76444. declare module BABYLON.GUI {
  76445. /**
  76446. * Class used to store a point for a MultiLine object.
  76447. * The point can be pure 2D coordinates, a mesh or a control
  76448. */
  76449. export class MultiLinePoint {
  76450. private _multiLine;
  76451. private _x;
  76452. private _y;
  76453. private _control;
  76454. private _mesh;
  76455. private _controlObserver;
  76456. private _meshObserver;
  76457. /** @hidden */
  76458. _point: BABYLON.Vector2;
  76459. /**
  76460. * Creates a new MultiLinePoint
  76461. * @param multiLine defines the source MultiLine object
  76462. */
  76463. constructor(multiLine: MultiLine);
  76464. /** Gets or sets x coordinate */
  76465. get x(): string | number;
  76466. set x(value: string | number);
  76467. /** Gets or sets y coordinate */
  76468. get y(): string | number;
  76469. set y(value: string | number);
  76470. /** Gets or sets the control associated with this point */
  76471. get control(): BABYLON.Nullable<Control>;
  76472. set control(value: BABYLON.Nullable<Control>);
  76473. /** Gets or sets the mesh associated with this point */
  76474. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76475. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76476. /** Resets links */
  76477. resetLinks(): void;
  76478. /**
  76479. * Gets a translation vector
  76480. * @returns the translation vector
  76481. */
  76482. translate(): BABYLON.Vector2;
  76483. private _translatePoint;
  76484. /** Release associated resources */
  76485. dispose(): void;
  76486. }
  76487. }
  76488. declare module BABYLON.GUI {
  76489. /**
  76490. * Class used to create multi line control
  76491. */
  76492. export class MultiLine extends Control {
  76493. name?: string | undefined;
  76494. private _lineWidth;
  76495. private _dash;
  76496. private _points;
  76497. private _minX;
  76498. private _minY;
  76499. private _maxX;
  76500. private _maxY;
  76501. /**
  76502. * Creates a new MultiLine
  76503. * @param name defines the control name
  76504. */
  76505. constructor(name?: string | undefined);
  76506. /** Gets or sets dash pattern */
  76507. get dash(): Array<number>;
  76508. set dash(value: Array<number>);
  76509. /**
  76510. * Gets point stored at specified index
  76511. * @param index defines the index to look for
  76512. * @returns the requested point if found
  76513. */
  76514. getAt(index: number): MultiLinePoint;
  76515. /** Function called when a point is updated */
  76516. onPointUpdate: () => void;
  76517. /**
  76518. * Adds new points to the point collection
  76519. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76520. * @returns the list of created MultiLinePoint
  76521. */
  76522. add(...items: (AbstractMesh | Control | {
  76523. x: string | number;
  76524. y: string | number;
  76525. })[]): MultiLinePoint[];
  76526. /**
  76527. * Adds a new point to the point collection
  76528. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76529. * @returns the created MultiLinePoint
  76530. */
  76531. push(item?: (AbstractMesh | Control | {
  76532. x: string | number;
  76533. y: string | number;
  76534. })): MultiLinePoint;
  76535. /**
  76536. * Remove a specific value or point from the active point collection
  76537. * @param value defines the value or point to remove
  76538. */
  76539. remove(value: number | MultiLinePoint): void;
  76540. /**
  76541. * Resets this object to initial state (no point)
  76542. */
  76543. reset(): void;
  76544. /**
  76545. * Resets all links
  76546. */
  76547. resetLinks(): void;
  76548. /** Gets or sets line width */
  76549. get lineWidth(): number;
  76550. set lineWidth(value: number);
  76551. set horizontalAlignment(value: number);
  76552. set verticalAlignment(value: number);
  76553. protected _getTypeName(): string;
  76554. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76555. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76556. _measure(): void;
  76557. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76558. dispose(): void;
  76559. }
  76560. }
  76561. declare module BABYLON.GUI {
  76562. /**
  76563. * Class used to create radio button controls
  76564. */
  76565. export class RadioButton extends Control {
  76566. name?: string | undefined;
  76567. private _isChecked;
  76568. private _background;
  76569. private _checkSizeRatio;
  76570. private _thickness;
  76571. /** Gets or sets border thickness */
  76572. get thickness(): number;
  76573. set thickness(value: number);
  76574. /** Gets or sets group name */
  76575. group: string;
  76576. /** BABYLON.Observable raised when isChecked is changed */
  76577. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76578. /** Gets or sets a value indicating the ratio between overall size and check size */
  76579. get checkSizeRatio(): number;
  76580. set checkSizeRatio(value: number);
  76581. /** Gets or sets background color */
  76582. get background(): string;
  76583. set background(value: string);
  76584. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76585. get isChecked(): boolean;
  76586. set isChecked(value: boolean);
  76587. /**
  76588. * Creates a new RadioButton
  76589. * @param name defines the control name
  76590. */
  76591. constructor(name?: string | undefined);
  76592. protected _getTypeName(): string;
  76593. _draw(context: CanvasRenderingContext2D): void;
  76594. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76595. /**
  76596. * Utility function to easily create a radio button with a header
  76597. * @param title defines the label to use for the header
  76598. * @param group defines the group to use for the radio button
  76599. * @param isChecked defines the initial state of the radio button
  76600. * @param onValueChanged defines the callback to call when value changes
  76601. * @returns a StackPanel containing the radio button and a textBlock
  76602. */
  76603. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76604. }
  76605. }
  76606. declare module BABYLON.GUI {
  76607. /**
  76608. * Class used to create slider controls
  76609. */
  76610. export class BaseSlider extends Control {
  76611. name?: string | undefined;
  76612. protected _thumbWidth: ValueAndUnit;
  76613. private _minimum;
  76614. private _maximum;
  76615. private _value;
  76616. private _isVertical;
  76617. protected _barOffset: ValueAndUnit;
  76618. private _isThumbClamped;
  76619. protected _displayThumb: boolean;
  76620. private _step;
  76621. private _lastPointerDownID;
  76622. protected _effectiveBarOffset: number;
  76623. protected _renderLeft: number;
  76624. protected _renderTop: number;
  76625. protected _renderWidth: number;
  76626. protected _renderHeight: number;
  76627. protected _backgroundBoxLength: number;
  76628. protected _backgroundBoxThickness: number;
  76629. protected _effectiveThumbThickness: number;
  76630. /** BABYLON.Observable raised when the sldier value changes */
  76631. onValueChangedObservable: BABYLON.Observable<number>;
  76632. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76633. get displayThumb(): boolean;
  76634. set displayThumb(value: boolean);
  76635. /** Gets or sets a step to apply to values (0 by default) */
  76636. get step(): number;
  76637. set step(value: number);
  76638. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76639. get barOffset(): string | number;
  76640. /** Gets main bar offset in pixels*/
  76641. get barOffsetInPixels(): number;
  76642. set barOffset(value: string | number);
  76643. /** Gets or sets thumb width */
  76644. get thumbWidth(): string | number;
  76645. /** Gets thumb width in pixels */
  76646. get thumbWidthInPixels(): number;
  76647. set thumbWidth(value: string | number);
  76648. /** Gets or sets minimum value */
  76649. get minimum(): number;
  76650. set minimum(value: number);
  76651. /** Gets or sets maximum value */
  76652. get maximum(): number;
  76653. set maximum(value: number);
  76654. /** Gets or sets current value */
  76655. get value(): number;
  76656. set value(value: number);
  76657. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76658. get isVertical(): boolean;
  76659. set isVertical(value: boolean);
  76660. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76661. get isThumbClamped(): boolean;
  76662. set isThumbClamped(value: boolean);
  76663. /**
  76664. * Creates a new BaseSlider
  76665. * @param name defines the control name
  76666. */
  76667. constructor(name?: string | undefined);
  76668. protected _getTypeName(): string;
  76669. protected _getThumbPosition(): number;
  76670. protected _getThumbThickness(type: string): number;
  76671. protected _prepareRenderingData(type: string): void;
  76672. private _pointerIsDown;
  76673. /** @hidden */
  76674. protected _updateValueFromPointer(x: number, y: number): void;
  76675. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76676. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76677. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76678. }
  76679. }
  76680. declare module BABYLON.GUI {
  76681. /**
  76682. * Class used to create slider controls
  76683. */
  76684. export class Slider extends BaseSlider {
  76685. name?: string | undefined;
  76686. private _background;
  76687. private _borderColor;
  76688. private _isThumbCircle;
  76689. protected _displayValueBar: boolean;
  76690. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76691. get displayValueBar(): boolean;
  76692. set displayValueBar(value: boolean);
  76693. /** Gets or sets border color */
  76694. get borderColor(): string;
  76695. set borderColor(value: string);
  76696. /** Gets or sets background color */
  76697. get background(): string;
  76698. set background(value: string);
  76699. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76700. get isThumbCircle(): boolean;
  76701. set isThumbCircle(value: boolean);
  76702. /**
  76703. * Creates a new Slider
  76704. * @param name defines the control name
  76705. */
  76706. constructor(name?: string | undefined);
  76707. protected _getTypeName(): string;
  76708. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76709. }
  76710. }
  76711. declare module BABYLON.GUI {
  76712. /** Class used to create a RadioGroup
  76713. * which contains groups of radio buttons
  76714. */
  76715. export class SelectorGroup {
  76716. /** name of SelectorGroup */
  76717. name: string;
  76718. private _groupPanel;
  76719. private _selectors;
  76720. private _groupHeader;
  76721. /**
  76722. * Creates a new SelectorGroup
  76723. * @param name of group, used as a group heading
  76724. */
  76725. constructor(
  76726. /** name of SelectorGroup */
  76727. name: string);
  76728. /** Gets the groupPanel of the SelectorGroup */
  76729. get groupPanel(): StackPanel;
  76730. /** Gets the selectors array */
  76731. get selectors(): StackPanel[];
  76732. /** Gets and sets the group header */
  76733. get header(): string;
  76734. set header(label: string);
  76735. /** @hidden */
  76736. private _addGroupHeader;
  76737. /** @hidden*/
  76738. _getSelector(selectorNb: number): StackPanel | undefined;
  76739. /** Removes the selector at the given position
  76740. * @param selectorNb the position of the selector within the group
  76741. */
  76742. removeSelector(selectorNb: number): void;
  76743. }
  76744. /** Class used to create a CheckboxGroup
  76745. * which contains groups of checkbox buttons
  76746. */
  76747. export class CheckboxGroup extends SelectorGroup {
  76748. /** Adds a checkbox as a control
  76749. * @param text is the label for the selector
  76750. * @param func is the function called when the Selector is checked
  76751. * @param checked is true when Selector is checked
  76752. */
  76753. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76754. /** @hidden */
  76755. _setSelectorLabel(selectorNb: number, label: string): void;
  76756. /** @hidden */
  76757. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76758. /** @hidden */
  76759. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76760. /** @hidden */
  76761. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76762. }
  76763. /** Class used to create a RadioGroup
  76764. * which contains groups of radio buttons
  76765. */
  76766. export class RadioGroup extends SelectorGroup {
  76767. private _selectNb;
  76768. /** Adds a radio button as a control
  76769. * @param label is the label for the selector
  76770. * @param func is the function called when the Selector is checked
  76771. * @param checked is true when Selector is checked
  76772. */
  76773. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76774. /** @hidden */
  76775. _setSelectorLabel(selectorNb: number, label: string): void;
  76776. /** @hidden */
  76777. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76778. /** @hidden */
  76779. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76780. /** @hidden */
  76781. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76782. }
  76783. /** Class used to create a SliderGroup
  76784. * which contains groups of slider buttons
  76785. */
  76786. export class SliderGroup extends SelectorGroup {
  76787. /**
  76788. * Adds a slider to the SelectorGroup
  76789. * @param label is the label for the SliderBar
  76790. * @param func is the function called when the Slider moves
  76791. * @param unit is a string describing the units used, eg degrees or metres
  76792. * @param min is the minimum value for the Slider
  76793. * @param max is the maximum value for the Slider
  76794. * @param value is the start value for the Slider between min and max
  76795. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76796. */
  76797. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76798. /** @hidden */
  76799. _setSelectorLabel(selectorNb: number, label: string): void;
  76800. /** @hidden */
  76801. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76802. /** @hidden */
  76803. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76804. /** @hidden */
  76805. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76806. }
  76807. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76808. * @see http://doc.babylonjs.com/how_to/selector
  76809. */
  76810. export class SelectionPanel extends Rectangle {
  76811. /** name of SelectionPanel */
  76812. name: string;
  76813. /** an array of SelectionGroups */
  76814. groups: SelectorGroup[];
  76815. private _panel;
  76816. private _buttonColor;
  76817. private _buttonBackground;
  76818. private _headerColor;
  76819. private _barColor;
  76820. private _barHeight;
  76821. private _spacerHeight;
  76822. private _labelColor;
  76823. private _groups;
  76824. private _bars;
  76825. /**
  76826. * Creates a new SelectionPanel
  76827. * @param name of SelectionPanel
  76828. * @param groups is an array of SelectionGroups
  76829. */
  76830. constructor(
  76831. /** name of SelectionPanel */
  76832. name: string,
  76833. /** an array of SelectionGroups */
  76834. groups?: SelectorGroup[]);
  76835. protected _getTypeName(): string;
  76836. /** Gets or sets the headerColor */
  76837. get headerColor(): string;
  76838. set headerColor(color: string);
  76839. private _setHeaderColor;
  76840. /** Gets or sets the button color */
  76841. get buttonColor(): string;
  76842. set buttonColor(color: string);
  76843. private _setbuttonColor;
  76844. /** Gets or sets the label color */
  76845. get labelColor(): string;
  76846. set labelColor(color: string);
  76847. private _setLabelColor;
  76848. /** Gets or sets the button background */
  76849. get buttonBackground(): string;
  76850. set buttonBackground(color: string);
  76851. private _setButtonBackground;
  76852. /** Gets or sets the color of separator bar */
  76853. get barColor(): string;
  76854. set barColor(color: string);
  76855. private _setBarColor;
  76856. /** Gets or sets the height of separator bar */
  76857. get barHeight(): string;
  76858. set barHeight(value: string);
  76859. private _setBarHeight;
  76860. /** Gets or sets the height of spacers*/
  76861. get spacerHeight(): string;
  76862. set spacerHeight(value: string);
  76863. private _setSpacerHeight;
  76864. /** Adds a bar between groups */
  76865. private _addSpacer;
  76866. /** Add a group to the selection panel
  76867. * @param group is the selector group to add
  76868. */
  76869. addGroup(group: SelectorGroup): void;
  76870. /** Remove the group from the given position
  76871. * @param groupNb is the position of the group in the list
  76872. */
  76873. removeGroup(groupNb: number): void;
  76874. /** Change a group header label
  76875. * @param label is the new group header label
  76876. * @param groupNb is the number of the group to relabel
  76877. * */
  76878. setHeaderName(label: string, groupNb: number): void;
  76879. /** Change selector label to the one given
  76880. * @param label is the new selector label
  76881. * @param groupNb is the number of the groupcontaining the selector
  76882. * @param selectorNb is the number of the selector within a group to relabel
  76883. * */
  76884. relabel(label: string, groupNb: number, selectorNb: number): void;
  76885. /** For a given group position remove the selector at the given position
  76886. * @param groupNb is the number of the group to remove the selector from
  76887. * @param selectorNb is the number of the selector within the group
  76888. */
  76889. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76890. /** For a given group position of correct type add a checkbox button
  76891. * @param groupNb is the number of the group to remove the selector from
  76892. * @param label is the label for the selector
  76893. * @param func is the function called when the Selector is checked
  76894. * @param checked is true when Selector is checked
  76895. */
  76896. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76897. /** For a given group position of correct type add a radio button
  76898. * @param groupNb is the number of the group to remove the selector from
  76899. * @param label is the label for the selector
  76900. * @param func is the function called when the Selector is checked
  76901. * @param checked is true when Selector is checked
  76902. */
  76903. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76904. /**
  76905. * For a given slider group add a slider
  76906. * @param groupNb is the number of the group to add the slider to
  76907. * @param label is the label for the Slider
  76908. * @param func is the function called when the Slider moves
  76909. * @param unit is a string describing the units used, eg degrees or metres
  76910. * @param min is the minimum value for the Slider
  76911. * @param max is the maximum value for the Slider
  76912. * @param value is the start value for the Slider between min and max
  76913. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76914. */
  76915. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76916. }
  76917. }
  76918. declare module BABYLON.GUI {
  76919. /**
  76920. * Class used to hold a the container for ScrollViewer
  76921. * @hidden
  76922. */
  76923. export class _ScrollViewerWindow extends Container {
  76924. parentClientWidth: number;
  76925. parentClientHeight: number;
  76926. private _freezeControls;
  76927. private _parentMeasure;
  76928. private _oldLeft;
  76929. private _oldTop;
  76930. get freezeControls(): boolean;
  76931. set freezeControls(value: boolean);
  76932. private _bucketWidth;
  76933. private _bucketHeight;
  76934. private _buckets;
  76935. private _bucketLen;
  76936. get bucketWidth(): number;
  76937. get bucketHeight(): number;
  76938. setBucketSizes(width: number, height: number): void;
  76939. private _useBuckets;
  76940. private _makeBuckets;
  76941. private _dispatchInBuckets;
  76942. private _updateMeasures;
  76943. private _updateChildrenMeasures;
  76944. private _restoreMeasures;
  76945. /**
  76946. * Creates a new ScrollViewerWindow
  76947. * @param name of ScrollViewerWindow
  76948. */
  76949. constructor(name?: string);
  76950. protected _getTypeName(): string;
  76951. /** @hidden */
  76952. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76953. /** @hidden */
  76954. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76955. private _scrollChildren;
  76956. private _scrollChildrenWithBuckets;
  76957. /** @hidden */
  76958. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76959. protected _postMeasure(): void;
  76960. }
  76961. }
  76962. declare module BABYLON.GUI {
  76963. /**
  76964. * Class used to create slider controls
  76965. */
  76966. export class ScrollBar extends BaseSlider {
  76967. name?: string | undefined;
  76968. private _background;
  76969. private _borderColor;
  76970. private _tempMeasure;
  76971. /** Gets or sets border color */
  76972. get borderColor(): string;
  76973. set borderColor(value: string);
  76974. /** Gets or sets background color */
  76975. get background(): string;
  76976. set background(value: string);
  76977. /**
  76978. * Creates a new Slider
  76979. * @param name defines the control name
  76980. */
  76981. constructor(name?: string | undefined);
  76982. protected _getTypeName(): string;
  76983. protected _getThumbThickness(): number;
  76984. _draw(context: CanvasRenderingContext2D): void;
  76985. private _first;
  76986. private _originX;
  76987. private _originY;
  76988. /** @hidden */
  76989. protected _updateValueFromPointer(x: number, y: number): void;
  76990. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76991. }
  76992. }
  76993. declare module BABYLON.GUI {
  76994. /**
  76995. * Class used to create slider controls
  76996. */
  76997. export class ImageScrollBar extends BaseSlider {
  76998. name?: string | undefined;
  76999. private _backgroundBaseImage;
  77000. private _backgroundImage;
  77001. private _thumbImage;
  77002. private _thumbBaseImage;
  77003. private _thumbLength;
  77004. private _thumbHeight;
  77005. private _barImageHeight;
  77006. private _tempMeasure;
  77007. /** Number of 90° rotation to apply on the images when in vertical mode */
  77008. num90RotationInVerticalMode: number;
  77009. /**
  77010. * Gets or sets the image used to render the background for horizontal bar
  77011. */
  77012. get backgroundImage(): Image;
  77013. set backgroundImage(value: Image);
  77014. /**
  77015. * Gets or sets the image used to render the thumb
  77016. */
  77017. get thumbImage(): Image;
  77018. set thumbImage(value: Image);
  77019. /**
  77020. * Gets or sets the length of the thumb
  77021. */
  77022. get thumbLength(): number;
  77023. set thumbLength(value: number);
  77024. /**
  77025. * Gets or sets the height of the thumb
  77026. */
  77027. get thumbHeight(): number;
  77028. set thumbHeight(value: number);
  77029. /**
  77030. * Gets or sets the height of the bar image
  77031. */
  77032. get barImageHeight(): number;
  77033. set barImageHeight(value: number);
  77034. /**
  77035. * Creates a new ImageScrollBar
  77036. * @param name defines the control name
  77037. */
  77038. constructor(name?: string | undefined);
  77039. protected _getTypeName(): string;
  77040. protected _getThumbThickness(): number;
  77041. _draw(context: CanvasRenderingContext2D): void;
  77042. private _first;
  77043. private _originX;
  77044. private _originY;
  77045. /** @hidden */
  77046. protected _updateValueFromPointer(x: number, y: number): void;
  77047. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77048. }
  77049. }
  77050. declare module BABYLON.GUI {
  77051. /**
  77052. * Class used to hold a viewer window and sliders in a grid
  77053. */
  77054. export class ScrollViewer extends Rectangle {
  77055. private _grid;
  77056. private _horizontalBarSpace;
  77057. private _verticalBarSpace;
  77058. private _dragSpace;
  77059. private _horizontalBar;
  77060. private _verticalBar;
  77061. private _barColor;
  77062. private _barBackground;
  77063. private _barImage;
  77064. private _horizontalBarImage;
  77065. private _verticalBarImage;
  77066. private _barBackgroundImage;
  77067. private _horizontalBarBackgroundImage;
  77068. private _verticalBarBackgroundImage;
  77069. private _barSize;
  77070. private _window;
  77071. private _pointerIsOver;
  77072. private _wheelPrecision;
  77073. private _onWheelObserver;
  77074. private _clientWidth;
  77075. private _clientHeight;
  77076. private _useImageBar;
  77077. private _thumbLength;
  77078. private _thumbHeight;
  77079. private _barImageHeight;
  77080. private _horizontalBarImageHeight;
  77081. private _verticalBarImageHeight;
  77082. private _oldWindowContentsWidth;
  77083. private _oldWindowContentsHeight;
  77084. /**
  77085. * Gets the horizontal scrollbar
  77086. */
  77087. get horizontalBar(): ScrollBar | ImageScrollBar;
  77088. /**
  77089. * Gets the vertical scrollbar
  77090. */
  77091. get verticalBar(): ScrollBar | ImageScrollBar;
  77092. /**
  77093. * Adds a new control to the current container
  77094. * @param control defines the control to add
  77095. * @returns the current container
  77096. */
  77097. addControl(control: BABYLON.Nullable<Control>): Container;
  77098. /**
  77099. * Removes a control from the current container
  77100. * @param control defines the control to remove
  77101. * @returns the current container
  77102. */
  77103. removeControl(control: Control): Container;
  77104. /** Gets the list of children */
  77105. get children(): Control[];
  77106. _flagDescendantsAsMatrixDirty(): void;
  77107. /**
  77108. * Freezes or unfreezes the controls in the window.
  77109. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77110. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77111. */
  77112. get freezeControls(): boolean;
  77113. set freezeControls(value: boolean);
  77114. /** Gets the bucket width */
  77115. get bucketWidth(): number;
  77116. /** Gets the bucket height */
  77117. get bucketHeight(): number;
  77118. /**
  77119. * Sets the bucket sizes.
  77120. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77121. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77122. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77123. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77124. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77125. * used), that's why it is not enabled by default.
  77126. * @param width width of the bucket
  77127. * @param height height of the bucket
  77128. */
  77129. setBucketSizes(width: number, height: number): void;
  77130. private _forceHorizontalBar;
  77131. private _forceVerticalBar;
  77132. /**
  77133. * Forces the horizontal scroll bar to be displayed
  77134. */
  77135. get forceHorizontalBar(): boolean;
  77136. set forceHorizontalBar(value: boolean);
  77137. /**
  77138. * Forces the vertical scroll bar to be displayed
  77139. */
  77140. get forceVerticalBar(): boolean;
  77141. set forceVerticalBar(value: boolean);
  77142. /**
  77143. * Creates a new ScrollViewer
  77144. * @param name of ScrollViewer
  77145. */
  77146. constructor(name?: string, isImageBased?: boolean);
  77147. /** Reset the scroll viewer window to initial size */
  77148. resetWindow(): void;
  77149. protected _getTypeName(): string;
  77150. private _buildClientSizes;
  77151. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77152. protected _postMeasure(): void;
  77153. /**
  77154. * Gets or sets the mouse wheel precision
  77155. * from 0 to 1 with a default value of 0.05
  77156. * */
  77157. get wheelPrecision(): number;
  77158. set wheelPrecision(value: number);
  77159. /** Gets or sets the scroll bar container background color */
  77160. get scrollBackground(): string;
  77161. set scrollBackground(color: string);
  77162. /** Gets or sets the bar color */
  77163. get barColor(): string;
  77164. set barColor(color: string);
  77165. /** Gets or sets the bar image */
  77166. get thumbImage(): Image;
  77167. set thumbImage(value: Image);
  77168. /** Gets or sets the horizontal bar image */
  77169. get horizontalThumbImage(): Image;
  77170. set horizontalThumbImage(value: Image);
  77171. /** Gets or sets the vertical bar image */
  77172. get verticalThumbImage(): Image;
  77173. set verticalThumbImage(value: Image);
  77174. /** Gets or sets the size of the bar */
  77175. get barSize(): number;
  77176. set barSize(value: number);
  77177. /** Gets or sets the length of the thumb */
  77178. get thumbLength(): number;
  77179. set thumbLength(value: number);
  77180. /** Gets or sets the height of the thumb */
  77181. get thumbHeight(): number;
  77182. set thumbHeight(value: number);
  77183. /** Gets or sets the height of the bar image */
  77184. get barImageHeight(): number;
  77185. set barImageHeight(value: number);
  77186. /** Gets or sets the height of the horizontal bar image */
  77187. get horizontalBarImageHeight(): number;
  77188. set horizontalBarImageHeight(value: number);
  77189. /** Gets or sets the height of the vertical bar image */
  77190. get verticalBarImageHeight(): number;
  77191. set verticalBarImageHeight(value: number);
  77192. /** Gets or sets the bar background */
  77193. get barBackground(): string;
  77194. set barBackground(color: string);
  77195. /** Gets or sets the bar background image */
  77196. get barImage(): Image;
  77197. set barImage(value: Image);
  77198. /** Gets or sets the horizontal bar background image */
  77199. get horizontalBarImage(): Image;
  77200. set horizontalBarImage(value: Image);
  77201. /** Gets or sets the vertical bar background image */
  77202. get verticalBarImage(): Image;
  77203. set verticalBarImage(value: Image);
  77204. private _setWindowPosition;
  77205. /** @hidden */
  77206. private _updateScroller;
  77207. _link(host: AdvancedDynamicTexture): void;
  77208. /** @hidden */
  77209. private _addBar;
  77210. /** @hidden */
  77211. private _attachWheel;
  77212. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77213. /** Releases associated resources */
  77214. dispose(): void;
  77215. }
  77216. }
  77217. declare module BABYLON.GUI {
  77218. /** Class used to render a grid */
  77219. export class DisplayGrid extends Control {
  77220. name?: string | undefined;
  77221. private _cellWidth;
  77222. private _cellHeight;
  77223. private _minorLineTickness;
  77224. private _minorLineColor;
  77225. private _majorLineTickness;
  77226. private _majorLineColor;
  77227. private _majorLineFrequency;
  77228. private _background;
  77229. private _displayMajorLines;
  77230. private _displayMinorLines;
  77231. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77232. get displayMinorLines(): boolean;
  77233. set displayMinorLines(value: boolean);
  77234. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77235. get displayMajorLines(): boolean;
  77236. set displayMajorLines(value: boolean);
  77237. /** Gets or sets background color (Black by default) */
  77238. get background(): string;
  77239. set background(value: string);
  77240. /** Gets or sets the width of each cell (20 by default) */
  77241. get cellWidth(): number;
  77242. set cellWidth(value: number);
  77243. /** Gets or sets the height of each cell (20 by default) */
  77244. get cellHeight(): number;
  77245. set cellHeight(value: number);
  77246. /** Gets or sets the tickness of minor lines (1 by default) */
  77247. get minorLineTickness(): number;
  77248. set minorLineTickness(value: number);
  77249. /** Gets or sets the color of minor lines (DarkGray by default) */
  77250. get minorLineColor(): string;
  77251. set minorLineColor(value: string);
  77252. /** Gets or sets the tickness of major lines (2 by default) */
  77253. get majorLineTickness(): number;
  77254. set majorLineTickness(value: number);
  77255. /** Gets or sets the color of major lines (White by default) */
  77256. get majorLineColor(): string;
  77257. set majorLineColor(value: string);
  77258. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77259. get majorLineFrequency(): number;
  77260. set majorLineFrequency(value: number);
  77261. /**
  77262. * Creates a new GridDisplayRectangle
  77263. * @param name defines the control name
  77264. */
  77265. constructor(name?: string | undefined);
  77266. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77267. protected _getTypeName(): string;
  77268. }
  77269. }
  77270. declare module BABYLON.GUI {
  77271. /**
  77272. * Class used to create slider controls based on images
  77273. */
  77274. export class ImageBasedSlider extends BaseSlider {
  77275. name?: string | undefined;
  77276. private _backgroundImage;
  77277. private _thumbImage;
  77278. private _valueBarImage;
  77279. private _tempMeasure;
  77280. get displayThumb(): boolean;
  77281. set displayThumb(value: boolean);
  77282. /**
  77283. * Gets or sets the image used to render the background
  77284. */
  77285. get backgroundImage(): Image;
  77286. set backgroundImage(value: Image);
  77287. /**
  77288. * Gets or sets the image used to render the value bar
  77289. */
  77290. get valueBarImage(): Image;
  77291. set valueBarImage(value: Image);
  77292. /**
  77293. * Gets or sets the image used to render the thumb
  77294. */
  77295. get thumbImage(): Image;
  77296. set thumbImage(value: Image);
  77297. /**
  77298. * Creates a new ImageBasedSlider
  77299. * @param name defines the control name
  77300. */
  77301. constructor(name?: string | undefined);
  77302. protected _getTypeName(): string;
  77303. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77304. }
  77305. }
  77306. declare module BABYLON.GUI {
  77307. /**
  77308. * Forcing an export so that this code will execute
  77309. * @hidden
  77310. */
  77311. const name = "Statics";
  77312. }
  77313. declare module BABYLON.GUI {
  77314. /**
  77315. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77316. */
  77317. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77318. /**
  77319. * Define the instrumented AdvancedDynamicTexture.
  77320. */
  77321. texture: AdvancedDynamicTexture;
  77322. private _captureRenderTime;
  77323. private _renderTime;
  77324. private _captureLayoutTime;
  77325. private _layoutTime;
  77326. private _onBeginRenderObserver;
  77327. private _onEndRenderObserver;
  77328. private _onBeginLayoutObserver;
  77329. private _onEndLayoutObserver;
  77330. /**
  77331. * Gets the perf counter used to capture render time
  77332. */
  77333. get renderTimeCounter(): BABYLON.PerfCounter;
  77334. /**
  77335. * Gets the perf counter used to capture layout time
  77336. */
  77337. get layoutTimeCounter(): BABYLON.PerfCounter;
  77338. /**
  77339. * Enable or disable the render time capture
  77340. */
  77341. get captureRenderTime(): boolean;
  77342. set captureRenderTime(value: boolean);
  77343. /**
  77344. * Enable or disable the layout time capture
  77345. */
  77346. get captureLayoutTime(): boolean;
  77347. set captureLayoutTime(value: boolean);
  77348. /**
  77349. * Instantiates a new advanced dynamic texture instrumentation.
  77350. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77351. * @param texture Defines the AdvancedDynamicTexture to instrument
  77352. */
  77353. constructor(
  77354. /**
  77355. * Define the instrumented AdvancedDynamicTexture.
  77356. */
  77357. texture: AdvancedDynamicTexture);
  77358. /**
  77359. * Dispose and release associated resources.
  77360. */
  77361. dispose(): void;
  77362. }
  77363. }
  77364. declare module BABYLON.GUI {
  77365. /**
  77366. * Class used to load GUI via XML.
  77367. */
  77368. export class XmlLoader {
  77369. private _nodes;
  77370. private _nodeTypes;
  77371. private _isLoaded;
  77372. private _objectAttributes;
  77373. private _parentClass;
  77374. /**
  77375. * Create a new xml loader
  77376. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77377. */
  77378. constructor(parentClass?: null);
  77379. private _getChainElement;
  77380. private _getClassAttribute;
  77381. private _createGuiElement;
  77382. private _parseGrid;
  77383. private _parseElement;
  77384. private _prepareSourceElement;
  77385. private _parseElementsFromSource;
  77386. private _parseXml;
  77387. /**
  77388. * Gets if the loading has finished.
  77389. * @returns whether the loading has finished or not
  77390. */
  77391. isLoaded(): boolean;
  77392. /**
  77393. * Gets a loaded node / control by id.
  77394. * @param id the Controls id set in the xml
  77395. * @returns element of type Control
  77396. */
  77397. getNodeById(id: string): any;
  77398. /**
  77399. * Gets all loaded nodes / controls
  77400. * @returns Array of controls
  77401. */
  77402. getNodes(): any;
  77403. /**
  77404. * Initiates the xml layout loading
  77405. * @param xmlFile defines the xml layout to load
  77406. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77407. * @param callback defines the callback called on layout load.
  77408. */
  77409. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77410. }
  77411. }
  77412. declare module BABYLON.GUI {
  77413. /**
  77414. * Class used to create containers for controls
  77415. */
  77416. export class Container3D extends Control3D {
  77417. private _blockLayout;
  77418. /**
  77419. * Gets the list of child controls
  77420. */
  77421. protected _children: Control3D[];
  77422. /**
  77423. * Gets the list of child controls
  77424. */
  77425. get children(): Array<Control3D>;
  77426. /**
  77427. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77428. * This is helpful to optimize layout operation when adding multiple children in a row
  77429. */
  77430. get blockLayout(): boolean;
  77431. set blockLayout(value: boolean);
  77432. /**
  77433. * Creates a new container
  77434. * @param name defines the container name
  77435. */
  77436. constructor(name?: string);
  77437. /**
  77438. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77439. * @returns the current container
  77440. */
  77441. updateLayout(): Container3D;
  77442. /**
  77443. * Gets a boolean indicating if the given control is in the children of this control
  77444. * @param control defines the control to check
  77445. * @returns true if the control is in the child list
  77446. */
  77447. containsControl(control: Control3D): boolean;
  77448. /**
  77449. * Adds a control to the children of this control
  77450. * @param control defines the control to add
  77451. * @returns the current container
  77452. */
  77453. addControl(control: Control3D): Container3D;
  77454. /**
  77455. * This function will be called everytime a new control is added
  77456. */
  77457. protected _arrangeChildren(): void;
  77458. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77459. /**
  77460. * Removes a control from the children of this control
  77461. * @param control defines the control to remove
  77462. * @returns the current container
  77463. */
  77464. removeControl(control: Control3D): Container3D;
  77465. protected _getTypeName(): string;
  77466. /**
  77467. * Releases all associated resources
  77468. */
  77469. dispose(): void;
  77470. /** Control rotation will remain unchanged */
  77471. static readonly UNSET_ORIENTATION: number;
  77472. /** Control will rotate to make it look at sphere central axis */
  77473. static readonly FACEORIGIN_ORIENTATION: number;
  77474. /** Control will rotate to make it look back at sphere central axis */
  77475. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77476. /** Control will rotate to look at z axis (0, 0, 1) */
  77477. static readonly FACEFORWARD_ORIENTATION: number;
  77478. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77479. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77480. }
  77481. }
  77482. declare module BABYLON.GUI {
  77483. /**
  77484. * Class used to manage 3D user interface
  77485. * @see http://doc.babylonjs.com/how_to/gui3d
  77486. */
  77487. export class GUI3DManager implements BABYLON.IDisposable {
  77488. private _scene;
  77489. private _sceneDisposeObserver;
  77490. private _utilityLayer;
  77491. private _rootContainer;
  77492. private _pointerObserver;
  77493. private _pointerOutObserver;
  77494. /** @hidden */
  77495. _lastPickedControl: Control3D;
  77496. /** @hidden */
  77497. _lastControlOver: {
  77498. [pointerId: number]: Control3D;
  77499. };
  77500. /** @hidden */
  77501. _lastControlDown: {
  77502. [pointerId: number]: Control3D;
  77503. };
  77504. /**
  77505. * BABYLON.Observable raised when the point picked by the pointer events changed
  77506. */
  77507. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77508. /** @hidden */
  77509. _sharedMaterials: {
  77510. [key: string]: BABYLON.Material;
  77511. };
  77512. /** Gets the hosting scene */
  77513. get scene(): BABYLON.Scene;
  77514. /** Gets associated utility layer */
  77515. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77516. /**
  77517. * Creates a new GUI3DManager
  77518. * @param scene
  77519. */
  77520. constructor(scene?: BABYLON.Scene);
  77521. private _handlePointerOut;
  77522. private _doPicking;
  77523. /**
  77524. * Gets the root container
  77525. */
  77526. get rootContainer(): Container3D;
  77527. /**
  77528. * Gets a boolean indicating if the given control is in the root child list
  77529. * @param control defines the control to check
  77530. * @returns true if the control is in the root child list
  77531. */
  77532. containsControl(control: Control3D): boolean;
  77533. /**
  77534. * Adds a control to the root child list
  77535. * @param control defines the control to add
  77536. * @returns the current manager
  77537. */
  77538. addControl(control: Control3D): GUI3DManager;
  77539. /**
  77540. * Removes a control from the root child list
  77541. * @param control defines the control to remove
  77542. * @returns the current container
  77543. */
  77544. removeControl(control: Control3D): GUI3DManager;
  77545. /**
  77546. * Releases all associated resources
  77547. */
  77548. dispose(): void;
  77549. }
  77550. }
  77551. declare module BABYLON.GUI {
  77552. /**
  77553. * Class used to transport BABYLON.Vector3 information for pointer events
  77554. */
  77555. export class Vector3WithInfo extends BABYLON.Vector3 {
  77556. /** defines the current mouse button index */
  77557. buttonIndex: number;
  77558. /**
  77559. * Creates a new Vector3WithInfo
  77560. * @param source defines the vector3 data to transport
  77561. * @param buttonIndex defines the current mouse button index
  77562. */
  77563. constructor(source: BABYLON.Vector3,
  77564. /** defines the current mouse button index */
  77565. buttonIndex?: number);
  77566. }
  77567. }
  77568. declare module BABYLON.GUI {
  77569. /**
  77570. * Class used as base class for controls
  77571. */
  77572. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77573. /** Defines the control name */
  77574. name?: string | undefined;
  77575. /** @hidden */
  77576. _host: GUI3DManager;
  77577. private _node;
  77578. private _downCount;
  77579. private _enterCount;
  77580. private _downPointerIds;
  77581. private _isVisible;
  77582. /** Gets or sets the control position in world space */
  77583. get position(): BABYLON.Vector3;
  77584. set position(value: BABYLON.Vector3);
  77585. /** Gets or sets the control scaling in world space */
  77586. get scaling(): BABYLON.Vector3;
  77587. set scaling(value: BABYLON.Vector3);
  77588. /** Callback used to start pointer enter animation */
  77589. pointerEnterAnimation: () => void;
  77590. /** Callback used to start pointer out animation */
  77591. pointerOutAnimation: () => void;
  77592. /** Callback used to start pointer down animation */
  77593. pointerDownAnimation: () => void;
  77594. /** Callback used to start pointer up animation */
  77595. pointerUpAnimation: () => void;
  77596. /**
  77597. * An event triggered when the pointer move over the control
  77598. */
  77599. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77600. /**
  77601. * An event triggered when the pointer move out of the control
  77602. */
  77603. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77604. /**
  77605. * An event triggered when the pointer taps the control
  77606. */
  77607. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77608. /**
  77609. * An event triggered when pointer is up
  77610. */
  77611. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77612. /**
  77613. * An event triggered when a control is clicked on (with a mouse)
  77614. */
  77615. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77616. /**
  77617. * An event triggered when pointer enters the control
  77618. */
  77619. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77620. /**
  77621. * Gets or sets the parent container
  77622. */
  77623. parent: BABYLON.Nullable<Container3D>;
  77624. private _behaviors;
  77625. /**
  77626. * Gets the list of attached behaviors
  77627. * @see http://doc.babylonjs.com/features/behaviour
  77628. */
  77629. get behaviors(): BABYLON.Behavior<Control3D>[];
  77630. /**
  77631. * Attach a behavior to the control
  77632. * @see http://doc.babylonjs.com/features/behaviour
  77633. * @param behavior defines the behavior to attach
  77634. * @returns the current control
  77635. */
  77636. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77637. /**
  77638. * Remove an attached behavior
  77639. * @see http://doc.babylonjs.com/features/behaviour
  77640. * @param behavior defines the behavior to attach
  77641. * @returns the current control
  77642. */
  77643. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77644. /**
  77645. * Gets an attached behavior by name
  77646. * @param name defines the name of the behavior to look for
  77647. * @see http://doc.babylonjs.com/features/behaviour
  77648. * @returns null if behavior was not found else the requested behavior
  77649. */
  77650. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77651. /** Gets or sets a boolean indicating if the control is visible */
  77652. get isVisible(): boolean;
  77653. set isVisible(value: boolean);
  77654. /**
  77655. * Creates a new control
  77656. * @param name defines the control name
  77657. */
  77658. constructor(
  77659. /** Defines the control name */
  77660. name?: string | undefined);
  77661. /**
  77662. * Gets a string representing the class name
  77663. */
  77664. get typeName(): string;
  77665. /**
  77666. * Get the current class name of the control.
  77667. * @returns current class name
  77668. */
  77669. getClassName(): string;
  77670. protected _getTypeName(): string;
  77671. /**
  77672. * Gets the transform node used by this control
  77673. */
  77674. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77675. /**
  77676. * Gets the mesh used to render this control
  77677. */
  77678. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77679. /**
  77680. * Link the control as child of the given node
  77681. * @param node defines the node to link to. Use null to unlink the control
  77682. * @returns the current control
  77683. */
  77684. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77685. /** @hidden **/
  77686. _prepareNode(scene: BABYLON.Scene): void;
  77687. /**
  77688. * Node creation.
  77689. * Can be overriden by children
  77690. * @param scene defines the scene where the node must be attached
  77691. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77692. */
  77693. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77694. /**
  77695. * Affect a material to the given mesh
  77696. * @param mesh defines the mesh which will represent the control
  77697. */
  77698. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77699. /** @hidden */
  77700. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77701. /** @hidden */
  77702. _onPointerEnter(target: Control3D): boolean;
  77703. /** @hidden */
  77704. _onPointerOut(target: Control3D): void;
  77705. /** @hidden */
  77706. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77707. /** @hidden */
  77708. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77709. /** @hidden */
  77710. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77711. /** @hidden */
  77712. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77713. /** @hidden */
  77714. _disposeNode(): void;
  77715. /**
  77716. * Releases all associated resources
  77717. */
  77718. dispose(): void;
  77719. }
  77720. }
  77721. declare module BABYLON.GUI {
  77722. /**
  77723. * Class used as a root to all buttons
  77724. */
  77725. export class AbstractButton3D extends Control3D {
  77726. /**
  77727. * Creates a new button
  77728. * @param name defines the control name
  77729. */
  77730. constructor(name?: string);
  77731. protected _getTypeName(): string;
  77732. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77733. }
  77734. }
  77735. declare module BABYLON.GUI {
  77736. /**
  77737. * Class used to create a button in 3D
  77738. */
  77739. export class Button3D extends AbstractButton3D {
  77740. /** @hidden */
  77741. protected _currentMaterial: BABYLON.Material;
  77742. private _facadeTexture;
  77743. private _content;
  77744. private _contentResolution;
  77745. private _contentScaleRatio;
  77746. /**
  77747. * Gets or sets the texture resolution used to render content (512 by default)
  77748. */
  77749. get contentResolution(): BABYLON.int;
  77750. set contentResolution(value: BABYLON.int);
  77751. /**
  77752. * Gets or sets the texture scale ratio used to render content (2 by default)
  77753. */
  77754. get contentScaleRatio(): number;
  77755. set contentScaleRatio(value: number);
  77756. protected _disposeFacadeTexture(): void;
  77757. protected _resetContent(): void;
  77758. /**
  77759. * Creates a new button
  77760. * @param name defines the control name
  77761. */
  77762. constructor(name?: string);
  77763. /**
  77764. * Gets or sets the GUI 2D content used to display the button's facade
  77765. */
  77766. get content(): Control;
  77767. set content(value: Control);
  77768. /**
  77769. * Apply the facade texture (created from the content property).
  77770. * This function can be overloaded by child classes
  77771. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77772. */
  77773. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77774. protected _getTypeName(): string;
  77775. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77776. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77777. /**
  77778. * Releases all associated resources
  77779. */
  77780. dispose(): void;
  77781. }
  77782. }
  77783. declare module BABYLON.GUI {
  77784. /**
  77785. * Abstract class used to create a container panel deployed on the surface of a volume
  77786. */
  77787. export abstract class VolumeBasedPanel extends Container3D {
  77788. private _columns;
  77789. private _rows;
  77790. private _rowThenColum;
  77791. private _orientation;
  77792. protected _cellWidth: number;
  77793. protected _cellHeight: number;
  77794. /**
  77795. * Gets or sets the distance between elements
  77796. */
  77797. margin: number;
  77798. /**
  77799. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77800. * | Value | Type | Description |
  77801. * | ----- | ----------------------------------- | ----------- |
  77802. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77803. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77804. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77805. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77806. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77807. */
  77808. get orientation(): number;
  77809. set orientation(value: number);
  77810. /**
  77811. * Gets or sets the number of columns requested (10 by default).
  77812. * The panel will automatically compute the number of rows based on number of child controls.
  77813. */
  77814. get columns(): BABYLON.int;
  77815. set columns(value: BABYLON.int);
  77816. /**
  77817. * Gets or sets a the number of rows requested.
  77818. * The panel will automatically compute the number of columns based on number of child controls.
  77819. */
  77820. get rows(): BABYLON.int;
  77821. set rows(value: BABYLON.int);
  77822. /**
  77823. * Creates new VolumeBasedPanel
  77824. */
  77825. constructor();
  77826. protected _arrangeChildren(): void;
  77827. /** Child classes must implement this function to provide correct control positioning */
  77828. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77829. /** Child classes can implement this function to provide additional processing */
  77830. protected _finalProcessing(): void;
  77831. }
  77832. }
  77833. declare module BABYLON.GUI {
  77834. /**
  77835. * Class used to create a container panel deployed on the surface of a cylinder
  77836. */
  77837. export class CylinderPanel extends VolumeBasedPanel {
  77838. private _radius;
  77839. /**
  77840. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77841. */
  77842. get radius(): BABYLON.float;
  77843. set radius(value: BABYLON.float);
  77844. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77845. private _cylindricalMapping;
  77846. }
  77847. }
  77848. declare module BABYLON.GUI {
  77849. /** @hidden */
  77850. export var fluentVertexShader: {
  77851. name: string;
  77852. shader: string;
  77853. };
  77854. }
  77855. declare module BABYLON.GUI {
  77856. /** @hidden */
  77857. export var fluentPixelShader: {
  77858. name: string;
  77859. shader: string;
  77860. };
  77861. }
  77862. declare module BABYLON.GUI {
  77863. /** @hidden */
  77864. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77865. INNERGLOW: boolean;
  77866. BORDER: boolean;
  77867. HOVERLIGHT: boolean;
  77868. TEXTURE: boolean;
  77869. constructor();
  77870. }
  77871. /**
  77872. * Class used to render controls with fluent desgin
  77873. */
  77874. export class FluentMaterial extends BABYLON.PushMaterial {
  77875. /**
  77876. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77877. */
  77878. innerGlowColorIntensity: number;
  77879. /**
  77880. * Gets or sets the inner glow color (white by default)
  77881. */
  77882. innerGlowColor: BABYLON.Color3;
  77883. /**
  77884. * Gets or sets alpha value (default is 1.0)
  77885. */
  77886. alpha: number;
  77887. /**
  77888. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77889. */
  77890. albedoColor: BABYLON.Color3;
  77891. /**
  77892. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77893. */
  77894. renderBorders: boolean;
  77895. /**
  77896. * Gets or sets border width (default is 0.5)
  77897. */
  77898. borderWidth: number;
  77899. /**
  77900. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77901. */
  77902. edgeSmoothingValue: number;
  77903. /**
  77904. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77905. */
  77906. borderMinValue: number;
  77907. /**
  77908. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77909. */
  77910. renderHoverLight: boolean;
  77911. /**
  77912. * Gets or sets the radius used to render the hover light (default is 1.0)
  77913. */
  77914. hoverRadius: number;
  77915. /**
  77916. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77917. */
  77918. hoverColor: BABYLON.Color4;
  77919. /**
  77920. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77921. */
  77922. hoverPosition: BABYLON.Vector3;
  77923. private _albedoTexture;
  77924. /** Gets or sets the texture to use for albedo color */
  77925. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77926. /**
  77927. * Creates a new Fluent material
  77928. * @param name defines the name of the material
  77929. * @param scene defines the hosting scene
  77930. */
  77931. constructor(name: string, scene: BABYLON.Scene);
  77932. needAlphaBlending(): boolean;
  77933. needAlphaTesting(): boolean;
  77934. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77935. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77936. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77937. getActiveTextures(): BABYLON.BaseTexture[];
  77938. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77939. dispose(forceDisposeEffect?: boolean): void;
  77940. clone(name: string): FluentMaterial;
  77941. serialize(): any;
  77942. getClassName(): string;
  77943. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77944. }
  77945. }
  77946. declare module BABYLON.GUI {
  77947. /**
  77948. * Class used to create a holographic button in 3D
  77949. */
  77950. export class HolographicButton extends Button3D {
  77951. private _backPlate;
  77952. private _textPlate;
  77953. private _frontPlate;
  77954. private _text;
  77955. private _imageUrl;
  77956. private _shareMaterials;
  77957. private _frontMaterial;
  77958. private _backMaterial;
  77959. private _plateMaterial;
  77960. private _pickedPointObserver;
  77961. private _tooltipFade;
  77962. private _tooltipTextBlock;
  77963. private _tooltipTexture;
  77964. private _tooltipMesh;
  77965. private _tooltipHoverObserver;
  77966. private _tooltipOutObserver;
  77967. private _disposeTooltip;
  77968. /**
  77969. * Rendering ground id of all the mesh in the button
  77970. */
  77971. set renderingGroupId(id: number);
  77972. get renderingGroupId(): number;
  77973. /**
  77974. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77975. */
  77976. set tooltipText(text: BABYLON.Nullable<string>);
  77977. get tooltipText(): BABYLON.Nullable<string>;
  77978. /**
  77979. * Gets or sets text for the button
  77980. */
  77981. get text(): string;
  77982. set text(value: string);
  77983. /**
  77984. * Gets or sets the image url for the button
  77985. */
  77986. get imageUrl(): string;
  77987. set imageUrl(value: string);
  77988. /**
  77989. * Gets the back material used by this button
  77990. */
  77991. get backMaterial(): FluentMaterial;
  77992. /**
  77993. * Gets the front material used by this button
  77994. */
  77995. get frontMaterial(): FluentMaterial;
  77996. /**
  77997. * Gets the plate material used by this button
  77998. */
  77999. get plateMaterial(): BABYLON.StandardMaterial;
  78000. /**
  78001. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78002. */
  78003. get shareMaterials(): boolean;
  78004. /**
  78005. * Creates a new button
  78006. * @param name defines the control name
  78007. */
  78008. constructor(name?: string, shareMaterials?: boolean);
  78009. protected _getTypeName(): string;
  78010. private _rebuildContent;
  78011. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78012. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78013. private _createBackMaterial;
  78014. private _createFrontMaterial;
  78015. private _createPlateMaterial;
  78016. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78017. /**
  78018. * Releases all associated resources
  78019. */
  78020. dispose(): void;
  78021. }
  78022. }
  78023. declare module BABYLON.GUI {
  78024. /**
  78025. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78026. */
  78027. export class MeshButton3D extends Button3D {
  78028. /** @hidden */
  78029. protected _currentMesh: BABYLON.Mesh;
  78030. /**
  78031. * Creates a new 3D button based on a mesh
  78032. * @param mesh mesh to become a 3D button
  78033. * @param name defines the control name
  78034. */
  78035. constructor(mesh: BABYLON.Mesh, name?: string);
  78036. protected _getTypeName(): string;
  78037. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78038. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78039. }
  78040. }
  78041. declare module BABYLON.GUI {
  78042. /**
  78043. * Class used to create a container panel deployed on the surface of a plane
  78044. */
  78045. export class PlanePanel extends VolumeBasedPanel {
  78046. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78047. }
  78048. }
  78049. declare module BABYLON.GUI {
  78050. /**
  78051. * Class used to create a container panel where items get randomized planar mapping
  78052. */
  78053. export class ScatterPanel extends VolumeBasedPanel {
  78054. private _iteration;
  78055. /**
  78056. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78057. */
  78058. get iteration(): BABYLON.float;
  78059. set iteration(value: BABYLON.float);
  78060. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78061. private _scatterMapping;
  78062. protected _finalProcessing(): void;
  78063. }
  78064. }
  78065. declare module BABYLON.GUI {
  78066. /**
  78067. * Class used to create a container panel deployed on the surface of a sphere
  78068. */
  78069. export class SpherePanel extends VolumeBasedPanel {
  78070. private _radius;
  78071. /**
  78072. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78073. */
  78074. get radius(): BABYLON.float;
  78075. set radius(value: BABYLON.float);
  78076. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78077. private _sphericalMapping;
  78078. }
  78079. }
  78080. declare module BABYLON.GUI {
  78081. /**
  78082. * Class used to create a stack panel in 3D on XY plane
  78083. */
  78084. export class StackPanel3D extends Container3D {
  78085. private _isVertical;
  78086. /**
  78087. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78088. */
  78089. get isVertical(): boolean;
  78090. set isVertical(value: boolean);
  78091. /**
  78092. * Gets or sets the distance between elements
  78093. */
  78094. margin: number;
  78095. /**
  78096. * Creates new StackPanel
  78097. * @param isVertical
  78098. */
  78099. constructor(isVertical?: boolean);
  78100. protected _arrangeChildren(): void;
  78101. }
  78102. }
  78103. declare module BABYLON {
  78104. /**
  78105. * Configuration for glTF validation
  78106. */
  78107. export interface IGLTFValidationConfiguration {
  78108. /**
  78109. * The url of the glTF validator.
  78110. */
  78111. url: string;
  78112. }
  78113. /**
  78114. * glTF validation
  78115. */
  78116. export class GLTFValidation {
  78117. /**
  78118. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78119. */
  78120. static Configuration: IGLTFValidationConfiguration;
  78121. private static _LoadScriptPromise;
  78122. /**
  78123. * Validate a glTF asset using the glTF-Validator.
  78124. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78125. * @param rootUrl The root url for the glTF
  78126. * @param fileName The file name for the glTF
  78127. * @param getExternalResource The callback to get external resources for the glTF validator
  78128. * @returns A promise that resolves with the glTF validation results once complete
  78129. */
  78130. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78131. }
  78132. }
  78133. declare module BABYLON {
  78134. /**
  78135. * Mode that determines the coordinate system to use.
  78136. */
  78137. export enum GLTFLoaderCoordinateSystemMode {
  78138. /**
  78139. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78140. */
  78141. AUTO = 0,
  78142. /**
  78143. * Sets the useRightHandedSystem flag on the scene.
  78144. */
  78145. FORCE_RIGHT_HANDED = 1
  78146. }
  78147. /**
  78148. * Mode that determines what animations will start.
  78149. */
  78150. export enum GLTFLoaderAnimationStartMode {
  78151. /**
  78152. * No animation will start.
  78153. */
  78154. NONE = 0,
  78155. /**
  78156. * The first animation will start.
  78157. */
  78158. FIRST = 1,
  78159. /**
  78160. * All animations will start.
  78161. */
  78162. ALL = 2
  78163. }
  78164. /**
  78165. * Interface that contains the data for the glTF asset.
  78166. */
  78167. export interface IGLTFLoaderData {
  78168. /**
  78169. * The object that represents the glTF JSON.
  78170. */
  78171. json: Object;
  78172. /**
  78173. * The BIN chunk of a binary glTF.
  78174. */
  78175. bin: Nullable<IDataBuffer>;
  78176. }
  78177. /**
  78178. * Interface for extending the loader.
  78179. */
  78180. export interface IGLTFLoaderExtension {
  78181. /**
  78182. * The name of this extension.
  78183. */
  78184. readonly name: string;
  78185. /**
  78186. * Defines whether this extension is enabled.
  78187. */
  78188. enabled: boolean;
  78189. /**
  78190. * Defines the order of this extension.
  78191. * The loader sorts the extensions using these values when loading.
  78192. */
  78193. order?: number;
  78194. }
  78195. /**
  78196. * Loader state.
  78197. */
  78198. export enum GLTFLoaderState {
  78199. /**
  78200. * The asset is loading.
  78201. */
  78202. LOADING = 0,
  78203. /**
  78204. * The asset is ready for rendering.
  78205. */
  78206. READY = 1,
  78207. /**
  78208. * The asset is completely loaded.
  78209. */
  78210. COMPLETE = 2
  78211. }
  78212. /** @hidden */
  78213. export interface IImportMeshAsyncOutput {
  78214. meshes: AbstractMesh[];
  78215. particleSystems: IParticleSystem[];
  78216. skeletons: Skeleton[];
  78217. animationGroups: AnimationGroup[];
  78218. lights: Light[];
  78219. transformNodes: TransformNode[];
  78220. }
  78221. /** @hidden */
  78222. export interface IGLTFLoader extends IDisposable {
  78223. readonly state: Nullable<GLTFLoaderState>;
  78224. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78225. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78226. }
  78227. /**
  78228. * File loader for loading glTF files into a scene.
  78229. */
  78230. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78231. /** @hidden */
  78232. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78233. /** @hidden */
  78234. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78235. /**
  78236. * Raised when the asset has been parsed
  78237. */
  78238. onParsedObservable: Observable<IGLTFLoaderData>;
  78239. private _onParsedObserver;
  78240. /**
  78241. * Raised when the asset has been parsed
  78242. */
  78243. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78244. /**
  78245. * 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.
  78246. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78247. * Defaults to true.
  78248. * @hidden
  78249. */
  78250. static IncrementalLoading: boolean;
  78251. /**
  78252. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78253. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78254. * @hidden
  78255. */
  78256. static HomogeneousCoordinates: boolean;
  78257. /**
  78258. * The coordinate system mode. Defaults to AUTO.
  78259. */
  78260. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78261. /**
  78262. * The animation start mode. Defaults to FIRST.
  78263. */
  78264. animationStartMode: GLTFLoaderAnimationStartMode;
  78265. /**
  78266. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78267. */
  78268. compileMaterials: boolean;
  78269. /**
  78270. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78271. */
  78272. useClipPlane: boolean;
  78273. /**
  78274. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78275. */
  78276. compileShadowGenerators: boolean;
  78277. /**
  78278. * Defines if the Alpha blended materials are only applied as coverage.
  78279. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78280. * If true, no extra effects are applied to transparent pixels.
  78281. */
  78282. transparencyAsCoverage: boolean;
  78283. /**
  78284. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78285. * Enabling will disable offline support and glTF validator.
  78286. * Defaults to false.
  78287. */
  78288. useRangeRequests: boolean;
  78289. /**
  78290. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78291. */
  78292. createInstances: boolean;
  78293. /**
  78294. * Function called before loading a url referenced by the asset.
  78295. */
  78296. preprocessUrlAsync: (url: string) => Promise<string>;
  78297. /**
  78298. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78299. */
  78300. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78301. private _onMeshLoadedObserver;
  78302. /**
  78303. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78304. */
  78305. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78306. /**
  78307. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78308. */
  78309. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78310. private _onTextureLoadedObserver;
  78311. /**
  78312. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78313. */
  78314. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78315. /**
  78316. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78317. */
  78318. readonly onMaterialLoadedObservable: Observable<Material>;
  78319. private _onMaterialLoadedObserver;
  78320. /**
  78321. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78322. */
  78323. set onMaterialLoaded(callback: (material: Material) => void);
  78324. /**
  78325. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78326. */
  78327. readonly onCameraLoadedObservable: Observable<Camera>;
  78328. private _onCameraLoadedObserver;
  78329. /**
  78330. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78331. */
  78332. set onCameraLoaded(callback: (camera: Camera) => void);
  78333. /**
  78334. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78335. * For assets with LODs, raised when all of the LODs are complete.
  78336. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78337. */
  78338. readonly onCompleteObservable: Observable<void>;
  78339. private _onCompleteObserver;
  78340. /**
  78341. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78342. * For assets with LODs, raised when all of the LODs are complete.
  78343. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78344. */
  78345. set onComplete(callback: () => void);
  78346. /**
  78347. * Observable raised when an error occurs.
  78348. */
  78349. readonly onErrorObservable: Observable<any>;
  78350. private _onErrorObserver;
  78351. /**
  78352. * Callback raised when an error occurs.
  78353. */
  78354. set onError(callback: (reason: any) => void);
  78355. /**
  78356. * Observable raised after the loader is disposed.
  78357. */
  78358. readonly onDisposeObservable: Observable<void>;
  78359. private _onDisposeObserver;
  78360. /**
  78361. * Callback raised after the loader is disposed.
  78362. */
  78363. set onDispose(callback: () => void);
  78364. /**
  78365. * Observable raised after a loader extension is created.
  78366. * Set additional options for a loader extension in this event.
  78367. */
  78368. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78369. private _onExtensionLoadedObserver;
  78370. /**
  78371. * Callback raised after a loader extension is created.
  78372. */
  78373. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78374. /**
  78375. * Defines if the loader logging is enabled.
  78376. */
  78377. get loggingEnabled(): boolean;
  78378. set loggingEnabled(value: boolean);
  78379. /**
  78380. * Defines if the loader should capture performance counters.
  78381. */
  78382. get capturePerformanceCounters(): boolean;
  78383. set capturePerformanceCounters(value: boolean);
  78384. /**
  78385. * Defines if the loader should validate the asset.
  78386. */
  78387. validate: boolean;
  78388. /**
  78389. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78390. */
  78391. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78392. private _onValidatedObserver;
  78393. /**
  78394. * Callback raised after a loader extension is created.
  78395. */
  78396. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78397. private _loader;
  78398. /**
  78399. * Name of the loader ("gltf")
  78400. */
  78401. name: string;
  78402. /** @hidden */
  78403. extensions: ISceneLoaderPluginExtensions;
  78404. /**
  78405. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78406. */
  78407. dispose(): void;
  78408. /** @hidden */
  78409. _clear(): void;
  78410. /** @hidden */
  78411. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78412. /** @hidden */
  78413. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78414. /** @hidden */
  78415. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78416. meshes: AbstractMesh[];
  78417. particleSystems: IParticleSystem[];
  78418. skeletons: Skeleton[];
  78419. animationGroups: AnimationGroup[];
  78420. }>;
  78421. /** @hidden */
  78422. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78423. /** @hidden */
  78424. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78425. /** @hidden */
  78426. canDirectLoad(data: string): boolean;
  78427. /** @hidden */
  78428. directLoad(scene: Scene, data: string): any;
  78429. /**
  78430. * The callback that allows custom handling of the root url based on the response url.
  78431. * @param rootUrl the original root url
  78432. * @param responseURL the response url if available
  78433. * @returns the new root url
  78434. */
  78435. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78436. /** @hidden */
  78437. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78438. /**
  78439. * The loader state or null if the loader is not active.
  78440. */
  78441. get loaderState(): Nullable<GLTFLoaderState>;
  78442. /**
  78443. * Returns a promise that resolves when the asset is completely loaded.
  78444. * @returns a promise that resolves when the asset is completely loaded.
  78445. */
  78446. whenCompleteAsync(): Promise<void>;
  78447. private _validate;
  78448. private _getLoader;
  78449. private _parseJson;
  78450. private _unpackBinaryAsync;
  78451. private _unpackBinaryV1Async;
  78452. private _unpackBinaryV2Async;
  78453. private static _parseVersion;
  78454. private static _compareVersion;
  78455. private static readonly _logSpaces;
  78456. private _logIndentLevel;
  78457. private _loggingEnabled;
  78458. /** @hidden */
  78459. _log: (message: string) => void;
  78460. /** @hidden */
  78461. _logOpen(message: string): void;
  78462. /** @hidden */
  78463. _logClose(): void;
  78464. private _logEnabled;
  78465. private _logDisabled;
  78466. private _capturePerformanceCounters;
  78467. /** @hidden */
  78468. _startPerformanceCounter: (counterName: string) => void;
  78469. /** @hidden */
  78470. _endPerformanceCounter: (counterName: string) => void;
  78471. private _startPerformanceCounterEnabled;
  78472. private _startPerformanceCounterDisabled;
  78473. private _endPerformanceCounterEnabled;
  78474. private _endPerformanceCounterDisabled;
  78475. }
  78476. }
  78477. declare module BABYLON.GLTF1 {
  78478. /**
  78479. * Enums
  78480. * @hidden
  78481. */
  78482. export enum EComponentType {
  78483. BYTE = 5120,
  78484. UNSIGNED_BYTE = 5121,
  78485. SHORT = 5122,
  78486. UNSIGNED_SHORT = 5123,
  78487. FLOAT = 5126
  78488. }
  78489. /** @hidden */
  78490. export enum EShaderType {
  78491. FRAGMENT = 35632,
  78492. VERTEX = 35633
  78493. }
  78494. /** @hidden */
  78495. export enum EParameterType {
  78496. BYTE = 5120,
  78497. UNSIGNED_BYTE = 5121,
  78498. SHORT = 5122,
  78499. UNSIGNED_SHORT = 5123,
  78500. INT = 5124,
  78501. UNSIGNED_INT = 5125,
  78502. FLOAT = 5126,
  78503. FLOAT_VEC2 = 35664,
  78504. FLOAT_VEC3 = 35665,
  78505. FLOAT_VEC4 = 35666,
  78506. INT_VEC2 = 35667,
  78507. INT_VEC3 = 35668,
  78508. INT_VEC4 = 35669,
  78509. BOOL = 35670,
  78510. BOOL_VEC2 = 35671,
  78511. BOOL_VEC3 = 35672,
  78512. BOOL_VEC4 = 35673,
  78513. FLOAT_MAT2 = 35674,
  78514. FLOAT_MAT3 = 35675,
  78515. FLOAT_MAT4 = 35676,
  78516. SAMPLER_2D = 35678
  78517. }
  78518. /** @hidden */
  78519. export enum ETextureWrapMode {
  78520. CLAMP_TO_EDGE = 33071,
  78521. MIRRORED_REPEAT = 33648,
  78522. REPEAT = 10497
  78523. }
  78524. /** @hidden */
  78525. export enum ETextureFilterType {
  78526. NEAREST = 9728,
  78527. LINEAR = 9728,
  78528. NEAREST_MIPMAP_NEAREST = 9984,
  78529. LINEAR_MIPMAP_NEAREST = 9985,
  78530. NEAREST_MIPMAP_LINEAR = 9986,
  78531. LINEAR_MIPMAP_LINEAR = 9987
  78532. }
  78533. /** @hidden */
  78534. export enum ETextureFormat {
  78535. ALPHA = 6406,
  78536. RGB = 6407,
  78537. RGBA = 6408,
  78538. LUMINANCE = 6409,
  78539. LUMINANCE_ALPHA = 6410
  78540. }
  78541. /** @hidden */
  78542. export enum ECullingType {
  78543. FRONT = 1028,
  78544. BACK = 1029,
  78545. FRONT_AND_BACK = 1032
  78546. }
  78547. /** @hidden */
  78548. export enum EBlendingFunction {
  78549. ZERO = 0,
  78550. ONE = 1,
  78551. SRC_COLOR = 768,
  78552. ONE_MINUS_SRC_COLOR = 769,
  78553. DST_COLOR = 774,
  78554. ONE_MINUS_DST_COLOR = 775,
  78555. SRC_ALPHA = 770,
  78556. ONE_MINUS_SRC_ALPHA = 771,
  78557. DST_ALPHA = 772,
  78558. ONE_MINUS_DST_ALPHA = 773,
  78559. CONSTANT_COLOR = 32769,
  78560. ONE_MINUS_CONSTANT_COLOR = 32770,
  78561. CONSTANT_ALPHA = 32771,
  78562. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78563. SRC_ALPHA_SATURATE = 776
  78564. }
  78565. /** @hidden */
  78566. export interface IGLTFProperty {
  78567. extensions?: {
  78568. [key: string]: any;
  78569. };
  78570. extras?: Object;
  78571. }
  78572. /** @hidden */
  78573. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78574. name?: string;
  78575. }
  78576. /** @hidden */
  78577. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78578. bufferView: string;
  78579. byteOffset: number;
  78580. byteStride: number;
  78581. count: number;
  78582. type: string;
  78583. componentType: EComponentType;
  78584. max?: number[];
  78585. min?: number[];
  78586. name?: string;
  78587. }
  78588. /** @hidden */
  78589. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78590. buffer: string;
  78591. byteOffset: number;
  78592. byteLength: number;
  78593. byteStride: number;
  78594. target?: number;
  78595. }
  78596. /** @hidden */
  78597. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78598. uri: string;
  78599. byteLength?: number;
  78600. type?: string;
  78601. }
  78602. /** @hidden */
  78603. export interface IGLTFShader extends IGLTFChildRootProperty {
  78604. uri: string;
  78605. type: EShaderType;
  78606. }
  78607. /** @hidden */
  78608. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78609. attributes: string[];
  78610. fragmentShader: string;
  78611. vertexShader: string;
  78612. }
  78613. /** @hidden */
  78614. export interface IGLTFTechniqueParameter {
  78615. type: number;
  78616. count?: number;
  78617. semantic?: string;
  78618. node?: string;
  78619. value?: number | boolean | string | Array<any>;
  78620. source?: string;
  78621. babylonValue?: any;
  78622. }
  78623. /** @hidden */
  78624. export interface IGLTFTechniqueCommonProfile {
  78625. lightingModel: string;
  78626. texcoordBindings: Object;
  78627. parameters?: Array<any>;
  78628. }
  78629. /** @hidden */
  78630. export interface IGLTFTechniqueStatesFunctions {
  78631. blendColor?: number[];
  78632. blendEquationSeparate?: number[];
  78633. blendFuncSeparate?: number[];
  78634. colorMask: boolean[];
  78635. cullFace: number[];
  78636. }
  78637. /** @hidden */
  78638. export interface IGLTFTechniqueStates {
  78639. enable: number[];
  78640. functions: IGLTFTechniqueStatesFunctions;
  78641. }
  78642. /** @hidden */
  78643. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78644. parameters: {
  78645. [key: string]: IGLTFTechniqueParameter;
  78646. };
  78647. program: string;
  78648. attributes: {
  78649. [key: string]: string;
  78650. };
  78651. uniforms: {
  78652. [key: string]: string;
  78653. };
  78654. states: IGLTFTechniqueStates;
  78655. }
  78656. /** @hidden */
  78657. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78658. technique?: string;
  78659. values: string[];
  78660. }
  78661. /** @hidden */
  78662. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78663. attributes: {
  78664. [key: string]: string;
  78665. };
  78666. indices: string;
  78667. material: string;
  78668. mode?: number;
  78669. }
  78670. /** @hidden */
  78671. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78672. primitives: IGLTFMeshPrimitive[];
  78673. }
  78674. /** @hidden */
  78675. export interface IGLTFImage extends IGLTFChildRootProperty {
  78676. uri: string;
  78677. }
  78678. /** @hidden */
  78679. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78680. magFilter?: number;
  78681. minFilter?: number;
  78682. wrapS?: number;
  78683. wrapT?: number;
  78684. }
  78685. /** @hidden */
  78686. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78687. sampler: string;
  78688. source: string;
  78689. format?: ETextureFormat;
  78690. internalFormat?: ETextureFormat;
  78691. target?: number;
  78692. type?: number;
  78693. babylonTexture?: Texture;
  78694. }
  78695. /** @hidden */
  78696. export interface IGLTFAmbienLight {
  78697. color?: number[];
  78698. }
  78699. /** @hidden */
  78700. export interface IGLTFDirectionalLight {
  78701. color?: number[];
  78702. }
  78703. /** @hidden */
  78704. export interface IGLTFPointLight {
  78705. color?: number[];
  78706. constantAttenuation?: number;
  78707. linearAttenuation?: number;
  78708. quadraticAttenuation?: number;
  78709. }
  78710. /** @hidden */
  78711. export interface IGLTFSpotLight {
  78712. color?: number[];
  78713. constantAttenuation?: number;
  78714. fallOfAngle?: number;
  78715. fallOffExponent?: number;
  78716. linearAttenuation?: number;
  78717. quadraticAttenuation?: number;
  78718. }
  78719. /** @hidden */
  78720. export interface IGLTFLight extends IGLTFChildRootProperty {
  78721. type: string;
  78722. }
  78723. /** @hidden */
  78724. export interface IGLTFCameraOrthographic {
  78725. xmag: number;
  78726. ymag: number;
  78727. zfar: number;
  78728. znear: number;
  78729. }
  78730. /** @hidden */
  78731. export interface IGLTFCameraPerspective {
  78732. aspectRatio: number;
  78733. yfov: number;
  78734. zfar: number;
  78735. znear: number;
  78736. }
  78737. /** @hidden */
  78738. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78739. type: string;
  78740. }
  78741. /** @hidden */
  78742. export interface IGLTFAnimationChannelTarget {
  78743. id: string;
  78744. path: string;
  78745. }
  78746. /** @hidden */
  78747. export interface IGLTFAnimationChannel {
  78748. sampler: string;
  78749. target: IGLTFAnimationChannelTarget;
  78750. }
  78751. /** @hidden */
  78752. export interface IGLTFAnimationSampler {
  78753. input: string;
  78754. output: string;
  78755. interpolation?: string;
  78756. }
  78757. /** @hidden */
  78758. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78759. channels?: IGLTFAnimationChannel[];
  78760. parameters?: {
  78761. [key: string]: string;
  78762. };
  78763. samplers?: {
  78764. [key: string]: IGLTFAnimationSampler;
  78765. };
  78766. }
  78767. /** @hidden */
  78768. export interface IGLTFNodeInstanceSkin {
  78769. skeletons: string[];
  78770. skin: string;
  78771. meshes: string[];
  78772. }
  78773. /** @hidden */
  78774. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78775. bindShapeMatrix: number[];
  78776. inverseBindMatrices: string;
  78777. jointNames: string[];
  78778. babylonSkeleton?: Skeleton;
  78779. }
  78780. /** @hidden */
  78781. export interface IGLTFNode extends IGLTFChildRootProperty {
  78782. camera?: string;
  78783. children: string[];
  78784. skin?: string;
  78785. jointName?: string;
  78786. light?: string;
  78787. matrix: number[];
  78788. mesh?: string;
  78789. meshes?: string[];
  78790. rotation?: number[];
  78791. scale?: number[];
  78792. translation?: number[];
  78793. babylonNode?: Node;
  78794. }
  78795. /** @hidden */
  78796. export interface IGLTFScene extends IGLTFChildRootProperty {
  78797. nodes: string[];
  78798. }
  78799. /** @hidden */
  78800. export interface IGLTFRuntime {
  78801. extensions: {
  78802. [key: string]: any;
  78803. };
  78804. accessors: {
  78805. [key: string]: IGLTFAccessor;
  78806. };
  78807. buffers: {
  78808. [key: string]: IGLTFBuffer;
  78809. };
  78810. bufferViews: {
  78811. [key: string]: IGLTFBufferView;
  78812. };
  78813. meshes: {
  78814. [key: string]: IGLTFMesh;
  78815. };
  78816. lights: {
  78817. [key: string]: IGLTFLight;
  78818. };
  78819. cameras: {
  78820. [key: string]: IGLTFCamera;
  78821. };
  78822. nodes: {
  78823. [key: string]: IGLTFNode;
  78824. };
  78825. images: {
  78826. [key: string]: IGLTFImage;
  78827. };
  78828. textures: {
  78829. [key: string]: IGLTFTexture;
  78830. };
  78831. shaders: {
  78832. [key: string]: IGLTFShader;
  78833. };
  78834. programs: {
  78835. [key: string]: IGLTFProgram;
  78836. };
  78837. samplers: {
  78838. [key: string]: IGLTFSampler;
  78839. };
  78840. techniques: {
  78841. [key: string]: IGLTFTechnique;
  78842. };
  78843. materials: {
  78844. [key: string]: IGLTFMaterial;
  78845. };
  78846. animations: {
  78847. [key: string]: IGLTFAnimation;
  78848. };
  78849. skins: {
  78850. [key: string]: IGLTFSkins;
  78851. };
  78852. currentScene?: Object;
  78853. scenes: {
  78854. [key: string]: IGLTFScene;
  78855. };
  78856. extensionsUsed: string[];
  78857. extensionsRequired?: string[];
  78858. buffersCount: number;
  78859. shaderscount: number;
  78860. scene: Scene;
  78861. rootUrl: string;
  78862. loadedBufferCount: number;
  78863. loadedBufferViews: {
  78864. [name: string]: ArrayBufferView;
  78865. };
  78866. loadedShaderCount: number;
  78867. importOnlyMeshes: boolean;
  78868. importMeshesNames?: string[];
  78869. dummyNodes: Node[];
  78870. forAssetContainer: boolean;
  78871. }
  78872. /** @hidden */
  78873. export interface INodeToRoot {
  78874. bone: Bone;
  78875. node: IGLTFNode;
  78876. id: string;
  78877. }
  78878. /** @hidden */
  78879. export interface IJointNode {
  78880. node: IGLTFNode;
  78881. id: string;
  78882. }
  78883. }
  78884. declare module BABYLON.GLTF1 {
  78885. /**
  78886. * Utils functions for GLTF
  78887. * @hidden
  78888. */
  78889. export class GLTFUtils {
  78890. /**
  78891. * Sets the given "parameter" matrix
  78892. * @param scene: the Scene object
  78893. * @param source: the source node where to pick the matrix
  78894. * @param parameter: the GLTF technique parameter
  78895. * @param uniformName: the name of the shader's uniform
  78896. * @param shaderMaterial: the shader material
  78897. */
  78898. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78899. /**
  78900. * Sets the given "parameter" matrix
  78901. * @param shaderMaterial: the shader material
  78902. * @param uniform: the name of the shader's uniform
  78903. * @param value: the value of the uniform
  78904. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78905. */
  78906. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78907. /**
  78908. * Returns the wrap mode of the texture
  78909. * @param mode: the mode value
  78910. */
  78911. static GetWrapMode(mode: number): number;
  78912. /**
  78913. * Returns the byte stride giving an accessor
  78914. * @param accessor: the GLTF accessor objet
  78915. */
  78916. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78917. /**
  78918. * Returns the texture filter mode giving a mode value
  78919. * @param mode: the filter mode value
  78920. */
  78921. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78922. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78923. /**
  78924. * Returns a buffer from its accessor
  78925. * @param gltfRuntime: the GLTF runtime
  78926. * @param accessor: the GLTF accessor
  78927. */
  78928. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78929. /**
  78930. * Decodes a buffer view into a string
  78931. * @param view: the buffer view
  78932. */
  78933. static DecodeBufferToText(view: ArrayBufferView): string;
  78934. /**
  78935. * Returns the default material of gltf. Related to
  78936. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78937. * @param scene: the Babylon.js scene
  78938. */
  78939. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78940. private static _DefaultMaterial;
  78941. }
  78942. }
  78943. declare module BABYLON.GLTF1 {
  78944. /**
  78945. * Implementation of the base glTF spec
  78946. * @hidden
  78947. */
  78948. export class GLTFLoaderBase {
  78949. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78950. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78951. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78952. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78953. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78954. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78955. }
  78956. /**
  78957. * glTF V1 Loader
  78958. * @hidden
  78959. */
  78960. export class GLTFLoader implements IGLTFLoader {
  78961. static Extensions: {
  78962. [name: string]: GLTFLoaderExtension;
  78963. };
  78964. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78965. state: Nullable<GLTFLoaderState>;
  78966. dispose(): void;
  78967. private _importMeshAsync;
  78968. /**
  78969. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78970. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78971. * @param scene the scene the meshes should be added to
  78972. * @param forAssetContainer defines if the entities must be stored in the scene
  78973. * @param data gltf data containing information of the meshes in a loaded file
  78974. * @param rootUrl root url to load from
  78975. * @param onProgress event that fires when loading progress has occured
  78976. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78977. */
  78978. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78979. private _loadAsync;
  78980. /**
  78981. * Imports all objects from a loaded gltf file and adds them to the scene
  78982. * @param scene the scene the objects should be added to
  78983. * @param data gltf data containing information of the meshes in a loaded file
  78984. * @param rootUrl root url to load from
  78985. * @param onProgress event that fires when loading progress has occured
  78986. * @returns a promise which completes when objects have been loaded to the scene
  78987. */
  78988. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78989. private _loadShadersAsync;
  78990. private _loadBuffersAsync;
  78991. private _createNodes;
  78992. }
  78993. /** @hidden */
  78994. export abstract class GLTFLoaderExtension {
  78995. private _name;
  78996. constructor(name: string);
  78997. get name(): string;
  78998. /**
  78999. * Defines an override for loading the runtime
  79000. * Return true to stop further extensions from loading the runtime
  79001. */
  79002. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79003. /**
  79004. * Defines an onverride for creating gltf runtime
  79005. * Return true to stop further extensions from creating the runtime
  79006. */
  79007. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79008. /**
  79009. * Defines an override for loading buffers
  79010. * Return true to stop further extensions from loading this buffer
  79011. */
  79012. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79013. /**
  79014. * Defines an override for loading texture buffers
  79015. * Return true to stop further extensions from loading this texture data
  79016. */
  79017. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79018. /**
  79019. * Defines an override for creating textures
  79020. * Return true to stop further extensions from loading this texture
  79021. */
  79022. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79023. /**
  79024. * Defines an override for loading shader strings
  79025. * Return true to stop further extensions from loading this shader data
  79026. */
  79027. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79028. /**
  79029. * Defines an override for loading materials
  79030. * Return true to stop further extensions from loading this material
  79031. */
  79032. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79033. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79034. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79035. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79036. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79037. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79038. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79039. private static LoadTextureBufferAsync;
  79040. private static CreateTextureAsync;
  79041. private static ApplyExtensions;
  79042. }
  79043. }
  79044. declare module BABYLON.GLTF1 {
  79045. /** @hidden */
  79046. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79047. private _bin;
  79048. constructor();
  79049. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79050. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79051. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79052. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79053. }
  79054. }
  79055. declare module BABYLON.GLTF1 {
  79056. /** @hidden */
  79057. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79058. constructor();
  79059. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79060. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79061. private _loadTexture;
  79062. }
  79063. }
  79064. declare module BABYLON.GLTF2.Loader {
  79065. /**
  79066. * Loader interface with an index field.
  79067. */
  79068. export interface IArrayItem {
  79069. /**
  79070. * The index of this item in the array.
  79071. */
  79072. index: number;
  79073. }
  79074. /**
  79075. * Loader interface with additional members.
  79076. */
  79077. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79078. /** @hidden */
  79079. _data?: Promise<ArrayBufferView>;
  79080. /** @hidden */
  79081. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79082. }
  79083. /**
  79084. * Loader interface with additional members.
  79085. */
  79086. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79087. }
  79088. /** @hidden */
  79089. export interface _IAnimationSamplerData {
  79090. input: Float32Array;
  79091. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79092. output: Float32Array;
  79093. }
  79094. /**
  79095. * Loader interface with additional members.
  79096. */
  79097. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79098. /** @hidden */
  79099. _data?: Promise<_IAnimationSamplerData>;
  79100. }
  79101. /**
  79102. * Loader interface with additional members.
  79103. */
  79104. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79105. channels: IAnimationChannel[];
  79106. samplers: IAnimationSampler[];
  79107. /** @hidden */
  79108. _babylonAnimationGroup?: AnimationGroup;
  79109. }
  79110. /**
  79111. * Loader interface with additional members.
  79112. */
  79113. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79114. /** @hidden */
  79115. _data?: Promise<ArrayBufferView>;
  79116. }
  79117. /**
  79118. * Loader interface with additional members.
  79119. */
  79120. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79121. /** @hidden */
  79122. _data?: Promise<ArrayBufferView>;
  79123. /** @hidden */
  79124. _babylonBuffer?: Promise<Buffer>;
  79125. }
  79126. /**
  79127. * Loader interface with additional members.
  79128. */
  79129. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79130. }
  79131. /**
  79132. * Loader interface with additional members.
  79133. */
  79134. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79135. /** @hidden */
  79136. _data?: Promise<ArrayBufferView>;
  79137. }
  79138. /**
  79139. * Loader interface with additional members.
  79140. */
  79141. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79142. }
  79143. /**
  79144. * Loader interface with additional members.
  79145. */
  79146. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79147. }
  79148. /**
  79149. * Loader interface with additional members.
  79150. */
  79151. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79152. baseColorTexture?: ITextureInfo;
  79153. metallicRoughnessTexture?: ITextureInfo;
  79154. }
  79155. /**
  79156. * Loader interface with additional members.
  79157. */
  79158. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79159. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79160. normalTexture?: IMaterialNormalTextureInfo;
  79161. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79162. emissiveTexture?: ITextureInfo;
  79163. /** @hidden */
  79164. _data?: {
  79165. [babylonDrawMode: number]: {
  79166. babylonMaterial: Material;
  79167. babylonMeshes: AbstractMesh[];
  79168. promise: Promise<void>;
  79169. };
  79170. };
  79171. }
  79172. /**
  79173. * Loader interface with additional members.
  79174. */
  79175. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79176. primitives: IMeshPrimitive[];
  79177. }
  79178. /**
  79179. * Loader interface with additional members.
  79180. */
  79181. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79182. /** @hidden */
  79183. _instanceData?: {
  79184. babylonSourceMesh: Mesh;
  79185. promise: Promise<any>;
  79186. };
  79187. }
  79188. /**
  79189. * Loader interface with additional members.
  79190. */
  79191. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79192. /**
  79193. * The parent glTF node.
  79194. */
  79195. parent?: INode;
  79196. /** @hidden */
  79197. _babylonTransformNode?: TransformNode;
  79198. /** @hidden */
  79199. _primitiveBabylonMeshes?: AbstractMesh[];
  79200. /** @hidden */
  79201. _babylonBones?: Bone[];
  79202. /** @hidden */
  79203. _numMorphTargets?: number;
  79204. }
  79205. /** @hidden */
  79206. export interface _ISamplerData {
  79207. noMipMaps: boolean;
  79208. samplingMode: number;
  79209. wrapU: number;
  79210. wrapV: number;
  79211. }
  79212. /**
  79213. * Loader interface with additional members.
  79214. */
  79215. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79216. /** @hidden */
  79217. _data?: _ISamplerData;
  79218. }
  79219. /**
  79220. * Loader interface with additional members.
  79221. */
  79222. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79223. }
  79224. /**
  79225. * Loader interface with additional members.
  79226. */
  79227. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79228. /** @hidden */
  79229. _data?: {
  79230. babylonSkeleton: Skeleton;
  79231. promise: Promise<void>;
  79232. };
  79233. }
  79234. /**
  79235. * Loader interface with additional members.
  79236. */
  79237. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79238. }
  79239. /**
  79240. * Loader interface with additional members.
  79241. */
  79242. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79243. }
  79244. /**
  79245. * Loader interface with additional members.
  79246. */
  79247. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79248. accessors?: IAccessor[];
  79249. animations?: IAnimation[];
  79250. buffers?: IBuffer[];
  79251. bufferViews?: IBufferView[];
  79252. cameras?: ICamera[];
  79253. images?: IImage[];
  79254. materials?: IMaterial[];
  79255. meshes?: IMesh[];
  79256. nodes?: INode[];
  79257. samplers?: ISampler[];
  79258. scenes?: IScene[];
  79259. skins?: ISkin[];
  79260. textures?: ITexture[];
  79261. }
  79262. }
  79263. declare module BABYLON.GLTF2 {
  79264. /**
  79265. * Interface for a glTF loader extension.
  79266. */
  79267. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79268. /**
  79269. * Called after the loader state changes to LOADING.
  79270. */
  79271. onLoading?(): void;
  79272. /**
  79273. * Called after the loader state changes to READY.
  79274. */
  79275. onReady?(): void;
  79276. /**
  79277. * Define this method to modify the default behavior when loading scenes.
  79278. * @param context The context when loading the asset
  79279. * @param scene The glTF scene property
  79280. * @returns A promise that resolves when the load is complete or null if not handled
  79281. */
  79282. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79283. /**
  79284. * Define this method to modify the default behavior when loading nodes.
  79285. * @param context The context when loading the asset
  79286. * @param node The glTF node property
  79287. * @param assign A function called synchronously after parsing the glTF properties
  79288. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79289. */
  79290. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79291. /**
  79292. * Define this method to modify the default behavior when loading cameras.
  79293. * @param context The context when loading the asset
  79294. * @param camera The glTF camera property
  79295. * @param assign A function called synchronously after parsing the glTF properties
  79296. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79297. */
  79298. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79299. /**
  79300. * @hidden
  79301. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79302. * @param context The context when loading the asset
  79303. * @param primitive The glTF mesh primitive property
  79304. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79305. */
  79306. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79307. /**
  79308. * @hidden
  79309. * Define this method to modify the default behavior when loading data for mesh primitives.
  79310. * @param context The context when loading the asset
  79311. * @param name The mesh name when loading the asset
  79312. * @param node The glTF node when loading the asset
  79313. * @param mesh The glTF mesh when loading the asset
  79314. * @param primitive The glTF mesh primitive property
  79315. * @param assign A function called synchronously after parsing the glTF properties
  79316. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79317. */
  79318. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79319. /**
  79320. * @hidden
  79321. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79322. * @param context The context when loading the asset
  79323. * @param material The glTF material property
  79324. * @param assign A function called synchronously after parsing the glTF properties
  79325. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79326. */
  79327. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79328. /**
  79329. * Define this method to modify the default behavior when creating materials.
  79330. * @param context The context when loading the asset
  79331. * @param material The glTF material property
  79332. * @param babylonDrawMode The draw mode for the Babylon material
  79333. * @returns The Babylon material or null if not handled
  79334. */
  79335. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79336. /**
  79337. * Define this method to modify the default behavior when loading material properties.
  79338. * @param context The context when loading the asset
  79339. * @param material The glTF material property
  79340. * @param babylonMaterial The Babylon material
  79341. * @returns A promise that resolves when the load is complete or null if not handled
  79342. */
  79343. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79344. /**
  79345. * Define this method to modify the default behavior when loading texture infos.
  79346. * @param context The context when loading the asset
  79347. * @param textureInfo The glTF texture info property
  79348. * @param assign A function called synchronously after parsing the glTF properties
  79349. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79350. */
  79351. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79352. /**
  79353. * @hidden
  79354. * Define this method to modify the default behavior when loading textures.
  79355. * @param context The context when loading the asset
  79356. * @param texture The glTF texture property
  79357. * @param assign A function called synchronously after parsing the glTF properties
  79358. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79359. */
  79360. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79361. /**
  79362. * Define this method to modify the default behavior when loading animations.
  79363. * @param context The context when loading the asset
  79364. * @param animation The glTF animation property
  79365. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79366. */
  79367. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79368. /**
  79369. * @hidden
  79370. * Define this method to modify the default behavior when loading skins.
  79371. * @param context The context when loading the asset
  79372. * @param node The glTF node property
  79373. * @param skin The glTF skin property
  79374. * @returns A promise that resolves when the load is complete or null if not handled
  79375. */
  79376. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79377. /**
  79378. * @hidden
  79379. * Define this method to modify the default behavior when loading uris.
  79380. * @param context The context when loading the asset
  79381. * @param property The glTF property associated with the uri
  79382. * @param uri The uri to load
  79383. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79384. */
  79385. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79386. /**
  79387. * Define this method to modify the default behavior when loading buffer views.
  79388. * @param context The context when loading the asset
  79389. * @param bufferView The glTF buffer view property
  79390. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79391. */
  79392. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79393. /**
  79394. * Define this method to modify the default behavior when loading buffers.
  79395. * @param context The context when loading the asset
  79396. * @param buffer The glTF buffer property
  79397. * @param byteOffset The byte offset to load
  79398. * @param byteLength The byte length to load
  79399. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79400. */
  79401. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79402. }
  79403. }
  79404. declare module BABYLON.GLTF2 {
  79405. /**
  79406. * Helper class for working with arrays when loading the glTF asset
  79407. */
  79408. export class ArrayItem {
  79409. /**
  79410. * Gets an item from the given array.
  79411. * @param context The context when loading the asset
  79412. * @param array The array to get the item from
  79413. * @param index The index to the array
  79414. * @returns The array item
  79415. */
  79416. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79417. /**
  79418. * Assign an `index` field to each item of the given array.
  79419. * @param array The array of items
  79420. */
  79421. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79422. }
  79423. /**
  79424. * The glTF 2.0 loader
  79425. */
  79426. export class GLTFLoader implements IGLTFLoader {
  79427. /** @hidden */
  79428. _completePromises: Promise<any>[];
  79429. /** @hidden */
  79430. _forAssetContainer: boolean;
  79431. /** Storage */
  79432. _babylonLights: Light[];
  79433. /** @hidden */
  79434. _disableInstancedMesh: number;
  79435. private _disposed;
  79436. private _parent;
  79437. private _state;
  79438. private _extensions;
  79439. private _rootUrl;
  79440. private _fileName;
  79441. private _uniqueRootUrl;
  79442. private _gltf;
  79443. private _bin;
  79444. private _babylonScene;
  79445. private _rootBabylonMesh;
  79446. private _defaultBabylonMaterialData;
  79447. private _progressCallback?;
  79448. private _requests;
  79449. private static _RegisteredExtensions;
  79450. /**
  79451. * The default glTF sampler.
  79452. */
  79453. static readonly DefaultSampler: ISampler;
  79454. /**
  79455. * Registers a loader extension.
  79456. * @param name The name of the loader extension.
  79457. * @param factory The factory function that creates the loader extension.
  79458. */
  79459. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79460. /**
  79461. * Unregisters a loader extension.
  79462. * @param name The name of the loader extension.
  79463. * @returns A boolean indicating whether the extension has been unregistered
  79464. */
  79465. static UnregisterExtension(name: string): boolean;
  79466. /**
  79467. * The loader state.
  79468. */
  79469. get state(): Nullable<GLTFLoaderState>;
  79470. /**
  79471. * The object that represents the glTF JSON.
  79472. */
  79473. get gltf(): IGLTF;
  79474. /**
  79475. * The BIN chunk of a binary glTF.
  79476. */
  79477. get bin(): Nullable<IDataBuffer>;
  79478. /**
  79479. * The parent file loader.
  79480. */
  79481. get parent(): GLTFFileLoader;
  79482. /**
  79483. * The Babylon scene when loading the asset.
  79484. */
  79485. get babylonScene(): Scene;
  79486. /**
  79487. * The root Babylon mesh when loading the asset.
  79488. */
  79489. get rootBabylonMesh(): Mesh;
  79490. /** @hidden */
  79491. constructor(parent: GLTFFileLoader);
  79492. /** @hidden */
  79493. dispose(): void;
  79494. /** @hidden */
  79495. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79496. /** @hidden */
  79497. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79498. private _loadAsync;
  79499. private _loadData;
  79500. private _setupData;
  79501. private _loadExtensions;
  79502. private _checkExtensions;
  79503. private _setState;
  79504. private _createRootNode;
  79505. /**
  79506. * Loads a glTF scene.
  79507. * @param context The context when loading the asset
  79508. * @param scene The glTF scene property
  79509. * @returns A promise that resolves when the load is complete
  79510. */
  79511. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79512. private _forEachPrimitive;
  79513. private _getMeshes;
  79514. private _getTransformNodes;
  79515. private _getSkeletons;
  79516. private _getAnimationGroups;
  79517. private _startAnimations;
  79518. /**
  79519. * Loads a glTF node.
  79520. * @param context The context when loading the asset
  79521. * @param node The glTF node property
  79522. * @param assign A function called synchronously after parsing the glTF properties
  79523. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79524. */
  79525. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79526. private _loadMeshAsync;
  79527. /**
  79528. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79529. * @param context The context when loading the asset
  79530. * @param name The mesh name when loading the asset
  79531. * @param node The glTF node when loading the asset
  79532. * @param mesh The glTF mesh when loading the asset
  79533. * @param primitive The glTF mesh primitive property
  79534. * @param assign A function called synchronously after parsing the glTF properties
  79535. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79536. */
  79537. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79538. private _loadVertexDataAsync;
  79539. private _createMorphTargets;
  79540. private _loadMorphTargetsAsync;
  79541. private _loadMorphTargetVertexDataAsync;
  79542. private static _LoadTransform;
  79543. private _loadSkinAsync;
  79544. private _loadBones;
  79545. private _loadBone;
  79546. private _loadSkinInverseBindMatricesDataAsync;
  79547. private _updateBoneMatrices;
  79548. private _getNodeMatrix;
  79549. /**
  79550. * Loads a glTF camera.
  79551. * @param context The context when loading the asset
  79552. * @param camera The glTF camera property
  79553. * @param assign A function called synchronously after parsing the glTF properties
  79554. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79555. */
  79556. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79557. private _loadAnimationsAsync;
  79558. /**
  79559. * Loads a glTF animation.
  79560. * @param context The context when loading the asset
  79561. * @param animation The glTF animation property
  79562. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79563. */
  79564. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79565. /**
  79566. * @hidden Loads a glTF animation channel.
  79567. * @param context The context when loading the asset
  79568. * @param animationContext The context of the animation when loading the asset
  79569. * @param animation The glTF animation property
  79570. * @param channel The glTF animation channel property
  79571. * @param babylonAnimationGroup The babylon animation group property
  79572. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79573. * @returns A void promise when the channel load is complete
  79574. */
  79575. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79576. private _loadAnimationSamplerAsync;
  79577. private _loadBufferAsync;
  79578. /**
  79579. * Loads a glTF buffer view.
  79580. * @param context The context when loading the asset
  79581. * @param bufferView The glTF buffer view property
  79582. * @returns A promise that resolves with the loaded data when the load is complete
  79583. */
  79584. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79585. private _loadAccessorAsync;
  79586. /** @hidden */
  79587. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79588. private _loadIndicesAccessorAsync;
  79589. private _loadVertexBufferViewAsync;
  79590. private _loadVertexAccessorAsync;
  79591. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79592. /** @hidden */
  79593. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79594. private _createDefaultMaterial;
  79595. /**
  79596. * Creates a Babylon material from a glTF material.
  79597. * @param context The context when loading the asset
  79598. * @param material The glTF material property
  79599. * @param babylonDrawMode The draw mode for the Babylon material
  79600. * @returns The Babylon material
  79601. */
  79602. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79603. /**
  79604. * Loads properties from a glTF material into a Babylon material.
  79605. * @param context The context when loading the asset
  79606. * @param material The glTF material property
  79607. * @param babylonMaterial The Babylon material
  79608. * @returns A promise that resolves when the load is complete
  79609. */
  79610. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79611. /**
  79612. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79613. * @param context The context when loading the asset
  79614. * @param material The glTF material property
  79615. * @param babylonMaterial The Babylon material
  79616. * @returns A promise that resolves when the load is complete
  79617. */
  79618. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79619. /**
  79620. * Loads the alpha properties from a glTF material into a Babylon material.
  79621. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79622. * @param context The context when loading the asset
  79623. * @param material The glTF material property
  79624. * @param babylonMaterial The Babylon material
  79625. */
  79626. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79627. /**
  79628. * Loads a glTF texture info.
  79629. * @param context The context when loading the asset
  79630. * @param textureInfo The glTF texture info property
  79631. * @param assign A function called synchronously after parsing the glTF properties
  79632. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79633. */
  79634. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79635. /** @hidden */
  79636. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79637. /** @hidden */
  79638. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79639. private _loadSampler;
  79640. /**
  79641. * Loads a glTF image.
  79642. * @param context The context when loading the asset
  79643. * @param image The glTF image property
  79644. * @returns A promise that resolves with the loaded data when the load is complete
  79645. */
  79646. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79647. /**
  79648. * Loads a glTF uri.
  79649. * @param context The context when loading the asset
  79650. * @param property The glTF property associated with the uri
  79651. * @param uri The base64 or relative uri
  79652. * @returns A promise that resolves with the loaded data when the load is complete
  79653. */
  79654. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79655. private _onProgress;
  79656. /**
  79657. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79658. * @param babylonObject the Babylon object with metadata
  79659. * @param pointer the JSON pointer
  79660. */
  79661. static AddPointerMetadata(babylonObject: {
  79662. metadata: any;
  79663. }, pointer: string): void;
  79664. private static _GetTextureWrapMode;
  79665. private static _GetTextureSamplingMode;
  79666. private static _GetTypedArrayConstructor;
  79667. private static _GetTypedArray;
  79668. private static _GetNumComponents;
  79669. private static _ValidateUri;
  79670. private static _GetDrawMode;
  79671. private _compileMaterialsAsync;
  79672. private _compileShadowGeneratorsAsync;
  79673. private _forEachExtensions;
  79674. private _applyExtensions;
  79675. private _extensionsOnLoading;
  79676. private _extensionsOnReady;
  79677. private _extensionsLoadSceneAsync;
  79678. private _extensionsLoadNodeAsync;
  79679. private _extensionsLoadCameraAsync;
  79680. private _extensionsLoadVertexDataAsync;
  79681. private _extensionsLoadMeshPrimitiveAsync;
  79682. private _extensionsLoadMaterialAsync;
  79683. private _extensionsCreateMaterial;
  79684. private _extensionsLoadMaterialPropertiesAsync;
  79685. private _extensionsLoadTextureInfoAsync;
  79686. private _extensionsLoadTextureAsync;
  79687. private _extensionsLoadAnimationAsync;
  79688. private _extensionsLoadSkinAsync;
  79689. private _extensionsLoadUriAsync;
  79690. private _extensionsLoadBufferViewAsync;
  79691. private _extensionsLoadBufferAsync;
  79692. /**
  79693. * Helper method called by a loader extension to load an glTF extension.
  79694. * @param context The context when loading the asset
  79695. * @param property The glTF property to load the extension from
  79696. * @param extensionName The name of the extension to load
  79697. * @param actionAsync The action to run
  79698. * @returns The promise returned by actionAsync or null if the extension does not exist
  79699. */
  79700. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79701. /**
  79702. * Helper method called by a loader extension to load a glTF extra.
  79703. * @param context The context when loading the asset
  79704. * @param property The glTF property to load the extra from
  79705. * @param extensionName The name of the extension to load
  79706. * @param actionAsync The action to run
  79707. * @returns The promise returned by actionAsync or null if the extra does not exist
  79708. */
  79709. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79710. /**
  79711. * Checks for presence of an extension.
  79712. * @param name The name of the extension to check
  79713. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79714. */
  79715. isExtensionUsed(name: string): boolean;
  79716. /**
  79717. * Increments the indentation level and logs a message.
  79718. * @param message The message to log
  79719. */
  79720. logOpen(message: string): void;
  79721. /**
  79722. * Decrements the indentation level.
  79723. */
  79724. logClose(): void;
  79725. /**
  79726. * Logs a message
  79727. * @param message The message to log
  79728. */
  79729. log(message: string): void;
  79730. /**
  79731. * Starts a performance counter.
  79732. * @param counterName The name of the performance counter
  79733. */
  79734. startPerformanceCounter(counterName: string): void;
  79735. /**
  79736. * Ends a performance counter.
  79737. * @param counterName The name of the performance counter
  79738. */
  79739. endPerformanceCounter(counterName: string): void;
  79740. }
  79741. }
  79742. declare module BABYLON.GLTF2.Loader.Extensions {
  79743. /**
  79744. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79745. */
  79746. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79747. /**
  79748. * The name of this extension.
  79749. */
  79750. readonly name: string;
  79751. /**
  79752. * Defines whether this extension is enabled.
  79753. */
  79754. enabled: boolean;
  79755. private _loader;
  79756. private _lights?;
  79757. /** @hidden */
  79758. constructor(loader: GLTFLoader);
  79759. /** @hidden */
  79760. dispose(): void;
  79761. /** @hidden */
  79762. onLoading(): void;
  79763. /** @hidden */
  79764. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79765. private _loadLightAsync;
  79766. }
  79767. }
  79768. declare module BABYLON.GLTF2.Loader.Extensions {
  79769. /**
  79770. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79771. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79772. * !!! Experimental Extension Subject to Changes !!!
  79773. */
  79774. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79775. /**
  79776. * The name of this extension.
  79777. */
  79778. readonly name: string;
  79779. /**
  79780. * Defines whether this extension is enabled.
  79781. */
  79782. enabled: boolean;
  79783. private _loader;
  79784. /** @hidden */
  79785. constructor(loader: GLTFLoader);
  79786. /** @hidden */
  79787. dispose(): void;
  79788. /** @hidden */
  79789. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79790. }
  79791. }
  79792. declare module BABYLON.GLTF2.Loader.Extensions {
  79793. /**
  79794. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79795. */
  79796. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79797. /**
  79798. * The name of this extension.
  79799. */
  79800. readonly name: string;
  79801. /**
  79802. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79803. */
  79804. dracoCompression?: DracoCompression;
  79805. /**
  79806. * Defines whether this extension is enabled.
  79807. */
  79808. enabled: boolean;
  79809. private _loader;
  79810. /** @hidden */
  79811. constructor(loader: GLTFLoader);
  79812. /** @hidden */
  79813. dispose(): void;
  79814. /** @hidden */
  79815. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79816. }
  79817. }
  79818. declare module BABYLON.GLTF2.Loader.Extensions {
  79819. /**
  79820. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79821. */
  79822. export class KHR_lights implements IGLTFLoaderExtension {
  79823. /**
  79824. * The name of this extension.
  79825. */
  79826. readonly name: string;
  79827. /**
  79828. * Defines whether this extension is enabled.
  79829. */
  79830. enabled: boolean;
  79831. private _loader;
  79832. private _lights?;
  79833. /** @hidden */
  79834. constructor(loader: GLTFLoader);
  79835. /** @hidden */
  79836. dispose(): void;
  79837. /** @hidden */
  79838. onLoading(): void;
  79839. /** @hidden */
  79840. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79841. }
  79842. }
  79843. declare module BABYLON.GLTF2.Loader.Extensions {
  79844. /**
  79845. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79846. */
  79847. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79848. /**
  79849. * The name of this extension.
  79850. */
  79851. readonly name: string;
  79852. /**
  79853. * Defines whether this extension is enabled.
  79854. */
  79855. enabled: boolean;
  79856. /**
  79857. * Defines a number that determines the order the extensions are applied.
  79858. */
  79859. order: number;
  79860. private _loader;
  79861. /** @hidden */
  79862. constructor(loader: GLTFLoader);
  79863. /** @hidden */
  79864. dispose(): void;
  79865. /** @hidden */
  79866. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79867. private _loadSpecularGlossinessPropertiesAsync;
  79868. }
  79869. }
  79870. declare module BABYLON.GLTF2.Loader.Extensions {
  79871. /**
  79872. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79873. */
  79874. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79875. /**
  79876. * The name of this extension.
  79877. */
  79878. readonly name: string;
  79879. /**
  79880. * Defines whether this extension is enabled.
  79881. */
  79882. enabled: boolean;
  79883. /**
  79884. * Defines a number that determines the order the extensions are applied.
  79885. */
  79886. order: number;
  79887. private _loader;
  79888. /** @hidden */
  79889. constructor(loader: GLTFLoader);
  79890. /** @hidden */
  79891. dispose(): void;
  79892. /** @hidden */
  79893. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79894. private _loadUnlitPropertiesAsync;
  79895. }
  79896. }
  79897. declare module BABYLON.GLTF2.Loader.Extensions {
  79898. /**
  79899. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79900. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79901. * !!! Experimental Extension Subject to Changes !!!
  79902. */
  79903. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79904. /**
  79905. * The name of this extension.
  79906. */
  79907. readonly name: string;
  79908. /**
  79909. * Defines whether this extension is enabled.
  79910. */
  79911. enabled: boolean;
  79912. /**
  79913. * Defines a number that determines the order the extensions are applied.
  79914. */
  79915. order: number;
  79916. private _loader;
  79917. /** @hidden */
  79918. constructor(loader: GLTFLoader);
  79919. /** @hidden */
  79920. dispose(): void;
  79921. /** @hidden */
  79922. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79923. private _loadClearCoatPropertiesAsync;
  79924. }
  79925. }
  79926. declare module BABYLON.GLTF2.Loader.Extensions {
  79927. /**
  79928. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79929. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79930. * !!! Experimental Extension Subject to Changes !!!
  79931. */
  79932. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79933. /**
  79934. * The name of this extension.
  79935. */
  79936. readonly name: string;
  79937. /**
  79938. * Defines whether this extension is enabled.
  79939. */
  79940. enabled: boolean;
  79941. /**
  79942. * Defines a number that determines the order the extensions are applied.
  79943. */
  79944. order: number;
  79945. private _loader;
  79946. /** @hidden */
  79947. constructor(loader: GLTFLoader);
  79948. /** @hidden */
  79949. dispose(): void;
  79950. /** @hidden */
  79951. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79952. private _loadSheenPropertiesAsync;
  79953. }
  79954. }
  79955. declare module BABYLON.GLTF2.Loader.Extensions {
  79956. /**
  79957. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79958. * !!! Experimental Extension Subject to Changes !!!
  79959. */
  79960. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79961. /**
  79962. * The name of this extension.
  79963. */
  79964. readonly name: string;
  79965. /**
  79966. * Defines whether this extension is enabled.
  79967. */
  79968. enabled: boolean;
  79969. /**
  79970. * Defines a number that determines the order the extensions are applied.
  79971. */
  79972. order: number;
  79973. private _loader;
  79974. /** @hidden */
  79975. constructor(loader: GLTFLoader);
  79976. /** @hidden */
  79977. dispose(): void;
  79978. /** @hidden */
  79979. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79980. private _loadSpecularPropertiesAsync;
  79981. }
  79982. }
  79983. declare module BABYLON.GLTF2.Loader.Extensions {
  79984. /**
  79985. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79986. * !!! Experimental Extension Subject to Changes !!!
  79987. */
  79988. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79989. /**
  79990. * Default ior Value from the spec.
  79991. */
  79992. private static readonly _DEFAULT_IOR;
  79993. /**
  79994. * The name of this extension.
  79995. */
  79996. readonly name: string;
  79997. /**
  79998. * Defines whether this extension is enabled.
  79999. */
  80000. enabled: boolean;
  80001. /**
  80002. * Defines a number that determines the order the extensions are applied.
  80003. */
  80004. order: number;
  80005. private _loader;
  80006. /** @hidden */
  80007. constructor(loader: GLTFLoader);
  80008. /** @hidden */
  80009. dispose(): void;
  80010. /** @hidden */
  80011. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80012. private _loadIorPropertiesAsync;
  80013. }
  80014. }
  80015. declare module BABYLON.GLTF2.Loader.Extensions {
  80016. /**
  80017. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80018. * !!! Experimental Extension Subject to Changes !!!
  80019. */
  80020. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80021. /**
  80022. * The name of this extension.
  80023. */
  80024. readonly name: string;
  80025. /**
  80026. * Defines whether this extension is enabled.
  80027. */
  80028. enabled: boolean;
  80029. private _loader;
  80030. /**
  80031. * The default variant name.
  80032. */
  80033. defaultVariant: string | undefined;
  80034. private _tagsToMap;
  80035. /** @hidden */
  80036. constructor(loader: GLTFLoader);
  80037. /** @hidden */
  80038. dispose(): void;
  80039. /**
  80040. * Return a list of available variants for this asset.
  80041. * @returns {string[]}
  80042. */
  80043. getVariants(): string[];
  80044. /**
  80045. * Select a variant by providing a list of variant tag names.
  80046. *
  80047. * @param {(string | string[])} variantName
  80048. */
  80049. selectVariant(variantName: string | string[]): void;
  80050. /**
  80051. * Select a variant by providing a single variant tag.
  80052. *
  80053. * @param {string} variantName
  80054. */
  80055. selectVariantTag(variantName: string): void;
  80056. /** @hidden */
  80057. onLoading(): void;
  80058. /** @hidden */
  80059. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80060. }
  80061. }
  80062. declare module BABYLON.GLTF2.Loader.Extensions {
  80063. /**
  80064. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80065. * !!! Experimental Extension Subject to Changes !!!
  80066. */
  80067. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80068. /**
  80069. * The name of this extension.
  80070. */
  80071. readonly name: string;
  80072. /**
  80073. * Defines whether this extension is enabled.
  80074. */
  80075. enabled: boolean;
  80076. /**
  80077. * Defines a number that determines the order the extensions are applied.
  80078. */
  80079. order: number;
  80080. private _loader;
  80081. /** @hidden */
  80082. constructor(loader: GLTFLoader);
  80083. /** @hidden */
  80084. dispose(): void;
  80085. /** @hidden */
  80086. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80087. private _loadTransparentPropertiesAsync;
  80088. }
  80089. }
  80090. declare module BABYLON.GLTF2.Loader.Extensions {
  80091. /**
  80092. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80093. */
  80094. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80095. /**
  80096. * The name of this extension.
  80097. */
  80098. readonly name: string;
  80099. /**
  80100. * Defines whether this extension is enabled.
  80101. */
  80102. enabled: boolean;
  80103. /** @hidden */
  80104. constructor(loader: GLTFLoader);
  80105. /** @hidden */
  80106. dispose(): void;
  80107. }
  80108. }
  80109. declare module BABYLON.GLTF2.Loader.Extensions {
  80110. /**
  80111. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80112. * !!! Experimental Extension Subject to Changes !!!
  80113. */
  80114. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80115. /** The name of this extension. */
  80116. readonly name: string;
  80117. /** Defines whether this extension is enabled. */
  80118. enabled: boolean;
  80119. private _loader;
  80120. /** @hidden */
  80121. constructor(loader: GLTFLoader);
  80122. /** @hidden */
  80123. dispose(): void;
  80124. /** @hidden */
  80125. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80126. }
  80127. }
  80128. declare module BABYLON.GLTF2.Loader.Extensions {
  80129. /**
  80130. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80131. */
  80132. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80133. /**
  80134. * The name of this extension.
  80135. */
  80136. readonly name: string;
  80137. /**
  80138. * Defines whether this extension is enabled.
  80139. */
  80140. enabled: boolean;
  80141. private _loader;
  80142. /** @hidden */
  80143. constructor(loader: GLTFLoader);
  80144. /** @hidden */
  80145. dispose(): void;
  80146. /** @hidden */
  80147. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80148. }
  80149. }
  80150. declare module BABYLON.GLTF2.Loader.Extensions {
  80151. /**
  80152. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80153. * !!! Experimental Extension Subject to Changes !!!
  80154. */
  80155. export class KHR_xmp implements IGLTFLoaderExtension {
  80156. /**
  80157. * The name of this extension.
  80158. */
  80159. readonly name: string;
  80160. /**
  80161. * Defines whether this extension is enabled.
  80162. */
  80163. enabled: boolean;
  80164. /**
  80165. * Defines a number that determines the order the extensions are applied.
  80166. */
  80167. order: number;
  80168. private _loader;
  80169. /** @hidden */
  80170. constructor(loader: GLTFLoader);
  80171. /** @hidden */
  80172. dispose(): void;
  80173. /**
  80174. * Called after the loader state changes to LOADING.
  80175. */
  80176. onLoading(): void;
  80177. }
  80178. }
  80179. declare module BABYLON.GLTF2.Loader.Extensions {
  80180. /**
  80181. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80182. */
  80183. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80184. /**
  80185. * The name of this extension.
  80186. */
  80187. readonly name: string;
  80188. /**
  80189. * Defines whether this extension is enabled.
  80190. */
  80191. enabled: boolean;
  80192. private _loader;
  80193. private _clips;
  80194. private _emitters;
  80195. /** @hidden */
  80196. constructor(loader: GLTFLoader);
  80197. /** @hidden */
  80198. dispose(): void;
  80199. /** @hidden */
  80200. onLoading(): void;
  80201. /** @hidden */
  80202. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80203. /** @hidden */
  80204. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80205. /** @hidden */
  80206. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80207. private _loadClipAsync;
  80208. private _loadEmitterAsync;
  80209. private _getEventAction;
  80210. private _loadAnimationEventAsync;
  80211. }
  80212. }
  80213. declare module BABYLON.GLTF2.Loader.Extensions {
  80214. /**
  80215. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80216. */
  80217. export class MSFT_lod implements IGLTFLoaderExtension {
  80218. /**
  80219. * The name of this extension.
  80220. */
  80221. readonly name: string;
  80222. /**
  80223. * Defines whether this extension is enabled.
  80224. */
  80225. enabled: boolean;
  80226. /**
  80227. * Defines a number that determines the order the extensions are applied.
  80228. */
  80229. order: number;
  80230. /**
  80231. * Maximum number of LODs to load, starting from the lowest LOD.
  80232. */
  80233. maxLODsToLoad: number;
  80234. /**
  80235. * Observable raised when all node LODs of one level are loaded.
  80236. * The event data is the index of the loaded LOD starting from zero.
  80237. * Dispose the loader to cancel the loading of the next level of LODs.
  80238. */
  80239. onNodeLODsLoadedObservable: Observable<number>;
  80240. /**
  80241. * Observable raised when all material LODs of one level are loaded.
  80242. * The event data is the index of the loaded LOD starting from zero.
  80243. * Dispose the loader to cancel the loading of the next level of LODs.
  80244. */
  80245. onMaterialLODsLoadedObservable: Observable<number>;
  80246. private _loader;
  80247. private _nodeIndexLOD;
  80248. private _nodeSignalLODs;
  80249. private _nodePromiseLODs;
  80250. private _materialIndexLOD;
  80251. private _materialSignalLODs;
  80252. private _materialPromiseLODs;
  80253. private _indexLOD;
  80254. private _bufferLODs;
  80255. /** @hidden */
  80256. constructor(loader: GLTFLoader);
  80257. /** @hidden */
  80258. dispose(): void;
  80259. /** @hidden */
  80260. onReady(): void;
  80261. /** @hidden */
  80262. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80263. /** @hidden */
  80264. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80265. /** @hidden */
  80266. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80267. /** @hidden */
  80268. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80269. /** @hidden */
  80270. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80271. private _loadBufferLOD;
  80272. /**
  80273. * Gets an array of LOD properties from lowest to highest.
  80274. */
  80275. private _getLODs;
  80276. private _disposeTransformNode;
  80277. private _disposeMaterials;
  80278. }
  80279. }
  80280. declare module BABYLON.GLTF2.Loader.Extensions {
  80281. /** @hidden */
  80282. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80283. readonly name: string;
  80284. enabled: boolean;
  80285. private _loader;
  80286. constructor(loader: GLTFLoader);
  80287. dispose(): void;
  80288. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80289. }
  80290. }
  80291. declare module BABYLON.GLTF2.Loader.Extensions {
  80292. /** @hidden */
  80293. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80294. readonly name: string;
  80295. enabled: boolean;
  80296. private _loader;
  80297. constructor(loader: GLTFLoader);
  80298. dispose(): void;
  80299. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80300. }
  80301. }
  80302. declare module BABYLON.GLTF2.Loader.Extensions {
  80303. /**
  80304. * Store glTF extras (if present) in BJS objects' metadata
  80305. */
  80306. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80307. /**
  80308. * The name of this extension.
  80309. */
  80310. readonly name: string;
  80311. /**
  80312. * Defines whether this extension is enabled.
  80313. */
  80314. enabled: boolean;
  80315. private _loader;
  80316. private _assignExtras;
  80317. /** @hidden */
  80318. constructor(loader: GLTFLoader);
  80319. /** @hidden */
  80320. dispose(): void;
  80321. /** @hidden */
  80322. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80323. /** @hidden */
  80324. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80325. /** @hidden */
  80326. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80327. }
  80328. }
  80329. declare module BABYLON {
  80330. /**
  80331. * Class reading and parsing the MTL file bundled with the obj file.
  80332. */
  80333. export class MTLFileLoader {
  80334. /**
  80335. * Invert Y-Axis of referenced textures on load
  80336. */
  80337. static INVERT_TEXTURE_Y: boolean;
  80338. /**
  80339. * All material loaded from the mtl will be set here
  80340. */
  80341. materials: StandardMaterial[];
  80342. /**
  80343. * This function will read the mtl file and create each material described inside
  80344. * This function could be improve by adding :
  80345. * -some component missing (Ni, Tf...)
  80346. * -including the specific options available
  80347. *
  80348. * @param scene defines the scene the material will be created in
  80349. * @param data defines the mtl data to parse
  80350. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80351. * @param forAssetContainer defines if the material should be registered in the scene
  80352. */
  80353. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80354. /**
  80355. * Gets the texture for the material.
  80356. *
  80357. * If the material is imported from input file,
  80358. * We sanitize the url to ensure it takes the textre from aside the material.
  80359. *
  80360. * @param rootUrl The root url to load from
  80361. * @param value The value stored in the mtl
  80362. * @return The Texture
  80363. */
  80364. private static _getTexture;
  80365. }
  80366. }
  80367. declare module BABYLON {
  80368. /**
  80369. * Options for loading OBJ/MTL files
  80370. */
  80371. type MeshLoadOptions = {
  80372. /**
  80373. * Defines if UVs are optimized by default during load.
  80374. */
  80375. OptimizeWithUV: boolean;
  80376. /**
  80377. * Defines custom scaling of UV coordinates of loaded meshes.
  80378. */
  80379. UVScaling: Vector2;
  80380. /**
  80381. * Invert model on y-axis (does a model scaling inversion)
  80382. */
  80383. InvertY: boolean;
  80384. /**
  80385. * Invert Y-Axis of referenced textures on load
  80386. */
  80387. InvertTextureY: boolean;
  80388. /**
  80389. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80390. */
  80391. ImportVertexColors: boolean;
  80392. /**
  80393. * Compute the normals for the model, even if normals are present in the file.
  80394. */
  80395. ComputeNormals: boolean;
  80396. /**
  80397. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80398. */
  80399. SkipMaterials: boolean;
  80400. /**
  80401. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80402. */
  80403. MaterialLoadingFailsSilently: boolean;
  80404. };
  80405. /**
  80406. * OBJ file type loader.
  80407. * This is a babylon scene loader plugin.
  80408. */
  80409. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80410. /**
  80411. * Defines if UVs are optimized by default during load.
  80412. */
  80413. static OPTIMIZE_WITH_UV: boolean;
  80414. /**
  80415. * Invert model on y-axis (does a model scaling inversion)
  80416. */
  80417. static INVERT_Y: boolean;
  80418. /**
  80419. * Invert Y-Axis of referenced textures on load
  80420. */
  80421. static get INVERT_TEXTURE_Y(): boolean;
  80422. static set INVERT_TEXTURE_Y(value: boolean);
  80423. /**
  80424. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80425. */
  80426. static IMPORT_VERTEX_COLORS: boolean;
  80427. /**
  80428. * Compute the normals for the model, even if normals are present in the file.
  80429. */
  80430. static COMPUTE_NORMALS: boolean;
  80431. /**
  80432. * Defines custom scaling of UV coordinates of loaded meshes.
  80433. */
  80434. static UV_SCALING: Vector2;
  80435. /**
  80436. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80437. */
  80438. static SKIP_MATERIALS: boolean;
  80439. /**
  80440. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80441. *
  80442. * Defaults to true for backwards compatibility.
  80443. */
  80444. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80445. /**
  80446. * Defines the name of the plugin.
  80447. */
  80448. name: string;
  80449. /**
  80450. * Defines the extension the plugin is able to load.
  80451. */
  80452. extensions: string;
  80453. /** @hidden */
  80454. obj: RegExp;
  80455. /** @hidden */
  80456. group: RegExp;
  80457. /** @hidden */
  80458. mtllib: RegExp;
  80459. /** @hidden */
  80460. usemtl: RegExp;
  80461. /** @hidden */
  80462. smooth: RegExp;
  80463. /** @hidden */
  80464. vertexPattern: RegExp;
  80465. /** @hidden */
  80466. normalPattern: RegExp;
  80467. /** @hidden */
  80468. uvPattern: RegExp;
  80469. /** @hidden */
  80470. facePattern1: RegExp;
  80471. /** @hidden */
  80472. facePattern2: RegExp;
  80473. /** @hidden */
  80474. facePattern3: RegExp;
  80475. /** @hidden */
  80476. facePattern4: RegExp;
  80477. /** @hidden */
  80478. facePattern5: RegExp;
  80479. private _forAssetContainer;
  80480. private _meshLoadOptions;
  80481. /**
  80482. * Creates loader for .OBJ files
  80483. *
  80484. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80485. */
  80486. constructor(meshLoadOptions?: MeshLoadOptions);
  80487. private static get currentMeshLoadOptions();
  80488. /**
  80489. * Calls synchronously the MTL file attached to this obj.
  80490. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80491. * Without this function materials are not displayed in the first frame (but displayed after).
  80492. * In consequence it is impossible to get material information in your HTML file
  80493. *
  80494. * @param url The URL of the MTL file
  80495. * @param rootUrl
  80496. * @param onSuccess Callback function to be called when the MTL file is loaded
  80497. * @private
  80498. */
  80499. private _loadMTL;
  80500. /**
  80501. * Instantiates a OBJ file loader plugin.
  80502. * @returns the created plugin
  80503. */
  80504. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80505. /**
  80506. * If the data string can be loaded directly.
  80507. *
  80508. * @param data string containing the file data
  80509. * @returns if the data can be loaded directly
  80510. */
  80511. canDirectLoad(data: string): boolean;
  80512. /**
  80513. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80514. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80515. * @param scene the scene the meshes should be added to
  80516. * @param data the OBJ data to load
  80517. * @param rootUrl root url to load from
  80518. * @param onProgress event that fires when loading progress has occured
  80519. * @param fileName Defines the name of the file to load
  80520. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80521. */
  80522. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80523. meshes: AbstractMesh[];
  80524. particleSystems: IParticleSystem[];
  80525. skeletons: Skeleton[];
  80526. animationGroups: AnimationGroup[];
  80527. }>;
  80528. /**
  80529. * Imports all objects from the loaded OBJ data and adds them to the scene
  80530. * @param scene the scene the objects should be added to
  80531. * @param data the OBJ data to load
  80532. * @param rootUrl root url to load from
  80533. * @param onProgress event that fires when loading progress has occured
  80534. * @param fileName Defines the name of the file to load
  80535. * @returns a promise which completes when objects have been loaded to the scene
  80536. */
  80537. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80538. /**
  80539. * Load into an asset container.
  80540. * @param scene The scene to load into
  80541. * @param data The data to import
  80542. * @param rootUrl The root url for scene and resources
  80543. * @param onProgress The callback when the load progresses
  80544. * @param fileName Defines the name of the file to load
  80545. * @returns The loaded asset container
  80546. */
  80547. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80548. /**
  80549. * Read the OBJ file and create an Array of meshes.
  80550. * Each mesh contains all information given by the OBJ and the MTL file.
  80551. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80552. *
  80553. * @param meshesNames
  80554. * @param scene Scene The scene where are displayed the data
  80555. * @param data String The content of the obj file
  80556. * @param rootUrl String The path to the folder
  80557. * @returns Array<AbstractMesh>
  80558. * @private
  80559. */
  80560. private _parseSolid;
  80561. }
  80562. }
  80563. declare module BABYLON {
  80564. /**
  80565. * STL file type loader.
  80566. * This is a babylon scene loader plugin.
  80567. */
  80568. export class STLFileLoader implements ISceneLoaderPlugin {
  80569. /** @hidden */
  80570. solidPattern: RegExp;
  80571. /** @hidden */
  80572. facetsPattern: RegExp;
  80573. /** @hidden */
  80574. normalPattern: RegExp;
  80575. /** @hidden */
  80576. vertexPattern: RegExp;
  80577. /**
  80578. * Defines the name of the plugin.
  80579. */
  80580. name: string;
  80581. /**
  80582. * Defines the extensions the stl loader is able to load.
  80583. * force data to come in as an ArrayBuffer
  80584. * we'll convert to string if it looks like it's an ASCII .stl
  80585. */
  80586. extensions: ISceneLoaderPluginExtensions;
  80587. /**
  80588. * Import meshes into a scene.
  80589. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80590. * @param scene The scene to import into
  80591. * @param data The data to import
  80592. * @param rootUrl The root url for scene and resources
  80593. * @param meshes The meshes array to import into
  80594. * @param particleSystems The particle systems array to import into
  80595. * @param skeletons The skeletons array to import into
  80596. * @param onError The callback when import fails
  80597. * @returns True if successful or false otherwise
  80598. */
  80599. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80600. /**
  80601. * Load into a scene.
  80602. * @param scene The scene to load into
  80603. * @param data The data to import
  80604. * @param rootUrl The root url for scene and resources
  80605. * @param onError The callback when import fails
  80606. * @returns true if successful or false otherwise
  80607. */
  80608. load(scene: Scene, data: any, rootUrl: string): boolean;
  80609. /**
  80610. * Load into an asset container.
  80611. * @param scene The scene to load into
  80612. * @param data The data to import
  80613. * @param rootUrl The root url for scene and resources
  80614. * @param onError The callback when import fails
  80615. * @returns The loaded asset container
  80616. */
  80617. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80618. private _isBinary;
  80619. private _parseBinary;
  80620. private _parseASCII;
  80621. }
  80622. }
  80623. declare module BABYLON {
  80624. /**
  80625. * Class for generating OBJ data from a Babylon scene.
  80626. */
  80627. export class OBJExport {
  80628. /**
  80629. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80630. * @param mesh defines the list of meshes to serialize
  80631. * @param materials defines if materials should be exported
  80632. * @param matlibname defines the name of the associated mtl file
  80633. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80634. * @returns the OBJ content
  80635. */
  80636. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80637. /**
  80638. * Exports the material(s) of a mesh in .MTL file format (text)
  80639. * @param mesh defines the mesh to extract the material from
  80640. * @returns the mtl content
  80641. */
  80642. static MTL(mesh: Mesh): string;
  80643. }
  80644. }
  80645. declare module BABYLON {
  80646. /** @hidden */
  80647. export var __IGLTFExporterExtension: number;
  80648. /**
  80649. * Interface for extending the exporter
  80650. * @hidden
  80651. */
  80652. export interface IGLTFExporterExtension {
  80653. /**
  80654. * The name of this extension
  80655. */
  80656. readonly name: string;
  80657. /**
  80658. * Defines whether this extension is enabled
  80659. */
  80660. enabled: boolean;
  80661. /**
  80662. * Defines whether this extension is required
  80663. */
  80664. required: boolean;
  80665. }
  80666. }
  80667. declare module BABYLON.GLTF2.Exporter {
  80668. /** @hidden */
  80669. export var __IGLTFExporterExtensionV2: number;
  80670. /**
  80671. * Interface for a glTF exporter extension
  80672. * @hidden
  80673. */
  80674. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80675. /**
  80676. * Define this method to modify the default behavior before exporting a texture
  80677. * @param context The context when loading the asset
  80678. * @param babylonTexture The Babylon.js texture
  80679. * @param mimeType The mime-type of the generated image
  80680. * @returns A promise that resolves with the exported texture
  80681. */
  80682. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80683. /**
  80684. * Define this method to get notified when a texture info is created
  80685. * @param context The context when loading the asset
  80686. * @param textureInfo The glTF texture info
  80687. * @param babylonTexture The Babylon.js texture
  80688. */
  80689. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80690. /**
  80691. * Define this method to modify the default behavior when exporting texture info
  80692. * @param context The context when loading the asset
  80693. * @param meshPrimitive glTF mesh primitive
  80694. * @param babylonSubMesh Babylon submesh
  80695. * @param binaryWriter glTF serializer binary writer instance
  80696. * @returns nullable IMeshPrimitive promise
  80697. */
  80698. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80699. /**
  80700. * Define this method to modify the default behavior when exporting a node
  80701. * @param context The context when exporting the node
  80702. * @param node glTF node
  80703. * @param babylonNode BabylonJS node
  80704. * @returns nullable INode promise
  80705. */
  80706. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80707. [key: number]: number;
  80708. }): Promise<Nullable<INode>>;
  80709. /**
  80710. * Define this method to modify the default behavior when exporting a material
  80711. * @param material glTF material
  80712. * @param babylonMaterial BabylonJS material
  80713. * @returns nullable IMaterial promise
  80714. */
  80715. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80716. /**
  80717. * Define this method to return additional textures to export from a material
  80718. * @param material glTF material
  80719. * @param babylonMaterial BabylonJS material
  80720. * @returns List of textures
  80721. */
  80722. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80723. /** Gets a boolean indicating that this extension was used */
  80724. wasUsed: boolean;
  80725. /** Gets a boolean indicating that this extension is required for the file to work */
  80726. required: boolean;
  80727. /**
  80728. * Called after the exporter state changes to EXPORTING
  80729. */
  80730. onExporting?(): void;
  80731. }
  80732. }
  80733. declare module BABYLON.GLTF2.Exporter {
  80734. /**
  80735. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80736. * @hidden
  80737. */
  80738. export class _GLTFMaterialExporter {
  80739. /**
  80740. * Represents the dielectric specular values for R, G and B
  80741. */
  80742. private static readonly _DielectricSpecular;
  80743. /**
  80744. * Allows the maximum specular power to be defined for material calculations
  80745. */
  80746. private static readonly _MaxSpecularPower;
  80747. /**
  80748. * Mapping to store textures
  80749. */
  80750. private _textureMap;
  80751. /**
  80752. * Numeric tolerance value
  80753. */
  80754. private static readonly _Epsilon;
  80755. /**
  80756. * Reference to the glTF Exporter
  80757. */
  80758. private _exporter;
  80759. constructor(exporter: _Exporter);
  80760. /**
  80761. * Specifies if two colors are approximately equal in value
  80762. * @param color1 first color to compare to
  80763. * @param color2 second color to compare to
  80764. * @param epsilon threshold value
  80765. */
  80766. private static FuzzyEquals;
  80767. /**
  80768. * Gets the materials from a Babylon scene and converts them to glTF materials
  80769. * @param scene babylonjs scene
  80770. * @param mimeType texture mime type
  80771. * @param images array of images
  80772. * @param textures array of textures
  80773. * @param materials array of materials
  80774. * @param imageData mapping of texture names to base64 textures
  80775. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80776. */
  80777. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80778. /**
  80779. * Makes a copy of the glTF material without the texture parameters
  80780. * @param originalMaterial original glTF material
  80781. * @returns glTF material without texture parameters
  80782. */
  80783. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80784. /**
  80785. * Specifies if the material has any texture parameters present
  80786. * @param material glTF Material
  80787. * @returns boolean specifying if texture parameters are present
  80788. */
  80789. _hasTexturesPresent(material: IMaterial): boolean;
  80790. /**
  80791. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80792. * @param babylonStandardMaterial
  80793. * @returns glTF Metallic Roughness Material representation
  80794. */
  80795. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80796. /**
  80797. * Computes the metallic factor
  80798. * @param diffuse diffused value
  80799. * @param specular specular value
  80800. * @param oneMinusSpecularStrength one minus the specular strength
  80801. * @returns metallic value
  80802. */
  80803. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80804. /**
  80805. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80806. * @param glTFMaterial glTF material
  80807. * @param babylonMaterial Babylon material
  80808. */
  80809. private static _SetAlphaMode;
  80810. /**
  80811. * Converts a Babylon Standard Material to a glTF Material
  80812. * @param babylonStandardMaterial BJS Standard Material
  80813. * @param mimeType mime type to use for the textures
  80814. * @param images array of glTF image interfaces
  80815. * @param textures array of glTF texture interfaces
  80816. * @param materials array of glTF material interfaces
  80817. * @param imageData map of image file name to data
  80818. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80819. */
  80820. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80821. private _finishMaterial;
  80822. /**
  80823. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80824. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80825. * @param mimeType mime type to use for the textures
  80826. * @param images array of glTF image interfaces
  80827. * @param textures array of glTF texture interfaces
  80828. * @param materials array of glTF material interfaces
  80829. * @param imageData map of image file name to data
  80830. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80831. */
  80832. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80833. /**
  80834. * Converts an image typed array buffer to a base64 image
  80835. * @param buffer typed array buffer
  80836. * @param width width of the image
  80837. * @param height height of the image
  80838. * @param mimeType mimetype of the image
  80839. * @returns base64 image string
  80840. */
  80841. private _createBase64FromCanvasAsync;
  80842. /**
  80843. * Generates a white texture based on the specified width and height
  80844. * @param width width of the texture in pixels
  80845. * @param height height of the texture in pixels
  80846. * @param scene babylonjs scene
  80847. * @returns white texture
  80848. */
  80849. private _createWhiteTexture;
  80850. /**
  80851. * 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
  80852. * @param texture1 first texture to resize
  80853. * @param texture2 second texture to resize
  80854. * @param scene babylonjs scene
  80855. * @returns resized textures or null
  80856. */
  80857. private _resizeTexturesToSameDimensions;
  80858. /**
  80859. * Converts an array of pixels to a Float32Array
  80860. * Throws an error if the pixel format is not supported
  80861. * @param pixels - array buffer containing pixel values
  80862. * @returns Float32 of pixels
  80863. */
  80864. private _convertPixelArrayToFloat32;
  80865. /**
  80866. * Convert Specular Glossiness Textures to Metallic Roughness
  80867. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80868. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80869. * @param diffuseTexture texture used to store diffuse information
  80870. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80871. * @param factors specular glossiness material factors
  80872. * @param mimeType the mime type to use for the texture
  80873. * @returns pbr metallic roughness interface or null
  80874. */
  80875. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80876. /**
  80877. * Converts specular glossiness material properties to metallic roughness
  80878. * @param specularGlossiness interface with specular glossiness material properties
  80879. * @returns interface with metallic roughness material properties
  80880. */
  80881. private _convertSpecularGlossinessToMetallicRoughness;
  80882. /**
  80883. * Calculates the surface reflectance, independent of lighting conditions
  80884. * @param color Color source to calculate brightness from
  80885. * @returns number representing the perceived brightness, or zero if color is undefined
  80886. */
  80887. private _getPerceivedBrightness;
  80888. /**
  80889. * Returns the maximum color component value
  80890. * @param color
  80891. * @returns maximum color component value, or zero if color is null or undefined
  80892. */
  80893. private _getMaxComponent;
  80894. /**
  80895. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80896. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80897. * @param mimeType mime type to use for the textures
  80898. * @param images array of glTF image interfaces
  80899. * @param textures array of glTF texture interfaces
  80900. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80901. * @param imageData map of image file name to data
  80902. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80903. * @returns glTF PBR Metallic Roughness factors
  80904. */
  80905. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80906. private _getGLTFTextureSampler;
  80907. private _getGLTFTextureWrapMode;
  80908. private _getGLTFTextureWrapModesSampler;
  80909. /**
  80910. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80911. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80912. * @param mimeType mime type to use for the textures
  80913. * @param images array of glTF image interfaces
  80914. * @param textures array of glTF texture interfaces
  80915. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80916. * @param imageData map of image file name to data
  80917. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80918. * @returns glTF PBR Metallic Roughness factors
  80919. */
  80920. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80921. /**
  80922. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80923. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80924. * @param mimeType mime type to use for the textures
  80925. * @param images array of glTF image interfaces
  80926. * @param textures array of glTF texture interfaces
  80927. * @param materials array of glTF material interfaces
  80928. * @param imageData map of image file name to data
  80929. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80930. */
  80931. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80932. private setMetallicRoughnessPbrMaterial;
  80933. private getPixelsFromTexture;
  80934. /**
  80935. * Extracts a texture from a Babylon texture into file data and glTF data
  80936. * @param babylonTexture Babylon texture to extract
  80937. * @param mimeType Mime Type of the babylonTexture
  80938. * @return glTF texture info, or null if the texture format is not supported
  80939. */
  80940. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80941. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80942. /**
  80943. * Builds a texture from base64 string
  80944. * @param base64Texture base64 texture string
  80945. * @param baseTextureName Name to use for the texture
  80946. * @param mimeType image mime type for the texture
  80947. * @param images array of images
  80948. * @param textures array of textures
  80949. * @param imageData map of image data
  80950. * @returns glTF texture info, or null if the texture format is not supported
  80951. */
  80952. private _getTextureInfoFromBase64;
  80953. }
  80954. }
  80955. declare module BABYLON {
  80956. /**
  80957. * Class for holding and downloading glTF file data
  80958. */
  80959. export class GLTFData {
  80960. /**
  80961. * Object which contains the file name as the key and its data as the value
  80962. */
  80963. glTFFiles: {
  80964. [fileName: string]: string | Blob;
  80965. };
  80966. /**
  80967. * Initializes the glTF file object
  80968. */
  80969. constructor();
  80970. /**
  80971. * Downloads the glTF data as files based on their names and data
  80972. */
  80973. downloadFiles(): void;
  80974. }
  80975. }
  80976. declare module BABYLON {
  80977. /**
  80978. * Holds a collection of exporter options and parameters
  80979. */
  80980. export interface IExportOptions {
  80981. /**
  80982. * Function which indicates whether a babylon node should be exported or not
  80983. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80984. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80985. */
  80986. shouldExportNode?(node: Node): boolean;
  80987. /**
  80988. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80989. * @param metadata source metadata to read from
  80990. * @returns the data to store to glTF node extras
  80991. */
  80992. metadataSelector?(metadata: any): any;
  80993. /**
  80994. * The sample rate to bake animation curves
  80995. */
  80996. animationSampleRate?: number;
  80997. /**
  80998. * Begin serialization without waiting for the scene to be ready
  80999. */
  81000. exportWithoutWaitingForScene?: boolean;
  81001. /**
  81002. * Indicates if coordinate system swapping root nodes should be included in export
  81003. */
  81004. includeCoordinateSystemConversionNodes?: boolean;
  81005. }
  81006. /**
  81007. * Class for generating glTF data from a Babylon scene.
  81008. */
  81009. export class GLTF2Export {
  81010. /**
  81011. * Exports the geometry of the scene to .gltf file format asynchronously
  81012. * @param scene Babylon scene with scene hierarchy information
  81013. * @param filePrefix File prefix to use when generating the glTF file
  81014. * @param options Exporter options
  81015. * @returns Returns an object with a .gltf file and associates texture names
  81016. * as keys and their data and paths as values
  81017. */
  81018. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81019. private static _PreExportAsync;
  81020. private static _PostExportAsync;
  81021. /**
  81022. * Exports the geometry of the scene to .glb file format asychronously
  81023. * @param scene Babylon scene with scene hierarchy information
  81024. * @param filePrefix File prefix to use when generating glb file
  81025. * @param options Exporter options
  81026. * @returns Returns an object with a .glb filename as key and data as value
  81027. */
  81028. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81029. }
  81030. }
  81031. declare module BABYLON.GLTF2.Exporter {
  81032. /**
  81033. * @hidden
  81034. */
  81035. export class _GLTFUtilities {
  81036. /**
  81037. * Creates a buffer view based on the supplied arguments
  81038. * @param bufferIndex index value of the specified buffer
  81039. * @param byteOffset byte offset value
  81040. * @param byteLength byte length of the bufferView
  81041. * @param byteStride byte distance between conequential elements
  81042. * @param name name of the buffer view
  81043. * @returns bufferView for glTF
  81044. */
  81045. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81046. /**
  81047. * Creates an accessor based on the supplied arguments
  81048. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81049. * @param name The name of the accessor
  81050. * @param type The type of the accessor
  81051. * @param componentType The datatype of components in the attribute
  81052. * @param count The number of attributes referenced by this accessor
  81053. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81054. * @param min Minimum value of each component in this attribute
  81055. * @param max Maximum value of each component in this attribute
  81056. * @returns accessor for glTF
  81057. */
  81058. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81059. /**
  81060. * Calculates the minimum and maximum values of an array of position floats
  81061. * @param positions Positions array of a mesh
  81062. * @param vertexStart Starting vertex offset to calculate min and max values
  81063. * @param vertexCount Number of vertices to check for min and max values
  81064. * @returns min number array and max number array
  81065. */
  81066. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81067. min: number[];
  81068. max: number[];
  81069. };
  81070. /**
  81071. * Converts a new right-handed Vector3
  81072. * @param vector vector3 array
  81073. * @returns right-handed Vector3
  81074. */
  81075. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81076. /**
  81077. * Converts a Vector3 to right-handed
  81078. * @param vector Vector3 to convert to right-handed
  81079. */
  81080. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81081. /**
  81082. * Converts a three element number array to right-handed
  81083. * @param vector number array to convert to right-handed
  81084. */
  81085. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81086. /**
  81087. * Converts a new right-handed Vector3
  81088. * @param vector vector3 array
  81089. * @returns right-handed Vector3
  81090. */
  81091. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81092. /**
  81093. * Converts a Vector3 to right-handed
  81094. * @param vector Vector3 to convert to right-handed
  81095. */
  81096. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81097. /**
  81098. * Converts a three element number array to right-handed
  81099. * @param vector number array to convert to right-handed
  81100. */
  81101. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81102. /**
  81103. * Converts a Vector4 to right-handed
  81104. * @param vector Vector4 to convert to right-handed
  81105. */
  81106. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81107. /**
  81108. * Converts a Vector4 to right-handed
  81109. * @param vector Vector4 to convert to right-handed
  81110. */
  81111. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81112. /**
  81113. * Converts a Quaternion to right-handed
  81114. * @param quaternion Source quaternion to convert to right-handed
  81115. */
  81116. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81117. /**
  81118. * Converts a Quaternion to right-handed
  81119. * @param quaternion Source quaternion to convert to right-handed
  81120. */
  81121. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81122. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81123. }
  81124. }
  81125. declare module BABYLON.GLTF2.Exporter {
  81126. /**
  81127. * Converts Babylon Scene into glTF 2.0.
  81128. * @hidden
  81129. */
  81130. export class _Exporter {
  81131. /**
  81132. * Stores the glTF to export
  81133. */
  81134. _glTF: IGLTF;
  81135. /**
  81136. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81137. */
  81138. _bufferViews: IBufferView[];
  81139. /**
  81140. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81141. */
  81142. _accessors: IAccessor[];
  81143. /**
  81144. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81145. */
  81146. _nodes: INode[];
  81147. /**
  81148. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81149. */
  81150. private _scenes;
  81151. /**
  81152. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81153. */
  81154. private _meshes;
  81155. /**
  81156. * Stores all the generated material information, which represents the appearance of each primitive
  81157. */
  81158. _materials: IMaterial[];
  81159. _materialMap: {
  81160. [materialID: number]: number;
  81161. };
  81162. /**
  81163. * Stores all the generated texture information, which is referenced by glTF materials
  81164. */
  81165. _textures: ITexture[];
  81166. /**
  81167. * Stores all the generated image information, which is referenced by glTF textures
  81168. */
  81169. _images: IImage[];
  81170. /**
  81171. * Stores all the texture samplers
  81172. */
  81173. _samplers: ISampler[];
  81174. /**
  81175. * Stores all the generated animation samplers, which is referenced by glTF animations
  81176. */
  81177. /**
  81178. * Stores the animations for glTF models
  81179. */
  81180. private _animations;
  81181. /**
  81182. * Stores the total amount of bytes stored in the glTF buffer
  81183. */
  81184. private _totalByteLength;
  81185. /**
  81186. * Stores a reference to the Babylon scene containing the source geometry and material information
  81187. */
  81188. _babylonScene: Scene;
  81189. /**
  81190. * Stores a map of the image data, where the key is the file name and the value
  81191. * is the image data
  81192. */
  81193. _imageData: {
  81194. [fileName: string]: {
  81195. data: Uint8Array;
  81196. mimeType: ImageMimeType;
  81197. };
  81198. };
  81199. /**
  81200. * Stores a map of the unique id of a node to its index in the node array
  81201. */
  81202. _nodeMap: {
  81203. [key: number]: number;
  81204. };
  81205. /**
  81206. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81207. */
  81208. _convertToRightHandedSystem: boolean;
  81209. /**
  81210. * Specifies if a Babylon node should be converted to right-handed on export
  81211. */
  81212. _convertToRightHandedSystemMap: {
  81213. [nodeId: number]: boolean;
  81214. };
  81215. _includeCoordinateSystemConversionNodes: boolean;
  81216. /**
  81217. * Baked animation sample rate
  81218. */
  81219. private _animationSampleRate;
  81220. private _options;
  81221. private _localEngine;
  81222. _glTFMaterialExporter: _GLTFMaterialExporter;
  81223. private _extensions;
  81224. private static _ExtensionNames;
  81225. private static _ExtensionFactories;
  81226. private _applyExtension;
  81227. private _applyExtensions;
  81228. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81229. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81230. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81231. [key: number]: number;
  81232. }): Promise<Nullable<INode>>;
  81233. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81234. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81235. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81236. private _forEachExtensions;
  81237. private _extensionsOnExporting;
  81238. /**
  81239. * Load glTF serializer extensions
  81240. */
  81241. private _loadExtensions;
  81242. /**
  81243. * Creates a glTF Exporter instance, which can accept optional exporter options
  81244. * @param babylonScene Babylon scene object
  81245. * @param options Options to modify the behavior of the exporter
  81246. */
  81247. constructor(babylonScene: Scene, options?: IExportOptions);
  81248. dispose(): void;
  81249. /**
  81250. * Registers a glTF exporter extension
  81251. * @param name Name of the extension to export
  81252. * @param factory The factory function that creates the exporter extension
  81253. */
  81254. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81255. /**
  81256. * Un-registers an exporter extension
  81257. * @param name The name fo the exporter extension
  81258. * @returns A boolean indicating whether the extension has been un-registered
  81259. */
  81260. static UnregisterExtension(name: string): boolean;
  81261. /**
  81262. * Lazy load a local engine
  81263. */
  81264. _getLocalEngine(): Engine;
  81265. private reorderIndicesBasedOnPrimitiveMode;
  81266. /**
  81267. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81268. * clock-wise during export to glTF
  81269. * @param submesh BabylonJS submesh
  81270. * @param primitiveMode Primitive mode of the mesh
  81271. * @param sideOrientation the winding order of the submesh
  81272. * @param vertexBufferKind The type of vertex attribute
  81273. * @param meshAttributeArray The vertex attribute data
  81274. * @param byteOffset The offset to the binary data
  81275. * @param binaryWriter The binary data for the glTF file
  81276. * @param convertToRightHandedSystem Converts the values to right-handed
  81277. */
  81278. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81279. /**
  81280. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81281. * clock-wise during export to glTF
  81282. * @param submesh BabylonJS submesh
  81283. * @param primitiveMode Primitive mode of the mesh
  81284. * @param sideOrientation the winding order of the submesh
  81285. * @param vertexBufferKind The type of vertex attribute
  81286. * @param meshAttributeArray The vertex attribute data
  81287. * @param byteOffset The offset to the binary data
  81288. * @param binaryWriter The binary data for the glTF file
  81289. * @param convertToRightHandedSystem Converts the values to right-handed
  81290. */
  81291. private reorderTriangleFillMode;
  81292. /**
  81293. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81294. * clock-wise during export to glTF
  81295. * @param submesh BabylonJS submesh
  81296. * @param primitiveMode Primitive mode of the mesh
  81297. * @param sideOrientation the winding order of the submesh
  81298. * @param vertexBufferKind The type of vertex attribute
  81299. * @param meshAttributeArray The vertex attribute data
  81300. * @param byteOffset The offset to the binary data
  81301. * @param binaryWriter The binary data for the glTF file
  81302. * @param convertToRightHandedSystem Converts the values to right-handed
  81303. */
  81304. private reorderTriangleStripDrawMode;
  81305. /**
  81306. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81307. * clock-wise during export to glTF
  81308. * @param submesh BabylonJS submesh
  81309. * @param primitiveMode Primitive mode of the mesh
  81310. * @param sideOrientation the winding order of the submesh
  81311. * @param vertexBufferKind The type of vertex attribute
  81312. * @param meshAttributeArray The vertex attribute data
  81313. * @param byteOffset The offset to the binary data
  81314. * @param binaryWriter The binary data for the glTF file
  81315. * @param convertToRightHandedSystem Converts the values to right-handed
  81316. */
  81317. private reorderTriangleFanMode;
  81318. /**
  81319. * Writes the vertex attribute data to binary
  81320. * @param vertices The vertices to write to the binary writer
  81321. * @param byteOffset The offset into the binary writer to overwrite binary data
  81322. * @param vertexAttributeKind The vertex attribute type
  81323. * @param meshAttributeArray The vertex attribute data
  81324. * @param binaryWriter The writer containing the binary data
  81325. * @param convertToRightHandedSystem Converts the values to right-handed
  81326. */
  81327. private writeVertexAttributeData;
  81328. /**
  81329. * Writes mesh attribute data to a data buffer
  81330. * Returns the bytelength of the data
  81331. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81332. * @param meshAttributeArray Array containing the attribute data
  81333. * @param binaryWriter The buffer to write the binary data to
  81334. * @param indices Used to specify the order of the vertex data
  81335. * @param convertToRightHandedSystem Converts the values to right-handed
  81336. */
  81337. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81338. /**
  81339. * Generates glTF json data
  81340. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81341. * @param glTFPrefix Text to use when prefixing a glTF file
  81342. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81343. * @returns json data as string
  81344. */
  81345. private generateJSON;
  81346. /**
  81347. * Generates data for .gltf and .bin files based on the glTF prefix string
  81348. * @param glTFPrefix Text to use when prefixing a glTF file
  81349. * @param dispose Dispose the exporter
  81350. * @returns GLTFData with glTF file data
  81351. */
  81352. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81353. /**
  81354. * Creates a binary buffer for glTF
  81355. * @returns array buffer for binary data
  81356. */
  81357. private _generateBinaryAsync;
  81358. /**
  81359. * Pads the number to a multiple of 4
  81360. * @param num number to pad
  81361. * @returns padded number
  81362. */
  81363. private _getPadding;
  81364. /**
  81365. * @hidden
  81366. */
  81367. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81368. /**
  81369. * Sets the TRS for each node
  81370. * @param node glTF Node for storing the transformation data
  81371. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81372. * @param convertToRightHandedSystem Converts the values to right-handed
  81373. */
  81374. private setNodeTransformation;
  81375. private getVertexBufferFromMesh;
  81376. /**
  81377. * Creates a bufferview based on the vertices type for the Babylon mesh
  81378. * @param kind Indicates the type of vertices data
  81379. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81380. * @param binaryWriter The buffer to write the bufferview data to
  81381. * @param convertToRightHandedSystem Converts the values to right-handed
  81382. */
  81383. private createBufferViewKind;
  81384. /**
  81385. * The primitive mode of the Babylon mesh
  81386. * @param babylonMesh The BabylonJS mesh
  81387. */
  81388. private getMeshPrimitiveMode;
  81389. /**
  81390. * Sets the primitive mode of the glTF mesh primitive
  81391. * @param meshPrimitive glTF mesh primitive
  81392. * @param primitiveMode The primitive mode
  81393. */
  81394. private setPrimitiveMode;
  81395. /**
  81396. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81397. * @param meshPrimitive glTF mesh primitive
  81398. * @param attributeKind vertex attribute
  81399. * @returns boolean specifying if uv coordinates are present
  81400. */
  81401. private setAttributeKind;
  81402. /**
  81403. * Sets data for the primitive attributes of each submesh
  81404. * @param mesh glTF Mesh object to store the primitive attribute information
  81405. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81406. * @param binaryWriter Buffer to write the attribute data to
  81407. * @param convertToRightHandedSystem Converts the values to right-handed
  81408. */
  81409. private setPrimitiveAttributesAsync;
  81410. /**
  81411. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81412. * @param node The node to check
  81413. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81414. */
  81415. private isBabylonCoordinateSystemConvertingNode;
  81416. /**
  81417. * Creates a glTF scene based on the array of meshes
  81418. * Returns the the total byte offset
  81419. * @param babylonScene Babylon scene to get the mesh data from
  81420. * @param binaryWriter Buffer to write binary data to
  81421. */
  81422. private createSceneAsync;
  81423. /**
  81424. * Creates a mapping of Node unique id to node index and handles animations
  81425. * @param babylonScene Babylon Scene
  81426. * @param nodes Babylon transform nodes
  81427. * @param binaryWriter Buffer to write binary data to
  81428. * @returns Node mapping of unique id to index
  81429. */
  81430. private createNodeMapAndAnimationsAsync;
  81431. /**
  81432. * Creates a glTF node from a Babylon mesh
  81433. * @param babylonMesh Source Babylon mesh
  81434. * @param binaryWriter Buffer for storing geometry data
  81435. * @param convertToRightHandedSystem Converts the values to right-handed
  81436. * @param nodeMap Node mapping of unique id to glTF node index
  81437. * @returns glTF node
  81438. */
  81439. private createNodeAsync;
  81440. }
  81441. /**
  81442. * @hidden
  81443. *
  81444. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81445. */
  81446. export class _BinaryWriter {
  81447. /**
  81448. * Array buffer which stores all binary data
  81449. */
  81450. private _arrayBuffer;
  81451. /**
  81452. * View of the array buffer
  81453. */
  81454. private _dataView;
  81455. /**
  81456. * byte offset of data in array buffer
  81457. */
  81458. private _byteOffset;
  81459. /**
  81460. * Initialize binary writer with an initial byte length
  81461. * @param byteLength Initial byte length of the array buffer
  81462. */
  81463. constructor(byteLength: number);
  81464. /**
  81465. * Resize the array buffer to the specified byte length
  81466. * @param byteLength
  81467. */
  81468. private resizeBuffer;
  81469. /**
  81470. * Get an array buffer with the length of the byte offset
  81471. * @returns ArrayBuffer resized to the byte offset
  81472. */
  81473. getArrayBuffer(): ArrayBuffer;
  81474. /**
  81475. * Get the byte offset of the array buffer
  81476. * @returns byte offset
  81477. */
  81478. getByteOffset(): number;
  81479. /**
  81480. * Stores an UInt8 in the array buffer
  81481. * @param entry
  81482. * @param byteOffset If defined, specifies where to set the value as an offset.
  81483. */
  81484. setUInt8(entry: number, byteOffset?: number): void;
  81485. /**
  81486. * Gets an UInt32 in the array buffer
  81487. * @param entry
  81488. * @param byteOffset If defined, specifies where to set the value as an offset.
  81489. */
  81490. getUInt32(byteOffset: number): number;
  81491. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81492. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81493. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81494. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81495. /**
  81496. * Stores a Float32 in the array buffer
  81497. * @param entry
  81498. */
  81499. setFloat32(entry: number, byteOffset?: number): void;
  81500. /**
  81501. * Stores an UInt32 in the array buffer
  81502. * @param entry
  81503. * @param byteOffset If defined, specifies where to set the value as an offset.
  81504. */
  81505. setUInt32(entry: number, byteOffset?: number): void;
  81506. }
  81507. }
  81508. declare module BABYLON.GLTF2.Exporter {
  81509. /**
  81510. * @hidden
  81511. * Interface to store animation data.
  81512. */
  81513. export interface _IAnimationData {
  81514. /**
  81515. * Keyframe data.
  81516. */
  81517. inputs: number[];
  81518. /**
  81519. * Value data.
  81520. */
  81521. outputs: number[][];
  81522. /**
  81523. * Animation interpolation data.
  81524. */
  81525. samplerInterpolation: AnimationSamplerInterpolation;
  81526. /**
  81527. * Minimum keyframe value.
  81528. */
  81529. inputsMin: number;
  81530. /**
  81531. * Maximum keyframe value.
  81532. */
  81533. inputsMax: number;
  81534. }
  81535. /**
  81536. * @hidden
  81537. */
  81538. export interface _IAnimationInfo {
  81539. /**
  81540. * The target channel for the animation
  81541. */
  81542. animationChannelTargetPath: AnimationChannelTargetPath;
  81543. /**
  81544. * The glTF accessor type for the data.
  81545. */
  81546. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81547. /**
  81548. * Specifies if quaternions should be used.
  81549. */
  81550. useQuaternion: boolean;
  81551. }
  81552. /**
  81553. * @hidden
  81554. * Utility class for generating glTF animation data from BabylonJS.
  81555. */
  81556. export class _GLTFAnimation {
  81557. /**
  81558. * @ignore
  81559. *
  81560. * Creates glTF channel animation from BabylonJS animation.
  81561. * @param babylonTransformNode - BabylonJS mesh.
  81562. * @param animation - animation.
  81563. * @param animationChannelTargetPath - The target animation channel.
  81564. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81565. * @param useQuaternion - Specifies if quaternions are used.
  81566. * @returns nullable IAnimationData
  81567. */
  81568. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81569. private static _DeduceAnimationInfo;
  81570. /**
  81571. * @ignore
  81572. * Create node animations from the transform node animations
  81573. * @param babylonNode
  81574. * @param runtimeGLTFAnimation
  81575. * @param idleGLTFAnimations
  81576. * @param nodeMap
  81577. * @param nodes
  81578. * @param binaryWriter
  81579. * @param bufferViews
  81580. * @param accessors
  81581. * @param convertToRightHandedSystem
  81582. * @param animationSampleRate
  81583. */
  81584. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81585. [key: number]: number;
  81586. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81587. /**
  81588. * @ignore
  81589. * Create node animations from the animation groups
  81590. * @param babylonScene
  81591. * @param glTFAnimations
  81592. * @param nodeMap
  81593. * @param nodes
  81594. * @param binaryWriter
  81595. * @param bufferViews
  81596. * @param accessors
  81597. * @param convertToRightHandedSystemMap
  81598. * @param animationSampleRate
  81599. */
  81600. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81601. [key: number]: number;
  81602. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81603. [nodeId: number]: boolean;
  81604. }, animationSampleRate: number): void;
  81605. private static AddAnimation;
  81606. /**
  81607. * Create a baked animation
  81608. * @param babylonTransformNode BabylonJS mesh
  81609. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81610. * @param animationChannelTargetPath animation target channel
  81611. * @param minFrame minimum animation frame
  81612. * @param maxFrame maximum animation frame
  81613. * @param fps frames per second of the animation
  81614. * @param inputs input key frames of the animation
  81615. * @param outputs output key frame data of the animation
  81616. * @param convertToRightHandedSystem converts the values to right-handed
  81617. * @param useQuaternion specifies if quaternions should be used
  81618. */
  81619. private static _CreateBakedAnimation;
  81620. private static _ConvertFactorToVector3OrQuaternion;
  81621. private static _SetInterpolatedValue;
  81622. /**
  81623. * Creates linear animation from the animation key frames
  81624. * @param babylonTransformNode BabylonJS mesh
  81625. * @param animation BabylonJS animation
  81626. * @param animationChannelTargetPath The target animation channel
  81627. * @param frameDelta The difference between the last and first frame of the animation
  81628. * @param inputs Array to store the key frame times
  81629. * @param outputs Array to store the key frame data
  81630. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81631. * @param useQuaternion Specifies if quaternions are used in the animation
  81632. */
  81633. private static _CreateLinearOrStepAnimation;
  81634. /**
  81635. * Creates cubic spline animation from the animation key frames
  81636. * @param babylonTransformNode BabylonJS mesh
  81637. * @param animation BabylonJS animation
  81638. * @param animationChannelTargetPath The target animation channel
  81639. * @param frameDelta The difference between the last and first frame of the animation
  81640. * @param inputs Array to store the key frame times
  81641. * @param outputs Array to store the key frame data
  81642. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81643. * @param useQuaternion Specifies if quaternions are used in the animation
  81644. */
  81645. private static _CreateCubicSplineAnimation;
  81646. private static _GetBasePositionRotationOrScale;
  81647. /**
  81648. * Adds a key frame value
  81649. * @param keyFrame
  81650. * @param animation
  81651. * @param outputs
  81652. * @param animationChannelTargetPath
  81653. * @param basePositionRotationOrScale
  81654. * @param convertToRightHandedSystem
  81655. * @param useQuaternion
  81656. */
  81657. private static _AddKeyframeValue;
  81658. /**
  81659. * Determine the interpolation based on the key frames
  81660. * @param keyFrames
  81661. * @param animationChannelTargetPath
  81662. * @param useQuaternion
  81663. */
  81664. private static _DeduceInterpolation;
  81665. /**
  81666. * Adds an input tangent or output tangent to the output data
  81667. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81668. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81669. * @param outputs The animation data by keyframe
  81670. * @param animationChannelTargetPath The target animation channel
  81671. * @param interpolation The interpolation type
  81672. * @param keyFrame The key frame with the animation data
  81673. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81674. * @param useQuaternion Specifies if quaternions are used
  81675. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81676. */
  81677. private static AddSplineTangent;
  81678. /**
  81679. * Get the minimum and maximum key frames' frame values
  81680. * @param keyFrames animation key frames
  81681. * @returns the minimum and maximum key frame value
  81682. */
  81683. private static calculateMinMaxKeyFrames;
  81684. }
  81685. }
  81686. declare module BABYLON.GLTF2.Exporter {
  81687. /** @hidden */
  81688. export var textureTransformPixelShader: {
  81689. name: string;
  81690. shader: string;
  81691. };
  81692. }
  81693. declare module BABYLON.GLTF2.Exporter.Extensions {
  81694. /**
  81695. * @hidden
  81696. */
  81697. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81698. private _recordedTextures;
  81699. /** Name of this extension */
  81700. readonly name: string;
  81701. /** Defines whether this extension is enabled */
  81702. enabled: boolean;
  81703. /** Defines whether this extension is required */
  81704. required: boolean;
  81705. /** Reference to the glTF exporter */
  81706. private _wasUsed;
  81707. constructor(exporter: _Exporter);
  81708. dispose(): void;
  81709. /** @hidden */
  81710. get wasUsed(): boolean;
  81711. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81712. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81713. /**
  81714. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81715. * @param babylonTexture
  81716. * @param offset
  81717. * @param rotation
  81718. * @param scale
  81719. * @param scene
  81720. */
  81721. private _textureTransformTextureAsync;
  81722. }
  81723. }
  81724. declare module BABYLON.GLTF2.Exporter.Extensions {
  81725. /**
  81726. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81727. */
  81728. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81729. /** The name of this extension. */
  81730. readonly name: string;
  81731. /** Defines whether this extension is enabled. */
  81732. enabled: boolean;
  81733. /** Defines whether this extension is required */
  81734. required: boolean;
  81735. /** Reference to the glTF exporter */
  81736. private _exporter;
  81737. private _lights;
  81738. /** @hidden */
  81739. constructor(exporter: _Exporter);
  81740. /** @hidden */
  81741. dispose(): void;
  81742. /** @hidden */
  81743. get wasUsed(): boolean;
  81744. /** @hidden */
  81745. onExporting(): void;
  81746. /**
  81747. * Define this method to modify the default behavior when exporting a node
  81748. * @param context The context when exporting the node
  81749. * @param node glTF node
  81750. * @param babylonNode BabylonJS node
  81751. * @param nodeMap Node mapping of unique id to glTF node index
  81752. * @returns nullable INode promise
  81753. */
  81754. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81755. [key: number]: number;
  81756. }): Promise<Nullable<INode>>;
  81757. }
  81758. }
  81759. declare module BABYLON.GLTF2.Exporter.Extensions {
  81760. /**
  81761. * @hidden
  81762. */
  81763. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81764. /** Name of this extension */
  81765. readonly name: string;
  81766. /** Defines whether this extension is enabled */
  81767. enabled: boolean;
  81768. /** Defines whether this extension is required */
  81769. required: boolean;
  81770. /** Reference to the glTF exporter */
  81771. private _textureInfos;
  81772. private _exportedTextures;
  81773. private _wasUsed;
  81774. constructor(exporter: _Exporter);
  81775. dispose(): void;
  81776. /** @hidden */
  81777. get wasUsed(): boolean;
  81778. private _getTextureIndex;
  81779. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81780. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81781. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81782. }
  81783. }
  81784. declare module BABYLON {
  81785. /**
  81786. * Class for generating STL data from a Babylon scene.
  81787. */
  81788. export class STLExport {
  81789. /**
  81790. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81791. * @param meshes list defines the mesh to serialize
  81792. * @param download triggers the automatic download of the file.
  81793. * @param fileName changes the downloads fileName.
  81794. * @param binary changes the STL to a binary type.
  81795. * @param isLittleEndian toggle for binary type exporter.
  81796. * @returns the STL as UTF8 string
  81797. */
  81798. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81799. }
  81800. }
  81801. declare module "babylonjs-gltf2interface" {
  81802. export = BABYLON.GLTF2;
  81803. }
  81804. /**
  81805. * Module for glTF 2.0 Interface
  81806. */
  81807. declare module BABYLON.GLTF2 {
  81808. /**
  81809. * The datatype of the components in the attribute
  81810. */
  81811. const enum AccessorComponentType {
  81812. /**
  81813. * Byte
  81814. */
  81815. BYTE = 5120,
  81816. /**
  81817. * Unsigned Byte
  81818. */
  81819. UNSIGNED_BYTE = 5121,
  81820. /**
  81821. * Short
  81822. */
  81823. SHORT = 5122,
  81824. /**
  81825. * Unsigned Short
  81826. */
  81827. UNSIGNED_SHORT = 5123,
  81828. /**
  81829. * Unsigned Int
  81830. */
  81831. UNSIGNED_INT = 5125,
  81832. /**
  81833. * Float
  81834. */
  81835. FLOAT = 5126,
  81836. }
  81837. /**
  81838. * Specifies if the attirbute is a scalar, vector, or matrix
  81839. */
  81840. const enum AccessorType {
  81841. /**
  81842. * Scalar
  81843. */
  81844. SCALAR = "SCALAR",
  81845. /**
  81846. * Vector2
  81847. */
  81848. VEC2 = "VEC2",
  81849. /**
  81850. * Vector3
  81851. */
  81852. VEC3 = "VEC3",
  81853. /**
  81854. * Vector4
  81855. */
  81856. VEC4 = "VEC4",
  81857. /**
  81858. * Matrix2x2
  81859. */
  81860. MAT2 = "MAT2",
  81861. /**
  81862. * Matrix3x3
  81863. */
  81864. MAT3 = "MAT3",
  81865. /**
  81866. * Matrix4x4
  81867. */
  81868. MAT4 = "MAT4",
  81869. }
  81870. /**
  81871. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81872. */
  81873. const enum AnimationChannelTargetPath {
  81874. /**
  81875. * Translation
  81876. */
  81877. TRANSLATION = "translation",
  81878. /**
  81879. * Rotation
  81880. */
  81881. ROTATION = "rotation",
  81882. /**
  81883. * Scale
  81884. */
  81885. SCALE = "scale",
  81886. /**
  81887. * Weights
  81888. */
  81889. WEIGHTS = "weights",
  81890. }
  81891. /**
  81892. * Interpolation algorithm
  81893. */
  81894. const enum AnimationSamplerInterpolation {
  81895. /**
  81896. * The animated values are linearly interpolated between keyframes
  81897. */
  81898. LINEAR = "LINEAR",
  81899. /**
  81900. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81901. */
  81902. STEP = "STEP",
  81903. /**
  81904. * The animation's interpolation is computed using a cubic spline with specified tangents
  81905. */
  81906. CUBICSPLINE = "CUBICSPLINE",
  81907. }
  81908. /**
  81909. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81910. */
  81911. const enum CameraType {
  81912. /**
  81913. * A perspective camera containing properties to create a perspective projection matrix
  81914. */
  81915. PERSPECTIVE = "perspective",
  81916. /**
  81917. * An orthographic camera containing properties to create an orthographic projection matrix
  81918. */
  81919. ORTHOGRAPHIC = "orthographic",
  81920. }
  81921. /**
  81922. * The mime-type of the image
  81923. */
  81924. const enum ImageMimeType {
  81925. /**
  81926. * JPEG Mime-type
  81927. */
  81928. JPEG = "image/jpeg",
  81929. /**
  81930. * PNG Mime-type
  81931. */
  81932. PNG = "image/png",
  81933. }
  81934. /**
  81935. * The alpha rendering mode of the material
  81936. */
  81937. const enum MaterialAlphaMode {
  81938. /**
  81939. * The alpha value is ignored and the rendered output is fully opaque
  81940. */
  81941. OPAQUE = "OPAQUE",
  81942. /**
  81943. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81944. */
  81945. MASK = "MASK",
  81946. /**
  81947. * 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)
  81948. */
  81949. BLEND = "BLEND",
  81950. }
  81951. /**
  81952. * The type of the primitives to render
  81953. */
  81954. const enum MeshPrimitiveMode {
  81955. /**
  81956. * Points
  81957. */
  81958. POINTS = 0,
  81959. /**
  81960. * Lines
  81961. */
  81962. LINES = 1,
  81963. /**
  81964. * Line Loop
  81965. */
  81966. LINE_LOOP = 2,
  81967. /**
  81968. * Line Strip
  81969. */
  81970. LINE_STRIP = 3,
  81971. /**
  81972. * Triangles
  81973. */
  81974. TRIANGLES = 4,
  81975. /**
  81976. * Triangle Strip
  81977. */
  81978. TRIANGLE_STRIP = 5,
  81979. /**
  81980. * Triangle Fan
  81981. */
  81982. TRIANGLE_FAN = 6,
  81983. }
  81984. /**
  81985. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81986. */
  81987. const enum TextureMagFilter {
  81988. /**
  81989. * Nearest
  81990. */
  81991. NEAREST = 9728,
  81992. /**
  81993. * Linear
  81994. */
  81995. LINEAR = 9729,
  81996. }
  81997. /**
  81998. * Minification filter. All valid values correspond to WebGL enums
  81999. */
  82000. const enum TextureMinFilter {
  82001. /**
  82002. * Nearest
  82003. */
  82004. NEAREST = 9728,
  82005. /**
  82006. * Linear
  82007. */
  82008. LINEAR = 9729,
  82009. /**
  82010. * Nearest Mip-Map Nearest
  82011. */
  82012. NEAREST_MIPMAP_NEAREST = 9984,
  82013. /**
  82014. * Linear Mipmap Nearest
  82015. */
  82016. LINEAR_MIPMAP_NEAREST = 9985,
  82017. /**
  82018. * Nearest Mipmap Linear
  82019. */
  82020. NEAREST_MIPMAP_LINEAR = 9986,
  82021. /**
  82022. * Linear Mipmap Linear
  82023. */
  82024. LINEAR_MIPMAP_LINEAR = 9987,
  82025. }
  82026. /**
  82027. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82028. */
  82029. const enum TextureWrapMode {
  82030. /**
  82031. * Clamp to Edge
  82032. */
  82033. CLAMP_TO_EDGE = 33071,
  82034. /**
  82035. * Mirrored Repeat
  82036. */
  82037. MIRRORED_REPEAT = 33648,
  82038. /**
  82039. * Repeat
  82040. */
  82041. REPEAT = 10497,
  82042. }
  82043. /**
  82044. * glTF Property
  82045. */
  82046. interface IProperty {
  82047. /**
  82048. * Dictionary object with extension-specific objects
  82049. */
  82050. extensions?: {
  82051. [key: string]: any;
  82052. };
  82053. /**
  82054. * Application-Specific data
  82055. */
  82056. extras?: any;
  82057. }
  82058. /**
  82059. * glTF Child of Root Property
  82060. */
  82061. interface IChildRootProperty extends IProperty {
  82062. /**
  82063. * The user-defined name of this object
  82064. */
  82065. name?: string;
  82066. }
  82067. /**
  82068. * Indices of those attributes that deviate from their initialization value
  82069. */
  82070. interface IAccessorSparseIndices extends IProperty {
  82071. /**
  82072. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82073. */
  82074. bufferView: number;
  82075. /**
  82076. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82077. */
  82078. byteOffset?: number;
  82079. /**
  82080. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82081. */
  82082. componentType: AccessorComponentType;
  82083. }
  82084. /**
  82085. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82086. */
  82087. interface IAccessorSparseValues extends IProperty {
  82088. /**
  82089. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82090. */
  82091. bufferView: number;
  82092. /**
  82093. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82094. */
  82095. byteOffset?: number;
  82096. }
  82097. /**
  82098. * Sparse storage of attributes that deviate from their initialization value
  82099. */
  82100. interface IAccessorSparse extends IProperty {
  82101. /**
  82102. * The number of attributes encoded in this sparse accessor
  82103. */
  82104. count: number;
  82105. /**
  82106. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82107. */
  82108. indices: IAccessorSparseIndices;
  82109. /**
  82110. * 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
  82111. */
  82112. values: IAccessorSparseValues;
  82113. }
  82114. /**
  82115. * 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
  82116. */
  82117. interface IAccessor extends IChildRootProperty {
  82118. /**
  82119. * The index of the bufferview
  82120. */
  82121. bufferView?: number;
  82122. /**
  82123. * The offset relative to the start of the bufferView in bytes
  82124. */
  82125. byteOffset?: number;
  82126. /**
  82127. * The datatype of components in the attribute
  82128. */
  82129. componentType: AccessorComponentType;
  82130. /**
  82131. * Specifies whether integer data values should be normalized
  82132. */
  82133. normalized?: boolean;
  82134. /**
  82135. * The number of attributes referenced by this accessor
  82136. */
  82137. count: number;
  82138. /**
  82139. * Specifies if the attribute is a scalar, vector, or matrix
  82140. */
  82141. type: AccessorType;
  82142. /**
  82143. * Maximum value of each component in this attribute
  82144. */
  82145. max?: number[];
  82146. /**
  82147. * Minimum value of each component in this attribute
  82148. */
  82149. min?: number[];
  82150. /**
  82151. * Sparse storage of attributes that deviate from their initialization value
  82152. */
  82153. sparse?: IAccessorSparse;
  82154. }
  82155. /**
  82156. * Targets an animation's sampler at a node's property
  82157. */
  82158. interface IAnimationChannel extends IProperty {
  82159. /**
  82160. * The index of a sampler in this animation used to compute the value for the target
  82161. */
  82162. sampler: number;
  82163. /**
  82164. * The index of the node and TRS property to target
  82165. */
  82166. target: IAnimationChannelTarget;
  82167. }
  82168. /**
  82169. * The index of the node and TRS property that an animation channel targets
  82170. */
  82171. interface IAnimationChannelTarget extends IProperty {
  82172. /**
  82173. * The index of the node to target
  82174. */
  82175. node: number;
  82176. /**
  82177. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82178. */
  82179. path: AnimationChannelTargetPath;
  82180. }
  82181. /**
  82182. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82183. */
  82184. interface IAnimationSampler extends IProperty {
  82185. /**
  82186. * The index of an accessor containing keyframe input values, e.g., time
  82187. */
  82188. input: number;
  82189. /**
  82190. * Interpolation algorithm
  82191. */
  82192. interpolation?: AnimationSamplerInterpolation;
  82193. /**
  82194. * The index of an accessor, containing keyframe output values
  82195. */
  82196. output: number;
  82197. }
  82198. /**
  82199. * A keyframe animation
  82200. */
  82201. interface IAnimation extends IChildRootProperty {
  82202. /**
  82203. * An array of channels, each of which targets an animation's sampler at a node's property
  82204. */
  82205. channels: IAnimationChannel[];
  82206. /**
  82207. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82208. */
  82209. samplers: IAnimationSampler[];
  82210. }
  82211. /**
  82212. * Metadata about the glTF asset
  82213. */
  82214. interface IAsset extends IChildRootProperty {
  82215. /**
  82216. * A copyright message suitable for display to credit the content creator
  82217. */
  82218. copyright?: string;
  82219. /**
  82220. * Tool that generated this glTF model. Useful for debugging
  82221. */
  82222. generator?: string;
  82223. /**
  82224. * The glTF version that this asset targets
  82225. */
  82226. version: string;
  82227. /**
  82228. * The minimum glTF version that this asset targets
  82229. */
  82230. minVersion?: string;
  82231. }
  82232. /**
  82233. * A buffer points to binary geometry, animation, or skins
  82234. */
  82235. interface IBuffer extends IChildRootProperty {
  82236. /**
  82237. * 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
  82238. */
  82239. uri?: string;
  82240. /**
  82241. * The length of the buffer in bytes
  82242. */
  82243. byteLength: number;
  82244. }
  82245. /**
  82246. * A view into a buffer generally representing a subset of the buffer
  82247. */
  82248. interface IBufferView extends IChildRootProperty {
  82249. /**
  82250. * The index of the buffer
  82251. */
  82252. buffer: number;
  82253. /**
  82254. * The offset into the buffer in bytes
  82255. */
  82256. byteOffset?: number;
  82257. /**
  82258. * The lenth of the bufferView in bytes
  82259. */
  82260. byteLength: number;
  82261. /**
  82262. * The stride, in bytes
  82263. */
  82264. byteStride?: number;
  82265. }
  82266. /**
  82267. * An orthographic camera containing properties to create an orthographic projection matrix
  82268. */
  82269. interface ICameraOrthographic extends IProperty {
  82270. /**
  82271. * The floating-point horizontal magnification of the view. Must not be zero
  82272. */
  82273. xmag: number;
  82274. /**
  82275. * The floating-point vertical magnification of the view. Must not be zero
  82276. */
  82277. ymag: number;
  82278. /**
  82279. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82280. */
  82281. zfar: number;
  82282. /**
  82283. * The floating-point distance to the near clipping plane
  82284. */
  82285. znear: number;
  82286. }
  82287. /**
  82288. * A perspective camera containing properties to create a perspective projection matrix
  82289. */
  82290. interface ICameraPerspective extends IProperty {
  82291. /**
  82292. * The floating-point aspect ratio of the field of view
  82293. */
  82294. aspectRatio?: number;
  82295. /**
  82296. * The floating-point vertical field of view in radians
  82297. */
  82298. yfov: number;
  82299. /**
  82300. * The floating-point distance to the far clipping plane
  82301. */
  82302. zfar?: number;
  82303. /**
  82304. * The floating-point distance to the near clipping plane
  82305. */
  82306. znear: number;
  82307. }
  82308. /**
  82309. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82310. */
  82311. interface ICamera extends IChildRootProperty {
  82312. /**
  82313. * An orthographic camera containing properties to create an orthographic projection matrix
  82314. */
  82315. orthographic?: ICameraOrthographic;
  82316. /**
  82317. * A perspective camera containing properties to create a perspective projection matrix
  82318. */
  82319. perspective?: ICameraPerspective;
  82320. /**
  82321. * Specifies if the camera uses a perspective or orthographic projection
  82322. */
  82323. type: CameraType;
  82324. }
  82325. /**
  82326. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82327. */
  82328. interface IImage extends IChildRootProperty {
  82329. /**
  82330. * 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
  82331. */
  82332. uri?: string;
  82333. /**
  82334. * The image's MIME type
  82335. */
  82336. mimeType?: ImageMimeType;
  82337. /**
  82338. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82339. */
  82340. bufferView?: number;
  82341. }
  82342. /**
  82343. * Material Normal Texture Info
  82344. */
  82345. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82346. /**
  82347. * The scalar multiplier applied to each normal vector of the normal texture
  82348. */
  82349. scale?: number;
  82350. }
  82351. /**
  82352. * Material Occlusion Texture Info
  82353. */
  82354. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82355. /**
  82356. * A scalar multiplier controlling the amount of occlusion applied
  82357. */
  82358. strength?: number;
  82359. }
  82360. /**
  82361. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82362. */
  82363. interface IMaterialPbrMetallicRoughness {
  82364. /**
  82365. * The material's base color factor
  82366. */
  82367. baseColorFactor?: number[];
  82368. /**
  82369. * The base color texture
  82370. */
  82371. baseColorTexture?: ITextureInfo;
  82372. /**
  82373. * The metalness of the material
  82374. */
  82375. metallicFactor?: number;
  82376. /**
  82377. * The roughness of the material
  82378. */
  82379. roughnessFactor?: number;
  82380. /**
  82381. * The metallic-roughness texture
  82382. */
  82383. metallicRoughnessTexture?: ITextureInfo;
  82384. }
  82385. /**
  82386. * The material appearance of a primitive
  82387. */
  82388. interface IMaterial extends IChildRootProperty {
  82389. /**
  82390. * 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
  82391. */
  82392. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82393. /**
  82394. * The normal map texture
  82395. */
  82396. normalTexture?: IMaterialNormalTextureInfo;
  82397. /**
  82398. * The occlusion map texture
  82399. */
  82400. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82401. /**
  82402. * The emissive map texture
  82403. */
  82404. emissiveTexture?: ITextureInfo;
  82405. /**
  82406. * 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
  82407. */
  82408. emissiveFactor?: number[];
  82409. /**
  82410. * The alpha rendering mode of the material
  82411. */
  82412. alphaMode?: MaterialAlphaMode;
  82413. /**
  82414. * The alpha cutoff value of the material
  82415. */
  82416. alphaCutoff?: number;
  82417. /**
  82418. * Specifies whether the material is double sided
  82419. */
  82420. doubleSided?: boolean;
  82421. }
  82422. /**
  82423. * Geometry to be rendered with the given material
  82424. */
  82425. interface IMeshPrimitive extends IProperty {
  82426. /**
  82427. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82428. */
  82429. attributes: {
  82430. [name: string]: number;
  82431. };
  82432. /**
  82433. * The index of the accessor that contains the indices
  82434. */
  82435. indices?: number;
  82436. /**
  82437. * The index of the material to apply to this primitive when rendering
  82438. */
  82439. material?: number;
  82440. /**
  82441. * The type of primitives to render. All valid values correspond to WebGL enums
  82442. */
  82443. mode?: MeshPrimitiveMode;
  82444. /**
  82445. * 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
  82446. */
  82447. targets?: {
  82448. [name: string]: number;
  82449. }[];
  82450. }
  82451. /**
  82452. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82453. */
  82454. interface IMesh extends IChildRootProperty {
  82455. /**
  82456. * An array of primitives, each defining geometry to be rendered with a material
  82457. */
  82458. primitives: IMeshPrimitive[];
  82459. /**
  82460. * Array of weights to be applied to the Morph Targets
  82461. */
  82462. weights?: number[];
  82463. }
  82464. /**
  82465. * A node in the node hierarchy
  82466. */
  82467. interface INode extends IChildRootProperty {
  82468. /**
  82469. * The index of the camera referenced by this node
  82470. */
  82471. camera?: number;
  82472. /**
  82473. * The indices of this node's children
  82474. */
  82475. children?: number[];
  82476. /**
  82477. * The index of the skin referenced by this node
  82478. */
  82479. skin?: number;
  82480. /**
  82481. * A floating-point 4x4 transformation matrix stored in column-major order
  82482. */
  82483. matrix?: number[];
  82484. /**
  82485. * The index of the mesh in this node
  82486. */
  82487. mesh?: number;
  82488. /**
  82489. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82490. */
  82491. rotation?: number[];
  82492. /**
  82493. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82494. */
  82495. scale?: number[];
  82496. /**
  82497. * The node's translation along the x, y, and z axes
  82498. */
  82499. translation?: number[];
  82500. /**
  82501. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82502. */
  82503. weights?: number[];
  82504. }
  82505. /**
  82506. * Texture sampler properties for filtering and wrapping modes
  82507. */
  82508. interface ISampler extends IChildRootProperty {
  82509. /**
  82510. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82511. */
  82512. magFilter?: TextureMagFilter;
  82513. /**
  82514. * Minification filter. All valid values correspond to WebGL enums
  82515. */
  82516. minFilter?: TextureMinFilter;
  82517. /**
  82518. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82519. */
  82520. wrapS?: TextureWrapMode;
  82521. /**
  82522. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82523. */
  82524. wrapT?: TextureWrapMode;
  82525. }
  82526. /**
  82527. * The root nodes of a scene
  82528. */
  82529. interface IScene extends IChildRootProperty {
  82530. /**
  82531. * The indices of each root node
  82532. */
  82533. nodes: number[];
  82534. }
  82535. /**
  82536. * Joints and matrices defining a skin
  82537. */
  82538. interface ISkin extends IChildRootProperty {
  82539. /**
  82540. * 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
  82541. */
  82542. inverseBindMatrices?: number;
  82543. /**
  82544. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82545. */
  82546. skeleton?: number;
  82547. /**
  82548. * 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)
  82549. */
  82550. joints: number[];
  82551. }
  82552. /**
  82553. * A texture and its sampler
  82554. */
  82555. interface ITexture extends IChildRootProperty {
  82556. /**
  82557. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82558. */
  82559. sampler?: number;
  82560. /**
  82561. * The index of the image used by this texture
  82562. */
  82563. source: number;
  82564. }
  82565. /**
  82566. * Reference to a texture
  82567. */
  82568. interface ITextureInfo extends IProperty {
  82569. /**
  82570. * The index of the texture
  82571. */
  82572. index: number;
  82573. /**
  82574. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82575. */
  82576. texCoord?: number;
  82577. }
  82578. /**
  82579. * The root object for a glTF asset
  82580. */
  82581. interface IGLTF extends IProperty {
  82582. /**
  82583. * An array of accessors. An accessor is a typed view into a bufferView
  82584. */
  82585. accessors?: IAccessor[];
  82586. /**
  82587. * An array of keyframe animations
  82588. */
  82589. animations?: IAnimation[];
  82590. /**
  82591. * Metadata about the glTF asset
  82592. */
  82593. asset: IAsset;
  82594. /**
  82595. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82596. */
  82597. buffers?: IBuffer[];
  82598. /**
  82599. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82600. */
  82601. bufferViews?: IBufferView[];
  82602. /**
  82603. * An array of cameras
  82604. */
  82605. cameras?: ICamera[];
  82606. /**
  82607. * Names of glTF extensions used somewhere in this asset
  82608. */
  82609. extensionsUsed?: string[];
  82610. /**
  82611. * Names of glTF extensions required to properly load this asset
  82612. */
  82613. extensionsRequired?: string[];
  82614. /**
  82615. * An array of images. An image defines data used to create a texture
  82616. */
  82617. images?: IImage[];
  82618. /**
  82619. * An array of materials. A material defines the appearance of a primitive
  82620. */
  82621. materials?: IMaterial[];
  82622. /**
  82623. * An array of meshes. A mesh is a set of primitives to be rendered
  82624. */
  82625. meshes?: IMesh[];
  82626. /**
  82627. * An array of nodes
  82628. */
  82629. nodes?: INode[];
  82630. /**
  82631. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82632. */
  82633. samplers?: ISampler[];
  82634. /**
  82635. * The index of the default scene
  82636. */
  82637. scene?: number;
  82638. /**
  82639. * An array of scenes
  82640. */
  82641. scenes?: IScene[];
  82642. /**
  82643. * An array of skins. A skin is defined by joints and matrices
  82644. */
  82645. skins?: ISkin[];
  82646. /**
  82647. * An array of textures
  82648. */
  82649. textures?: ITexture[];
  82650. }
  82651. /**
  82652. * The glTF validation results
  82653. * @ignore
  82654. */
  82655. interface IGLTFValidationResults {
  82656. info: {
  82657. generator: string;
  82658. hasAnimations: boolean;
  82659. hasDefaultScene: boolean;
  82660. hasMaterials: boolean;
  82661. hasMorphTargets: boolean;
  82662. hasSkins: boolean;
  82663. hasTextures: boolean;
  82664. maxAttributesUsed: number;
  82665. primitivesCount: number
  82666. };
  82667. issues: {
  82668. messages: Array<string>;
  82669. numErrors: number;
  82670. numHints: number;
  82671. numInfos: number;
  82672. numWarnings: number;
  82673. truncated: boolean
  82674. };
  82675. mimeType: string;
  82676. uri: string;
  82677. validatedAt: string;
  82678. validatorVersion: string;
  82679. }
  82680. /**
  82681. * The glTF validation options
  82682. */
  82683. interface IGLTFValidationOptions {
  82684. /** Uri to use */
  82685. uri?: string;
  82686. /** Function used to load external resources */
  82687. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82688. /** Boolean indicating that we need to validate accessor data */
  82689. validateAccessorData?: boolean;
  82690. /** max number of issues allowed */
  82691. maxIssues?: number;
  82692. /** Ignored issues */
  82693. ignoredIssues?: Array<string>;
  82694. /** Value to override severy settings */
  82695. severityOverrides?: Object;
  82696. }
  82697. /**
  82698. * The glTF validator object
  82699. * @ignore
  82700. */
  82701. interface IGLTFValidator {
  82702. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82703. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82704. }
  82705. }
  82706. declare module BABYLON {
  82707. /** @hidden */
  82708. export var cellPixelShader: {
  82709. name: string;
  82710. shader: string;
  82711. };
  82712. }
  82713. declare module BABYLON {
  82714. /** @hidden */
  82715. export var cellVertexShader: {
  82716. name: string;
  82717. shader: string;
  82718. };
  82719. }
  82720. declare module BABYLON {
  82721. export class CellMaterial extends BABYLON.PushMaterial {
  82722. private _diffuseTexture;
  82723. diffuseTexture: BABYLON.BaseTexture;
  82724. diffuseColor: BABYLON.Color3;
  82725. _computeHighLevel: boolean;
  82726. computeHighLevel: boolean;
  82727. private _disableLighting;
  82728. disableLighting: boolean;
  82729. private _maxSimultaneousLights;
  82730. maxSimultaneousLights: number;
  82731. constructor(name: string, scene: BABYLON.Scene);
  82732. needAlphaBlending(): boolean;
  82733. needAlphaTesting(): boolean;
  82734. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82735. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82736. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82737. getAnimatables(): BABYLON.IAnimatable[];
  82738. getActiveTextures(): BABYLON.BaseTexture[];
  82739. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82740. dispose(forceDisposeEffect?: boolean): void;
  82741. getClassName(): string;
  82742. clone(name: string): CellMaterial;
  82743. serialize(): any;
  82744. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82745. }
  82746. }
  82747. declare module BABYLON {
  82748. export class CustomShaderStructure {
  82749. FragmentStore: string;
  82750. VertexStore: string;
  82751. constructor();
  82752. }
  82753. export class ShaderSpecialParts {
  82754. constructor();
  82755. Fragment_Begin: string;
  82756. Fragment_Definitions: string;
  82757. Fragment_MainBegin: string;
  82758. Fragment_Custom_Diffuse: string;
  82759. Fragment_Before_Lights: string;
  82760. Fragment_Before_Fog: string;
  82761. Fragment_Custom_Alpha: string;
  82762. Fragment_Before_FragColor: string;
  82763. Vertex_Begin: string;
  82764. Vertex_Definitions: string;
  82765. Vertex_MainBegin: string;
  82766. Vertex_Before_PositionUpdated: string;
  82767. Vertex_Before_NormalUpdated: string;
  82768. Vertex_After_WorldPosComputed: string;
  82769. Vertex_MainEnd: string;
  82770. }
  82771. export class CustomMaterial extends BABYLON.StandardMaterial {
  82772. static ShaderIndexer: number;
  82773. CustomParts: ShaderSpecialParts;
  82774. _isCreatedShader: boolean;
  82775. _createdShaderName: string;
  82776. _customUniform: string[];
  82777. _newUniforms: string[];
  82778. _newUniformInstances: {
  82779. [name: string]: any;
  82780. };
  82781. _newSamplerInstances: {
  82782. [name: string]: BABYLON.Texture;
  82783. };
  82784. _customAttributes: string[];
  82785. FragmentShader: string;
  82786. VertexShader: string;
  82787. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82788. ReviewUniform(name: string, arr: string[]): string[];
  82789. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82790. constructor(name: string, scene: BABYLON.Scene);
  82791. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82792. AddAttribute(name: string): CustomMaterial;
  82793. Fragment_Begin(shaderPart: string): CustomMaterial;
  82794. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82795. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82796. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82797. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82798. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82799. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82800. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82801. Vertex_Begin(shaderPart: string): CustomMaterial;
  82802. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82803. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82804. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82805. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82806. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82807. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82808. }
  82809. }
  82810. declare module BABYLON {
  82811. export class ShaderAlebdoParts {
  82812. constructor();
  82813. Fragment_Begin: string;
  82814. Fragment_Definitions: string;
  82815. Fragment_MainBegin: string;
  82816. Fragment_Custom_Albedo: string;
  82817. Fragment_Before_Lights: string;
  82818. Fragment_Custom_MetallicRoughness: string;
  82819. Fragment_Custom_MicroSurface: string;
  82820. Fragment_Before_Fog: string;
  82821. Fragment_Custom_Alpha: string;
  82822. Fragment_Before_FragColor: string;
  82823. Vertex_Begin: string;
  82824. Vertex_Definitions: string;
  82825. Vertex_MainBegin: string;
  82826. Vertex_Before_PositionUpdated: string;
  82827. Vertex_Before_NormalUpdated: string;
  82828. Vertex_After_WorldPosComputed: string;
  82829. Vertex_MainEnd: string;
  82830. }
  82831. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82832. static ShaderIndexer: number;
  82833. CustomParts: ShaderAlebdoParts;
  82834. _isCreatedShader: boolean;
  82835. _createdShaderName: string;
  82836. _customUniform: string[];
  82837. _newUniforms: string[];
  82838. _newUniformInstances: {
  82839. [name: string]: any;
  82840. };
  82841. _newSamplerInstances: {
  82842. [name: string]: BABYLON.Texture;
  82843. };
  82844. _customAttributes: string[];
  82845. FragmentShader: string;
  82846. VertexShader: string;
  82847. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82848. ReviewUniform(name: string, arr: string[]): string[];
  82849. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82850. constructor(name: string, scene: BABYLON.Scene);
  82851. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82852. AddAttribute(name: string): PBRCustomMaterial;
  82853. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82854. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82855. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82856. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82857. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82858. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82859. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82860. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82861. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82862. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82863. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82864. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82865. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82866. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82867. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82868. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82869. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82870. }
  82871. }
  82872. declare module BABYLON {
  82873. /** @hidden */
  82874. export var firePixelShader: {
  82875. name: string;
  82876. shader: string;
  82877. };
  82878. }
  82879. declare module BABYLON {
  82880. /** @hidden */
  82881. export var fireVertexShader: {
  82882. name: string;
  82883. shader: string;
  82884. };
  82885. }
  82886. declare module BABYLON {
  82887. export class FireMaterial extends BABYLON.PushMaterial {
  82888. private _diffuseTexture;
  82889. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82890. private _distortionTexture;
  82891. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82892. private _opacityTexture;
  82893. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82894. diffuseColor: BABYLON.Color3;
  82895. speed: number;
  82896. private _scaledDiffuse;
  82897. private _lastTime;
  82898. constructor(name: string, scene: BABYLON.Scene);
  82899. needAlphaBlending(): boolean;
  82900. needAlphaTesting(): boolean;
  82901. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82902. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82903. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82904. getAnimatables(): BABYLON.IAnimatable[];
  82905. getActiveTextures(): BABYLON.BaseTexture[];
  82906. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82907. getClassName(): string;
  82908. dispose(forceDisposeEffect?: boolean): void;
  82909. clone(name: string): FireMaterial;
  82910. serialize(): any;
  82911. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82912. }
  82913. }
  82914. declare module BABYLON {
  82915. /** @hidden */
  82916. export var furPixelShader: {
  82917. name: string;
  82918. shader: string;
  82919. };
  82920. }
  82921. declare module BABYLON {
  82922. /** @hidden */
  82923. export var furVertexShader: {
  82924. name: string;
  82925. shader: string;
  82926. };
  82927. }
  82928. declare module BABYLON {
  82929. export class FurMaterial extends BABYLON.PushMaterial {
  82930. private _diffuseTexture;
  82931. diffuseTexture: BABYLON.BaseTexture;
  82932. private _heightTexture;
  82933. heightTexture: BABYLON.BaseTexture;
  82934. diffuseColor: BABYLON.Color3;
  82935. furLength: number;
  82936. furAngle: number;
  82937. furColor: BABYLON.Color3;
  82938. furOffset: number;
  82939. furSpacing: number;
  82940. furGravity: BABYLON.Vector3;
  82941. furSpeed: number;
  82942. furDensity: number;
  82943. furOcclusion: number;
  82944. furTexture: BABYLON.DynamicTexture;
  82945. private _disableLighting;
  82946. disableLighting: boolean;
  82947. private _maxSimultaneousLights;
  82948. maxSimultaneousLights: number;
  82949. highLevelFur: boolean;
  82950. _meshes: BABYLON.AbstractMesh[];
  82951. private _furTime;
  82952. constructor(name: string, scene: BABYLON.Scene);
  82953. get furTime(): number;
  82954. set furTime(furTime: number);
  82955. needAlphaBlending(): boolean;
  82956. needAlphaTesting(): boolean;
  82957. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82958. updateFur(): void;
  82959. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82960. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82961. getAnimatables(): BABYLON.IAnimatable[];
  82962. getActiveTextures(): BABYLON.BaseTexture[];
  82963. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82964. dispose(forceDisposeEffect?: boolean): void;
  82965. clone(name: string): FurMaterial;
  82966. serialize(): any;
  82967. getClassName(): string;
  82968. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82969. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82970. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82971. }
  82972. }
  82973. declare module BABYLON {
  82974. /** @hidden */
  82975. export var gradientPixelShader: {
  82976. name: string;
  82977. shader: string;
  82978. };
  82979. }
  82980. declare module BABYLON {
  82981. /** @hidden */
  82982. export var gradientVertexShader: {
  82983. name: string;
  82984. shader: string;
  82985. };
  82986. }
  82987. declare module BABYLON {
  82988. export class GradientMaterial extends BABYLON.PushMaterial {
  82989. private _maxSimultaneousLights;
  82990. maxSimultaneousLights: number;
  82991. topColor: BABYLON.Color3;
  82992. topColorAlpha: number;
  82993. bottomColor: BABYLON.Color3;
  82994. bottomColorAlpha: number;
  82995. offset: number;
  82996. scale: number;
  82997. smoothness: number;
  82998. private _disableLighting;
  82999. disableLighting: boolean;
  83000. constructor(name: string, scene: BABYLON.Scene);
  83001. needAlphaBlending(): boolean;
  83002. needAlphaTesting(): boolean;
  83003. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83004. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83005. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83006. getAnimatables(): BABYLON.IAnimatable[];
  83007. dispose(forceDisposeEffect?: boolean): void;
  83008. clone(name: string): GradientMaterial;
  83009. serialize(): any;
  83010. getClassName(): string;
  83011. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83012. }
  83013. }
  83014. declare module BABYLON {
  83015. /** @hidden */
  83016. export var gridPixelShader: {
  83017. name: string;
  83018. shader: string;
  83019. };
  83020. }
  83021. declare module BABYLON {
  83022. /** @hidden */
  83023. export var gridVertexShader: {
  83024. name: string;
  83025. shader: string;
  83026. };
  83027. }
  83028. declare module BABYLON {
  83029. /**
  83030. * The grid materials allows you to wrap any shape with a grid.
  83031. * Colors are customizable.
  83032. */
  83033. export class GridMaterial extends BABYLON.PushMaterial {
  83034. /**
  83035. * Main color of the grid (e.g. between lines)
  83036. */
  83037. mainColor: BABYLON.Color3;
  83038. /**
  83039. * Color of the grid lines.
  83040. */
  83041. lineColor: BABYLON.Color3;
  83042. /**
  83043. * The scale of the grid compared to unit.
  83044. */
  83045. gridRatio: number;
  83046. /**
  83047. * Allows setting an offset for the grid lines.
  83048. */
  83049. gridOffset: BABYLON.Vector3;
  83050. /**
  83051. * The frequency of thicker lines.
  83052. */
  83053. majorUnitFrequency: number;
  83054. /**
  83055. * The visibility of minor units in the grid.
  83056. */
  83057. minorUnitVisibility: number;
  83058. /**
  83059. * The grid opacity outside of the lines.
  83060. */
  83061. opacity: number;
  83062. /**
  83063. * Determine RBG output is premultiplied by alpha value.
  83064. */
  83065. preMultiplyAlpha: boolean;
  83066. private _opacityTexture;
  83067. opacityTexture: BABYLON.BaseTexture;
  83068. private _gridControl;
  83069. /**
  83070. * constructor
  83071. * @param name The name given to the material in order to identify it afterwards.
  83072. * @param scene The scene the material is used in.
  83073. */
  83074. constructor(name: string, scene: BABYLON.Scene);
  83075. /**
  83076. * Returns wehter or not the grid requires alpha blending.
  83077. */
  83078. needAlphaBlending(): boolean;
  83079. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83080. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83081. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83082. /**
  83083. * Dispose the material and its associated resources.
  83084. * @param forceDisposeEffect will also dispose the used effect when true
  83085. */
  83086. dispose(forceDisposeEffect?: boolean): void;
  83087. clone(name: string): GridMaterial;
  83088. serialize(): any;
  83089. getClassName(): string;
  83090. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83091. }
  83092. }
  83093. declare module BABYLON {
  83094. /** @hidden */
  83095. export var lavaPixelShader: {
  83096. name: string;
  83097. shader: string;
  83098. };
  83099. }
  83100. declare module BABYLON {
  83101. /** @hidden */
  83102. export var lavaVertexShader: {
  83103. name: string;
  83104. shader: string;
  83105. };
  83106. }
  83107. declare module BABYLON {
  83108. export class LavaMaterial extends BABYLON.PushMaterial {
  83109. private _diffuseTexture;
  83110. diffuseTexture: BABYLON.BaseTexture;
  83111. noiseTexture: BABYLON.BaseTexture;
  83112. fogColor: BABYLON.Color3;
  83113. speed: number;
  83114. movingSpeed: number;
  83115. lowFrequencySpeed: number;
  83116. fogDensity: number;
  83117. private _lastTime;
  83118. diffuseColor: BABYLON.Color3;
  83119. private _disableLighting;
  83120. disableLighting: boolean;
  83121. private _unlit;
  83122. unlit: boolean;
  83123. private _maxSimultaneousLights;
  83124. maxSimultaneousLights: number;
  83125. private _scaledDiffuse;
  83126. constructor(name: string, scene: BABYLON.Scene);
  83127. needAlphaBlending(): boolean;
  83128. needAlphaTesting(): boolean;
  83129. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83130. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83131. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83132. getAnimatables(): BABYLON.IAnimatable[];
  83133. getActiveTextures(): BABYLON.BaseTexture[];
  83134. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83135. dispose(forceDisposeEffect?: boolean): void;
  83136. clone(name: string): LavaMaterial;
  83137. serialize(): any;
  83138. getClassName(): string;
  83139. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83140. }
  83141. }
  83142. declare module BABYLON {
  83143. /** @hidden */
  83144. export var mixPixelShader: {
  83145. name: string;
  83146. shader: string;
  83147. };
  83148. }
  83149. declare module BABYLON {
  83150. /** @hidden */
  83151. export var mixVertexShader: {
  83152. name: string;
  83153. shader: string;
  83154. };
  83155. }
  83156. declare module BABYLON {
  83157. export class MixMaterial extends BABYLON.PushMaterial {
  83158. /**
  83159. * Mix textures
  83160. */
  83161. private _mixTexture1;
  83162. mixTexture1: BABYLON.BaseTexture;
  83163. private _mixTexture2;
  83164. mixTexture2: BABYLON.BaseTexture;
  83165. /**
  83166. * Diffuse textures
  83167. */
  83168. private _diffuseTexture1;
  83169. diffuseTexture1: BABYLON.Texture;
  83170. private _diffuseTexture2;
  83171. diffuseTexture2: BABYLON.Texture;
  83172. private _diffuseTexture3;
  83173. diffuseTexture3: BABYLON.Texture;
  83174. private _diffuseTexture4;
  83175. diffuseTexture4: BABYLON.Texture;
  83176. private _diffuseTexture5;
  83177. diffuseTexture5: BABYLON.Texture;
  83178. private _diffuseTexture6;
  83179. diffuseTexture6: BABYLON.Texture;
  83180. private _diffuseTexture7;
  83181. diffuseTexture7: BABYLON.Texture;
  83182. private _diffuseTexture8;
  83183. diffuseTexture8: BABYLON.Texture;
  83184. /**
  83185. * Uniforms
  83186. */
  83187. diffuseColor: BABYLON.Color3;
  83188. specularColor: BABYLON.Color3;
  83189. specularPower: number;
  83190. private _disableLighting;
  83191. disableLighting: boolean;
  83192. private _maxSimultaneousLights;
  83193. maxSimultaneousLights: number;
  83194. constructor(name: string, scene: BABYLON.Scene);
  83195. needAlphaBlending(): boolean;
  83196. needAlphaTesting(): boolean;
  83197. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83198. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83199. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83200. getAnimatables(): BABYLON.IAnimatable[];
  83201. getActiveTextures(): BABYLON.BaseTexture[];
  83202. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83203. dispose(forceDisposeEffect?: boolean): void;
  83204. clone(name: string): MixMaterial;
  83205. serialize(): any;
  83206. getClassName(): string;
  83207. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83208. }
  83209. }
  83210. declare module BABYLON {
  83211. /** @hidden */
  83212. export var normalPixelShader: {
  83213. name: string;
  83214. shader: string;
  83215. };
  83216. }
  83217. declare module BABYLON {
  83218. /** @hidden */
  83219. export var normalVertexShader: {
  83220. name: string;
  83221. shader: string;
  83222. };
  83223. }
  83224. declare module BABYLON {
  83225. export class NormalMaterial extends BABYLON.PushMaterial {
  83226. private _diffuseTexture;
  83227. diffuseTexture: BABYLON.BaseTexture;
  83228. diffuseColor: BABYLON.Color3;
  83229. private _disableLighting;
  83230. disableLighting: boolean;
  83231. private _maxSimultaneousLights;
  83232. maxSimultaneousLights: number;
  83233. constructor(name: string, scene: BABYLON.Scene);
  83234. needAlphaBlending(): boolean;
  83235. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83236. needAlphaTesting(): boolean;
  83237. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83238. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83239. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83240. getAnimatables(): BABYLON.IAnimatable[];
  83241. getActiveTextures(): BABYLON.BaseTexture[];
  83242. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83243. dispose(forceDisposeEffect?: boolean): void;
  83244. clone(name: string): NormalMaterial;
  83245. serialize(): any;
  83246. getClassName(): string;
  83247. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83248. }
  83249. }
  83250. declare module BABYLON {
  83251. /** @hidden */
  83252. export var shadowOnlyPixelShader: {
  83253. name: string;
  83254. shader: string;
  83255. };
  83256. }
  83257. declare module BABYLON {
  83258. /** @hidden */
  83259. export var shadowOnlyVertexShader: {
  83260. name: string;
  83261. shader: string;
  83262. };
  83263. }
  83264. declare module BABYLON {
  83265. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83266. private _activeLight;
  83267. private _needAlphaBlending;
  83268. constructor(name: string, scene: BABYLON.Scene);
  83269. shadowColor: BABYLON.Color3;
  83270. needAlphaBlending(): boolean;
  83271. needAlphaTesting(): boolean;
  83272. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83273. get activeLight(): BABYLON.IShadowLight;
  83274. set activeLight(light: BABYLON.IShadowLight);
  83275. private _getFirstShadowLightForMesh;
  83276. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83277. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83278. clone(name: string): ShadowOnlyMaterial;
  83279. serialize(): any;
  83280. getClassName(): string;
  83281. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83282. }
  83283. }
  83284. declare module BABYLON {
  83285. /** @hidden */
  83286. export var simplePixelShader: {
  83287. name: string;
  83288. shader: string;
  83289. };
  83290. }
  83291. declare module BABYLON {
  83292. /** @hidden */
  83293. export var simpleVertexShader: {
  83294. name: string;
  83295. shader: string;
  83296. };
  83297. }
  83298. declare module BABYLON {
  83299. export class SimpleMaterial extends BABYLON.PushMaterial {
  83300. private _diffuseTexture;
  83301. diffuseTexture: BABYLON.BaseTexture;
  83302. diffuseColor: BABYLON.Color3;
  83303. private _disableLighting;
  83304. disableLighting: boolean;
  83305. private _maxSimultaneousLights;
  83306. maxSimultaneousLights: number;
  83307. constructor(name: string, scene: BABYLON.Scene);
  83308. needAlphaBlending(): boolean;
  83309. needAlphaTesting(): boolean;
  83310. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83311. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83312. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83313. getAnimatables(): BABYLON.IAnimatable[];
  83314. getActiveTextures(): BABYLON.BaseTexture[];
  83315. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83316. dispose(forceDisposeEffect?: boolean): void;
  83317. clone(name: string): SimpleMaterial;
  83318. serialize(): any;
  83319. getClassName(): string;
  83320. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83321. }
  83322. }
  83323. declare module BABYLON {
  83324. /** @hidden */
  83325. export var skyPixelShader: {
  83326. name: string;
  83327. shader: string;
  83328. };
  83329. }
  83330. declare module BABYLON {
  83331. /** @hidden */
  83332. export var skyVertexShader: {
  83333. name: string;
  83334. shader: string;
  83335. };
  83336. }
  83337. declare module BABYLON {
  83338. /**
  83339. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83340. * @see https://doc.babylonjs.com/extensions/sky
  83341. */
  83342. export class SkyMaterial extends BABYLON.PushMaterial {
  83343. /**
  83344. * Defines the overall luminance of sky in interval ]0, 1[.
  83345. */
  83346. luminance: number;
  83347. /**
  83348. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83349. */
  83350. turbidity: number;
  83351. /**
  83352. * Defines the sky appearance (light intensity).
  83353. */
  83354. rayleigh: number;
  83355. /**
  83356. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83357. */
  83358. mieCoefficient: number;
  83359. /**
  83360. * Defines the amount of haze particles following the Mie scattering theory.
  83361. */
  83362. mieDirectionalG: number;
  83363. /**
  83364. * Defines the distance of the sun according to the active scene camera.
  83365. */
  83366. distance: number;
  83367. /**
  83368. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83369. * "inclined".
  83370. */
  83371. inclination: number;
  83372. /**
  83373. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83374. * an object direction and a reference direction.
  83375. */
  83376. azimuth: number;
  83377. /**
  83378. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83379. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83380. */
  83381. sunPosition: BABYLON.Vector3;
  83382. /**
  83383. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83384. * .sunPosition property.
  83385. */
  83386. useSunPosition: boolean;
  83387. /**
  83388. * Defines an offset vector used to get a horizon offset.
  83389. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83390. */
  83391. cameraOffset: BABYLON.Vector3;
  83392. private _cameraPosition;
  83393. /**
  83394. * Instantiates a new sky material.
  83395. * This material allows to create dynamic and texture free
  83396. * effects for skyboxes by taking care of the atmosphere state.
  83397. * @see https://doc.babylonjs.com/extensions/sky
  83398. * @param name Define the name of the material in the scene
  83399. * @param scene Define the scene the material belong to
  83400. */
  83401. constructor(name: string, scene: BABYLON.Scene);
  83402. /**
  83403. * Specifies if the material will require alpha blending
  83404. * @returns a boolean specifying if alpha blending is needed
  83405. */
  83406. needAlphaBlending(): boolean;
  83407. /**
  83408. * Specifies if this material should be rendered in alpha test mode
  83409. * @returns false as the sky material doesn't need alpha testing.
  83410. */
  83411. needAlphaTesting(): boolean;
  83412. /**
  83413. * Get the texture used for alpha test purpose.
  83414. * @returns null as the sky material has no texture.
  83415. */
  83416. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83417. /**
  83418. * Get if the submesh is ready to be used and all its information available.
  83419. * Child classes can use it to update shaders
  83420. * @param mesh defines the mesh to check
  83421. * @param subMesh defines which submesh to check
  83422. * @param useInstances specifies that instances should be used
  83423. * @returns a boolean indicating that the submesh is ready or not
  83424. */
  83425. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83426. /**
  83427. * Binds the submesh to this material by preparing the effect and shader to draw
  83428. * @param world defines the world transformation matrix
  83429. * @param mesh defines the mesh containing the submesh
  83430. * @param subMesh defines the submesh to bind the material to
  83431. */
  83432. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83433. /**
  83434. * Get the list of animatables in the material.
  83435. * @returns the list of animatables object used in the material
  83436. */
  83437. getAnimatables(): BABYLON.IAnimatable[];
  83438. /**
  83439. * Disposes the material
  83440. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83441. */
  83442. dispose(forceDisposeEffect?: boolean): void;
  83443. /**
  83444. * Makes a duplicate of the material, and gives it a new name
  83445. * @param name defines the new name for the duplicated material
  83446. * @returns the cloned material
  83447. */
  83448. clone(name: string): SkyMaterial;
  83449. /**
  83450. * Serializes this material in a JSON representation
  83451. * @returns the serialized material object
  83452. */
  83453. serialize(): any;
  83454. /**
  83455. * Gets the current class name of the material e.g. "SkyMaterial"
  83456. * Mainly use in serialization.
  83457. * @returns the class name
  83458. */
  83459. getClassName(): string;
  83460. /**
  83461. * Creates a sky material from parsed material data
  83462. * @param source defines the JSON representation of the material
  83463. * @param scene defines the hosting scene
  83464. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83465. * @returns a new sky material
  83466. */
  83467. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83468. }
  83469. }
  83470. declare module BABYLON {
  83471. /** @hidden */
  83472. export var terrainPixelShader: {
  83473. name: string;
  83474. shader: string;
  83475. };
  83476. }
  83477. declare module BABYLON {
  83478. /** @hidden */
  83479. export var terrainVertexShader: {
  83480. name: string;
  83481. shader: string;
  83482. };
  83483. }
  83484. declare module BABYLON {
  83485. export class TerrainMaterial extends BABYLON.PushMaterial {
  83486. private _mixTexture;
  83487. mixTexture: BABYLON.BaseTexture;
  83488. private _diffuseTexture1;
  83489. diffuseTexture1: BABYLON.Texture;
  83490. private _diffuseTexture2;
  83491. diffuseTexture2: BABYLON.Texture;
  83492. private _diffuseTexture3;
  83493. diffuseTexture3: BABYLON.Texture;
  83494. private _bumpTexture1;
  83495. bumpTexture1: BABYLON.Texture;
  83496. private _bumpTexture2;
  83497. bumpTexture2: BABYLON.Texture;
  83498. private _bumpTexture3;
  83499. bumpTexture3: BABYLON.Texture;
  83500. diffuseColor: BABYLON.Color3;
  83501. specularColor: BABYLON.Color3;
  83502. specularPower: number;
  83503. private _disableLighting;
  83504. disableLighting: boolean;
  83505. private _maxSimultaneousLights;
  83506. maxSimultaneousLights: number;
  83507. constructor(name: string, scene: BABYLON.Scene);
  83508. needAlphaBlending(): boolean;
  83509. needAlphaTesting(): boolean;
  83510. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83511. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83512. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83513. getAnimatables(): BABYLON.IAnimatable[];
  83514. getActiveTextures(): BABYLON.BaseTexture[];
  83515. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83516. dispose(forceDisposeEffect?: boolean): void;
  83517. clone(name: string): TerrainMaterial;
  83518. serialize(): any;
  83519. getClassName(): string;
  83520. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83521. }
  83522. }
  83523. declare module BABYLON {
  83524. /** @hidden */
  83525. export var triplanarPixelShader: {
  83526. name: string;
  83527. shader: string;
  83528. };
  83529. }
  83530. declare module BABYLON {
  83531. /** @hidden */
  83532. export var triplanarVertexShader: {
  83533. name: string;
  83534. shader: string;
  83535. };
  83536. }
  83537. declare module BABYLON {
  83538. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83539. mixTexture: BABYLON.BaseTexture;
  83540. private _diffuseTextureX;
  83541. diffuseTextureX: BABYLON.BaseTexture;
  83542. private _diffuseTextureY;
  83543. diffuseTextureY: BABYLON.BaseTexture;
  83544. private _diffuseTextureZ;
  83545. diffuseTextureZ: BABYLON.BaseTexture;
  83546. private _normalTextureX;
  83547. normalTextureX: BABYLON.BaseTexture;
  83548. private _normalTextureY;
  83549. normalTextureY: BABYLON.BaseTexture;
  83550. private _normalTextureZ;
  83551. normalTextureZ: BABYLON.BaseTexture;
  83552. tileSize: number;
  83553. diffuseColor: BABYLON.Color3;
  83554. specularColor: BABYLON.Color3;
  83555. specularPower: number;
  83556. private _disableLighting;
  83557. disableLighting: boolean;
  83558. private _maxSimultaneousLights;
  83559. maxSimultaneousLights: number;
  83560. constructor(name: string, scene: BABYLON.Scene);
  83561. needAlphaBlending(): boolean;
  83562. needAlphaTesting(): boolean;
  83563. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83564. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83565. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83566. getAnimatables(): BABYLON.IAnimatable[];
  83567. getActiveTextures(): BABYLON.BaseTexture[];
  83568. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83569. dispose(forceDisposeEffect?: boolean): void;
  83570. clone(name: string): TriPlanarMaterial;
  83571. serialize(): any;
  83572. getClassName(): string;
  83573. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83574. }
  83575. }
  83576. declare module BABYLON {
  83577. /** @hidden */
  83578. export var waterPixelShader: {
  83579. name: string;
  83580. shader: string;
  83581. };
  83582. }
  83583. declare module BABYLON {
  83584. /** @hidden */
  83585. export var waterVertexShader: {
  83586. name: string;
  83587. shader: string;
  83588. };
  83589. }
  83590. declare module BABYLON {
  83591. export class WaterMaterial extends BABYLON.PushMaterial {
  83592. renderTargetSize: BABYLON.Vector2;
  83593. private _bumpTexture;
  83594. bumpTexture: BABYLON.BaseTexture;
  83595. diffuseColor: BABYLON.Color3;
  83596. specularColor: BABYLON.Color3;
  83597. specularPower: number;
  83598. private _disableLighting;
  83599. disableLighting: boolean;
  83600. private _maxSimultaneousLights;
  83601. maxSimultaneousLights: number;
  83602. /**
  83603. * @param {number}: Represents the wind force
  83604. */
  83605. windForce: number;
  83606. /**
  83607. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83608. */
  83609. windDirection: BABYLON.Vector2;
  83610. /**
  83611. * @param {number}: Wave height, represents the height of the waves
  83612. */
  83613. waveHeight: number;
  83614. /**
  83615. * @param {number}: Bump height, represents the bump height related to the bump map
  83616. */
  83617. bumpHeight: number;
  83618. /**
  83619. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83620. */
  83621. private _bumpSuperimpose;
  83622. bumpSuperimpose: boolean;
  83623. /**
  83624. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83625. */
  83626. private _fresnelSeparate;
  83627. fresnelSeparate: boolean;
  83628. /**
  83629. * @param {boolean}: bump Waves modify the reflection.
  83630. */
  83631. private _bumpAffectsReflection;
  83632. bumpAffectsReflection: boolean;
  83633. /**
  83634. * @param {number}: The water color blended with the refraction (near)
  83635. */
  83636. waterColor: BABYLON.Color3;
  83637. /**
  83638. * @param {number}: The blend factor related to the water color
  83639. */
  83640. colorBlendFactor: number;
  83641. /**
  83642. * @param {number}: The water color blended with the reflection (far)
  83643. */
  83644. waterColor2: BABYLON.Color3;
  83645. /**
  83646. * @param {number}: The blend factor related to the water color (reflection, far)
  83647. */
  83648. colorBlendFactor2: number;
  83649. /**
  83650. * @param {number}: Represents the maximum length of a wave
  83651. */
  83652. waveLength: number;
  83653. /**
  83654. * @param {number}: Defines the waves speed
  83655. */
  83656. waveSpeed: number;
  83657. /**
  83658. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83659. * will avoid calculating useless pixels in the pixel shader of the water material.
  83660. */
  83661. disableClipPlane: boolean;
  83662. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83663. private _mesh;
  83664. private _refractionRTT;
  83665. private _reflectionRTT;
  83666. private _reflectionTransform;
  83667. private _lastTime;
  83668. private _lastDeltaTime;
  83669. private _useLogarithmicDepth;
  83670. private _waitingRenderList;
  83671. private _imageProcessingConfiguration;
  83672. private _imageProcessingObserver;
  83673. /**
  83674. * Gets a boolean indicating that current material needs to register RTT
  83675. */
  83676. get hasRenderTargetTextures(): boolean;
  83677. /**
  83678. * Constructor
  83679. */
  83680. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83681. get useLogarithmicDepth(): boolean;
  83682. set useLogarithmicDepth(value: boolean);
  83683. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83684. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83685. addToRenderList(node: any): void;
  83686. enableRenderTargets(enable: boolean): void;
  83687. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83688. get renderTargetsEnabled(): boolean;
  83689. needAlphaBlending(): boolean;
  83690. needAlphaTesting(): boolean;
  83691. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83692. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83693. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83694. private _createRenderTargets;
  83695. getAnimatables(): BABYLON.IAnimatable[];
  83696. getActiveTextures(): BABYLON.BaseTexture[];
  83697. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83698. dispose(forceDisposeEffect?: boolean): void;
  83699. clone(name: string): WaterMaterial;
  83700. serialize(): any;
  83701. getClassName(): string;
  83702. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83703. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83704. }
  83705. }
  83706. declare module BABYLON {
  83707. /** @hidden */
  83708. export var asciiartPixelShader: {
  83709. name: string;
  83710. shader: string;
  83711. };
  83712. }
  83713. declare module BABYLON {
  83714. /**
  83715. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83716. *
  83717. * It basically takes care rendering the font front the given font size to a texture.
  83718. * This is used later on in the postprocess.
  83719. */
  83720. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83721. private _font;
  83722. private _text;
  83723. private _charSize;
  83724. /**
  83725. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83726. */
  83727. get charSize(): number;
  83728. /**
  83729. * Create a new instance of the Ascii Art FontTexture class
  83730. * @param name the name of the texture
  83731. * @param font the font to use, use the W3C CSS notation
  83732. * @param text the caracter set to use in the rendering.
  83733. * @param scene the scene that owns the texture
  83734. */
  83735. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83736. /**
  83737. * Gets the max char width of a font.
  83738. * @param font the font to use, use the W3C CSS notation
  83739. * @return the max char width
  83740. */
  83741. private getFontWidth;
  83742. /**
  83743. * Gets the max char height of a font.
  83744. * @param font the font to use, use the W3C CSS notation
  83745. * @return the max char height
  83746. */
  83747. private getFontHeight;
  83748. /**
  83749. * Clones the current AsciiArtTexture.
  83750. * @return the clone of the texture.
  83751. */
  83752. clone(): AsciiArtFontTexture;
  83753. /**
  83754. * Parses a json object representing the texture and returns an instance of it.
  83755. * @param source the source JSON representation
  83756. * @param scene the scene to create the texture for
  83757. * @return the parsed texture
  83758. */
  83759. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83760. }
  83761. /**
  83762. * Option available in the Ascii Art Post Process.
  83763. */
  83764. export interface IAsciiArtPostProcessOptions {
  83765. /**
  83766. * The font to use following the w3c font definition.
  83767. */
  83768. font?: string;
  83769. /**
  83770. * The character set to use in the postprocess.
  83771. */
  83772. characterSet?: string;
  83773. /**
  83774. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83775. * This number is defined between 0 and 1;
  83776. */
  83777. mixToTile?: number;
  83778. /**
  83779. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83780. * This number is defined between 0 and 1;
  83781. */
  83782. mixToNormal?: number;
  83783. }
  83784. /**
  83785. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83786. *
  83787. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83788. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83789. */
  83790. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83791. /**
  83792. * The font texture used to render the char in the post process.
  83793. */
  83794. private _asciiArtFontTexture;
  83795. /**
  83796. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83797. * This number is defined between 0 and 1;
  83798. */
  83799. mixToTile: number;
  83800. /**
  83801. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83802. * This number is defined between 0 and 1;
  83803. */
  83804. mixToNormal: number;
  83805. /**
  83806. * Instantiates a new Ascii Art Post Process.
  83807. * @param name the name to give to the postprocess
  83808. * @camera the camera to apply the post process to.
  83809. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83810. */
  83811. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83812. }
  83813. }
  83814. declare module BABYLON {
  83815. /** @hidden */
  83816. export var digitalrainPixelShader: {
  83817. name: string;
  83818. shader: string;
  83819. };
  83820. }
  83821. declare module BABYLON {
  83822. /**
  83823. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83824. *
  83825. * It basically takes care rendering the font front the given font size to a texture.
  83826. * This is used later on in the postprocess.
  83827. */
  83828. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83829. private _font;
  83830. private _text;
  83831. private _charSize;
  83832. /**
  83833. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83834. */
  83835. get charSize(): number;
  83836. /**
  83837. * Create a new instance of the Digital Rain FontTexture class
  83838. * @param name the name of the texture
  83839. * @param font the font to use, use the W3C CSS notation
  83840. * @param text the caracter set to use in the rendering.
  83841. * @param scene the scene that owns the texture
  83842. */
  83843. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83844. /**
  83845. * Gets the max char width of a font.
  83846. * @param font the font to use, use the W3C CSS notation
  83847. * @return the max char width
  83848. */
  83849. private getFontWidth;
  83850. /**
  83851. * Gets the max char height of a font.
  83852. * @param font the font to use, use the W3C CSS notation
  83853. * @return the max char height
  83854. */
  83855. private getFontHeight;
  83856. /**
  83857. * Clones the current DigitalRainFontTexture.
  83858. * @return the clone of the texture.
  83859. */
  83860. clone(): DigitalRainFontTexture;
  83861. /**
  83862. * Parses a json object representing the texture and returns an instance of it.
  83863. * @param source the source JSON representation
  83864. * @param scene the scene to create the texture for
  83865. * @return the parsed texture
  83866. */
  83867. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83868. }
  83869. /**
  83870. * Option available in the Digital Rain Post Process.
  83871. */
  83872. export interface IDigitalRainPostProcessOptions {
  83873. /**
  83874. * The font to use following the w3c font definition.
  83875. */
  83876. font?: string;
  83877. /**
  83878. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83879. * This number is defined between 0 and 1;
  83880. */
  83881. mixToTile?: number;
  83882. /**
  83883. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83884. * This number is defined between 0 and 1;
  83885. */
  83886. mixToNormal?: number;
  83887. }
  83888. /**
  83889. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83890. *
  83891. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83892. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83893. */
  83894. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83895. /**
  83896. * The font texture used to render the char in the post process.
  83897. */
  83898. private _digitalRainFontTexture;
  83899. /**
  83900. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83901. * This number is defined between 0 and 1;
  83902. */
  83903. mixToTile: number;
  83904. /**
  83905. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83906. * This number is defined between 0 and 1;
  83907. */
  83908. mixToNormal: number;
  83909. /**
  83910. * Instantiates a new Digital Rain Post Process.
  83911. * @param name the name to give to the postprocess
  83912. * @camera the camera to apply the post process to.
  83913. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83914. */
  83915. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83916. }
  83917. }
  83918. declare module BABYLON {
  83919. /** @hidden */
  83920. export var brickProceduralTexturePixelShader: {
  83921. name: string;
  83922. shader: string;
  83923. };
  83924. }
  83925. declare module BABYLON {
  83926. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83927. private _numberOfBricksHeight;
  83928. private _numberOfBricksWidth;
  83929. private _jointColor;
  83930. private _brickColor;
  83931. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83932. updateShaderUniforms(): void;
  83933. get numberOfBricksHeight(): number;
  83934. set numberOfBricksHeight(value: number);
  83935. get numberOfBricksWidth(): number;
  83936. set numberOfBricksWidth(value: number);
  83937. get jointColor(): BABYLON.Color3;
  83938. set jointColor(value: BABYLON.Color3);
  83939. get brickColor(): BABYLON.Color3;
  83940. set brickColor(value: BABYLON.Color3);
  83941. /**
  83942. * Serializes this brick procedural texture
  83943. * @returns a serialized brick procedural texture object
  83944. */
  83945. serialize(): any;
  83946. /**
  83947. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83948. * @param parsedTexture defines parsed texture data
  83949. * @param scene defines the current scene
  83950. * @param rootUrl defines the root URL containing brick procedural texture information
  83951. * @returns a parsed Brick Procedural BABYLON.Texture
  83952. */
  83953. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83954. }
  83955. }
  83956. declare module BABYLON {
  83957. /** @hidden */
  83958. export var cloudProceduralTexturePixelShader: {
  83959. name: string;
  83960. shader: string;
  83961. };
  83962. }
  83963. declare module BABYLON {
  83964. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83965. private _skyColor;
  83966. private _cloudColor;
  83967. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83968. updateShaderUniforms(): void;
  83969. get skyColor(): BABYLON.Color4;
  83970. set skyColor(value: BABYLON.Color4);
  83971. get cloudColor(): BABYLON.Color4;
  83972. set cloudColor(value: BABYLON.Color4);
  83973. /**
  83974. * Serializes this cloud procedural texture
  83975. * @returns a serialized cloud procedural texture object
  83976. */
  83977. serialize(): any;
  83978. /**
  83979. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83980. * @param parsedTexture defines parsed texture data
  83981. * @param scene defines the current scene
  83982. * @param rootUrl defines the root URL containing cloud procedural texture information
  83983. * @returns a parsed Cloud Procedural BABYLON.Texture
  83984. */
  83985. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83986. }
  83987. }
  83988. declare module BABYLON {
  83989. /** @hidden */
  83990. export var fireProceduralTexturePixelShader: {
  83991. name: string;
  83992. shader: string;
  83993. };
  83994. }
  83995. declare module BABYLON {
  83996. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83997. private _time;
  83998. private _speed;
  83999. private _autoGenerateTime;
  84000. private _fireColors;
  84001. private _alphaThreshold;
  84002. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84003. updateShaderUniforms(): void;
  84004. render(useCameraPostProcess?: boolean): void;
  84005. static get PurpleFireColors(): BABYLON.Color3[];
  84006. static get GreenFireColors(): BABYLON.Color3[];
  84007. static get RedFireColors(): BABYLON.Color3[];
  84008. static get BlueFireColors(): BABYLON.Color3[];
  84009. get autoGenerateTime(): boolean;
  84010. set autoGenerateTime(value: boolean);
  84011. get fireColors(): BABYLON.Color3[];
  84012. set fireColors(value: BABYLON.Color3[]);
  84013. get time(): number;
  84014. set time(value: number);
  84015. get speed(): BABYLON.Vector2;
  84016. set speed(value: BABYLON.Vector2);
  84017. get alphaThreshold(): number;
  84018. set alphaThreshold(value: number);
  84019. /**
  84020. * Serializes this fire procedural texture
  84021. * @returns a serialized fire procedural texture object
  84022. */
  84023. serialize(): any;
  84024. /**
  84025. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84026. * @param parsedTexture defines parsed texture data
  84027. * @param scene defines the current scene
  84028. * @param rootUrl defines the root URL containing fire procedural texture information
  84029. * @returns a parsed Fire Procedural BABYLON.Texture
  84030. */
  84031. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84032. }
  84033. }
  84034. declare module BABYLON {
  84035. /** @hidden */
  84036. export var grassProceduralTexturePixelShader: {
  84037. name: string;
  84038. shader: string;
  84039. };
  84040. }
  84041. declare module BABYLON {
  84042. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84043. private _grassColors;
  84044. private _groundColor;
  84045. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84046. updateShaderUniforms(): void;
  84047. get grassColors(): BABYLON.Color3[];
  84048. set grassColors(value: BABYLON.Color3[]);
  84049. get groundColor(): BABYLON.Color3;
  84050. set groundColor(value: BABYLON.Color3);
  84051. /**
  84052. * Serializes this grass procedural texture
  84053. * @returns a serialized grass procedural texture object
  84054. */
  84055. serialize(): any;
  84056. /**
  84057. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84058. * @param parsedTexture defines parsed texture data
  84059. * @param scene defines the current scene
  84060. * @param rootUrl defines the root URL containing grass procedural texture information
  84061. * @returns a parsed Grass Procedural BABYLON.Texture
  84062. */
  84063. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84064. }
  84065. }
  84066. declare module BABYLON {
  84067. /** @hidden */
  84068. export var marbleProceduralTexturePixelShader: {
  84069. name: string;
  84070. shader: string;
  84071. };
  84072. }
  84073. declare module BABYLON {
  84074. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84075. private _numberOfTilesHeight;
  84076. private _numberOfTilesWidth;
  84077. private _amplitude;
  84078. private _jointColor;
  84079. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84080. updateShaderUniforms(): void;
  84081. get numberOfTilesHeight(): number;
  84082. set numberOfTilesHeight(value: number);
  84083. get amplitude(): number;
  84084. set amplitude(value: number);
  84085. get numberOfTilesWidth(): number;
  84086. set numberOfTilesWidth(value: number);
  84087. get jointColor(): BABYLON.Color3;
  84088. set jointColor(value: BABYLON.Color3);
  84089. /**
  84090. * Serializes this marble procedural texture
  84091. * @returns a serialized marble procedural texture object
  84092. */
  84093. serialize(): any;
  84094. /**
  84095. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84096. * @param parsedTexture defines parsed texture data
  84097. * @param scene defines the current scene
  84098. * @param rootUrl defines the root URL containing marble procedural texture information
  84099. * @returns a parsed Marble Procedural BABYLON.Texture
  84100. */
  84101. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84102. }
  84103. }
  84104. declare module BABYLON {
  84105. /** @hidden */
  84106. export var normalMapProceduralTexturePixelShader: {
  84107. name: string;
  84108. shader: string;
  84109. };
  84110. }
  84111. declare module BABYLON {
  84112. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84113. private _baseTexture;
  84114. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84115. updateShaderUniforms(): void;
  84116. render(useCameraPostProcess?: boolean): void;
  84117. resize(size: any, generateMipMaps: any): void;
  84118. get baseTexture(): BABYLON.Texture;
  84119. set baseTexture(texture: BABYLON.Texture);
  84120. /**
  84121. * Serializes this normal map procedural texture
  84122. * @returns a serialized normal map procedural texture object
  84123. */
  84124. serialize(): any;
  84125. /**
  84126. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84127. * @param parsedTexture defines parsed texture data
  84128. * @param scene defines the current scene
  84129. * @param rootUrl defines the root URL containing normal map procedural texture information
  84130. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84131. */
  84132. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84133. }
  84134. }
  84135. declare module BABYLON {
  84136. /** @hidden */
  84137. export var perlinNoiseProceduralTexturePixelShader: {
  84138. name: string;
  84139. shader: string;
  84140. };
  84141. }
  84142. declare module BABYLON {
  84143. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84144. time: number;
  84145. timeScale: number;
  84146. translationSpeed: number;
  84147. private _currentTranslation;
  84148. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84149. updateShaderUniforms(): void;
  84150. render(useCameraPostProcess?: boolean): void;
  84151. resize(size: any, generateMipMaps: any): void;
  84152. /**
  84153. * Serializes this perlin noise procedural texture
  84154. * @returns a serialized perlin noise procedural texture object
  84155. */
  84156. serialize(): any;
  84157. /**
  84158. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84159. * @param parsedTexture defines parsed texture data
  84160. * @param scene defines the current scene
  84161. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84162. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84163. */
  84164. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84165. }
  84166. }
  84167. declare module BABYLON {
  84168. /** @hidden */
  84169. export var roadProceduralTexturePixelShader: {
  84170. name: string;
  84171. shader: string;
  84172. };
  84173. }
  84174. declare module BABYLON {
  84175. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84176. private _roadColor;
  84177. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84178. updateShaderUniforms(): void;
  84179. get roadColor(): BABYLON.Color3;
  84180. set roadColor(value: BABYLON.Color3);
  84181. /**
  84182. * Serializes this road procedural texture
  84183. * @returns a serialized road procedural texture object
  84184. */
  84185. serialize(): any;
  84186. /**
  84187. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84188. * @param parsedTexture defines parsed texture data
  84189. * @param scene defines the current scene
  84190. * @param rootUrl defines the root URL containing road procedural texture information
  84191. * @returns a parsed Road Procedural BABYLON.Texture
  84192. */
  84193. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84194. }
  84195. }
  84196. declare module BABYLON {
  84197. /** @hidden */
  84198. export var starfieldProceduralTexturePixelShader: {
  84199. name: string;
  84200. shader: string;
  84201. };
  84202. }
  84203. declare module BABYLON {
  84204. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84205. private _time;
  84206. private _alpha;
  84207. private _beta;
  84208. private _zoom;
  84209. private _formuparam;
  84210. private _stepsize;
  84211. private _tile;
  84212. private _brightness;
  84213. private _darkmatter;
  84214. private _distfading;
  84215. private _saturation;
  84216. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84217. updateShaderUniforms(): void;
  84218. get time(): number;
  84219. set time(value: number);
  84220. get alpha(): number;
  84221. set alpha(value: number);
  84222. get beta(): number;
  84223. set beta(value: number);
  84224. get formuparam(): number;
  84225. set formuparam(value: number);
  84226. get stepsize(): number;
  84227. set stepsize(value: number);
  84228. get zoom(): number;
  84229. set zoom(value: number);
  84230. get tile(): number;
  84231. set tile(value: number);
  84232. get brightness(): number;
  84233. set brightness(value: number);
  84234. get darkmatter(): number;
  84235. set darkmatter(value: number);
  84236. get distfading(): number;
  84237. set distfading(value: number);
  84238. get saturation(): number;
  84239. set saturation(value: number);
  84240. /**
  84241. * Serializes this starfield procedural texture
  84242. * @returns a serialized starfield procedural texture object
  84243. */
  84244. serialize(): any;
  84245. /**
  84246. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84247. * @param parsedTexture defines parsed texture data
  84248. * @param scene defines the current scene
  84249. * @param rootUrl defines the root URL containing startfield procedural texture information
  84250. * @returns a parsed Starfield Procedural BABYLON.Texture
  84251. */
  84252. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84253. }
  84254. }
  84255. declare module BABYLON {
  84256. /** @hidden */
  84257. export var woodProceduralTexturePixelShader: {
  84258. name: string;
  84259. shader: string;
  84260. };
  84261. }
  84262. declare module BABYLON {
  84263. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84264. private _ampScale;
  84265. private _woodColor;
  84266. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84267. updateShaderUniforms(): void;
  84268. get ampScale(): number;
  84269. set ampScale(value: number);
  84270. get woodColor(): BABYLON.Color3;
  84271. set woodColor(value: BABYLON.Color3);
  84272. /**
  84273. * Serializes this wood procedural texture
  84274. * @returns a serialized wood procedural texture object
  84275. */
  84276. serialize(): any;
  84277. /**
  84278. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84279. * @param parsedTexture defines parsed texture data
  84280. * @param scene defines the current scene
  84281. * @param rootUrl defines the root URL containing wood procedural texture information
  84282. * @returns a parsed Wood Procedural BABYLON.Texture
  84283. */
  84284. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84285. }
  84286. }